Exporting Geometry

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Exporting Geometry

Post by jimmythepage »

Hi...
I'm doing a project in Ogl for my University and for earn time my ideas was to create an exporter in irrlicht that push out the geometry of some my mesh..I create the exporter and works but theres a problem:(i explain with an example)

If i export a tringolated cube(that in maya have only 8 vertices and 8 index set) the result is that the cube have 36 vertices..it is possible that irrlicht that is so fast isn't optimized for vertices reducement??How can i export well the geometry??

tnx a lot...if it doesn't clear(my english is very bad),please tell me...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

Well, if you wrote the exporter, you should know why the cube has 36 vertices, not?

Actually you need 24 vertices to create a cube. 36 means, that half the vertices are doubled, probably because a side is created with 2 triangles and the two vertices the triangles have in common are not shared.
24 vertices are needes, because each vertex is adjacent to three cube sides and you need a normal pointing toward each side. Since a vertex can only have one normal, you have to have three vertices for each corner. 3x8=24.
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

tnx for the answer...

I've already now this,but my question was if there is a way to don't export doubled vertices...Like in mel for example that push out only the vertices that are useful and then the index do the magic...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

What format do you use? What modeller and what tool to export from this modeller? And what exactly do you do to get the results you get? I don't think I understand what you are talking about.

And what "exporter"? Export from irrlicht to something?
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

ok sorry for my few info...

The exporter that i create export from irrlicht(any model that irrlicht support) from a my format(.jtm) that for now is similar to raw format(only geometry information)..

I use this code for to do this:

Code: Select all

IAnimatedMesh* anim_mesh=smgr->getMesh(meshfilename);..
IMesh* mesh= anim_mesh->getMesh(0);..
for(int i=0; i<mesh->getMeshBufferCount(); i++)
	{
		IMeshBuffer* buffer=mesh->getMeshBuffer(i);..
                for(int j=0; j<buffer->getVertexCount(); j++)
		{
			S3DVertex* vx=(S3DVertex*)buffer->getVertices();...
                        float dat=0;

			//writing position
			dat=vx[j].Pos.X;
			fprintf(stream,"%f\n",dat);....
                 ...}
           ...}
for(int j=0; j<buffer->getIndexCount(); j++)
		{
			u16* vx=buffer->getIndices();
                        fprintf(stream,"%d\n",dat);
			
		}
this is the main parts of the program...

My result on this program is(this is the exported cube):

Code: Select all

1  (number of mesh)
36 (number of vertices)
-1.036254 (coords of vertices,normals and uv)
-0.000000
1.396897
0.000000
...
36(number of index..)
0 (and the indexs...)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Now i have post,i think,all the info..My question is:is there a way to export the vertices that are useful without any copy of that vertices??36 vertices per one cube means that in a scene of 2000 i have found 7000+ exported poly..this is a terrible waste....and this means too that to export the index is useless because the vertices are sequential...

tnx
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

someone could help me??very tnx a lot
Post Reply