proj home

Files   Classes   Functions   Hierarchy  

cubedraw3d Class Reference

Draw the cube in 3D. More...

#include <cubedraw3d.h>

Inheritance diagram for cubedraw3d:
Collaboration diagram for cubedraw3d:

List of all members.

Public Member Functions

 cubedraw3d (cube const &cb_, doublec dx_)
 Initialize the parameters only.
void draw ()
 Write out the OpenGL directly.

Public Attributes

double dx
 The side length of a face.


Detailed Description

Draw the cube in 3D.

Definition at line 10 of file cubedraw3d.h.


Constructor & Destructor Documentation

cubedraw3d::cubedraw3d ( cube const &  cb_,
doublec  dx_ 
)

Initialize the parameters only.

Definition at line 84 of file cubedraw3d.cpp.

00088   : cubedraw(cb_), dx(dx_) {}


Member Function Documentation

void cubedraw3d::draw (  )  [virtual]

Write out the OpenGL directly.

Reimplemented from cubedraw.

Definition at line 12 of file cubedraw3d.cpp.

References cubedraw::cb, cube::cs, dx, glerrordisplay(), cursor::j, and cursor::k.

00013 {
00014   doublec w = dx * 3.0;
00015 
00016   glPushMatrix();
00017   glTranslated(0.0,0.0,w);
00018   writeface(0);
00019   cursor const & cs(cb.cs);
00020   double y = dx/3.0;
00021   glTranslated((dx-y)*0.5+cs.j*dx,dx*0.4+cs.k*dx,0.01);
00022   glPushAttrib(GL_CURRENT_BIT);
00023   glPushAttrib(GL_LIGHTING);
00024 
00025   glDisable(GL_LIGHTING);
00026 
00027   {
00028     glBegin(GL_TRIANGLES);
00029 
00030     
00031     glColor3f(1.0,0.0,0.0);
00032     glNormal3d(0.0,0.0,1.0);     
00033     glVertex3d(0.0,0.0,0.0);
00034 
00035     glColor3f(1.0,0.0,0.0);
00036     glNormal3d(0.0,0.0,1.0);     
00037     glVertex3d(y,0.0,0.0);
00038   
00039     glColor3f(0.0,0.0,1.0);
00040     glNormal3d(0.0,0.0,1.0);     
00041     glVertex3d(y*0.5,y*0.866,0.0);
00042 
00043     glEnd();
00044   }
00045 
00046   glPopAttrib();
00047   glPopAttrib();
00048   
00049   glPopMatrix();
00050 
00051   glPushMatrix();
00052   glRotated(180.0,0.0,1.0,0.0);
00053   glTranslated(-w,0.0,0.0);
00054   writeface(2);
00055   glPopMatrix();
00056 
00057   glPushMatrix();
00058   glTranslated(w,0.0,w);
00059   glRotated(90.0,0.0,1.0,0.0);
00060   writeface(1);
00061   glPopMatrix();
00062 
00063   glPushMatrix();
00064   glRotated(-90.0,0.0,1.0,0.0);
00065   writeface(3);
00066   glPopMatrix();
00067 
00068   // Top
00069   glPushMatrix();
00070   glTranslated(0.0,w,w);
00071   glRotated(-90.0,1.0,0.0,0.0);
00072   writeface(5);
00073   glPopMatrix();
00074 
00075   glPushMatrix();
00076   glRotated(90.0,1.0,0.0,0.0);
00077   writeface(4);
00078   glPopMatrix();
00079 
00080   glerrordisplay();
00081 }


Member Data Documentation

The side length of a face.

Definition at line 17 of file cubedraw3d.h.

Referenced by draw().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:49:52 2011 for Chelton Evans Source by  doxygen 1.5.8