本文整理汇总了C++中Joint::setId方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::setId方法的具体用法?C++ Joint::setId怎么用?C++ Joint::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joint
的用法示例。
在下文中一共展示了Joint::setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmlParseJoint
Joint* JointInteraction::xmlParseJoint(IrrXMLReader* xml, std::string& jointType)
{
bool finished = false;
Constraint* constraint = NULL;
Joint* joint = JointFactory::create(xml->getAttributeValue("type"));
jointType = xml->getAttributeValue("type");
joint->setWorld(world);
joint->setId(atoi(xml->getAttributeValue("id")));
joint->setJointInteractionClass(this);
if (xml->getAttributeValue("active"))
joint->setActive(atoi(xml->getAttributeValue("active")));
while (!finished && xml && xml->read())
{
switch (xml->getNodeType())
{
case EXN_ELEMENT:
if (!strcmp("entities", xml->getNodeName()))
{
xmlParseEntities(xml, joint);
} // else if
else if (!strcmp("anchor", xml->getNodeName()))
{
if (!jointType.compare("ball") || !jointType.compare("Ball") || !jointType.compare("BALL"))
{
BallJoint* ball = dynamic_cast<BallJoint*>(joint);
ball->setAnchor(atof(xml->getAttributeValue("xPos")), atof(xml->getAttributeValue("yPos")), atof(xml->getAttributeValue("zPos")));
} // if
else if (!jointType.compare("hinge") || !jointType.compare("Hinge") || !jointType.compare("HINGE"))
{
HingeJoint* hinge = dynamic_cast<HingeJoint*>(joint);
hinge->setAnchor(atof(xml->getAttributeValue("xPos")), atof(xml->getAttributeValue("yPos")), atof(xml->getAttributeValue("zPos")));
} // else if
else if (!jointType.compare("universal") || !jointType.compare("Universal") || !jointType.compare("UNIVERSAL"))
{
UniversalJoint* universal = dynamic_cast<UniversalJoint*>(joint);
universal->setAnchor(atof(xml->getAttributeValue("xPos")), atof(xml->getAttributeValue("yPos")), atof(xml->getAttributeValue("zPos")));
} // else if
else if (!jointType.compare("hinge2") || !jointType.compare("Hinge2") || !jointType.compare("HINGE2"))
{
Hinge2Joint* hinge2 = dynamic_cast<Hinge2Joint*>(joint);
hinge2->setAnchor(atof(xml->getAttributeValue("xPos")), atof(xml->getAttributeValue("yPos")), atof(xml->getAttributeValue("zPos")));
} // else if
else
printd(WARNING, "JointInteraction::loadJoints(): WARNING: JOINT-TYPE %s NEEDS NO anchor ELEMENT!!!\n", jointType.c_str());
} // else if
else if (!strcmp("axis", xml->getNodeName()))
{
if (!jointType.compare("hinge") || !jointType.compare("Hinge") || !jointType.compare("HINGE"))
{
HingeJoint* hinge = dynamic_cast<HingeJoint*>(joint);
hinge->setAxis(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
} // if
else if (!jointType.compare("slider") || !jointType.compare("Slider") || !jointType.compare("SLIDER"))
{
SliderJoint* slider = dynamic_cast<SliderJoint*>(joint);
slider->setAxis(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
} // else if
else if (!jointType.compare("universal") || !jointType.compare("Universal") || !jointType.compare("UNIVERSAL")) {
UniversalJoint* universal = dynamic_cast<UniversalJoint*>(joint);
if (atoi(xml->getAttributeValue("index")) == 1)
universal->setAxis1(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
else if (atoi(xml->getAttributeValue("index")) == 2)
universal->setAxis2(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
else
printd(WARNING, "JointInteraction::loadJoints(): WARNING: WRONG ATTRIBUTE FOUND IN axis ELEMENT of UniversalJoint!!!\n");
} // else if
else if (!jointType.compare("hinge2") || !jointType.compare("Hinge2") || !jointType.compare("HINGE2")) {
Hinge2Joint* hinge2 = dynamic_cast<Hinge2Joint*>(joint);
if (atoi(xml->getAttributeValue("index")) == 1)
hinge2->setAxis1(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
else if (atoi(xml->getAttributeValue("index")) == 2)
hinge2->setAxis2(atof(xml->getAttributeValue("xDir")), atof(xml->getAttributeValue("yDir")), atof(xml->getAttributeValue("zDir")));
else
printd(WARNING, "JointInteraction::loadJoints(): WARNING: WRONG ATTRIBUTE FOUND IN axis ELEMENT of Hinge2Joint!!!\n");
} // else if
else
printd(WARNING, "JointInteraction::loadJoints(): WARNING: JOINT-TYPE %s NEEDS NO axis ELEMENT!!!\n", jointType.c_str());
} // else if
else if (!strcmp("angles", xml->getNodeName()))
{
if (!jointType.compare("hinge") || !jointType.compare("Hinge") || !jointType.compare("HINGE"))
{
HingeJoint* hinge = dynamic_cast<HingeJoint*>(joint);
hinge->setAngles(atof(xml->getAttributeValue("min")), atof(xml->getAttributeValue("max")));
} // if
else
printd(WARNING, "JointInteraction::loadJoints(): WARNING: JOINT-TYPE %s HAS NO angles ELEMENT!!!\n", jointType.c_str());
} // else if
else if (!strcmp("positions", xml->getNodeName()))
{
SliderJoint* slider = dynamic_cast<SliderJoint*>(joint);
slider->setPositions(atof(xml->getAttributeValue("min")), atof(xml->getAttributeValue("max")));
} // else if
else if (!strcmp("activateIF", xml->getNodeName()))
{
constraint = new Constraint(this);
constraint->setActionType(Constraint::ACTIVATEIF);
constraint->setOwner(joint);
//.........这里部分代码省略.........