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