[程式] PhysX:CharacterControl會穿透地面?

看板GameDesign (遊戲設計)作者 (sqaure)時間15年前 (2009/12/14 02:10), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
最近正在嘗試自己把PhysX整合到Ogre (不是用NxOgre) 但我把Character Control的那個Example整合到Ogre 每次我的Character Controller 都會穿越地面。 大部份的code都是從那個範例複製過來的, 唯一不同的地方就是terrain的部分 這是我create terrain的部分: // Create ground plane NxPlaneShapeDesc planeDesc; planeDesc.group = GROUP_COLLIDABLE_NON_PUSHABLE; NxActorDesc actorDesc; actorDesc.shapes.pushBack(&planeDesc); NxActor* terrain = gScene->createActor(actorDesc); NxShape*const* shapes = terrain->getShapes(); NxU32 nShapes = terrain->getNbShapes(); while (nShapes--) { shapes[nShapes]->setGroup(GROUP_COLLIDABLE_NON_PUSHABLE); } 此時,我建立的box都可以掉落在地面上,就Character Controller不能 初始Character controller: NxCapsuleControllerDesc desc; desc.position.x = pos.x; desc.position.y = pos.y; desc.position.z = pos.z; desc.height = box_size.y +10; //height; desc.radius = ( (box_size.x+box_size.z) / 2 ) / 2 ;//radius; desc.skinWidth = 0.1f; desc.slopeLimit = cosf(NxMath::degToRad(45.0f)); desc.stepOffset = 0.5f; desc.upDirection = NX_Y; desc.climbingMode = CLIMB_EASY; desc.callback = &mReport; mController = mManager->createController(scene, desc); 移動部分: #define COLLIDABLE_MASK (1<<GROUP_COLLIDABLE_NON_PUSHABLE) | (1<<GROUP_COLLIDABLE_PUSHABLE) void MyCharacterController::Move(const NxVec3 &disp, NxU32 &flag) { mController->move(disp, COLLIDABLE_MASK, 0.001, flag); } 建立箱子的部分: // Create body NxBodyDesc bodyDesc; bodyDesc.angularDamping = 0.5f; bodyDesc.mass = 1; NxBoxShapeDesc boxDesc; boxDesc.dimensions = NxVec3((float)box_size.x, (float)box_size.y, (float)box_size.z); boxDesc.group = GROUP_COLLIDABLE_NON_PUSHABLE; NxActorDesc actorDesc; actorDesc.shapes.pushBack(&boxDesc); actorDesc.body = &bodyDesc; 想問問大家有什麼意見嗎? 是CharacterController 的collision group不同? 但其他部份我都沒有動過阿... 幾乎跟example一模一樣 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.184.243

12/14 23:51, , 1F
我可以問一下const前面為何要加 *嗎?
12/14 23:51, 1F

12/16 00:25, , 2F
沒有注意到這邊過..應該是複製example的...
12/16 00:25, 2F
文章代碼(AID): #1B9IuSlJ (GameDesign)
文章代碼(AID): #1B9IuSlJ (GameDesign)