mnm23
22-06-2006 00:45:37
First jsut wanted to say i have been on this site for a while and the post on these forums have helped me out with a lot of code. This is a great site and very easy to navigate when searching for problems.
I am currently making a MORPG for a school assignment.
Now to my problem, I have a player class where i have the basic call funtions to create a entity, sceneNode, and physics. So far everything is working well, the gravity is good, when my characters run into eachother they either fall down or stumble back. The problem im having now is im trying to get the ninjas (which im using as a test entity) sword to have its own type of collision. Im trying to call the bone that controls the ninjas sword or to set its own collision around the sword without interfering with the collision of the ninja. I have looked through the ogre demo for skeleton and the ogrenewt demo for joints and ragdoll, but still no luck. I think im probably over looking something.
This is part of my player code.
this is my world state where everything gets called. This is the portion of it that calls PlayerState.
Any help is much appreciated. Thanks
I am currently making a MORPG for a school assignment.
Now to my problem, I have a player class where i have the basic call funtions to create a entity, sceneNode, and physics. So far everything is working well, the gravity is good, when my characters run into eachother they either fall down or stumble back. The problem im having now is im trying to get the ninjas (which im using as a test entity) sword to have its own type of collision. Im trying to call the bone that controls the ninjas sword or to set its own collision around the sword without interfering with the collision of the ninja. I have looked through the ogre demo for skeleton and the ogrenewt demo for joints and ragdoll, but still no luck. I think im probably over looking something.
This is part of my player code.
PlayerState::PlayerState(Ogre::SceneManager* sm, Ogre::SceneNode* sn, char* name, char* meshName) : GameInit(sm,sn,name,meshName)
{
this->mPoints = 0;
this->mWDir = this->mSDir = this->mTDir = OFF;
this->mWalk = this->mJump = this->mStrafe = 0;
this->mRound = 0;
this->mOnGround = false;
this->mFalling = false;
this->mAnimated = false;
mAb = 0;
GameInformation::getInstance()->addAvatar(name,this);
Ogre::String pname;
for(int i = 0; i < PROJS; i++)
{
pname = "proj " + Ogre::StringConverter::toString( i );
this->mProjs[i] = new Projectiles(sm,0,(char*)pname.c_str(),"barrel.mesh",name);
this->mProjs[i]->initBody(GameInformation::getInstance()->getWorld(),Ogre::Vector3(0.15,0.15,0.15),5,CONVEX,"projectile");
this->mProjs[i]->getEntity()->setMaterialName("Examples/RustySteel");
this->mProjs[i]->getSceneNode()->setVisible(false);
}
}
PlayerState::PlayerState(Ogre::SceneManager* sm, Ogre::Entity*ent, Ogre::SceneNode *sn) : GameInit(ent,sn)
{
// this->isHit = false;
this->mPoints = 0;
this->mWDir = this->mSDir = this->mTDir = POSITIVE;
this->mWalk = this->mJump = this->mStrafe = 0;
this->mRound = 0;
this->mOnGround = false;
this->mFalling = false;
this->mAnimated = false;
mAb = 0;
OgreNewt::World *tempW = GameInformation::getInstance()->getWorld();
Ogre::String pname;
for(int i = 0; i < PROJS; i++)
{
pname = "proj " + Ogre::StringConverter::toString( i );
this->mProjs[i] = new Projectiles(sm,0,(char*)pname.c_str(),"barrel.mesh",(char*)ent->getName().c_str());
this->mProjs[i]->initBody(tempW,Ogre::Vector3(0.15,0.15,0.15),5,CONVEX,"projectile");
this->mProjs[i]->getEntity()->setMaterialName("Examples/RustySteel");
this->mProjs[i]->getSceneNode()->setVisible(false);
}
}
PlayerState::~PlayerState()
{
for(int i = 0; i < PROJS;i++)
if(this->mProjs[i])
delete mProjs[i];
}
void PlayerState::initBody(OgreNewt::World *world, Ogre::Vector3 size, float mass, BODYTYPE btype, char *matName)
{
if(!world)
myNamespace::writeF("GameEnt.log","world is broken");
Ogre::Vector3 inertia;
OgreNewt::ConvexCollision* ncol;
OgreNewt::Collision* col;
this->mSceneNode->setScale(size);
switch(btype)
{
case CONVEX:
ncol = new OgreNewt::CollisionPrimitives::ConvexHull( world, this->mSceneNode);
this->mBody = new OgreNewt::Body( world, ncol );
ncol->calculateInertialMatrix(inertia,Vector3(0,0,0));
delete ncol;
this->mBody->setMassMatrix( mass, inertia );
this->mBody->setAutoFreeze(0);
break;
case TREE:
col = new OgreNewt::CollisionPrimitives::TreeCollision(world,this->mSceneNode,false);
this->mBody = new OgreNewt::Body( world, col );
delete col;
break;
}
GameInformation *temp = GameInformation::getInstance();
this->mBody->setMaterialGroupID(temp->getMaterial(matName));
this->mBody->setUserData(this);
this->mBody->attachToNode( this->mSceneNode );
this->mBody->setPositionOrientation(this->mSceneNode->getPosition(), Ogre::Quaternion::IDENTITY );
OgreNewt::Joint *joint = new OgreNewt::BasicJoints::UpVector(world,this->mBody,this->mUp);
//this->mBody->setCenterOfMass(Ogre::Vector3(0,10,0)*size);
this->mBody->setCustomForceAndTorqueCallback(fastdelegate::MakeDelegate( this, &PlayerState::physicsUpdate));
}
this is my world state where everything gets called. This is the portion of it that calls PlayerState.
avatar1 = new PlayerState(mSceneMgr,0,"avatar1","ninja.mesh");
avatar1->initOrientation(Ogre::Vector3::NEGATIVE_UNIT_Z,Ogre::Vector3::UNIT_Y);
avatar1->initBody(mWorld,Vector3(0.01,0.01,0.01),100,CONVEX,"player");
avatar1->setSpeed(1500,0.3,650,20);
avatar1->getBody()->setPositionOrientation(Vector3(261, 110, 287),Ogre::Quaternion::IDENTITY);
avatar1->initAnim("Idle1");
Any help is much appreciated. Thanks