Hope this is the right forum for this question…
I am having difficulty getting a true translation vector from a transform.
BranchGroup bg1 = new BranchGroup();
BranchGroup bg11 = new BranchGroup();
TransformGroup tg1 = new TransformGroup();
TransformGroup tg11 = new TransformGroup();
Transform3D trans1 = new Transform3D();
Transform3D trans11 = new Transform3D();
Vector3f v1 = new Vector3f(0.0f, 1.0f, 0.0f);
trans1.setTranslation(v1);
tg1.setTransform(trans1);
bg1.addChild(tg1);
v1.set(0.0f, -1.0f, 0.0f);
trans11.setTranslation(v1);
tg11.setTransform(trans11);
bg11.addChild(tg11);
So far so good. I omit any geometry because I don’t believe it really matters. Here is where I get an issue…
BranchGroup bg2 = new BranchGroup();
TransformGroup tg2 = new TransformGroup();
Transform3D trans2 = new Transform3D();
tg2.addChild(bg1); // attaching previous BranchGroup to this TransformGroup
tg2.addChild(bg11);
trans2.rotX(Math.PI);
tg2.setTransform(trans2);
bg2.addChild(tg2);
// Now let's try to get that translation out
Transform3D t3d = new Transform3D();
t3d.mul(trans1, trans2);
Vector3f v = new Vector3f();
t3d.get(v);
System.out.println(v.toString());
That will output: (0.0, 1.0, 0.0)
Strictly speaking, that isn’t what I’m looking for. The object that I attach to tg1 will have swapped places with the object attached to tg11. Of course, it will rotated 180degrees from it’s starting axis.
What I want is to be able to get the new vector on it’s location (in this case, I was looking for an output of: (0.0, -1.0, 0.0)
Is that possible? Thanks in advance for any help.
(I apologize if any of the code is off, this is not the actual code I’m working on. The actual code is a little too obfuscated to easily show what I’m looking for. This is merely an example of what I’m trying for.)