forked from teamnwah/openmw-tes3coop
Movement keys; View angles
This commit is contained in:
parent
76f2a82884
commit
192d634098
3 changed files with 35 additions and 8 deletions
|
@ -176,11 +176,11 @@ namespace MWWorld
|
|||
//set the DebugRenderingMode. To disable it,set it to 0
|
||||
//eng->setDebugRenderingMode(1);
|
||||
|
||||
//set the walkdirection to 0 (no movement) for every actor)
|
||||
//set the movement keys to 0 (no movement) for every actor)
|
||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
|
||||
{
|
||||
OEngine::Physic::PhysicActor* act = it->second;
|
||||
act->setWalkDirection(btVector3(0,0,0));
|
||||
act->setMovement(0,0,0);
|
||||
}
|
||||
|
||||
playerMove::playercmd& pm_ref = playerphysics->cmd;
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace Physic
|
|||
mBoxRotationInverse = btQuaternion(inverse.x, inverse.y, inverse.z,inverse.w);
|
||||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||
pmove = new playerMove;
|
||||
pmove->mEngine = mEngine;
|
||||
}
|
||||
|
||||
PhysicActor::~PhysicActor()
|
||||
|
@ -77,9 +78,18 @@ namespace Physic
|
|||
return collisionMode;
|
||||
}
|
||||
|
||||
void PhysicActor::setWalkDirection(const btVector3& mvt)
|
||||
void PhysicActor::setMovement(signed char rightmove, signed char forwardmove, signed char upmove)
|
||||
{
|
||||
|
||||
playerMove::playercmd& pm_ref = pmove->cmd;
|
||||
pm_ref.rightmove = rightmove;
|
||||
pm_ref.forwardmove = forwardmove;
|
||||
pm_ref.upmove = upmove;
|
||||
}
|
||||
|
||||
void PhysicActor::setPmoveViewAngles(float pitch, float yaw, float roll){
|
||||
pmove->ps.viewangles.x = pitch;
|
||||
pmove->ps.viewangles.y = yaw;
|
||||
pmove->ps.viewangles.z = roll;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,6 +120,8 @@ namespace Physic
|
|||
void PhysicActor::setPosition(const Ogre::Vector3 pos)
|
||||
{
|
||||
mEngine->adjustRigidBody(mBody, pos, getRotation(), mBoxScaledTranslation, mBoxRotation);
|
||||
btVector3 vec = mBody->getWorldTransform().getOrigin();
|
||||
pmove->ps.origin = Ogre::Vector3(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
void PhysicActor::setScale(float scale){
|
||||
|
@ -127,6 +139,12 @@ namespace Physic
|
|||
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
|
||||
}
|
||||
|
||||
void PhysicActor::runPmove(){
|
||||
Pmove(pmove);
|
||||
Ogre::Vector3 newpos = pmove->ps.origin;
|
||||
mBody->getWorldTransform().setOrigin(btVector3(newpos.x, newpos.y, newpos.z));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -68,11 +68,9 @@ namespace Physic
|
|||
void setCurrentWater(bool hasWater, int waterHeight);
|
||||
|
||||
/**
|
||||
* This function set the walkDirection. This is not relative to the actor orientation.
|
||||
* I think it's also needed to take time into account. A typical call should look like this:
|
||||
* setWalkDirection( mvt * orientation * dt)
|
||||
* This function sets the movement keys for pmove
|
||||
*/
|
||||
void setWalkDirection(const btVector3& mvt);
|
||||
void setMovement(signed char rightmove, signed char forwardmove, signed char upmove);
|
||||
|
||||
/**
|
||||
* This adjusts the rotation of a PhysicActor
|
||||
|
@ -106,11 +104,22 @@ namespace Physic
|
|||
*/
|
||||
void setPosition(const Ogre::Vector3 pos);
|
||||
|
||||
/**
|
||||
* Sets the view angles for pmove directly.
|
||||
* Remember, add 90 for yaw. Set roll to 0.
|
||||
*/
|
||||
void setPmoveViewAngles(float pitch, float yaw, float roll);
|
||||
|
||||
/**
|
||||
* Sets the scale of the PhysicActor
|
||||
*/
|
||||
void setScale(float scale);
|
||||
|
||||
/**
|
||||
* Runs pmove for this PhysicActor
|
||||
*/
|
||||
void runPmove();
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue