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

Physical.h

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 #ifndef OPENCAL_PHYSICAL_H 00012 #define OPENCAL_PHYSICAL_H 00013 00014 // Includes 00015 #include <OpenCAL/global.h> 00016 00017 #include <OpenCAL/Vector3.h> 00018 using OpenCAL::Utils::Vector3; 00019 00020 00021 namespace OpenCAL 00022 { 00023 // Forward declarations 00024 00028 class OPENCAL_API Physical 00029 { 00030 protected: 00031 // Member variables 00032 mutable Vector3 m_velocity, m_force; 00033 float m_oneOverMass; 00034 00035 public: 00036 // Destructor 00037 virtual ~Physical(); 00038 00039 // Get functions 00040 virtual const Vector3 &getVelocity() const { return m_velocity; } 00041 virtual Vector3 *getVelocityP() { return &m_velocity; } 00042 Vector3 getMomentum() const { return m_velocity * getMass(); } 00043 const Vector3 &getForce() const { return m_force; } 00044 Vector3 *getForceP() { return &m_force; } 00045 Vector3 getAccelleration() const { return m_force * m_oneOverMass; } 00046 float getMass() const; 00047 float getOneOverMass() const { return m_oneOverMass; } 00048 bool hasInfiniteMass() const { return m_oneOverMass == 0.0f; } 00049 00050 // Set functions 00051 void setVelocity(const Vector3 &velocity) { m_velocity = velocity; } 00052 void setForce(const Vector3 &force) { m_force = force; } 00053 virtual void addForce(const Vector3 &force) { m_force += force; } 00054 void resetForce() { m_force = Vector3::zero; } 00055 void setAccelleration(const Vector3 &accelleration); 00056 void setMass(float mass); 00057 void setOneOverMass(float oneOverMass) { m_oneOverMass = oneOverMass; } 00058 void setInfiniteMass() { m_oneOverMass = 0.0f; } 00059 //void fix() { m_oneOverMass = 0.0f; m_velocity = m_force = Vector3::zero; } 00060 00061 protected: 00062 // Constructor is protected, so no instance of this base class can be made 00063 Physical(float mass = 1.0); 00064 }; 00065 } 00066 00067 #endif // OPENCAL_PHYSICAL_H

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