1

我对 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 位置的阅读。

4

1 回答 1

2

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;
于 2014-11-28T11:25:02.830 回答