Objects a bit above the ground

spacegaier

15-03-2008 15:17:52

Hi,

if created a simple arena for my game, consisting of a plane on which all the other things should stand. The walls and the ball do it in the right way. However, the goal bodies (NxOgre::CompoundShape) and the player (NxOgre::Character), are alway a bit over the plane.

I've have found in the forum that setting the mStepOffset of the player should solve the character problem, but it doesn't.




Here my code (could you also take a look at my way how I calculate my CompoundShapes; is it senseful to first load the mesh into an Ogre::Entity to retrieve the needed indormation or is there a better way?):

// Ground
NxOgre::ShapeParams groundShapeParams;
groundShapeParams.setToDefault();
groundShapeParams.mMeshScale = NxVec3(3,1,2);
groundShapeParams.mMaterialAsName = "stdMat";

NxOgre::ActorParams groundActorParams;
groundActorParams.setToDefault();
groundActorParams.mMass = 0;
groundActorParams.mNodeScale = Vector3(3,1,2);

NxOgre::Body *ground = m_pNxScene->createBody("groundBody;GroundPlane3.0.mesh", new NxOgre::TriangleMeshShape("GroundPlane3.0.mesh", groundShapeParams), NxOgre::Pose(Vector3(0,0,0)), groundActorParams);

// Walls
NxOgre::ShapeParams wallShapeParamsX;
wallShapeParamsX.setToDefault();
wallShapeParamsX.mMeshScale = NxVec3(3,1,1);
wallShapeParamsX.mMaterialAsName = "stdMat";

NxOgre::ActorParams wallActorParamsX;
wallActorParamsX.setToDefault();
wallActorParamsX.mMass = 0;
wallActorParamsX.mNodeScale = Vector3(3,1,1);

NxOgre::ShapeParams wallShapeParamsY;
wallShapeParamsY.setToDefault();
wallShapeParamsY.mMeshScale = NxVec3(2,1,1);
wallShapeParamsY.mMaterialAsName = "stdMat";

NxOgre::ActorParams wallActorParamsY;
wallActorParamsY.setToDefault();
wallActorParamsY.mMass = 0;
wallActorParamsY.mNodeScale = Vector3(2,1,1);

NxOgre::Body *wall1 = m_pNxScene->createBody("wall1;Wall3.0.mesh", new NxOgre::ConvexShape("Wall3.0.mesh", wallShapeParamsX), NxOgre::Pose(Vector3( 0, 2.5, -20)), wallActorParamsX);
NxOgre::Body *wall2 = m_pNxScene->createBody("wall2;Wall3.0.mesh", new NxOgre::ConvexShape("Wall3.0.mesh", wallShapeParamsX), NxOgre::Pose(Vector3( 0, 2.5, 20)), wallActorParamsX);
NxOgre::Body *wall3 = m_pNxScene->createBody("wall3;Wall3.0.mesh", new NxOgre::ConvexShape("Wall3.0.mesh", wallShapeParamsY), NxOgre::Pose(Vector3(-20, 2.5, 0), Quaternion(Radian(Degree(90)), Vector3(0,1,0))), wallActorParamsY);
NxOgre::Body *wall4 = m_pNxScene->createBody("wall4;Wall3.0.mesh", new NxOgre::ConvexShape("Wall3.0.mesh", wallShapeParamsY), NxOgre::Pose(Vector3( 20, 2.5, 0), Quaternion(Radian(Degree(90)), Vector3(0,1,0))), wallActorParamsY);
wall1->getEntity()->setCastShadows(true);
wall2->getEntity()->setCastShadows(true);
wall3->getEntity()->setCastShadows(true);
wall4->getEntity()->setCastShadows(true);

// Goals
NxOgre::ShapeParams goalShapeParams;
goalShapeParams.setToDefault();
goalShapeParams.mGroupAsName = "goalsSG";

NxOgre::ActorParams goalActorParams;
goalActorParams.setToDefault();
goalActorParams.mMass = 0;

