Hello,
I write a little Java3D program and I need to display a 2D layer on top of my 3D scene with
- dynamic stats (FPF, memory usage, …)
- dynamic hour (rendered as an analog watch).
I searched on the web and I think I would use a PlatformGeometry
So, I created the following structure
PlatformGeometry => TransformGroup => BranchGroup => Text2D
But I have to create/update the Text2D on every frame.
When I try to do that (add a Text2D as a Child of the BranchGroup), I get an error
javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be added
I get an equivalent error when I try to remove previous Text2D child from the BranchGroup.
I think I gave the needed capabilities to the BranchGroup.
_statsBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
_statsBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
I also see I can remove the BranchGroup from the TransformGroup without getting any error. But, I don’t think it’s efficient on every frame to
- remove ‘2D stats’ BranchGroup from ‘2D stats’ TransformGroup
- create new ‘2D stats’ BranchGroup
- create new Text2D and add it as child to ‘2D stats’ BranchGroup
- add new ‘2D stats’ BranchGroup to the ‘2D stats’ TransformGroup.
So, what is the best solution ?
Thanks for all.