Does exist any way to export a mesh on a Obj file?

Software: Away3D 4.x

agventu, Newbie
Posted: 23 December 2014 04:04 PM   Total Posts: 8

I can’t find the way to export a mesh on a OBJ file.      I’ve ported a project from 3.6 to 4.x and now I realize that doesn’t exist anymore the ObjExporter class.      I need help with this.

Thanks!

   

therealloft, Member
Posted: 29 December 2014 11:25 PM   Total Posts: 65   [ # 1 ]

I have a script that exports an objectcontainer3d to awd file it thats any help

   

agventu, Newbie
Posted: 30 December 2014 02:20 AM   Total Posts: 8   [ # 2 ]

But I need export to obj because then I could to convert it to stl file.   

Could I convert a awd file in a stl file?  I don’t know.

   

Avatar
Fabrice Closier, Administrator
Posted: 30 December 2014 03:04 PM   Total Posts: 1265   [ # 3 ]

stl is may be the most simple bin format around. You can write this using away in no time. Any model loaded can be exported.
you simply declare an header of 80 bytes and reserve 4 bytes for the face count. So header is exactly 84 bytes. you can push whatever you want into the first 80 bytes. Some exporters push their own name, version and sometimes color infos in there for instance.


_byteArray.endian = Endian.LITTLE_ENDIAN;
_byteArray.writeUTFBytes(“my STL exporter”);
while(_byteArray.length

   

agventu, Newbie
Posted: 30 December 2014 03:33 PM   Total Posts: 8   [ # 4 ]

Thanks for reply.

The problem is that in 4.x version doesn’t exist anymore the faces data, I have to get it from vertexData or indexData.  That’s right? 

So, how I could know when it ends a face and begins the next?

   

Avatar
Fabrice Closier, Administrator
Posted: 30 December 2014 06:54 PM   Total Posts: 1265   [ # 5 ]

of course it exits. How would the gpu know which face to draw?
a face is defined by 3 indices in a row. For instance the first face equals
indices[0], indices[1] and indices[2]. the values stored are to be multiplied by 3 to access the x value of a vertice.  add 1 to this value and you have the y, add 1 again and you get the z. If you use compact geometries, you will have to add the corresponding offset and strides.

here’s the order of the compact subgeometry data.
0 - 2: vertex position X, Y, Z
3 - 5: normal X, Y, Z
6 - 8: tangent X, Y, Z
9 - 10: U V  
11 - 12: Secondary U V

you can also use, again only in compact geometries case, the stripBuffer method. For instance var verticesOnly = subgeom.stripBuffer(0, 3);

using buffers from subGeometry or from stripbuffer, to get the vertex v0 of the first face,  vo.x = vertices[ indices[0] * 3] , vo.y = vertices[ (indices[0] * 3) +1] , , vo.z = vertices[ (indices[0] * 3) +2] , go to indices[ next index] to retrieve v1, then v2. normals and tangent are to be retreived same way. For uvs, multiply by 2, not 3.

just make some tests on a plane and add some traces…

   

agventu, Newbie
Posted: 30 December 2014 07:13 PM   Total Posts: 8   [ # 6 ]

Thank you very much!!

I’ve never could understand.    I had too much problems to get the order of vertices from vertexData.      I’ll try to make an exporter with this approach.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X