Hello Dean,

Thursday, 27 January 00, you wrote:

DK> Hi,

DK> I want to be able to orbit my view around the center of object in 3D space.  
Currently I am rotating my view which causes my object to disappear from view and so I 
have to pan over to where the object is.  I want to be able to orbit my view around an
DK> object so that the object never leaves my view.  I do not want to rotate the 
object, I want it to stay in its true position when it was read in.  Can anyone tell 
me how to do this and what math is involved?  Can I establish an anchor or pivot point
DK> for my view to rotate around?  Please help if you can, I'm trying to resolve this 
ASAP.

DK> Thanks,

DK> Dean


try this one...should work.
but well, its early in the morning...don't
bother me with the mathematical stuff :o)



//***************************************************************************
/**
Responsible for the ability to rotate the camera 360 degrees vertical
and horizontal around a point (0,1,0)
@param vertical
@param horizontal
@param radius
*/
//***************************************************************************

public void changeView(double vertical, double horizontal, double radius){
double angleH = horizontal / 180.0 * Math.PI;
double angleV = vertical / 180.0 * Math.PI;

eyeX = radius * Math.sin(angleH);
eyeZ = radius * Math.cos(angleH);

eyeY = radius * Math.cos(angleV);
eyeX = eyeX     * Math.sin(angleV);
eyeZ = eyeZ     * Math.sin(angleV);

Point3d  eyeLocation = new  Point3d(eyeX, eyeY, eyeZ);
Point3d  lookingAt   = new  Point3d(eyeX / 2, eyeY / 2, eyeZ / 2);
Vector3d up          = new Vector3d(0.0d, (vertical > 180 ? -1.0d : 1.0d), 0.0d);

viewpoint.lookAt(eyeLocation, lookingAt, up);
viewpoint.invert();
vpTrans.setTransform(viewpoint);
}


public void mouseDragged(MouseEvent e) {

       int newX = e.getX();
       int newY = e.getY() - 90;


       posX -= (newX - startX) / 2;

       posX = posX % 360;

       if (posX < 1) posX = 360 - posX;

       posY -= (newY - startY) / 2;

       posY = posY % 360;

       if (posY < 1) posY = 360 - posY;

       changeView(posY,posX,distance);

startX = newX;
startY = newY;
    }

public void mousePressed(MouseEvent e) {
startX = e.getX();
startY = e.getY();
}

Best regards,
 Uwe                            mailto:[EMAIL PROTECTED]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to