Well, I tired your code breakfast, but it doesn’t turn with the model all the way. It only turns one distance and that is it. Here is the code that I’m using, some of it should look very familiar to you 8)
private void initCamera()
{
camTrans = new Transform3D();
camVec = new Vector3d();
camTG.getTransform(camTrans);
camTrans.get(camVec);
}
private void translateCamera(Transform3D ourTrans)
{
Vector3d ourVec = new Vector3d();
Vector3d up = new Vector3d(0, 1, 0);
ourTrans.get(ourVec);
ourVec.add(new Vector3d(-1.0d, 1.0d, 0.0d));
Point3d cam = new Point3d();
Point3d man = new Point3d();
camTrans.setTranslation(ourVec);
ourTrans.transform(man);
camTrans.transform(cam);
man.y = man.y +1.0;
camTrans.lookAt(cam, man, up);
camTrans.invert();
camTG.setTransform(camTrans);
}
private void rotateCamera(Transform3D ourTrans)
{
Vector3d currentPos = new Vector3d();
camTrans.get( currentPos );
double nowX = currentPos.x;
double nowY = currentPos.z;
Point3d rotationCentre = new Point3d();
ourTrans.transform( rotationCentre );
nowX = nowX-rotationCentre.x;
nowY = nowY-rotationCentre.z;
double lenVec = 1.0d;
nowY = (Math.sin(rotateYAmount * speed*2)*lenVec);
nowX = (-Math.cos(rotateYAmount * speed*2)*lenVec);
nowX = nowX+ rotationCentre.x;
nowY = nowY+ rotationCentre.z;
currentPos.x = nowX;
currentPos.z = nowY;
camTrans.set(currentPos);
camTrans.lookAt(new Point3d(currentPos.x, currentPos.y, currentPos.z),
new Point3d(rotationCentre.x, rotationCentre.y+1.0d, rotationCentre.z), new Vector3d(0, 1, 0));
camTrans.invert();
camTG.setTransform(camTrans);
}