Attach an object to a presentation platform in Java3D

In my Java3D application, I have a movable viewing platform (for example, using the "OrbitBehavior" and "KeyNavigatorBehavior" behavior), so I can change my perspective on the scene. Now I would like to add an object that is โ€œstaticโ€ above my view, i.e. It always looks in the same way when I move my view (for example, like a playerโ€™s gun in FPS). To date, I have tried the following two approaches to this problem, but none of them have worked.

1 / Attach my object to the ViewPlatform (through a special BranchGroup plus TransformGroup). In this case, my object simply does not appear (I'm absolutely not sure that it is allowed to perform such an operation actually ...). This is part of my code:

Code: (with viewViewPlatform)

BranchGroup fixedBG = new BranchGroup();
TransformGroup fixedTG = new TransformGroup();
fixedTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
fixedTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D transfo = new Transform3D();
transfo.setTranslation(new Vector3f(0.2f, 0.0f, -1.0f));
fixedTG.setTransform(transfo);
ColorCube fixedCube = new ColorCube(0.2);
fixedTG.addChild(fixedCube);
view.addChild(fixedBG);

2/ ( + , getTransform() getViewPlatformTransform() - - , PF ) . , ( , , ). , , , / KeyNavigator ( - ).

, , , , , , ...

(PS: , : )

+3
1

100%, , - (http://graphcomp.com/info/specs/java3d/j3dguide/Intro.doc.html#47470), , , . , , , . - , . ColorCube , , . , , . , , .

+2
source

Source: https://habr.com/ru/post/1719616/


All Articles