1
C / C++ /C# / Re: [C++] Opengl Glut 3D Mesh Topolgy
« on: June 09, 2011 »
I think you are translating the world coordinates twice. This means that you have changed the position of the world's origin. You might consider pushing a transformation on, executing the drawing code, the popping it off the stack. Then draw your lines in the world coordinates.
I've not used glut but often those shape drawing commands like to draw a shape at position (0,0,0). This means you have to shift the world cordinates to where you want, draw the shape then return to the original coordinates.
Thanks pixel! It's starting to make sense

Code: [Select]
void drawNode() {
glColor3f(1.0f, 1.0f, 1.0f);
// Draw node
glTranslatef(0.0f ,0.75f, 0.0f);
glutSolidCube(1);
glBegin(GL_LINES); //Begin drawing lines
// 2 end points on line
glVertex3f(0.0f, 0.75f, 0.0f);
glVertex3f(0.0f, 2.0f, 0.0f);
glEnd();
// Draw node2
glTranslatef(0.0f, 2.0f, 0.0f);
glutSolidCube(1);
}
// Draw 36 Nodes
for(int i = -3; i < 3; i++)
for(int j=-3; j < 3; j++)
{
glPushMatrix();
glTranslatef(i*10.0f, 0.0f, j * 10.0f);
drawNode();
glPopMatrix();
}
}