00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00039 #include "../include/IPSA/SoCollisionShapeBox.h"
00040 #include <Inventor/nodes/SoCube.h>
00041
00042 SO_KIT_SOURCE(SoCollisionShapeBox);
00043
00046 void SoCollisionShapeBox::initClass()
00047 {
00048 SO_KIT_INIT_CLASS(SoCollisionShapeBox, SoCollisionShape, "CollisionShape");
00049 }
00050
00051
00058 SoCollisionShapeBox::SoCollisionShapeBox(const SbString& nodeName )
00059 : SoCollisionShape(nodeName)
00060 {
00061 SO_KIT_CONSTRUCTOR(SoCollisionShapeBox);
00062 isBuiltIn = TRUE;
00063
00064 SO_KIT_ADD_FIELD(dimension,(1.0f, 1.0f, 1.0f));
00065
00066 SO_KIT_CHANGE_ENTRY_TYPE(visualisation,SoCube,SoCube);
00067 SO_KIT_CHANGE_NULL_BY_DEFAULT(visualisation, FALSE);
00068
00069 SO_KIT_INIT_INSTANCE();
00070
00071 updateOdePropertiesTrigger.appendConnection(&dimension);
00072 }
00073
00074
00078 SoCollisionShape* SoCollisionShapeBox::copy(SbBool copyConnections) const
00079 {
00080
00081
00082 SoCollisionShapeBox* newSoCollisionShape = dynamic_cast<SoCollisionShapeBox*> (SoCollisionShape::copy(copyConnections));
00083 newSoCollisionShape->setUpConnections(TRUE, TRUE);
00084 return newSoCollisionShape;
00085 }
00086
00087
00092 void SoCollisionShapeBox::updateVisualisationAndOdeProperties()
00093 {
00094 const SbVec3f dim = this->dimension.getValue();
00095 const dGeomID boxID = this->geometry;
00096 if (NULL != boxID)
00097 dGeomBoxSetLengths(boxID, dim[0], dim[1], dim[2]);
00098
00099 SoCube* visualisationShape = dynamic_cast<SoCube*> (getPart("visualisation", TRUE));
00100 if (NULL != visualisationShape)
00101 {
00102 visualisationShape->width.setValue(dim[0]);
00103 visualisationShape->height.setValue(dim[1]);
00104 visualisationShape->depth.setValue(dim[2]);
00105 }
00106 }
00107
00115 dGeomID SoCollisionShapeBox::cGeom(const SbMatrix& mm)
00116 {
00117 assert(space != NULL);
00118
00119 const SbVec3f dim = this->dimension.getValue();
00120
00121 return dCreateBox(space, dim[0], dim[1], dim[2]);
00122 }