www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: bgilb3 on March 13, 2005, 11:26:05 am

Title: Object Rotation
Post by: bgilb3 on March 13, 2005, 11:26:05 am
Code: [Select]
shape.translate(0f,0f,forwardSpeed);
shape.rotateY(turnSpeed);


i was wondering how i can make the rotatation permanent? Like how the cameras MoveIN thing works. Because no matter what the rotation is, the shape always just goes outward from the camera ( im trying to make it so when you rotate the object, its direction changes ) ie when you hit forward it goes another direction )
Title: Object Rotation
Post by: EgonOlsen on March 13, 2005, 05:29:00 pm
If i understand you correctly, try something like

Code: [Select]
shape.translate(shape.getZAxis());
Title: Object Rotation
Post by: Anonymous on March 13, 2005, 06:43:34 pm
Yeah I tried that, kinda works except ..

It doesn't allow me to define a speed :-(
Title: Object Rotation
Post by: EgonOlsen on March 13, 2005, 06:47:10 pm
Try something like this:

Code: [Select]
SimpleVector s=shape.getZAxis();
s.scalarMul(speed);
shape.translate(s);
Title: Object Rotation
Post by: Anonymous on March 13, 2005, 06:57:59 pm
Gotcha, thanks that worked :D
Title: Object Rotation
Post by: bgilb3 on March 13, 2005, 08:17:57 pm
How can i get the camera to follow something around like 3rd person?
Title: Object Rotation
Post by: EgonOlsen on March 14, 2005, 05:06:55 pm
Depends on your actual needs. One way of doing it be found in sources of the  car example.
Title: Object Rotation
Post by: bgilb3 on March 14, 2005, 11:13:03 pm
so complicated :oops:
Title: Object Rotation
Post by: EgonOlsen on March 15, 2005, 12:40:30 am
Quote from: "bgilb3"
so complicated :oops:
Not really. It's in the CarTest.java in moveCamera. It's not that complicated...
Title: Object Rotation
Post by: brad3 on March 16, 2005, 12:08:52 am
Okay i got the camera to follow the object around, now im not sure how to get the camera to have the same rotation is the object
Title: Object Rotation
Post by: EgonOlsen on March 16, 2005, 07:43:34 am
Depends on what you mean exactly. You may try to align them using Camera.align(<Object3D>) or use Camera.lookAt(<SimpleVector>) with the transformed center of the Object3D as point to look at.