How to create SharedNode instances with the same position (and rotation)?

Hi



I plan to use SharedNode in 2 differents situations:

  • a single Node has to appear several times in the scenegraph at the same position as it is physically the same object (it is necessary for the cells-and-portals implementation when an object overlaps several cells)
  • a single Node has to appear several times in the scenegraph at different positions as it is not physically the same object (it is necessary when the same kind of object appears several times)



    By default, several SharedNode instances built with the same Node can have different scale and position, can't they? If so, the second case is obviously not a problem but how can I do for the first case? How can I force several SharedNode instances to have exactly the same position?



    Finally, it would be fine to update the documentation of SharedNode to explain more clearly how to use this class.

I suppose you could just give them the same Vector reference with setLocalTranslation… the question is why would you do that.

Alric said:

I suppose you could just give them the same Vector reference with setLocalTranslation.. the question is why would you do that.

The scenegraph used in TUER is structurally different of the scenegraph of JME 2, I have to tinker a bit to use my scenegraph inside JME 2. When an object overlaps 2 rooms, it has to be drawn once but if only one of these rooms is visible, this object has to be considered as visible, that is why it has to be associated with 2 cells and then 2 nodes. As JME 2 does not support nodes with several parents, I have to use SharedNode. When I move such an object, all SharedNode instances that represent it has to use the same position.

I will look at the source code again to check if your solution is enough, I want to avoid bugs (for example, a single object being duplicated when I don't want to do it). Thanks.