00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "phycylinder.h"
00021 #include "private/phyobjectprivate.h"
00022 #include "private/worldprivate.h"
00023
00024 namespace farsa {
00025
00026 PhyCylinder::PhyCylinder( real radius, real height, World* w, QString name, const wMatrix& tm )
00027 : PhyObject( w, name, tm, false ) {
00028 radiusv = radius;
00029 heightv = height;
00030 w->pushObject( this );
00031 createPrivateObject();
00032 changedMatrix();
00033 }
00034
00035 PhyCylinder::~PhyCylinder() {
00036 #ifdef WORLDSIM_USE_NEWTON
00037
00038 #endif
00039 }
00040
00041 void PhyCylinder::createPrivateObject() {
00042 #ifdef WORLDSIM_USE_NEWTON
00043 NewtonCollision* c = NewtonCreateCylinder( worldpriv->world, radiusv, heightv, 1, 0 );
00044 wMatrix initialTransformationMatrix = wMatrix::identity();
00045 priv->body = NewtonCreateBody( worldpriv->world, c, &initialTransformationMatrix[0][0] );
00046 priv->collision = c;
00047 NewtonBodySetAutoSleep( priv->body, 0 );
00048 setMass( 1 );
00049 NewtonBodySetUserData( priv->body, this );
00050 NewtonBodySetLinearDamping( priv->body, 0.0 );
00051 wVector zero = wVector(0,0,0,0);
00052 NewtonBodySetAngularDamping( priv->body, &zero[0] );
00053 NewtonBodySetAutoSleep( priv->body, 0 );
00054 NewtonBodySetFreezeState( priv->body, 0 );
00055
00056 NewtonBodySetTransformCallback( priv->body, (PhyObjectPrivate::setTransformHandler) );
00057 NewtonBodySetForceAndTorqueCallback( priv->body, (PhyObjectPrivate::applyForceAndTorqueHandler) );
00058 #endif
00059 }
00060
00061 }