From 06b57b2c99c5ae67a8f724cbba212a5192cf5d6e Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 9 Feb 2009 11:21:46 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@74 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/body/Body.cpp | 39 ++++++++++++++++ sources/reactphysics3d/body/RigidBody.cpp | 57 +++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 sources/reactphysics3d/body/Body.cpp create mode 100644 sources/reactphysics3d/body/RigidBody.cpp diff --git a/sources/reactphysics3d/body/Body.cpp b/sources/reactphysics3d/body/Body.cpp new file mode 100644 index 00000000..41d62045 --- /dev/null +++ b/sources/reactphysics3d/body/Body.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + * Copyright (C) 2009 Daniel Chappuis * + **************************************************************************** + * This file is part of ReactPhysics3D. * + * * + * ReactPhysics3D is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * ReactPhysics3D is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with ReactPhysics3D. If not, see . * + ***************************************************************************/ + + // Libraries + #include "Body.h" + + // We want to use the ReactPhysics3D namespace + using namespace reactphysics3d; + + // Constructor + Body::Body(Kilogram mass) { + this->mass = mass; + } + + // Copy-constructor + Body::Body(const Body& body) { + this->mass = body.mass; + } + + // Destructor + Body::~Body() { + + } diff --git a/sources/reactphysics3d/body/RigidBody.cpp b/sources/reactphysics3d/body/RigidBody.cpp new file mode 100644 index 00000000..0a4052cc --- /dev/null +++ b/sources/reactphysics3d/body/RigidBody.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** + * Copyright (C) 2009 Daniel Chappuis * + **************************************************************************** + * This file is part of ReactPhysics3D. * + * * + * ReactPhysics3D is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * ReactPhysics3D is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with ReactPhysics3D. If not, see . * + ***************************************************************************/ + + // Libraries + #include "RigidBody.h" + + // We want to use the ReactPhysics3D namespace + using namespace reactphysics3d; + + // Constructor + RigidBody::RigidBody(const Vector3D& position, const Kilogram& mass, const Matrix3x3& inertiaTensor) + : Body(mass), inertiaTensor(inertiaTensor), + currentBodyState(position, inertiaTensor.getInverse(),Kilogram(1.0/mass.getValue())), + previousBodyState(position, inertiaTensor.getInverse(), Kilogram(1.0/mass.getValue())) { + isMotionEnabled = true; + isCollisionEnabled = true; + } + + // Copy-constructor + RigidBody::RigidBody(const RigidBody& rigidBody) : Body(rigidBody), inertiaTensor(rigidBody.inertiaTensor), + currentBodyState(rigidBody.currentBodyState), previousBodyState(rigidBody.previousBodyState) { + this->isMotionEnabled = rigidBody.isMotionEnabled; + this->isCollisionEnabled = rigidBody.isCollisionEnabled; + } + + // Destructor + RigidBody::~RigidBody() { + + }; + +// Return the force on the body at time t +Vector3D RigidBody::computeForce(Time time) const { + // TODO : Implement this method + return Vector3D(1*time.getValue(),0,0); +} + +// Return the torque on the body at time +Vector3D RigidBody::computeTorque(Time time) const { + // TODO : Implement this method + return Vector3D(1*time.getValue(),0,0); +}