Archived

This topic is now archived and is closed to further replies.

ogl

GluProject

Recommended Posts

Hi What do you need to know to use gluproject - what would the coordinates of the object be for instance for the cuboid below and what would the window coordinates be? glTranslated(1.0, 1.0, 1.0); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); //horizontal side right face glBegin(GL_POLYGON); glNormal3d( 0.3, 0.0, 0.0); glVertex3d( 0.9, 0.3, 0.3); glVertex3d( 0.9, -0.3, 0.3); glVertex3d( 0.9, -0.3, -0.3); glVertex3d( 0.9, 0.3, -0.3); glEnd(); //horizontal side left face glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( -0.3, 0.0, 0.0); glVertex3d( -0.9, -0.3, 0.3); glVertex3d( -0.9, 0.3, 0.3); glVertex3d( -0.9, 0.3, -0.3); glVertex3d( -0.9, -0.3, -0.3); glEnd(); //Top of cuboid glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.3, 0.0); glVertex3d( 0.9, 0.3, 0.3); glVertex3d( -0.9, 0.3, 0.3); glVertex3d( -0.9, 0.3, -0.3); glVertex3d( 0.9, 0.3, -0.3); glEnd(); //Bottom face of cuboid glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, -0.3, 0.0); glVertex3d( -0.9, -0.3, 0.3); glVertex3d( 0.9, -0.3, 0.3); glVertex3d( 0.9, -0.3, -0.3); glVertex3d( -0.9, -0.3, -0.3); glEnd(); //Front face of cuboid glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PurpleSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, 0.3); glVertex3d( -0.5, 0.3, 0.3); //top right corner glVertex3d( -0.9, 0.3, 0.3); //top left corner glVertex3d( -0.9, -0.3, 0.3); //bottom left corner glVertex3d( -0.5, -0.3, 0.3); //bottom right corner glEnd(); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, 0.3); glVertex3d( -0.2, 0.3, 0.3); glVertex3d( -0.5, 0.3, 0.3); glVertex3d( -0.5, -0.3, 0.3); glVertex3d( -0.2, -0.3, 0.3); glEnd(); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PurpleSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, 0.3); glVertex3d( 0.2, 0.3, 0.3); glVertex3d( -0.2, 0.3, 0.3); glVertex3d( -0.2, -0.3, 0.3); glVertex3d( 0.2, -0.3, 0.3); glEnd(); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, 0.3); glVertex3d( 0.5, 0.3, 0.3); glVertex3d( 0.2, 0.3, 0.3); glVertex3d( 0.2, -0.3, 0.3); glVertex3d( 0.5, -0.3, 0.3); glEnd(); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PurpleSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, 0.3); glVertex3d( 0.9, 0.3, 0.3); glVertex3d( 0.5, 0.3, 0.3); glVertex3d( 0.5, -0.3, 0.3); glVertex3d( 0.9, -0.3, 0.3); glEnd(); //Back face of cuboid glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlueSurface); glBegin(GL_POLYGON); glNormal3d( 0.0, 0.0, -0.3); glVertex3d( -0.9, 0.3, -0.3); glVertex3d( 0.9, 0.3, -0.3); glVertex3d( 0.9, -0.3, -0.3); glVertex3d( -0.9, -0.3, -0.3); glEnd(); thanx ogl

Share this post


Link to post
Share on other sites
Take all those points and project them onto the x, y plane where z = 0. Do it just like creating a shadow... In fact, it IS a shadow in a manner of speaking. I''m sure there''s gotta be some tuts out there... Of course, if you feel that you are able to read through pages of books and suck out all the info you need instead of use something like NeHe''s nice tuts, then check out the OGL SuperBible... It''s got a section on shadows.

S.

Share this post


Link to post
Share on other sites