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

PointMass.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "PointMass.h" 00013 #include <OpenCAL/System.h> 00014 #include <OpenCAL/Renderer.h> 00015 #include <OpenCAL/PhaseSpace.h> 00016 using namespace OpenCAL; 00017 00018 #include <OpenCAL/Material.h> 00019 using Utils::Material; 00020 00021 using namespace std; 00022 00023 00024 /****************************** 00025 * Constructors and destructor * 00026 ******************************/ 00027 00028 PointMass::PointMass(System *parent, float mass) 00029 : PhysicalObject(parent, mass) 00030 { 00031 // Don't draw a point mass by default (mostly used in agregates) 00032 m_draw = false; 00033 } 00034 00035 PointMass::~PointMass() 00036 { 00037 } 00038 00039 00040 /****************** 00041 * Other functions * 00042 ******************/ 00043 00044 void PointMass::render() 00045 { 00046 Renderer *renderer = m_parent->getRenderer(); 00047 if(!renderer) return; 00048 00049 renderer->renderPoint(m_position, 2.0f); 00050 } 00051 00052 void PointMass::addToState(PhaseSpace *state) 00053 { 00054 state->concat(m_position); 00055 state->concat(m_velocity); 00056 } 00057 00058 void PointMass::addToDerivative(PhaseSpace *deriv) 00059 { 00060 bool fixed = isFixed(); 00061 00062 deriv->concat(fixed ? Vector3::zero : getVelocity()); 00063 deriv->concat(fixed ? Vector3::zero : getAccelleration()); 00064 } 00065 00066 void PointMass::fromState(PhaseSpace *state) 00067 { 00068 if(isFixed()) 00069 state->skip(6); 00070 else 00071 { 00072 m_position.setX(state->getNext()); 00073 m_position.setY(state->getNext()); 00074 m_position.setZ(state->getNext()); 00075 00076 m_velocity.setX(state->getNext()); 00077 m_velocity.setY(state->getNext()); 00078 m_velocity.setZ(state->getNext()); 00079 } 00080 00081 // @warning Should this be done here? 00082 m_force = Vector3::zero; 00083 } 00084 00085 /* 00086 #ifdef USE_OPENGL 00087 void PointMass::drawGL() 00088 { 00089 //if(!m_draw) return; 00090 00091 Utils::Material mat; 00092 mat.applyGL(); 00093 00094 // Draw the point mass 00095 glBegin(GL_POINTS); 00096 glVertex3fv(m_position); 00097 glEnd(); 00098 } 00099 #endif // USE_OPENGL 00100 */ 00101 00102 00103 /********************** 00104 * Protected functions * 00105 **********************/

Generated on Sun Aug 15 19:19:23 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8