8 #include "heightSensor.h"
11 heightSensor::heightSensor(){
16 heightSensor::heightSensor(
const btRigidBody *body,btVector3 worldPos,
int nodeNumber,
tgWorld& world)
21 attachedRelativeOriginalPosition=worldPos;
22 this->nodeNumber = nodeNumber;
26 btVector3 heightSensor::getRelativePosition()
const
28 btTransform tr = attachedBody->getWorldTransform();
29 btVector3 worldPos = tr * attachedRelativeOriginalPosition;
30 return worldPos-this->attachedBody->getCenterOfMassPosition();
34 btVector3 heightSensor::getWorldPosition()
const
36 btTransform tr = attachedBody->getWorldTransform();
37 return tr * attachedRelativeOriginalPosition;
40 double heightSensor::getHeight()
const
42 double distance = -1.0;
44 btVector3 origin=this->getWorldPosition();
45 btVector3 end = origin;
47 origin.setY(origin.getY()-1);
48 btCollisionWorld::AllHitsRayResultCallback rayCallback(origin, end);
49 btworld->rayTest(origin, end, rayCallback);
50 if(rayCallback.hasHit())
53 rayCallback.m_hitPointWorld[idx] = origin - rayCallback.m_hitPointWorld[idx];
54 distance=rayCallback.m_hitPointWorld[idx].getY();
static btDynamicsWorld & worldToDynamicsWorld(const tgWorld &world)