Author Topic: Object Siblings  (Read 1158 times)

Offline AppletMan

  • byte
  • *
  • Posts: 3
    • View Profile
Object Siblings
« on: December 23, 2010, 01:20:20 am »
Suggesting the ability to create object siblings or groups of objects in JPCT.

My problem was this...  I'm using software rendering and I've made a point-and-click world editor and have 3DS walls for my world with partially transparent glass and opaque frames.  I cannot use a world object model transparency because the transparency, when set, translates to the entire object.  I cannot use a transparent (black) section of a texture because it's fairly all or nothing with the transparent area.  If I use two objects and join them with child/parent relationships and click on one section to translate the entire group only selecting the parent object effects the group.  My solution was to load two separate objects and join them with my own sibling relationship.

I'm familiar with addChild() and addParent() methods, however they only work in one direction.  It would be nice to group objects together with a  method such as “addSibling()”.  I could then select any one of those objects and the translations I apply would effect all of them equally.   I've worked with many grouped model translations which, even when the object exist in separate locations, it's nice to be able to move them together as a unit once arranged.

The only translation which would be a problem would be rotations.  In most sibling relationships, the objects rotate as a unit from a common center rather then all of them turning at the same time in their own matrix.  So far, in JPCT, I've only worked with objects sharing a common center.

I've created my own method to accomplish the same goal with setUserObject() as a sibling object which follows the same translations.  Before applying the translation I check to see if it “hasSibling()” and then apply the translations to all of the siblings if they exist via looping through an array.

Thanks for the awesomeness of JPCT!  I've been working with it, on and off, for about two years and it's fantastic.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11965
    • View Profile
    • http://www.jpct.net
Re: Object Siblings
« Reply #1 on: December 25, 2010, 10:38:07 pm »
I feel that this problem is something that should be solved at the application level (as you did) and maybe not by engine itself, because the requirements of what a sibling exactly is and how it behaves might be different in each case.

Another option i can think of would be to use a dummy parent for all objects. So what makes them siblings would be that they all belong to one parent.