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

PhysicsSystem.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_PHYSICSSYSTEM_H 00012 #define OPENCAL_PHYSICSSYSTEM_H 00013 00014 // Includes 00015 #include <OpenCAL/global.h> 00016 #include <OpenCAL/System.h> 00017 //#include <OpenCAL/PhaseSpace.h> 00018 #include <OpenCAL/ODESource.h> 00019 00020 /* 00021 #include <vector> 00022 using std::vector; 00023 */ 00024 00025 00026 namespace OpenCAL 00027 { 00028 // Forward declarations 00029 class PhysicalObject; 00030 class Force; 00031 class Constraint; 00032 class ODESolver; 00033 00034 00040 class OPENCAL_API PhysicsSystem: public System, public ODESource 00041 { 00042 protected: 00043 // Typedefs 00044 /* 00045 typedef vector<PhysicalObject *> ObjectList; 00046 typedef vector<Force *> ForceList; 00047 typedef vector<Constraint *> ConstraintList; 00048 */ 00049 00050 // Member variables 00051 /* 00052 ObjectList m_objects; 00053 ForceList m_forces; 00054 ConstraintList m_constraints; 00055 */ 00056 ODESolver *m_solver; 00057 float m_maxStepSize; 00058 00059 public: 00060 // Constructors and destructor 00061 PhysicsSystem(System *parent); 00062 virtual ~PhysicsSystem(); 00063 00064 // Get functions 00065 PhysicalObject *getPhysicalObject(unsigned int i) { return (PhysicalObject *) m_objects[i]; } 00067 virtual Force *getForce(unsigned int i) { return (Force *) m_actors[i]; } 00069 virtual Constraint *getConstraint(unsigned int i) { return (Constraint *) m_agents[i]; } 00071 00072 float getMaxStepSize() const { return m_maxStepSize; } 00073 00074 // Set functions 00076 void setMaxStepSize(float stepSize) { m_maxStepSize = stepSize; } 00077 00078 // Force functions 00079 void addForce(const Vector3 &force); 00080 void resetForces(); 00081 00082 // Step functions 00083 virtual void step(float deltaSeconds); 00084 00085 /* 00086 // Phase space functions 00087 PhaseSpace getState() const; 00088 void setState(const PhaseSpace &state); 00089 PhaseSpace getDerivative() const; 00090 */ 00091 // ODE Source functions 00092 virtual void fillState(); 00093 virtual void fillDerivative(); 00094 virtual void fromState(); 00095 00096 // Other functions 00097 virtual void initialize(); 00098 00099 protected: 00100 // Add functions 00101 //virtual void addObject(Object *object); 00102 //virtual void addActor(Actor *actor); 00103 //virtual void addAgent(Agent *agent); 00104 00105 00106 /* 00107 virtual void addObject(PhysicalObject *object) { m_objects.push_back(object); } 00108 virtual void addForce(Force *force) { m_forces.push_back(force); } 00109 virtual void addConstraint(Constraint *constraint) { m_constraints.push_back(constraint); } 00110 00111 // Delete functions 00112 virtual void deleteObject(PhysicalObject *object); 00113 virtual void deleteForce(Force *force); 00114 virtual void deleteConstraint(Constraint *constraint); 00115 */ 00116 00117 //friend class PhysicalObject; 00118 //friend class Force; 00119 //friend class Constraint; 00120 }; 00121 } 00122 00123 #endif // OPENCAL_PHYSICSSYSTEM_H

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