I've been writing a dae collada importer, all is going well with geometries etc,
I am a little stuck to implement a quick method when it comes to converting geometry and transform data from Z-up, X-up to unitys Y-up world space.
I already can translate,rotate and scale geometry vertices on a node level to the correct positions by multiplying the imported vertex data by the geometry nodes transfrom data using a TRS matrix and MultiplyPoint3x4(vtx), but am looking for a decent/quick method to correct the vertex and transform data to correspond with unity's cartesian co-ord system.
some kind of vertex pos/translate pos from (a,b,c) to (b,0-a,c) and possibly some kind of quaternion or Euler.v3 from (a,b,c,w)/(a,b,c) to (0-c,b,0-a)
Any links to code or anything not too algebraic would be most usefull.
I found the below is working with Max and sketchup exports:
private Vector3 UpPosConv(Vector3 v) {
Vector3 r=new Vector3();
//All x,y,z Up right handed -> Y_up left, Vertex or Translate Positions
switch (up_axis) {
case 0: //xR-yL
r=new Vector3(0-v.y,v.x,0-v.z);
break;
case 1: //yR-yL
r=new Vector3(v.x,v.y,0-v.z);
break;
case 2: //zR-zL
r=new Vector3(v.x,v.z,v.y);
break;
}
return r;
}
private Vector3 UpScaleConv(Vector3 v) {
Vector3 r=new Vector3();
//All x,y,z Up right handed -> Y_up left, Scale Factors
switch (up_axis) {
case 0: //xR-yL
r=new Vector3(v.y,v.x,v.z);
break;
case 1: //yR-yL
r=new Vector3(v.x,v.y,v.z);
break;
case 2: //zR-zL
r=new Vector3(v.x,v.z,v.y);
break;
}
return r;
}
private Vector3 UpRotDirConv(Vector3 v) {
Vector3 r=new Vector3();
//All x,y,z Up right handed -> Y_up left,Convert Rotation(axis)Directions
switch (up_axis) {
case 0: //xR-yL
r=new Vector3(v.y,0-v.x,v.z);
break;
case 1: //yR-yL
r=new Vector3(0-v.x,0-v.y,v.z);
break;
case 2: //zR-zL
r=new Vector3(0-v.x,0-v.z,0-v.y);
break;
}
return r;
}
I am concerned that this may be wrong and is only working with the examples I can get hold of or create.
Unity's native Collada import not cutting it for you? I'm always interested in the shortcomings of such things. Working on X3D import myself. Sorry I don't have an answer for you handy, will see what I can find.
– DaveAThanks again for the response, its a runtime importer, I'll be publishing them soon for free, OBJ is working fantastically now, just finishing the DAE one, but dealing with grouping and parenting, so trying to find a efficient and conclusive method, however I understand code much better than algebra you find on wikipedia.
– anon40755444