-
May 4th, 2008, 09:59 AM
#1
3D object scaling
Hello,
My first question is about rendering a pyramid with a certain dimension using opengl.
My code renders the pyramid using fixed vertices coordinates :
Code:
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Front)
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f); // Left Of Triangle (Front)
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 1.0f); // Right Of Triangle (Front)
glEnd();
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Right)
glTexCoord2f(0.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 1.0f); // Left Of Triangle (Right)
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f); // Right Of Triangle (Right)
glEnd();
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Back)
glTexCoord2f(0.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, -1.0f); // Left Of Triangle (Back)
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, -1.0f); // Right Of Triangle (Back)
glEnd();
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f); // Top Of Triangle (Left)
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-1.0f,-1.0f,-1.0f); // Left Of Triangle (Left)
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f); // Right Of Triangle (Left)
glEnd();
The problem is that I need to take the size of the pyramid from the user, the triangle's side. I haven't managed to figure out how to change the vertices coordinates using the side put in by the user.(the side being held in a variable, for example "side") and render the scaled pyramid.
Another question is about glut texturing. Is it possible to add textures on objects rendered with glut functions? For example : glutTorus, can accept textured images on it, like the objects rendered with glu?
Thank you in advance for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|