Chapter 25.   Readers Comments


Making an Avatar Visible

Abu Alkhadher (1st August 2006) wrote:

Your 3D Maze example includes a makeAvatar() method in WrapMaze3D which is meant to create an on-screen cone representing the user. It's described on p.675 of your book. When I uncomment the call to the method in prepareViewPoint(), nothing appears. Why?


My response (1st August):

The avatar (the cone) wasn't meant to be visible to the camera, only to other users. If you want the cone to be visible, then try this version of the makeAvatar() method:

private TransformGroup makeAvatar()
  Transform3D t3d = new Transform3D();

  // to move cone out in front of camera
  // t3d.setTranslation( new Vector3d(0, 0, -1));
     // or
  // to make the cone point in front of the camera
  t3d.rotX(-Math.PI/2);    // rotate so top of cone is facing front (was +)
  t3d.setTranslation( new Vector3d(0, -0.9, -1.2));

  TransformGroup userTG = new TransformGroup(t3d);
  userTG.addChild( new Cone(0.35f, 1.0f) );  // avatar is a thin cone
  return userTG;
}  // end of makeAvatar()

The first setTranslation() call (which is commented out) will move the cone out in front of the camera. If you decide to use it, then comment out the rotX() and setTranslation() calls below it. They rotate the cone then move it so that its apex is pointing in the forward direction.


Dr. Andrew Davison
Back to my home page