phyellipsoid.cpp
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2014 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #include "phyellipsoid.h"
21 #include "private/phyobjectprivate.h"
22 #include "private/worldprivate.h"
23 
24 namespace farsa {
25 
26 PhyEllipsoid::PhyEllipsoid( real radiusx, real radiusy, real radiusz, World* w, QString name, const wMatrix& tm )
27  : PhyObject( w, name, tm, false ) {
28  this->radiusx = radiusx;
29  this->radiusy = radiusy;
30  this->radiusz = radiusz;
31  w->pushObject( this );
33  changedMatrix();
34 }
35 
37 #ifdef WORLDSIM_USE_NEWTON
38  /* nothing to do */
39 #endif
40 }
41 
43 #ifdef WORLDSIM_USE_NEWTON
44  NewtonCollision* c = NewtonCreateSphere( worldpriv->world, radiusx, radiusy, radiusz, 1, 0 );
45  wMatrix initialTransformationMatrix = wMatrix::identity(); // The transformation matrix is set in other places
46  priv->body = NewtonCreateBody( worldpriv->world, c, &initialTransformationMatrix[0][0] );
47  priv->collision = NewtonBodyGetCollision( priv->body );
48  //NewtonReleaseCollision( worldpriv->world, c );
49  NewtonBodySetAutoSleep( priv->body, 0 );
50  setMass( 1 );
51  NewtonBodySetUserData( priv->body, this );
52  NewtonBodySetLinearDamping( priv->body, 0.0 );
53  wVector zero = wVector(0,0,0,0);
54  NewtonBodySetAngularDamping( priv->body, &zero[0] );
55  NewtonBodySetAutoSleep( priv->body, 0 );
56  NewtonBodySetFreezeState( priv->body, 0 );
57  // Sets the signal-wrappers callback
58  NewtonBodySetTransformCallback( priv->body, (PhyObjectPrivate::setTransformHandler) );
59  NewtonBodySetForceAndTorqueCallback( priv->body, (PhyObjectPrivate::applyForceAndTorqueHandler) );
60 #endif
61 }
62 
63 } // end namespace farsa
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
void setMass(real)
Set the mass without touching the Inertia data.
Definition: phyobject.cpp:219
PhyEllipsoid(real radiusX, real radiusY, real radiusZ, World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity())
Create a physics sphere object and insert it in the world passed.
World class.
Definition: world.h:223
virtual ~PhyEllipsoid()
Destroy this object.
PhyObjectPrivate * priv
Engine encapsulation.
Definition: phyobject.h:159
wMatrix class
Definition: wmatrix.h:48
float real
virtual void changedMatrix()
syncronize this object with underlying physic object
Definition: phyobject.cpp:145
void createPrivateObject()
Engine encapsulation.
PhyObject class.
Definition: phyobject.h:46