BUG with the “recenter at load” options in Prefab ?

Software: Prefab3D

aeki, Member
Posted: 29 April 2013 05:02 PM   Total Posts: 73

Hi all,

I need to import a 3D model from 3dsMax to away3D. My model has several meshes.

I’ve exported my 3D Max model to OBJ format, then I’ve loaded it in Prefab (version 2.143) and then I’ve exported it as an AWD file in order to load it in my Away3D app.

For the Prefab step of this workflow, I tried first loading my OBJ file without the option “Recenter Model at load”. In Away3D when I check for each mesh of my 3D model :

  > bounds : minX, minY, minZ etc.. are given in global coordinates (WorldSpace coordinates)
  > (x,y,z) = scenePosition = pivotPoint = scenePosition are all equal to (0,0,0)
  > scaling operation on individual meshes are incorrect (relative to some pivotPoint which is not the center oh the mesh).

Because, i had this issue about scaling, I’ve searched the forum and I’ve discovered the Prefab “recenter model at load” With this option checked, I export an new AWD file, and scaling is OK : scaling transformations on each mesh are relative to the center of gravity of each mesh! BUT :

  > bounds of each mesh (minX, minY, minZ etc..) are now given in local coordinates relative to the center of gravity of the mesh
  > (x,y,z) = scenePosition = pivotPoint = scenePosition are all equal to (0,0,0)

So I don’t have access anymore at WorldSpace coordinates for each mesh of my model. What am I doing wrong? Is it a bug?

   

Avatar
Fabrice Closier, Administrator
Posted: 29 April 2013 06:27 PM   Total Posts: 1265   [ # 1 ]

It’s certainly not a bug. In fact this feature was added because of obj. This format doesn’t have any scenetransform concepts. The vertices are transformed prior to export and there is no way to extract another position than either 0,0,0 (standard obj definition) or by recentering (the option that Prefab gives you) at object space level, giving you the equivallent of the center of the mesh data.
If you need to have meshes with pivots other than their centers, you cannot use the obj format. Unless you know what you need and offset them by hand using the menu geometry/edit object center prior export to awd2.

   

aeki, Member
Posted: 29 April 2013 07:05 PM   Total Posts: 73   [ # 2 ]

Thanks for your quick answer.

i still don’t get it :

I do need to have meshes with pivots at their centers of gravity AND to get meshes with their position in global coordinates in Away3D.

In Prefab, when using the “recenter” option, I clearly see in the bottom bar that the position of each mesh is not (0,0,0) anymore but the correct position in global space. So why, when loading to Away3D, do I get (x,y,z) = scenePosition = pivotPoint all equal to (0,0,0) ?

To me, the scenePosition property (which if I am right is expressed in global coordinates) should equal the corrected position I can see in Prefab??

   

Avatar
Fabrice Closier, Administrator
Posted: 29 April 2013 07:32 PM   Total Posts: 1265   [ # 3 ]

If you load the same obj, you will get 0,0,0 in Away3d because there is no rencenter routine being applied.
If you load an obj, recenter in Prefab and export as awd2 from Prefab. If the resulting mesh.x, mesh.y, mesh.z are still 0 in Away3D then there is indeed a bug.

The scenePosition should indeed be the equivallent of global transform of the mesh (a mesh with x = 100, if addchilded in a container that is at 100, the scenePosition.x should be 200 and position.x 100. If not this is a bug.

Note that the pivotPoint variable is not set from awd data. That’s why it remains 0,0,0. The pivot point influence the current transform. It is set (on top of my head) only by collada and 3ds parsers because the information is explicit in these files.

If you think there is a bug—> please fill an issue on github + enough info to reproduce,

   

aeki, Member
Posted: 30 April 2013 07:52 AM   Total Posts: 73   [ # 4 ]

Ok, it works as you described, my problem is due to my code .

For my app, I’ve overrided the Mesh Class to a customMesh class and hence the AWDParser to instanciate customMesh instead of Mesh when parsing AWD files.

I am realizing that when instanciating my customMesh in the parseMeshInstance method of AWDParser, scenePosition is not yet extract/calculated from data. So my problem is not yet solved, but at least, it seems there is no bug in Away3D.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X