本文整理汇总了C++中Joint::getConstraint方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::getConstraint方法的具体用法?C++ Joint::getConstraint怎么用?C++ Joint::getConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joint
的用法示例。
在下文中一共展示了Joint::getConstraint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createJoint
Joint* PhysicsSim::createJoint(PhysicalObject* obj1, PhysicalObject* obj2, Vector3D anchor, Vector3D axis)
{
Joint* jt = new Joint(obj1, obj2, anchor, axis);
dynamicsWorld->addConstraint(jt->getConstraint(), true);
joints_list.push_back(jt);
return jt;
}
示例2: loadPhysicalObjects
bool PhysicsSim::loadPhysicalObjects(PhysicalStructure &structure, stringc mesh_filename, Vector3D position, bool lock2d)
{
stringc physics_filename = mesh_filename;
physics_filename.remove(".dae");
physics_filename.append(".bullet");
physics_filename = mediaDirectory + physics_filename;
if(smgr->getFileSystem()->existFile(physics_filename))
{
stringw collada_filename = smgr->getFileSystem()->getAbsolutePath(mediaDirectory) + mesh_filename;
if(smgr->getFileSystem()->existFile(collada_filename))
{
btBlenderImporter* fileLoader = new btBlenderImporter(position);
fileLoader->loadFile(physics_filename.c_str());
smgr->getMesh(collada_filename);
for(int i = 0; i < fileLoader->getNumRigidBodies(); i++)
{
btRigidBody* rb = (btRigidBody*)fileLoader->getRigidBodyByIndex(i);
if(lock2d)
{
rb->setLinearFactor(btVector3(1,0,1));
rb->setAngularFactor(btVector3(0,1,0));
}
stringc meshname(fileLoader->getNameForPointer(rb));
stringc bodyname = meshname;
stringc tex_file = meshname;
s32 underline = tex_file.findFirst('_');
if(underline < 0)
underline = tex_file.findFirst('.');
if(underline > -1)
tex_file = tex_file.subString(0, underline+1);
tex_file = mediaDirectory + tex_file + ".jpg";
if(fileLoader->getNumRigidBodies() > 1)
meshname = collada_filename + "#" + meshname + "-mesh";
else
meshname = collada_filename;
IAnimatedMesh *mesh = smgr->getMeshCache()->getMeshByName(meshname);
if(mesh){
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh, smgr->getRootSceneNode());
node->setMaterialFlag(EMF_LIGHTING, true);
node->setMaterialFlag(EMF_TEXTURE_WRAP, false);
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
node->addShadowVolumeSceneNode(0,-1,false);
if(smgr->getFileSystem()->existFile(tex_file))
{
node->setMaterialTexture(0, driver->getTexture(tex_file));
}
PhysicalObject* pobj = new PhysicalObject(node, rb, bodyname);
objects_list.push_back(pobj);
structure.bodies.push_back(pobj);
dynamicsWorld->addRigidBody(pobj->getRigidBody());
}
}
for(int i = 0; i < fileLoader->getNumConstraints(); i++)
{
Joint* jt = new Joint(fileLoader->getConstraintByIndex(i));
joints_list.push_back(jt);
structure.joints.push_back(jt);
btTypedConstraint* constr = jt->getConstraint();
dynamicsWorld->addConstraint(constr, true);
}
delete fileLoader;
updateObjects();
return true;
}
}
return false;
}