Hi,
I’ve fixed this
Problem. But there’s a new one. Now, the object (ship) rotates around the
Global Origin not around his own local Origin!!!
Here’s the
code:
targetTG.getTransform(localVworld);
rotation.x =
xAngle;
rotation.y =
yAngle;
rotation.z =
0.0f;
localVworld.transform(position);
localVworld.transform(rotation);
shipRotator.x
= rotation.x;
shipRotator.y
= rotation.y;
shipRotator.z
= rotation.z;
shipRotator.angle = 1.0f;
shipPosForViewRot.x = position.x;
shipPosForViewRot.y = position.y;
shipPosForViewRot.z =
position.z;
//Positionsvector an das Transform3Dobjekt übergeben
posTrans.setTranslation(position);
posTrans.setRotation(shipRotator);
//Die Rotation in
posTrans einspeisen ;)
//posTrans.mul(rotXY3d);
return
posTrans;
Greets
Juan
-----Ursprüngliche
Nachricht-----
Von:
Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]
Im Auftrag von Lewis
Walker
Gesendet: Sonntag, 7.
September 2003 10:28
An:
[EMAIL PROTECTED]
Betreff: Re: [JAVA3D] local rotation
possible?
Excuse
the sketchy details, but I can point you in the right direction (I
think).
Ultimately, the
translation / rotation etc. is encapsulated in a single Transformation between
Local and World Coordinate Systems. This single Transformation, however, is
obtained by traversing the scene graph from the root, all the way to your
ship, and multiplying together all the Transform3Ds found along the
way.
This
is just normal maths - you can combine transformations represented by
matrices, by performing matrix multiplication. However - Matrix multiplication
is not commutative, which means that A x B does not equal B x A in general.
i.e. a rotation followed by a translation is not the same as a translation
followed by a rotation.
Could
it be that you are post-multiplying your transformations, when it should be a
pre-multiplication, or vice versa? I don't know whether you are even
explicitly separating out your translation and rotation in the scene graph. If
not, I probably would change it so that you are. It makes it easier
conceptually, and Java3D will probably optimise it at runtime anyway, so you
don't have to worry about an overhead.
Try
parenting your ship with a Transform3D which is a rotation, and parenting that
with a Transform3D which is a translation. (I might have that the wrong way
round. If so - swap the rotation and the
translation!).
Then,
you can change your rotations and translations independantly by setting the
corresponding Transform3D.
-----Original
Message-----
From:
Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]
On Behalf Of Johannes
Neubauer
Sent: 06 September
2003 16:55
To:
[EMAIL PROTECTED]
Subject: [JAVA3D] local rotation
possible?
Hi,
Here's the link: http://www.kingsware.de/j3d/gamerot.zip
I have a new
problem. I update only the x- and y-rotation of my ship every Frame. It sets
the rotation by looking at the Mouse position. But my ship rotates over all
axis x,y AND z, but not at the same time!!! It looks like Java3D decides,
which are the x and y axis from the viewplatforms point of view!! Is that
right?
How can I set a "local"-Rotation, which rotates the
local axis not the "viewed" one
I had the same
problem, only the other way around, with Translation. The ship moved on the
global axis instead of flying, depending on the ships current rotation.
I fixed this problem like
this(not exactly):
Code:
//Position
Vector3f position = new Vector3f(x,y,z);
Transform3D posTrans = new Transform3D();
//Rotation
Transform3D rotX3d = new Transform3D();
Transform3D rotY3d = new Transform3D();
Transform3D rotXY3d = new Transform3D();
//change the XY-Rotation (with
MouseAngle) rotX3d.rotX(xAngle);
rotY3d.rotY(yAngle);
rotXY3d.mul(rotX3d, rotY3d);
//The solution! now the
positiontranslation is local!
rotXY3d.transform(position);
posTrans.set(position);
|
|
Is there any
possibility to do this with rotation. There must be the possibility to
rotate over the local axis!
I've read
something about the following function:
Code:
view.getLocalToVWorld(Transform3D
trans) |
|
Is
this a possibility? Anyone fixed this problem, yet
Greets and thanks,
Juan
===========================================================================
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".
===========================================================================
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".
=========================================================================== 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".