Center of Transform seems to be misplaced after loading unprimitive 3ds object ?

Started by kbjansen, June 14, 2012, 09:51:59 PM

Previous topic - Next topic

kbjansen

Huhu,

I am going to try to load a 3ds object (it's one single vehicle mesh) to jpct-ae to connect it with a jbullet rigidbody.
The rigidbody needs the transform's center to set a rigidbodyshape correctly.

Problem is, that the center of the vehicle transform (Object3d.getTransformedCenter()) at runtime doesn't equal with the center of the object in 3ds max. Even a moving of the object in 3ds max away from (0,0,0) doesn't cause a difference (the shown transformedCenter of the vehicle is still the same).

But, that doesn't concern to all objects I'd loaded with jpct the same way!
The transformed center of a spherical soccer ball matches exactly with the one from 3DS Max.

Anyone of you knows this issue?
Is it possible that the .3ds-exporter of 3DS max generates a center of the transform relatively to the size and not position of the object?
Or is the vector of this center generated while serializing the object's 3ds. file with jpct?

I method like Object3D.setTransformedCenter(new SimpleVector()) would be great. Then I may reset manually the center of the vehicle at object creation time.


If some more information, code-snippets or explanation screenshots are required I can deliver them in addition.
(sorry for linguistic bloopers, but this problem made me insane and dizzy .'S )


EDIT:
The 3d object passes through the following workflow:

3DS MAX -> Export as .3ds-file -> Serialization 3ds. to .ser-file -> Zip
... Android Build process ...
Runtime: -> unzipping -> load via Loader.loadSerializedObject and object3d creation

EgonOlsen

You can't set a transformed center (because it depends on...well, transformations), but you can set the center and the rotation pivot. When using 3ds files, you can also try to set this to true: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Config.html#useRotationPivotFrom3DS Edit:...before loading the file, of course.

kbjansen

thanks for your quick response, i'll give it a try tomorrow

Edit:
ok, set Config.useRotationPivotFrom3DS to true, before serializing and before loading the 3ds object.
The console log after serializing says: Setting rotation pivot of object chassis_jPCT-2 to (0.0,0.0,0.0) - so just fine

But at runtime the center of the transformed is still on wrong position. But the pivot vector and the center of transform have the same
value - see pic1 (that yellow tall peak is set to the transformed Center):


pic1

So lets try another vehicle - same placement in 3ds Editor, same pivot alignment -> result: TransformedCenter of the 2nd car is now in the middle of the vehicle, BUT the vehicle is rotated about 90 degrees and not set to the center of the world - see pic 2


pic2

So a ghost whispered to me to just reimport the 3ds.files to 3ds Max and...... badumm tsss
result of that action:
the pivot of the 2nd vehicle is rerotated about 90 degrees (don't know why) and
to 1st car mesh was added a swollen big invisible mesh in y-direction (WTF)

So I think there are some issues with the 3ds-exporter

kbjansen

some more trys:
I'd imported the vehicle.3ds to blender. With the exception of the rerotation of the 2nd vehicle it's all just ok. The pivot points seems to be on the right place in blender.

... so, I recognize that the so called "Selection Center" of the 3ds max Polygon editor in vertex mode resembles the in jpct shown transformed center (see pic1 previous post).
Some more recherche show that this "Vertex Selection Center" is the calculated geometric center of 3DS max.
http://docs.autodesk.com/3DSMAX/15/ENU/3ds-Max-Help/index.html?url=files/GUID-4B35174B-AAC4-470D-8A4E-89608EB6914D.htm,topicNumber=d30e57453


Is it possible that the transformed center of objects in jpct equals this geometric center?

Now, i no more believe that there is an error in exporting the 3ds. file referring to the pivot point.
(this other thing, i mean, the rerotating of the 2nd mesh, could be some failure of mine)

EgonOlsen

To be honest, i somehow lost the track here...
   
The default behaviour of jPCT is this: When calling build(), the geometric center of the mesh will be calculated and used for both the center and the rotation pivot (these two points aren't the same in jPCT). You can set them both to other values after build(), if you want to. getTransformedCenter() returns the center transformed in world space. Rotations happen around the rotation pivot.
If you enable that config-switch, both values will be taken from the file instead and not changed when calling build(). You have to make sure to use the latest versions of both, jPCT and jPCT-AE, because former version didn't serialize the center/rotation pivot.

kbjansen

Thanks for your informative explanation, Egon! Everything seems to be clear now!

Updated jpct and jpct-ae like you'd said. No, difference.
But with setting the object's center and pivot programmatically AFTER build() is called, there is no problem anymore.
I've already tried to call setCenter() and setRotationPivot() before, but didn't see that I called build() another time after object creation
in physics routine - what a silly and nooby mistake :S

So thanks again