00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
#ifndef OPENCAL_PHYSICSSYSTEM_H
00012
#define OPENCAL_PHYSICSSYSTEM_H
00013
00014
00015
#include <OpenCAL/global.h>
00016
#include <OpenCAL/System.h>
00017
00018
#include <OpenCAL/ODESource.h>
00019
00020
00021
00022
00023
00024
00025
00026
namespace OpenCAL
00027 {
00028
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
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
ODESolver *m_solver;
00057
float m_maxStepSize;
00058
00059
public:
00060
00061 PhysicsSystem(
System *parent);
00062
virtual ~PhysicsSystem();
00063
00064
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
00076 void setMaxStepSize(
float stepSize) { m_maxStepSize = stepSize; }
00077
00078
00079
void addForce(
const Vector3 &force);
00080
void resetForces();
00081
00082
00083
virtual void step(
float deltaSeconds);
00084
00085
00086
00087
00088
00089
00090
00091
00092
virtual void fillState();
00093
virtual void fillDerivative();
00094
virtual void fromState();
00095
00096
00097
virtual void initialize();
00098
00099
protected:
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 };
00121 }
00122
00123
#endif // OPENCAL_PHYSICSSYSTEM_H