vertex ordering opengl cal3d

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

vertex ordering opengl cal3d

Post by Gorgon Zola »

Hi
I'm working on a Cal3d SceneNode and have come to a problem I don't completely understand.

the following screenshot should show a paladin wallking around.
notice the jitter on the skin? it seems that the triangles are drawn the wrong way (wrong rotation or something).

Image
Image

if i view the same paladin in the modelviewer provided with cal3d there's no problem

Image
Image

i'am using opengl in irrlicht and in the cal3d modelviewer but irrlicht seems to configure something that shuffels the vertex order?
eric (an irrlicht user) had the idea that it might have something to do with different coordinate systems - left-handed vs. right-handed. but i don't know where/how i can circumvent this.

if anyone has any idea where i could start looking for the error please let me know, i don't have any clue where i should start searching :(

thanks
tom
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Yeah, did it. If anybody is interested in the scenenode just send me a mail
Image
joy
Posts: 124
Joined: Tue Apr 27, 2004 9:15 am
Location: Germany

Post by joy »

Could you shortly summerize what the solution or the mistake was?
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

joy wrote:Could you shortly summerize what the solution or the mistake was?
It was a type confusion with the vertex indextable. So, irrlicht is completely innocent :)

In Cal3D you can get the index array for the faces with the following code

Code: Select all

CalIndex meshFaces[50000][3];
int faceCount =pCalRenderer->getFaces(&meshFaces[0][0]);
The typedef for 'CalIndex' is either a 'unsigned short' or an 'int'. I didn't know that because visual studio only showed me the 'unsigned short' typedef with intellisense :x . So i assumed that the typecast '(const irr::u16*)meshFaces' would be enough to let the mesh draw.
Well, it wasn't!
So, i decided to use an irrlicht meshbuffer and what do you think - it suddenly worked :wink:

Code: Select all

mb.Indices.clear();
for(int i=0; i<faceCount; ++i)
{
  mb.Indices.push_back(meshFaces[i][0]);
  mb.Indices.push_back(meshFaces[i][1]);
  mb.Indices.push_back(meshFaces[i][2]);
}
Now, for the lefthanded versus righthanded coordinate problem:
this doesn't affect the rendering in the local way (triangle scattering or what ever) but in a global way, rotations are the oposit way round and vertecis are mirrored.

I hope this helps prevent similar errors :)
Manakel166

Post by Manakel166 »

If i remember well , Cal3d is using D3D style matrix which is the opposite of OpenGL matrix
In one informations are given row by row and for the other they are given col by col.

Anyway, i would love to have a look on you cal3dscene node , did you use Server classes for Models Caching?

my mail is woody 66 G at AOL COM
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post by warui »

Why not put the code on the website ? http://www.eve-corp.com/ provides free hosting for irrlicht projects.
Tomasz Nowakowski
Openoko - www.openoko.pl
Post Reply