00001 00002 00003 00004 00005 // ChangeLog 00006 // Dec 07, 2004 - Bruno de Oliveira Schneider 00007 // - Added ComputeBoundingBox(). 00008 // Sep 30, 2004 - Bruno de Oliveira Schneider 00009 // - Code typing has been cleaned. DoxyGen documentation started. Indentation fixed. 00010 // - Removed "vp" prefix from every method name. 00011 // - Removed (empty) vpRender method. 00012 // - Added DrawInstanceOGL method. 00013 // - Added code for initializing transform matrices in constructors. 00014 // - Added "material" attribute and related Get/Set methods. 00015 // Oct 10, 2000 - Anderson Maciel 00016 // - Methods atualization. 00017 // Aug 10, 2000 - Anderson Maciel 00018 // - Classes declaration. 00019 00020 #ifdef VP_OGL 00021 #include <GL/glu.h> 00022 #endif 00023 #include "vpsphere.h" 00024 00025 VPSphere::VPSphere() : VPGraphicObj() { 00026 radius = 1.0; 00027 } 00028 00029 VPSphere::VPSphere( float fRad ) : VPGraphicObj() { 00030 radius = fRad; 00031 } 00032 00033 void VPSphere::SetRadius( float r ) { 00034 radius = r; 00035 } 00036 00037 float VPSphere::GetRadius( void ) { 00038 return radius; 00039 } 00040 00041 void VPSphere::ComputeBoundingBox() { 00042 bBox.SetSmallerX(-radius); 00043 bBox.SetSmallerY(-radius); 00044 bBox.SetSmallerZ(-radius); 00045 bBox.SetGreaterX(radius); 00046 bBox.SetGreaterY(radius); 00047 bBox.SetGreaterZ(radius); 00048 } 00049 00050 bool VPSphere::DrawInstanceOGL() const { 00051 #ifdef VP_OGL 00052 GLUquadricObj* qObj = gluNewQuadric(); 00053 bool result = material.DrawOGL(); 00054 00055 gluQuadricDrawStyle(qObj, GLU_FILL); 00056 gluQuadricNormals(qObj, GLU_SMOOTH); 00057 gluSphere(qObj, radius, 15, 15); 00058 gluDeleteQuadric(qObj); 00059 return result; 00060 #else 00061 return false; 00062 #endif 00063 }