www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Klaudiusz on June 29, 2007, 09:17:44 pm

Title: cloneObject() and setRotationPivot - what's wrong?
Post by: Klaudiusz 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.
Title: Re: cloneObject() and setRotationPivot - what's wrong?
Post by: EgonOlsen 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?
Title: Re: cloneObject() and setRotationPivot - what's wrong?
Post by: Klaudiusz on June 29, 2007, 11:31:29 pm
Yes, ofcourse.

Have a look at my source test object:

(http://img504.imageshack.us/img504/4229/jpct006cm8.th.jpg) (http://img504.imageshack.us/my.php?image=jpct006cm8.jpg)


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:

(http://img403.imageshack.us/img403/9430/jpct002ma0.th.jpg) (http://img403.imageshack.us/my.php?image=jpct002ma0.jpg)
(http://img248.imageshack.us/img248/4786/jpct003ec0.th.jpg) (http://img248.imageshack.us/my.php?image=jpct003ec0.jpg)



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:


(http://img509.imageshack.us/img509/6649/jpct004ne2.th.jpg) (http://img509.imageshack.us/my.php?image=jpct004ne2.jpg)
(http://img118.imageshack.us/img118/8632/jpct005hx8.th.jpg) (http://img118.imageshack.us/my.php?image=jpct005hx8.jpg)


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

Title: Re: cloneObject() and setRotationPivot - what's wrong?
Post by: EgonOlsen 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()?
Title: Re: cloneObject() and setRotationPivot - what's wrong?
Post by: Klaudiusz on June 30, 2007, 07:48:16 pm
I used setRotationPivot after build .... everything is OK! :)

Thank You