PDA

View Full Version : dealing individual objects



kingslee
13th November 2006, 00:30
hello,

I draw 4 individual objects stic together(4 cubes to form a square in blender)and export it to VRML2 format. In that i have points and coordindex for each object.so I create array list(glnewlist()) for each and print on the screen.

but the objects are not as before, it merged or in unordered manner
is there something to do with transformations?

any idea about dealing this ,please?
thanks


glNewList(2, GL_COMPILE);

for (int i=0; i<6; i++)
{
glBegin(GL_POLYGON);
x=Friend2[faceRefs2[i][0]][0];
y=Friend2[faceRefs2[i][0]][1];
z=Friend2[faceRefs2[i][0]][2];
glVertex3f(x, y, z);
x=Friend2[faceRefs2[i][1]][0];
y=Friend2[faceRefs2[i][1]][1];
z=Friend2[faceRefs2[i][1]][2];
glVertex3f(x, y, z);
x=Friend2[faceRefs2[i][2]][0];
y=Friend2[faceRefs2[i][2]][1];
z=Friend2[faceRefs2[i][2]][2];
glVertex3f(x, y, z);
x=Friend2[faceRefs2[i][3]][0];
y=Friend2[faceRefs2[i][3]][1];
z=Friend2[faceRefs2[i][3]][2];
glVertex3f(x, y, z);
if(faceRefs2[i][4] != -1)
{
x=Friend2[faceRefs2[i][4]][0];
y=Friend2[faceRefs2[i][4]][1];
z=Friend2[faceRefs2[i][4]][2];
glVertex3f(x, y, z);
}
glEnd();
}
glColor3f(1.0f,0.0f,1.0f);
glBegin(GL_QUADS);
x=Friend2[4][0];
y=Friend2[4][1];
z=Friend2[4][2];
glVertex3f(x,y,z);
x=Friend2[5][0];
y=Friend2[5][1];
z=Friend2[5][2];
glVertex3f(x,y,z);
x=Friend2[6][0];
y=Friend2[6][1];
z=Friend2[6][2];
glVertex3f(x,y,z);
x=Friend2[7][0];
y=Friend2[7][1];
z=Friend2[7][2];
glVertex3f(x,y,z);
glEnd();

glEndList();

jacek
13th November 2006, 00:51
Could you post the contents of Friend2 and faceRefs2 arrays for such crippled object?

kingslee
13th November 2006, 00:54
these are the array list for the 3 objects and I make the list and print
Friend are points and facreRefs are coordIndex


GLfloat Friend[8][3]={
{0.163, -1.0, -1.262},
{0.163, -1.0, 0.738},
{-0.032, -1.0, 0.738},
{-0.032, -1.0, -1.262},
{0.163, 1.0, -1.262},
{0.163, 1.0, 0.738},
{-0.032, 1.0, 0.738},
{-0.032, 1.0, -1.262}
};
int faceRefs[6][5]={
{0, 1, 2, 3, -1},
{4, 7, 6, 5, -1},
{0, 4, 5, 1, -1},
{1, 5, 6, 2, -1},
{2, 6, 7, 3, -1},
{4, 0, 3, 7, -1}
};




GLfloat Friend2[8][3]={ {1.962, -1.0, -0.156},
{ 1.962, -1.0, 0.113},
{ -2.312, -1.0, 0.113},
{-2.312, -1.0, -0.156},
{1.962, 1.0, -0.156},
{1.962, 1.0, 0.113},
{-2.312, 1.0, 0.113},
{-2.312, 1.0, -0.1562}
};
int faceRefs2[6][5]={
{0, 1, 2, 3, -1},
{4, 7, 6, 5, -1},
{0, 4, 5, 1, -1},
{1, 5, 6, 2, -1},
{2, 6, 7, 3, -1},
{4, 0, 3, 7, -1}
};




GLfloat Friend3[8][3]={
{-1.846, -1.0, -0.891},
{-1.846, -1.0, 1.109},
{-2.046, -1.0, 1.109},
{-2.046, -1.0, -0.891},
{-1.846, 1.0, -0.891},
{-1.846, 1.0, 1.109},
{-2.046, 1.0, 1.109},
{-2.046, 1.0, -0.891}
};

int faceRefs3[6][5]={
{0, 1, 2, 3, -1},
{4, 7, 6, 5, -1},
{0, 4, 5, 1, -1},
{1, 5, 6, 2, -1},
{2, 6, 7, 3, -1},
{4, 0, 3, 7, -1}
};

jacek
13th November 2006, 01:21
these are the array list for the 3 objects and I make the list and print
How should these objects look like?

So far I see only one problem: the normals are assigned in a wrong way, because you draw vertices of some faces in reverse order.

kingslee
13th November 2006, 01:43
Thank you jacek for your reply.
I here by attach the screen schots - top view and bit tilted top view and the vrml file.
i changed the extension of vrml to txt for uploading (check11.txt)

jacek
13th November 2006, 13:48
It looks like your VRML file is corrupted. If you open it in a VRML viewer, you'll get the same object as in OpenGL.

kingslee
14th November 2006, 07:02
thansk jacek !
Is there something to do with the world cordinates .. as I get it from otehr forum

the explanation.

This seems to be a problem of moving the coordinate system to the correct position. I don't know blender that well, but if it works like other 3D modellers it's likely that the object's vertices are stored in object space along with a world space transform of the object.

Example: You have two boxes (axis aligned, coords in world space):
1) min = (0/0/0), max = (1/1/1)
2) min = (2/2/2), max = (3/3/3)

Storing the verts in object space (centers at (0.5/0.5/0.5) and (2.5/2.5/2.5) in world space) gives :

min = (-0.5/-0.5/-0.5) and max = (0.5/0.5/0.5) for BOTH boxes.

Rendering them without moving box2's coordinate system to (2.5/2.5/2.5) in world space results in box2 drawn on top of box1.

/
/draw box1
glPushMatrix();
glTranslatef(box1.pos.x, box1.pos.y, box1.pos.z);
box1.draw();
glPopMatrix();

//draw box2
glPushMatrix();
glTranslatef(box2.pos.x, box2.pos.y, box2.pos.z);
box2.draw();
glPopMatrix();


But the problem is I dont know how to get the position of x yz from the array list.

is that possible?

jacek
15th November 2006, 00:42
Maybe you should just try a more recent version? I have Blender 2.27a and there are two VRML97 exporters. Both seem to work correctly.

kingslee
15th November 2006, 02:18
thanks jacek for ur reply.
I use blender 2.42a and vrml 2.

then I will try with vrml97 export and get back to you.

thanks

kingslee
15th November 2006, 02:28
OMG
It works perfectly with the vrml viewer


the thing is, in the vrml2 export, there is no translation information of each objects.


regards
kings