jonnys
17-08-2008 04:18:06
How do you set actor groups and collision callbacks in NxOgre 1.0.21 Bleeding Edge?
This is my code and I want to make custom collisions between the robot and the box. How would I go by doing this?
Code for robot
code for box
This is my code and I want to make custom collisions between the robot and the box. How would I go by doing this?
Code for robot
robot = mSceneMgr->createEntity("Robot","robot.mesh");
robot->setCastShadows(true);
robotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode", Vector3(0,0,0));
robotNode->attachObject(robot);
//robotNode->scale(0.5,0.5,0.5);
//robotNode->setPosition(20,2,40);
//St animation of the tobot
mAnimationState = robot->getAnimationState("Walk");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
//Physics parameters
ActorParams robotAp;
robotAp.setToDefault();
robotAp.mMass = 50;
robotAp.mDensity = 0;
robotAp.mBodyFlags |= NX_BF_DISABLE_GRAVITY;
//Actor group
robotAp.mGroupAsName = "Robot";
NodeRenderableParams robotNrp;
robotNrp.setToDefault();
robotNrp.mGraphicsModel = "robot.mesh";
robotNrp.mGraphicsModelScale = NxVec3(0.2, 0.2, 0.2);
robotNrp.mIdentifier = robotNode->getName();
robotNrp.mIdentifierUsage = nrp.IU_Use;
robotNrp.mMode = RenderableSource::RM_Interpolate;
//Inherit the scale from the mesh
//robotNrp.mGraphicsModelScaleInherit = true;
//Robot position and orientation
NxOgre::Pose robotPose(20, 100, 40);
Ogre::AxisAlignedBox boxBounds1 = robot->getBoundingBox();
body2 = mScene->createBody(nrp2.mIdentifier, new Cube( boxBounds1.getSize() ), robotPose, robotNrp, robotAp);
code for box
////////OBJECT1//////
ent = mSceneMgr->createEntity( "Box", "box.mesh" );
ent->setCastShadows(true);
ent->setMaterialName("box");
box = mSceneMgr->getRootSceneNode()->createChildSceneNode( "boxnode",Vector3(0,0,0) /*Vector3::ZERO*/);
box->attachObject( ent );
//box->showBoundingBox(true);
ActorParams ap;
ap.setToDefault();
ap.mMass = 5;
ap.mDensity = 0;
ap.mBodyFlags |= NX_BF_DISABLE_GRAVITY;
NodeRenderableParams nrp;
nrp.setToDefault();
nrp.mGraphicsModel = "box.mesh";
nrp.mGraphicsModelScale = NxVec3(1, 1, 1);
nrp.mIdentifier = box->getName();
nrp.mIdentifierUsage = nrp.IU_Use;
nrp.mMode = RenderableSource::RM_Interpolate;
//Shape parameters
ShapeParams shapeParams;
shapeParams.setToDefault();
NxOgre::Pose actorPose(50, 100, 40);
//NxOgre::Pose actorPose(Vector3::ZERO);
Ogre::AxisAlignedBox boxBounds = box->getAttachedObject("Box" )->getBoundingBox();
body = mScene->createBody(nrp.mIdentifier, new Cube( boxBounds.getSize(), shapeParams), actorPose, nrp, ap);