Code: Select all
void CShip::InjectMovement(int InjectedMovement)
{
mInjectedMovement = InjectedMovement;
switch (mInjectedMovement)
{
case 1:
mfPitch -= 5.0;
break;
case 2:
mfPitch += 5.0;
break;
case 3:
mfRoll -= 5;
break;
case 4:
mfRoll += 5;
break;
case 5:
mfSpeed += mPhysikconst[2];
if (mfSpeed > mPhysikconst[4])
mfSpeed = mPhysikconst[4];
break;
case 6:
mfSpeed -= mPhysikconst[3];
if (mfSpeed < mPhysikconst[5])
mfSpeed = mPhysikconst[5];
break;
case 7:
mfAfterburner = mPhysikconst[1];
break;
case 8: // switch between 1st and 3rd person view
if (mPlayerShip)
{
if (mbFirstPerson)
{
// third person
mCameraNode->setPosition( Vector3( 0, 50, -200) );
mbFirstPerson = false;
}
else
{
// first person
mCameraNode->setPosition( Vector3( 0, 5, 40) );
mbFirstPerson = true;
}
}
break;
}
}
so about the ai. i thought there should be some "exact" methodes first, which are later on started from the random or cost based ai (the options a ship can choose from (i.e. chase target ship, try to face target, flee from target))
im currently trying to realiese this "exact methodes".
i.e. the player is behind the enemy. the enemy decieds to try to chase the player (get behind him).
i would create 3 planes trough the middle of the npc ship and would check if a spot behind the the target (the player) where the npc ship wants to position itself is above/below, left/right, front/rear relative to the npc ships position. then i would start the
npcship->InjectMovement(/*depending on whether the target(the player) is left right and so on*/);
if the player doesnt move, or if i recheck the planes every frame the npc ship should be possible to reach this spot behin the player ship sooner or later.but, if it reaches the spot, i would most certainly not face to back of the player, the npc ships orientation would be wrong, so the player would be in a bad angle for the npc ship to fire its weapons (which are mounted front).
that all wouldnt be the problem if my npc ships could move free into all 3 direction of the 3d space. but as they are aircraft like ships, they only accelerate into one direction(front).
i would need a routine that calculates what movement is to be injected now, to reach a destinatet point with a given orientation as soon as possible (based in its physical constants, that define the speed it can change its pitch / yaw / roll angles).
i read about bezier curves for camera flights. is that maybe a solution ?that would bring me away from my injectmovement methode. to simulate different ships, this physical constants that define the angle rotation speed around the 3 axis are important for me.
i thought that might be a mathematik problem others have dealed with allready. any advice, links or code ? thx for you time