00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00038 #include "../include/IPSA/SoCollisionShapeSphere.h"
00039 #include <Inventor/nodes/SoSphere.h>
00040
00041 SO_KIT_SOURCE(SoCollisionShapeSphere);
00042
00045 void SoCollisionShapeSphere::initClass()
00046 {
00047 SO_KIT_INIT_CLASS(SoCollisionShapeSphere, SoCollisionShape, "CollisionShape");
00048 }
00049
00050
00057 SoCollisionShapeSphere::SoCollisionShapeSphere(const SbString& nodeName )
00058 : SoCollisionShape(nodeName)
00059 {
00060 SO_KIT_CONSTRUCTOR(SoCollisionShapeSphere);
00061 isBuiltIn = TRUE;
00062
00063 SO_KIT_ADD_FIELD(radius,(1.0f));
00064
00065 SO_KIT_CHANGE_ENTRY_TYPE(visualisation,SoSphere,SoSphere);
00066 SO_KIT_CHANGE_NULL_BY_DEFAULT(visualisation, FALSE);
00067
00068 SO_KIT_INIT_INSTANCE();
00069
00070 updateOdePropertiesTrigger.appendConnection(&radius);
00071 }
00072
00073
00077 SoCollisionShape* SoCollisionShapeSphere::copy(SbBool copyConnections) const
00078 {
00079
00080
00081 SoCollisionShapeSphere* newSoCollisionShape = dynamic_cast<SoCollisionShapeSphere*> (SoCollisionShape::copy(copyConnections));
00082 newSoCollisionShape->setUpConnections(TRUE, TRUE);
00083 return newSoCollisionShape;
00084 }
00085
00086
00090 void SoCollisionShapeSphere::updateVisualisationAndOdeProperties()
00091 {
00092 const dGeomID sphereID = this->geometry;
00093 if (NULL != sphereID)
00094 dGeomSphereSetRadius(sphereID, this->radius.getValue());
00095
00096 SoSphere* visualisationShape = dynamic_cast<SoSphere*> (getPart("visualisation", TRUE));
00097 if (NULL != visualisationShape)
00098 {
00099 visualisationShape->radius.setValue(this->radius.getValue());
00100 }
00101 }
00102
00103
00112 dGeomID SoCollisionShapeSphere::cGeom(const SbMatrix& mm)
00113 {
00114 assert(space != NULL);
00115
00116 return dCreateSphere(space, radius.getValue());
00117 }