This a little difficult subject to me...
I would like to understand how to create exporter of 3D data.
To export material infos of this kind of information is really easy... but 3D data...
I do not speak about the programming language but what kind of data I need to export 3D information.
Final output will be an ASCII file. I do not know yet if XML or another kind.
This is first to understand how it works.
I would like to understand what I need to create polygons, to connect edge, etc...
And what is the order O_o...
when I give a look in a Collada file there are the following data :
- position
- normal
- geotangent
- geobinormal
- map1 (probably the Uvs)
I do not know where to go, my research on google is not the best because I maybe do not have the right key word, etc...
Does someone already create this kind of stuff?
Is there a tutorial or technical documentation speaking about polygon structure on a full model?
Replies
For example, the 3ds Max SDK is the best place to learn Max data export. They also have an older export framework called iGame that's free to d/l.
Like to get the faces I'd do something like:
string TheFaces[] = `polyInfo -fv ($YourMesh + ".f[" + $YourFace + "]")`; // gets the vert NUMBER not LOCATION on each face
So the output from that would be what maya is looking for YourMesh.f[XX].
Then for each face I'd get the verts and turn that into an array. And get the point info use pointposition on each one. I'd get the vert normal from getAttr.
For normals, you can use Polyinfo, but you gotta freeze the mesh first. But you can get each vert normal in getAttr as well. Hell you can do a lot with getAttr.
the basics are vertex positions, face-to-vertex data, face-normals data
for texture support you additionally need vertex or face -to-uv data and maybe texture name (imo its better to don't store it in here but it depends)
you have to decide here if you want t allow a vertex to have only one ore more uv-coordinates
all other stuff is additional:
smoothing groups
skin weights
...
- vertex array (3 elements: each holding x,y,z positions)
- face array (3 elements: each pointing to the index of the vertex array of that vertex)
- uvVertex array (same as vertex, holds U & V coordinates of the UV verts)
- uvFace array (same amount and order as the face array but points to uvVertex indexes)
thats itThe important thing to remember is that the face and UVface array have the same length and each index represents the same face. Vertex and UVvertex arrays though can be completely different this is because UV verts can be merged and stacked for example.
pseudo example code:
you are probably doing this in maya which I don't know well - in max I could give you an example on how to read out this data.
If you are using 3ds max as the app then you have a very good example in the Maxscript Help on How to Read and Write Geometry Data to an ASCII file.
Very interesting stuff!!
Guyomu also gave to me this url : http://nehe.gamedev.net/
It look very interesting and will try the first lesson on the left.
I do not want to create crazy stuff, just would like to understand a little more some technical point about 3D...
Anyway, I will keep updated this thread about my progression!
@EricChadwick : first I only would like to understand what you need to save 3D info.
@Lamont : yeah I will try Python this time. Melscript make me sleepy... I need new and fresh stuff
@ rollin ; Yup I understand! About skinning etc... I will wait to export&import my first cube... and after level.... hahah! but yeah I realloy would like to learn more about it once I will start!
@renderhjs : your exemple is very interesting! About UvVtx and UvFcs, what is the difference?
Once seems to be 2D and the other one 3D?
@ akramparvez I am using maya to export, but for the import I do not know yet. maybe the openGl thing but this is first to understand how it work. and with time I will think about the structure. I do not have any experience in this kind of stuff then... I will do.. again.. one more time... and again... and then I will do it fior real. hahaha.
Really thank you guys!
The face arrays booth UV and Geometry Face arrays point with index numbers to the corresponding verts. 0 for example means the 1st vertex in that array, 1 means the 2nd array because arrays usually start at the index 0.
For every face however you need to assign 3 vertex points because all 3d models consist in the end of triangles. So that face array describes which 3 vertex id's are used to construct this face.
Here is a example of how the ASE format works:
Here is the progression : http://a.samavan.com/openGL/SamaTest_A.exe
(file size : 120ko, do not need to install, double click on it)
Exporter is done with Python from Maya.
*.exe file built with Visual C++ express 2008 and openGL Library.
To explain quickly, my python script creates the C++ code I need to create the model with OpenGL and then I copy&past it in the main code as closed function for yet. (I didn't learn to load that kind of thing dynamically with C++ yet T_T...)
It Look like that :
I currently create all polygons one per one using the GL_POLYGONS method.
I tried the GL_POLYGON_STRIP but nothing in Maya is done for helping in this way...
Then very difficult part, I didn't success to writte a right structure for it...
I also added the vertex color.
I will try the Uvs + texture part...
If someone has a model without texture for yet with cool vertex color on it I will be happy to create a *.exe file especially for it!
The link I give on the top is a 475 poly model and the file size is about 120ko....
The exporter will also add extra C++ line to make ready the model for instancing in Open GL!
Once the openGL read the data it stocks it and I can call the model as an intense during the simulation.
I also found a way to insert texture data in the *.exe when compiling.
Finally only one exe file with 3D + texture data and do not need to install for trying it.
Now the exported data look something like that :
Here is the demo : http://a.samavan.com/openGL/SamaTest_B.exe
I instance a model of 1157 triangle 80x100 time.
800 instances = 925 600 poly
I would be glad if someone could try it and let me know if this is slow or run fine on his computer.
Image name is SamaTest.exe in the TaskManager.
Now I will try out bones + skin data...
good progress by the way
- how to install all the shit :
http://www.mrmoen.com/2008/03/30/opengl-with-visual-c-express-edition/
- Cool tutorial to start openGL :
http://nehe.gamedev.net/lesson.asp?index=01
http://nehe.gamedev.net/lesson.asp?index=02
- And then python for Maya if you want to create your exporter, hoping you already know melscript
http://www.chadvernon.com/blog/tutorials/python-scripting-for-maya-artists/
@giyomu : lol, yeah in one year not before!
@jfyelle : Oh no no but the main idea is how to create his own exporter and then to understand how will be used the data.
I choose to start with C++ in OpenGL (thing I never touched 10 days ago....) and then try to understand how to build a model + uvs + texture with gl.h and glu.h library.
There is no wish to create something new etc... just wishing to understand!
I am on the bones system + skin now...
This is... not cute to read, I have for one week to understand all this shit in openGL before updating my python script
About FBX exporter, when you give a look inside, you finally understand you need one more script to import it in openGL.
With my script, if a programmer wanted to get my 3D from Maya for openGL use, he do not need a reader.
I export directly the 3D model ready for openGL use with C++ synthax.
Then when the engine read my file, it use it directly. There is not conversion.
But anyway I do not plan to create a game, just would like to progress in learning with practice and then want to share if someone want to try the experience too!
Does someone has a good tutorial about bone structure and skinning method in openGL C++?
I do not success to find a good "easy" one with Google.
http://www.gamedev.net/community/forums/topic.asp?topic_id=549125