Ogre::Entity *goal = m_pSceneMgr->createEntity("goal", "Goal_3.0_14m.mesh");
Vector3 goalSize = goal->getBoundingBox().getSize();
NxOgre::CubeShape *pile1Goal1 = new NxOgre::CubeShape(1, goalSize.y-1, goalSize.z, "offset: 6.5 0 0");
NxOgre::CubeShape *pile2Goal1 = new NxOgre::CubeShape(1, goalSize.y-1, goalSize.z, "offset: -6.5 0 0");
NxOgre::CubeShape *cross_pileGoal1 = new NxOgre::CubeShape(goalSize.x, 1, goalSize.z, "offset: 0 2 0");
NxOgre::CubeShape *pile1Goal2 = new NxOgre::CubeShape(1, goalSize.y-1, goalSize.z, "offset: 6.5 0 0");
NxOgre::CubeShape *pile2Goal2 = new NxOgre::CubeShape(1, goalSize.y-1, goalSize.z, "offset: -6.5 0 0");
NxOgre::CubeShape *cross_pileGoal2 = new NxOgre::CubeShape(goalSize.x, 1, goalSize.z, "offset: 0 2 0");

NxOgre::CompoundShape *compound1 = new NxOgre::CompoundShape(pile1Goal1, pile2Goal1, cross_pileGoal1);
compound1->mParams.mGroupAsName = "goalsSG";
NxOgre::CompoundShape *compound2 = new NxOgre::CompoundShape(pile1Goal2, pile2Goal2, cross_pileGoal2);
compound2->mParams.mGroupAsName = "goalSG";

NxOgre::Body *goal1 = m_pNxScene->createBody("goal1;Goal_3.0_14m.mesh", compound1, NxOgre::Pose(Vector3( 20-1.5, goalSize.y / 2, 0), Quaternion(Radian(Degree( 90)), Vector3(0,1,0))), goalActorParams);
NxOgre::Body *goal2 = m_pNxScene->createBody("goal2;Goal_3.0_14m.mesh", compound2, NxOgre::Pose(Vector3(-20+1.5, goalSize.y / 2, 0), Quaternion(Radian(Degree(270)), Vector3(0,1,0))), goalActorParams);

// Player_1
NxOgre::CharacterParams params;
params.setToDefault();
params.mStepOffset = 0.0;
params.mType = NxOgre::CharacterParams::CT_Box;
m_pPlayer1Character = m_pNxScene->createCharacter("Player1", NxOgre::Pose(Vector3(0,0,0),Quaternion::IDENTITY),params);
m_pPlayer1Character->createNode();
m_pPlayer1Character->attachMesh("Player3.0.mesh");
m_pPlayer1Character->getNxController()->setCollision(true);
m_pPlayer1Character->setMovementVectorController(new myMovement());
m_pPlayer1Character->getEntity()->setCastShadows(true);
m_pPlayer1Character->setPosition(Vector3(0,m_pPlayer1Character->getEntity()->getBoundingBox().getSize().y / 2, 0));
m_pPlayer1Character->getNode()->showBoundingBox(true);

// Ball
NxOgre::ShapeParams ballShapeParams;
ballShapeParams.setToDefault();
ballShapeParams.mGroupAsName = "ballSG";
ballShapeParams.mMaterialAsName = "stdMat";

m_pBallBody = m_pNxScene->createBody("ballBody;sphere.2m.mesh", new NxOgre::SphereShape(1, ballShapeParams), NxOgre::Pose(Vector3(-5,1,0)), "mass: 0.1");
m_pBallBody->getNode()->showBoundingBox(false);
m_pBallBody->getEntity()->setCastShadows(true);

spacegaier

16-03-2008 10:42:35

No ideas?

dbrock

17-03-2008 04:55:45

your plane is probably just too low and needs to be moved up a unit (the node, not your physx ground), and the other things are in the right spot. Either that, or your net and player node need to be moved down.

I think cubeshapes are treated like the pivot point was put in the center. so if you position it at x/y 0,0, its size would be 0.5 and -0.5, so theres still a 0.5 unit gap between the ground and the net.