Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vpcylinder.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // ChangeLog
00006 // Jun 01, 2005 - Andreia Schneider
00007 //- Fixed bottom orientation.
00008 // Mar 21, 2005 - Bruno de Oliveira Schneider
00009 // - Added ComputeBoundingBox.
00010 // Oct 13, 2004 - Bruno de Oliveira Schneider
00011 // - Code typing has been cleaned. DoxyGen documentation started.
00012 // - Removed "vp" prefix from every method name.
00013 // - Removed (empty) vpRender method.
00014 // - Added DrawInstanceOGL method.
00015 // - Added code for initializing transform matrices in constructors.
00016 // - Added "material" attribute and related Get/Set methods.
00017 // Aug 10, 2000 - Anderson Maciel
00018 // - Classes declaration.
00019 // Jun 28, 2000 - Anderson Maciel
00020 // - Methods atualization.
00021 
00022 #include "vpcylinder.h"
00023 #ifdef VP_OGL
00024 #include <GL/glu.h>
00025 #endif
00026 
00027 //?
00028 #include <iostream>
00029 using namespace std;
00030 
00031 
00032 VPCylinder::VPCylinder() : VPGraphicObj() {
00033     height = radius = 1.0;
00034     side = top = bottom = true;
00035 }
00036 
00037 VPCylinder::VPCylinder( float fHi, float fRad ) : VPGraphicObj() {
00038     height = fHi;
00039     radius = fRad;
00040 }
00041 
00042 VPCylinder::VPCylinder( float fHi, float fRad, bool bS, bool bT, bool bB )
00043            : VPGraphicObj() {
00044     height = fHi;
00045     radius = fRad;
00046     side = bS;
00047     top = bT;
00048     bottom = bB;
00049 }
00050 
00051 void VPCylinder::ComputeBoundingBox() {
00052     bBox.SetBoundingBox(-radius, -radius, 0, radius, radius, top);
00053 }
00054 
00055 void VPCylinder::SetHeight( float h ){
00056     height = h;
00057 }
00058 
00059 void VPCylinder::SetRadius( float r ){
00060     radius = r;
00061 }
00062 
00063 void VPCylinder::ShowSide( bool yesno ){
00064     side = yesno;
00065 }
00066 
00067 void VPCylinder::ShowTop( bool yesno ){
00068     top = yesno;
00069 }
00070 
00071 void VPCylinder::ShowBottom( bool yesno ){
00072     bottom = yesno;
00073 }
00074 
00075 float VPCylinder::GetHeight( void ){
00076     return height;
00077 }
00078 
00079 float VPCylinder::GetRadius( void ){
00080     return radius;
00081 }
00082 
00083 bool VPCylinder::ShowSide( void ){
00084     return side;
00085 }
00086 
00087 bool VPCylinder::ShowTop( void ){
00088     return top;
00089 }
00090 
00091 bool VPCylinder::ShowBottom( void ){
00092     return bottom;
00093 }
00094 
00095 bool VPCylinder::DrawInstanceOGL() const {
00096 #ifdef VP_OGL
00097     GLUquadricObj* qObj = gluNewQuadric();
00098 
00099     bool result = material.DrawOGL();
00100     // Render sides
00101     if (side) {
00102         gluQuadricDrawStyle(qObj, GLU_FILL);
00103         gluQuadricNormals(qObj, GLU_SMOOTH);
00104         gluCylinder(qObj, radius, radius, height, 15, 1);
00105     }
00106     // Render bottom
00107     if (bottom) {
00108         gluQuadricOrientation(qObj,GLU_INSIDE);
00109         gluDisk(qObj, 0.0, radius, 15, 1);
00110     }
00111     // Render top
00112     if (top) {
00113         glPushMatrix();
00114         gluQuadricOrientation(qObj,GLU_OUTSIDE);
00115         glTranslatef(0.0f, 0.0f, height);
00116         gluDisk(qObj, 0.0, radius, 15, 1);
00117         glPopMatrix();
00118     }
00119     gluDeleteQuadric(qObj);
00120     return result;
00121 #else
00122     return false;
00123 #endif
00124 }

Generated on Tue Sep 6 10:00:03 2005 for VPAT by  doxygen 1.4.4