Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

glutm/axes.cpp

Go to the documentation of this file.
00001 #include "axes.h"
00002 
00007 #include <glt/matrix.h>
00008 #include <glt/rgb.h>
00009 
00010 #include <glutm/shape.h>
00011 #include <glutm/glut.h>
00012 
00013 GlutAxes::GlutAxes(const double size)
00014 {
00015     GltShape *cylinder;
00016     GltShape *cone;
00017 
00018     const double radius = 0.05;
00019     const double length = 0.8;
00020 
00021     // Add the component shapes to the container.
00022     // Smart pointers will ensure that these nodes
00023     // are deleted when no longer in use.
00024 
00025     push_back(cylinder = new GlutCylinder(true,radius,length));
00026     push_back(cone = new GlutCone(true,radius*2.0,1.0-length));
00027 
00028     // Position the cone at the end of the cylinder
00029 
00030     cone->transformation() *= matrixTranslate(VectorZ*length);
00031 
00032     // All colours are taken from OpenGL state, 
00033     // rather than the individual nodes
00034 
00035     inheritColor() = true;
00036 
00037     cylinder->inheritColor() = true;
00038     cone    ->inheritColor() = true;
00039 
00040     // Scale the whole axes by the desired size
00041 
00042     transformation() *= matrixScale(size);
00043 }
00044 
00045 GlutAxes::~GlutAxes()
00046 {
00047 }
00048 
00049 void
00050 GlutAxes::draw() const
00051 {
00052     if (!visible())
00053         return;
00054 
00055     // X Axes
00056 
00057     glPushMatrix();
00058         glRotateY(90.0);
00059         red.glColor();
00060         GltShapes::draw();
00061     glPopMatrix();
00062 
00063     // Y Axes
00064     
00065     glPushMatrix();
00066         glRotateX(-90.0);
00067         green.glColor();
00068         GltShapes::draw();
00069     glPopMatrix();
00070 
00071     // Z Axes
00072 
00073     blue.glColor();
00074     GltShapes::draw();
00075 }

Generated on Tue Nov 5 11:11:04 2002 for GLT by doxygen1.2.18