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...
Exporting Geometry
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.
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.
-
- Posts: 16
- Joined: Sun May 21, 2006 8:52 pm
-
- Posts: 16
- Joined: Sun May 21, 2006 8:52 pm
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:
this is the main parts of the program...
My result on this program is(this is the exported cube):
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
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);
}
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
tnx