1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 10:36:42 +00:00

Awesome, working

This commit is contained in:
Jason Hooks 2012-03-27 20:17:54 -04:00
parent 318355f1be
commit b9fabce9c4
5 changed files with 44 additions and 44 deletions

View file

@ -273,8 +273,8 @@ namespace MWClass
vector.y = getMovementSettings (ptr).mForwardBackward * 127; vector.y = getMovementSettings (ptr).mForwardBackward * 127;
vector.z = getMovementSettings(ptr).mUpDown * 127; vector.z = getMovementSettings(ptr).mUpDown * 127;
if (getStance (ptr, Run, false)) //if (getStance (ptr, Run, false))
vector *= 2; // vector *= 2;
return vector; return vector;
} }

View file

@ -116,7 +116,6 @@ namespace MWWorld
pm_ref.upmove = dir1.y; pm_ref.upmove = dir1.y;
//std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n"; //std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n";
//playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); //playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees();
//std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n"; //std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n";
@ -124,11 +123,15 @@ namespace MWWorld
} }
else else
{ {
Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Quaternion quat = yawNode->getOrientation();
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
pm_ref.rightmove = -dir1.x; pm_ref.rightmove = -dir1.x;
pm_ref.forwardmove = dir1.z; pm_ref.forwardmove = dir1.z;
pm_ref.upmove = dir.y; pm_ref.upmove = dir1.y;
dir = 0.025*(quat*dir1); dir = 0.025*(quat*dir1);
} }

View file

