Author Topic: cloneObject() and setRotationPivot - what's wrong?  (Read 4455 times)

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
cloneObject() and setRotationPivot - what's wrong?
« on: June 29, 2007, 09:17:44 pm »
Hi,

I have the source object and i just use cloneObject(). Everything is OK until i use simply setRotationPivot(new SimpleVector(0, 0, 0)) for each of them. The source object is modified OK, but there is no difference in cloned object behaviour. Should i use some additional method for clone the object?

Thank You in advice.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: cloneObject() and setRotationPivot - what's wrong?
« Reply #1 on: June 29, 2007, 10:34:26 pm »
The rotation pivot isn't related to cloning in any way...but i'm not quite sure what you want to achieve and what you are getting instead. Maybe a little code snippet can help to illustrate the problem?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: cloneObject() and setRotationPivot - what's wrong?
« Reply #2 on: June 29, 2007, 11:31:29 pm »
Yes, ofcourse.

Have a look at my source test object:




Well i have defined SourceObject and i clone him:

Code: [Select]
....
ClonedObject= SourceObject.cloneObject();
SourceObject.build();
ClonedObject.build();
theWorld.addObject(SourceObject);
theWorld.addObject(ClonedObject);

The result can You see below. Both object are transparenced, rotated by X Angle:






But the result is bad because i had no centered object. I have to use the Pivot:


Code: [Select]
....
ClonedObject= SourceObject.cloneObject();
SourceObject.setRotationPivot(new SimpleVector(0, 0, 0));
ClonedObject.setRotationPivot(new SimpleVector(0, 0, 0));
SourceObject.build();
ClonedObject.build();
theWorld.addObject(SourceObject);
theWorld.addObject(ClonedObject);


The same situation, maybe little differend camera only:






My Souce Object is rotated correctly (his one end stay in the same place), but ClonedObject behaviour has not changed...

« Last Edit: June 29, 2007, 11:34:32 pm by Klaudiusz »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: cloneObject() and setRotationPivot - what's wrong?
« Reply #3 on: June 30, 2007, 02:40:12 pm »
build() resets the rotation pivot (not mentioned in the docs for build() but in the part about setRotationPivot()). So you should change the order. However, that doesn't explain why the pivot seems to be different on the cloned object (or am i fooled by the perspective here?). If not, then what are the rotations pivots of both objects after calling build()?

Offline Klaudiusz

  • int
  • **
  • Posts: 75
    • View Profile
Re: cloneObject() and setRotationPivot - what's wrong?
« Reply #4 on: June 30, 2007, 07:48:16 pm »
I used setRotationPivot after build .... everything is OK! :)

Thank You