本文整理汇总了C++中Bone::ID方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::ID方法的具体用法?C++ Bone::ID怎么用?C++ Bone::ID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::ID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: worldDrawList
string IESoRWorld::worldDrawList()
{
//This will be written to json
//fastwriter is not human readable --> compact
//exactly what we want to sent to our html files
Json::FastWriter* writer = new Json::FastWriter();
//root is what we'll be sending back with all the shapes (stored in shapes!)
Json::Value root;
Json::Value shapes;
//we'll loop through all required body information
b2Body * B = this->world->GetBodyList();
while(B != NULL)
{
if(B->GetUserData())
{
//fetch our body identifier
PhysicsID* pid = static_cast<PhysicsID*>(B->GetUserData());//*((string*)B->GetUserData());
std::string bodyID = pid->ID();
//we must get all our shapes
b2Fixture* F = B->GetFixtureList();
//cycle through the shapes
while(F != NULL)
{
//Hold our shape drawing information
Json::Value singleShape;
switch (F->GetType())
{
case b2Shape::e_circle:
{
b2CircleShape* circle = (b2CircleShape*) F->GetShape();
/* Do stuff with a circle shape */
Json::Value center = positionToJSONValue(circle->m_p);
Json::Value radius = circle->m_radius;
singleShape["type"] = "Circle";
singleShape["bodyOffset"] = positionToJSONValue(B->GetPosition());
singleShape["rotation"] = B->GetAngle();
singleShape["center"] = center;
singleShape["radius"] = circle->m_radius;
singleShape["color"] = "#369";
}
break;
case b2Shape::e_polygon:
{
b2PolygonShape* poly = (b2PolygonShape*) F->GetShape();
/* Do stuff with a polygon shape */
Json::Value points = listOfPoints(poly->m_vertices, poly->m_count);
singleShape["type"] = "Polygon";
singleShape["points"] = points;
singleShape["bodyOffset"] = positionToJSONValue(B->GetPosition());
singleShape["rotation"] = B->GetAngle();
singleShape["color"] = "#38F";
}
break;
}
//Each shape is the unique combination of
pid = static_cast<PhysicsID*>(F->GetUserData());//*((string*)B->GetUserData());
string shapeID = pid->ID();// *((string*)F->GetUserData());
string fullID = bodyID + "_" + shapeID;
shapes[fullID] = singleShape;
F = F->GetNext();
}
}
B = B->GetNext();
}
//we set our shapes using the body loops
root["shapes"] = shapes;
//we now need to process all of our joints as well
b2Joint * J = this->world->GetJointList();
Json::Value joints;
while(J != NULL)
{
if(J->GetUserData())
{
//fetch our body identifier
Bone* jid = static_cast<Bone*>(J->GetUserData());
//we grab the joint identifier
std::string bodyID = jid->ID();
//Hold our joint drawing information
Json::Value singleJoint;
//we should use the body identifiers
//but they both need to exist for this to be valid
//.........这里部分代码省略.........