@ -93,6 +93,7 @@ static inline void PM_ClipVelocity(const Ogre::Vector3& in, const Ogre::Vector3&
{ {
change = normal[i]*backoff; change = normal[i]*backoff;
out[i] = in[i] - change; out[i] = in[i] - change;
}*/ }*/
float changex = normal.x * backoff; float changex = normal.x * backoff;
out.x = in.x - changex; out.x = in.x - changex;
@ -178,7 +179,7 @@ bool PM_SlideMove( bool gravity )
float into; float into;
Ogre::Vector3 endVelocity; Ogre::Vector3 endVelocity;
Ogre::Vector3 endClipVelocity; Ogre::Vector3 endClipVelocity;
std::cout << "Slide move" << pm->ps.velocity << "\n";
numbumps = 4; numbumps = 4;
// primal_velocity = pm->ps->velocity // primal_velocity = pm->ps->velocity
@ -415,7 +416,7 @@ int PM_StepSlideMove( bool gravity )
// vec3_t delta, delta2; // vec3_t delta, delta2;
Ogre::Vector3 up, down; Ogre::Vector3 up, down;
float stepSize; float stepSize;
std::cout << "Step Slide move" << pm->ps.velocity << "\n";
// start_o = pm->ps->origin // start_o = pm->ps->origin
//VectorCopy (pm->ps->origin, start_o); //VectorCopy (pm->ps->origin, start_o);
@ -543,7 +544,7 @@ int PM_StepSlideMove( bool gravity )
void PM_Friction(void) void PM_Friction(void)
{ {
std::cout << "Friction\n";
Ogre::Vector3 vec; Ogre::Vector3 vec;
float* vel; float* vel;
float speed, newspeed, control; float speed, newspeed, control;
@ -639,7 +640,6 @@ static void PM_Accelerate( Ogre::Vector3& wishdir, float wishspeed, float accel
{ {
// int i; // int i;
float addspeed, accelspeed, currentspeed; float addspeed, accelspeed, currentspeed;
std::cout << "Accelerate\n";
// currentspeed = pm->ps->velocity dot wishdir // currentspeed = pm->ps->velocity dot wishdir
//currentspeed = DotProduct (pm->ps->velocity, wishdir); //currentspeed = DotProduct (pm->ps->velocity, wishdir);
@ -712,7 +712,7 @@ static void PM_WaterMove( playerMove* const pm )
Ogre::Vector3 wishdir; Ogre::Vector3 wishdir;
float scale; float scale;
float vel; float vel;
std::cout << "Water moving";
/*if ( PM_CheckWaterJump() ) /*if ( PM_CheckWaterJump() )
{ {
PM_WaterJumpMove(); PM_WaterJumpMove();
@ -838,7 +838,7 @@ static void PM_WalkMove( playerMove* const pmove )
playerMove::playercmd cmd; playerMove::playercmd cmd;
float accelerate; float accelerate;
float vel; float vel;
std::cout << "Walking" << pm->ps.velocity << "\n";
if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 )
pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f)
@ -851,6 +851,7 @@ static void PM_WalkMove( playerMove* const pmove )
if ( PM_CheckJump () ) if ( PM_CheckJump () )
{ {
// jumped away // jumped away
if ( pm->ps.waterlevel > 1 ) if ( pm->ps.waterlevel > 1 )
PM_WaterMove(pmove); PM_WaterMove(pmove);
@ -928,13 +929,14 @@ static void PM_WalkMove( playerMove* const pmove )
PM_Friction (); PM_Friction ();
std::cout << "After friction" << pm->ps.velocity << "\n";
//bprintf("vel: (%f, %f, %f)\n", pm->ps.velocity.x, pm->ps.velocity.y, pm->ps.velocity.z); //bprintf("vel: (%f, %f, %f)\n", pm->ps.velocity.x, pm->ps.velocity.y, pm->ps.velocity.z);
fmove = pm->cmd.forwardmove; fmove = pm->cmd.forwardmove;
smove = pm->cmd.rightmove; smove = pm->cmd.rightmove;
cmd = pm->cmd; cmd = pm->cmd;
scale = PM_CmdScale( &cmd ); scale = PM_CmdScale( &cmd );
@ -953,22 +955,23 @@ static void PM_WalkMove( playerMove* const pmove )
// project the forward and right directions onto the ground plane // project the forward and right directions onto the ground plane
PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP ); PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP );
PM_ClipVelocity (pml.right, pml.groundTrace.planenormal, pml.right, OVERCLIP ); PM_ClipVelocity (pml.right, pml.groundTrace.planenormal, pml.right, OVERCLIP );
std::cout << "Clip velocity" << pm->ps.velocity << "\n"; //std::cout << "Clip velocity" << pm->ps.velocity << "\n";
// //
VectorNormalize (pml.forward); VectorNormalize (pml.forward);
VectorNormalize (pml.right); VectorNormalize (pml.right);
//pml.forward = pml.forward.normalise(); //pml.forward = pml.forward.normalise();
//pml.right = pml.right.normalise(); //pml.right = pml.right.normalise();
std::cout << "forward2" << pml.forward << "\n"; //std::cout << "forward2" << pml.forward << "\n";
std::cout << "right2" << pml.right << "\n"; //std::cout << "right2" << pml.right << "\n";
// wishvel = (pml.forward * fmove) + (pml.right * smove); // wishvel = (pml.forward * fmove) + (pml.right * smove);
//for ( i = 0 ; i < 3 ; i++ ) //for ( i = 0 ; i < 3 ; i++ )
//wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove;
wishvel = pml.forward * fmove + pml.right * smove; wishvel = pml.forward * fmove + pml.right * smove;
std::cout << "WishVel" << wishvel << "\n";
//bprintf("f: (%f, %f, %f), s: (%f, %f, %f)\n", fmove, smove); //bprintf("f: (%f, %f, %f), s: (%f, %f, %f)\n", fmove, smove);
@ -981,9 +984,9 @@ static void PM_WalkMove( playerMove* const pmove )
wishdir = wishvel; wishdir = wishvel;
wishspeed = VectorNormalize(wishdir); wishspeed = VectorNormalize(wishdir);
std::cout << "Wishspeed: " << wishspeed << "\n"; //std::cout << "Wishspeed: " << wishspeed << "\n";
wishspeed *= scale; wishspeed *= scale;
std::cout << "Wishspeed scaled:" << wishspeed << "\n"; //std::cout << "Wishspeed scaled:" << wishspeed << "\n";
// clamp the speed lower if ducking // clamp the speed lower if ducking
if ( pm->cmd.ducking ) if ( pm->cmd.ducking )
@ -1010,7 +1013,7 @@ static void PM_WalkMove( playerMove* const pmove )
PM_Accelerate (wishdir, wishspeed, accelerate); PM_Accelerate (wishdir, wishspeed, accelerate);
std::cout << "Velocityafter: " << pm->ps.velocity << "\n"; //std::cout << "Velocityafter: " << pm->ps.velocity << "\n";
//Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); //Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]);
//Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity)); //Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity));
@ -1025,18 +1028,18 @@ static void PM_WalkMove( playerMove* const pmove )
//vel = VectorLength(pm->ps->velocity); //vel = VectorLength(pm->ps->velocity);
vel = pm->ps.velocity.length(); vel = pm->ps.velocity.length();
std::cout << "The length" << vel << "\n"; //std::cout << "The length" << vel << "\n";
// slide along the ground plane // slide along the ground plane
PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal, PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal,
pm->ps.velocity, OVERCLIP ); pm->ps.velocity, OVERCLIP );
std::cout << "Velocity clipped" << pm->ps.velocity << "\n"; //std::cout << "Velocity clipped" << pm->ps.velocity << "\n";
// don't decrease velocity when going up or down a slope // don't decrease velocity when going up or down a slope
VectorNormalize(pm->ps.velocity); VectorNormalize(pm->ps.velocity);
//pm->ps.velocity = pm->ps.velocity.normalise(); //pm->ps.velocity = pm->ps.velocity.normalise();
std::cout << "Final:" << pm->ps.velocity << "\n"; //std::cout << "Final:" << pm->ps.velocity << "\n";
//VectorScale(pm->ps->velocity, vel, pm->ps->velocity); //VectorScale(pm->ps->velocity, vel, pm->ps->velocity);
pm->ps.velocity = pm->ps.velocity * vel; pm->ps.velocity = pm->ps.velocity * vel;
@ -1048,7 +1051,7 @@ static void PM_WalkMove( playerMove* const pmove )
PM_StepSlideMove( false ); PM_StepSlideMove( false );
//Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity)); //Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity));
std::cout << "Walk2" << pm->ps.velocity << "\n";
} }
@ -1056,7 +1059,7 @@ void PM_UpdateViewAngles( playerMove::playerStruct* const ps, playerMove::player
{ {
short temp; short temp;
int i; int i;
std::cout << "Updating viewangles\n";
//while(1); //while(1);
//if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) //if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION)
@ -1178,7 +1181,6 @@ static bool PM_CorrectAllSolid(traceResults* const trace)
{ {
int i, j, k; int i, j, k;
Ogre::Vector3 point; Ogre::Vector3 point;
std::cout << "Correct all solid\n";
//if ( pm->debugLevel ) //if ( pm->debugLevel )
//Com_Printf("%i:allsolid\n", c_pmove); //Com_Printf("%i:allsolid\n", c_pmove);
@ -1236,7 +1238,7 @@ static void PM_CrashLand( void )
float vel, acc; float vel, acc;
float t; float t;
float a, b, c, den; float a, b, c, den;
std::cout << "Crash land\n";
// decide which landing animation to use // decide which landing animation to use
/*if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) /*if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP )
PM_ForceLegsAnim( LEGS_LANDB ); PM_ForceLegsAnim( LEGS_LANDB );
@ -1378,7 +1380,6 @@ static void PM_CrashLand( void )
static void PM_GroundTrace( void ) static void PM_GroundTrace( void )
{ {
std::cout << "Ground trace" << pm->ps.velocity << "\n";
Ogre::Vector3 point; Ogre::Vector3 point;
traceResults trace; traceResults trace;
@ -1484,13 +1485,12 @@ static void PM_GroundTrace( void )
// don't reset the z velocity for slopes // don't reset the z velocity for slopes
// pm->ps->velocity[2] = 0; // pm->ps->velocity[2] = 0;
std::cout << "Ground trace2" << pm->ps.velocity << "\n";
//PM_AddTouchEnt( trace.entityNum ); //PM_AddTouchEnt( trace.entityNum );
} }
static void PM_AirMove() static void PM_AirMove()
{ {
std::cout << "Air move " << pm->ps.velocity << "\n";
//int i; //int i;
Ogre::Vector3 wishvel; Ogre::Vector3 wishvel;
float fmove, smove; float fmove, smove;
@ -1516,8 +1516,8 @@ static void PM_AirMove()
//pml.right[2] = 0; //pml.right[2] = 0;
pml.right.z = 0; pml.right.z = 0;
//VectorNormalize (pml.forward); //VectorNormalize (pml.forward);
pml.forward = Ogre::Vector3(pml.forward.normalise()); VectorNormalize(pml.forward);
pml.right = Ogre::Vector3(pml.right.normalise()); VectorNormalize(pml.right);
//VectorNormalize (pml.right); //VectorNormalize (pml.right);
//for ( i = 0 ; i < 2 ; i++ ) //for ( i = 0 ; i < 2 ; i++ )
@ -1554,7 +1554,6 @@ static void PM_AirMove()
#endif*/ #endif*/
/*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/; /*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/;
std::cout << "Velocity 2 " << pm->ps.velocity << "\n";
} }
static void PM_NoclipMove( void ) static void PM_NoclipMove( void )
@ -1602,9 +1601,7 @@ static void PM_NoclipMove( void )
//for (i=0 ; i<3 ; i++) //for (i=0 ; i<3 ; i++)
//wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove;
std::cout << "Forward" << pml.forward << "\n";
std::cout << "Right" << pml.right << "\n";
std::cout << "Up" << pml.up << "\n";
wishvel = pml.forward * fmove + pml.right * smove; wishvel = pml.forward * fmove + pml.right * smove;
//wishvel[2] += pm->cmd.upmove; //wishvel[2] += pm->cmd.upmove;
wishvel.z += pm->cmd.upmove; wishvel.z += pm->cmd.upmove;
@ -1614,6 +1611,7 @@ static void PM_NoclipMove( void )
wishspeed = VectorNormalize(wishdir); wishspeed = VectorNormalize(wishdir);
wishspeed *= scale; wishspeed *= scale;
PM_Accelerate( wishdir, wishspeed, pm_accelerate ); PM_Accelerate( wishdir, wishspeed, pm_accelerate );
// move // move
@ -1747,6 +1745,7 @@ void PM_SetWaterLevel( playerMove* const pm )
void PmoveSingle (playerMove* const pmove) void PmoveSingle (playerMove* const pmove)
{ {
//pm = pmove; //pm = pmove;
// Aedra doesn't support Q3-style VM traps D: //while(1); // Aedra doesn't support Q3-style VM traps D: //while(1);
@ -1898,7 +1897,7 @@ void PmoveSingle (playerMove* const pmove)
if ( pm->ps.move_type == PM_SPECTATOR ) if ( pm->ps.move_type == PM_SPECTATOR )
{ {
std::cout << "SPECTATOR\n";
//PM_CheckDuck (); //PM_CheckDuck ();
PM_FlyMove (); PM_FlyMove ();
PM_DropTimers (); PM_DropTimers ();
@ -1907,20 +1906,19 @@ void PmoveSingle (playerMove* const pmove)
if ( pm->ps.move_type == PM_NOCLIP ) if ( pm->ps.move_type == PM_NOCLIP )
{ {
std::cout << "NOCLIP\n";
PM_NoclipMove (); PM_NoclipMove ();
PM_DropTimers (); PM_DropTimers ();
return; return;
} }
if (pm->ps.move_type == PM_FREEZE){ if (pm->ps.move_type == PM_FREEZE){
std::cout << "FREEZE\n";
return; // no movement at all return; // no movement at all
} }
if ( pm->ps.move_type == PM_INTERMISSION || pm->ps.move_type == PM_SPINTERMISSION){ if ( pm->ps.move_type == PM_INTERMISSION || pm->ps.move_type == PM_SPINTERMISSION){
std::cout << "INTERMISSION\n";
return; // no movement at all return; // no movement at all
} }
@ -2006,6 +2004,7 @@ void Ext_UpdateViewAngles(playerMove* const pm)
void Pmove (playerMove* const pmove) void Pmove (playerMove* const pmove)
{ {
int fmove = pmove->cmd.forwardmove;
pm = pmove; pm = pmove;
int finalTime; int finalTime;

View file

@ -90,7 +90,7 @@ struct playerMove
{ {
struct playerStruct struct playerStruct
{ {
playerStruct() : gravity(50.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) playerStruct() : gravity(800.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0)
{ {
origin = Ogre::Vector3(733.164f,900.0f, 839.432f); origin = Ogre::Vector3(733.164f,900.0f, 839.432f);
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);

View file

@ -32,9 +32,8 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr
//Ogre::Vector3 endReplace = startReplace; //Ogre::Vector3 endReplace = startReplace;
//endReplace.z -= .25; //endReplace.z -= .25;
const bool hasHit = NewPhysicsTrace<collisionWorldTrace>(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); const bool hasHit = NewPhysicsTrace<collisionWorldTrace>(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, 0.0, rotation), isInterior, enginePass);
if(hasHit)
std::cout << "Has hit\n";
if (out.fraction < 0.001f) if (out.fraction < 0.001f)
results->startsolid = true; results->startsolid = true;
else else
@ -180,8 +179,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3&
const bool hasHit = newTraceCallback.hasHit(); const bool hasHit = newTraceCallback.hasHit();
if(hasHit)
std::cout << "HIT\n";
return hasHit; return hasHit;