阅读PhysX中的位置Actor

时间:2014-11-18 00:28:31

标签: physx

我对PhysX SDK 2.8.1

有疑问

我是演员:

NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
NxSphereShapeDesc sphereDesc;
sphereDesc.radius = 1.5f;
actorDesc.shapes.pushBack(&sphereDesc);
actorDesc.body = &bodyDesc;
actorDesc.density = 10;
actorDesc.globalPose.t = NxVec3(0.0f, 25.0f, 0.0f);
NxActor *dynamicActor = gsc->createActor(actorDesc);

我希望控制台打印出演员的当前位置。怎么做?以下内容不起作用:

for (int i = 0; i <= 10; i++) {
    //Step PhysX simulation  
    if (gsc)
        StepPhysX(); 
    NxMat34 pose = dynamicActor->getGlobalPose();
    cout <<pose.t << endl;
}

具体取决于我阅读Y的位置。

1 个答案:

答案 0 :(得分:1)

std :: cout无法使用NxVec3(你的post.t是)。

如果要打印出dynamicActor的全局位置,
你需要分别打印出NxVec3变量的X,Y,Z分量

NxVec3 trans = dynamicActor->getGlobalPose().t;  // or you could use "dynamicActor->getGlobalPosition()"

std::cout << trans.x << ", " << trans.y << ", " << trans.z << std::endl;