Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

sphere.cc

Go to the documentation of this file.
00001 #include "sphere.hh"
00002 #include "register.hh"
00003 
00004 namespace anoid {
00005     namespace plugin {
00006 
00007         using namespace config;
00008 
00009         DtShapeRef sphereshape;
00010         GLuint display; // For some reason I cannot load classes with static members
00011         bool inited = false;
00012 
00013         void Sphere::redraw() {
00014             glCallList(display);
00015             Shape::redraw();
00016         }
00017 
00018         void Sphere::init(Configuration &c) {
00019             if (!inited) {
00020                 inited = true;
00021                 display = glGenLists(1);
00022 
00023                 sphereshape = dtSphere(0.5);
00024 
00025                 GLUquadricObj *pObj = gluNewQuadric();
00026                 gluQuadricNormals(pObj, GLU_SMOOTH);
00027                 gluQuadricDrawStyle(pObj, GLU_FILL);
00028 
00029                 glNewList(display, GL_COMPILE);
00030                 gluSphere(pObj, 0.5, 25, 25);
00031                 glEndList();
00032 
00033                 gluDeleteQuadric(pObj);
00034             }
00035 
00036             dtCreateObject(parent, sphereshape);
00037             Shape::init(c);
00038         }
00039 
00040         void Sphere::getInverseInertiaTensor(double *output, double a, double b, double c) {
00041             Shape::getInverseInertiaTensor(output, a, b, c);
00042 
00043             output[0] = 5.0 / (b*b + c*c);
00044             output[5] = 5.0 / (a*a + c*c);
00045             output[10] = 5.0 / (a*a + b*b);
00046         }
00047 
00048         Register(Sphere)
00049 
00050     };
00051 };

Anoid NG © Michael Westergaard, Martin Stig Stissing, Ronni Michael Laursen, and Kristian Bisgaard Lassen