00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00026
00027
00028 PointMass::PointMass(
System *parent,
float mass)
00029 :
PhysicalObject(parent, mass)
00030 {
00031
00032 m_draw =
false;
00033 }
00034
00035 PointMass::~PointMass()
00036 {
00037 }
00038
00039
00040
00041
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
00082 m_force = Vector3::zero;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105