[PhysX] 4화 Actor

Grphics 2009. 5. 11. 14:25
그림 1. 실행화면


오늘만 2번째 강좌를 올리네요. 1화는 내용이 많아서 정말 정리하기가 어려웠는데, 뒤로 갈 수록 짧아지네요~ 정리하는 입장에서는 좋네요~

이번에 배울 내용은 Actor 입니다. Actor는 3D 공간의 충돌 개체를 의미합니다. 여기에는 세가지 종류가 있습니다.
    1. Dynamic
    2. Kinematic
    3. Static
딱 이름만 봐도 대충 알 수 있겠죠? 아니라고요? 사실 저도 아니에요...-_-

Dynamic. 이름이 참 다이나믹하죠? 이 액터는 힘에 의해서 움직일 수도 있고, 충돌도 가능한 객체입니다. 지금까지 우리가 만든 액터들이 모두 Dynamic 액터입니다.

Knematic. 낯선 단어네요. 운동학적인 이라는 뜻이라네요. 이 액터는 한 위치에서 다른 위치로 이동(transfer)는 가능하지만, 힘에 의해서 움직일 수 있는 객체는 아니라고 하네요.
PhysX 도움말에 다음과 같이 나와있네요.
Kinematic actors are special dynamic actors that are not influenced by forces (such as gravity), and have no momentum. They are considered to have infinite mass and can be moved around the world using the moveGlobal*() methods. They will push regular dynamic actors out of the way. Kinematics will not collide with static or other kinematic objects.
Kinematic actors are great for moving platforms or characters, where direct motion control is desired.
모두들 영어는 잘 하실테니.... ㅈㅅㅈㅅ 대충 번역하자면,  다음과 같습니다.
Kinematic 액터는 힘에 영향을 받지 않고, 운동량을 갖지않는 특별한 Dynamic 액터입니다. 무한 질랑을 가진 물체로 간주하며, moveGlobal*() 계열의 함수로 움직일 수 있습니다. 일반적인 Dynamic 액터를 밀 수도 있습니다. 하지만 다른 Static 이나 Kinematic 물체와는 충돌하지 않습니다.  Kinematic 액터는 움직이는 플랫폼이나 캐릭터와 같이 직접적인 조작이 필요한 곳에서 쓰면 좋습니다.
Static. '정적인' 이라는 뜻을 지닌 단어입니다. 이 액터는 어떤 방법을 쓰더라도 움직일 수 없는 녀석입니다. 즉 고정된 물체를 의미합니다. 바닥이나 건물을 생각하시면 좋겠네요.

이 부분도 사실 설명할 부분이 없네요. Kinematic과 Static은 Dynamic 액터를 만드는 방법에서 약간만 바꾸면 됩니다. 박스는 Dynamic, 캡슐은 Kinemaitc, 구는 Static 입니다. Dynamic 함수와 다른 부분을 Kinematic, Static 색으로 표시하겠습니다.

소스 1. Dynamic, Kinematic, Static의 차이
NxActor* CreateDynamicActor()
{
    NxActorDesc actorDesc;
    NxBodyDesc bodyDesc;

    NxBoxShapeDesc boxDesc;
    boxDesc.dimensions = NxVec3(1.0f, 1.0f, 1.0f);
    actorDesc.shapes.push_back(&boxDesc);

    actorDesc.density = 1.0f;
    actorDesc.globalPose.t = NxVec3(6.0f, 1.0f, 0.0f);
    actorDesc.body = &bodyDesc;
   
    NxActor* pActor = gScene->createActor(actorDesc);
    assert(pActor);

    return pActor;
}

NxActor* CreateKinematicsActor()
{
    NxActorDesc actorDesc;
    NxBodyDesc bodyDesc;

    bodyDesc.flags |= NX_BF_KINEMATIC;

    NxCapsuleShapeDesc  capDesc;
    capDesc.radius = 1.0f;
    capDesc.height = 1.5f;
    actorDesc.shapes.push_back(&capDesc);

    actorDesc.density = 1.0f;
    actorDesc.globalPose.t = NxVec3(0.0f, 3.0f, 0.0f);
    actorDesc.body = &bodyDesc;
   
    NxActor* pActor = gScene->createActor(actorDesc);
    assert(pActor);

    return pActor;
}

NxActor* CreateStaticActor()
{
    NxActorDesc actorDesc;
    //NxBodyDesc bodyDesc;

    NxSphereShapeDesc sphereDesc;
    sphereDesc.radius = 1.8f;
    actorDesc.shapes.push_back(&sphereDesc);

    //actorDesc.density = 1.0f; <- static 이기 때문에 무게가 필요없다.
    actorDesc.globalPose.t = NxVec3(-6.0f, 5.0f, 0.0f);
    actorDesc.body = NULL;
   
    NxActor* pActor = gScene->createActor(actorDesc);
    assert(pActor);

    return pActor;
}

소스 뷰어로 보고싶으시면 여길...
posted by 스펜서.