bassackwardness lefthand vs righthand -1 scaling etc

Software: Away3D 4.x

Avatar
Choons, Sr. Member
Posted: 14 October 2011 12:30 AM   Total Posts: 281

Hi guys- so I’m working on some 3D biology stuff and running into the ages old issue of my imported models being backwards/mirrored since Away3D is a left-handed system. I know that a hacky fix is to scale to -1 across the x-axis. While that hack corrects orientation, I’ve had and seen many others report problems then with shading and lighting on the object. So since it looks like this will ALWAYS be an issue with Away3D, what is the CORRECT way once and for all to get an imported model that is backwards to be 100% right in Away3D? Maybe we could have a sticky in the forum for this if there is really a correct way to do it?

   

Richard Olsson, Administrator
Posted: 14 October 2011 06:05 PM   Total Posts: 1192   [ # 1 ]

If you are using a file format which dictates the coordinate system of it’s content (e.g. AWD2, AWD1, 3DS, AC3D, OBJ) the parser should automatically convert it so that it looks right in Away3D. If you are using a file format where the axes are ambiguous then for obvious reasons this cannot happen automatically. In these cases, try doing a Geometry.applyTransform() with a Matrix3D that is scaled negatively on those axes that you need to flip. We are considering wrapping this trick into some utility class, but at the moment you have to do it manually.

   

Avatar
Choons, Sr. Member
Posted: 14 October 2011 11:26 PM   Total Posts: 281   [ # 2 ]

thanks, Richard. I’ll try the Geometry.applyTransform() approach and report back how it works. Getting the lighting to work properly and the texture to be correct (letters & numbers especially) is the trick

   

Tim Knip, Moderator
Posted: 15 October 2011 01:58 AM   Total Posts: 7   [ # 3 ]

Having the exact same problem with the COLLADA format with my DAEParser https://github.com/away3d/away3d-core-fp11/pull/140.

Now, not to bug and of course understanding the implications…
Afaik most 3D formats around use the opposite coordinate space…

Now, why is Away in the - ahem - wrong space?

It would save all of us a lot of headaches if Away3D would decide to ‘conform’. Also because it seems a reasonably easy fix, as its afaik mainly a projection thing.

Maybe I’m underestimating the problem of moving to other coordinate system. But maybe it could be considered for 4.0.

My 2 cents.

   

Avatar
Choons, Sr. Member
Posted: 15 October 2011 02:11 AM   Total Posts: 281   [ # 4 ]

actually Unity3D & DirectX itself are left-handed coordinate systems like Away3D as well so it’s not an unusual issue, but yeah I agree it’s weird that the top 3D modeling programs are all right-handed and the top game engines are all left-handed. Go figure?? So it’s better to just accept that there’s no real standard and concentrate on the best way to do the conversions, I think. It sure is one of those “WTF?” things about the 3D CG world.

   

Richard Olsson, Administrator
Posted: 15 October 2011 06:29 AM   Total Posts: 1192   [ # 5 ]

It shouldn’t really be a problem. The parser should convert if necessary (that’s your job, Tim, and if you need help let me know) and the programmer should never have to care about it.

Choons, if you are having problems, please explain what file format and what generator you are using, and if possible send me the file (preferably containing text or something like that so it is clear that it is flipped.) If it is one of the file formats that explicitly define the coordinate space (including 3DS, standard OBJ, DAE, AWD et c) then it’s either a bug in the encoder or in our parser, and we will want to get to the bottom of it. If it’s a bug with our parser, we will fix it.

So please do not settle with a problem thinking “that’s just the way it is”. Because in most cases it shouldn’t have to. smile

   

Tim Knip, Moderator
Posted: 18 October 2011 03:09 PM   Total Posts: 7   [ # 6 ]

Solved! (at least for DAEParser).

Do this to your transforms:

/** 
 * Converts the matrix from RH (DAE) to LH (Away3D)
 *
 * @param matrix
 */
public function convertMatrix(matrix Matrix3D) : void
{
 
var indices Vector.<int> = Vector.<int>([26891114]);
 var 
raw Vector.<Number> = matrix.rawData;
 var 
int;
 for (
0indices.lengthi++) {
  raw[indices[i]] 
*= -1.0;
 
}
 matrix
.rawData raw;

Then for all vertices of your geometry:

v.= -v.z

Don’t forget to reverse the winding of the triangles!

For skinning: convert the skin’s bindshapematrix and all joint’s inverse bind matrices.

Thank you Richard Olsson!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X