Beispiel #1
0
void CODEGeom::init()
{
	dGeomID	geom=create();
	m_geom_transform=dCreateGeomTransform(0);
	dGeomTransformSetCleanup(m_geom_transform,0);
	dGeomSetData(m_geom_transform,0);
	dGeomTransformSetGeom(m_geom_transform,geom);
	dGeomTransformSetInfo(m_geom_transform,1);
	dGeomCreateUserData(geom);
	dGeomUserDataSetBoneId(geom,m_bone_id);
}
  void Transform::init(const OdeHandle& odeHandle, double mass, const OsgHandle& osgHandle,
                       char mode) {
    // Primitive::body is ignored (removed) from mode
    assert(parent && parent->getBody() != 0 && child); // parent and child must exist
    assert(child->getBody() == 0 && child->getGeom() == 0); // child should not be initialised
    this->mode = mode | Primitive::_Transform;
    if (!substanceManuallySet)
      substance = odeHandle.substance;

    QMP_CRITICAL(6);
    // our own geom is just a transform
    geom = dCreateGeomTransform(odeHandle.space);
    dGeomTransformSetInfo(geom, 1);
    dGeomTransformSetCleanup(geom, 0);

    // the child geom must go into space 0 (because it inherits the space from the transform geom)
    OdeHandle odeHandleChild(odeHandle);
    odeHandleChild.space = 0;
    // the root node for the child is the transform node of the parent
    OsgHandle osgHandleChild(osgHandle);
    osgHandleChild.parent = parent->getOSGPrimitive()->getTransform();
    assert(osgHandleChild.scene);
    // initialise the child
    child->init(odeHandleChild, mass, osgHandleChild, (mode & ~Primitive::Body) | Primitive::_Child );
    // move the child to the right place (in local coordinates)
    child->setPose(pose);

    // assoziate the child with the transform geom
    dGeomTransformSetGeom (geom, child->getGeom());
    // finally bind the transform the body of parent
    dGeomSetBody (geom, parent->getBody());
    dGeomSetData(geom, (void*)this); // set primitive as geom data

    // we assign the body here. Since our mode is Transform it is not destroyed
    body=parent->getBody();

    QMP_END_CRITICAL(6);
  }