made NPC heli rotors rotate

This commit is contained in:
aap 2020-07-21 09:58:53 +02:00
parent 5bedca7692
commit 0fba76a565
3 changed files with 52 additions and 1 deletions

View File

@ -273,7 +273,7 @@ enum Config {
// Vehicles // Vehicles
#define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher
//#define REMOVE_TREADABLE_PATHFIND #define CPLANE_ROTORS // make the rotors of the NPC police heli rotate
// Pickups // Pickups
//#define MONEY_MESSAGES //#define MONEY_MESSAGES

View File

@ -16,6 +16,7 @@
#include "Fluff.h" #include "Fluff.h"
#include "World.h" #include "World.h"
#include "HandlingMgr.h" #include "HandlingMgr.h"
#include "Heli.h"
#include "Plane.h" #include "Plane.h"
//--MIAMI: file done //--MIAMI: file done
@ -88,6 +89,9 @@ CPlane::CPlane(int32 id, uint8 CreatedBy)
m_level = LEVEL_GENERIC; m_level = LEVEL_GENERIC;
m_isFarAway = false; m_isFarAway = false;
#ifdef CPLANE_ROTORS
m_fRotorRotation = 0.0f;
#endif
} }
CPlane::~CPlane() CPlane::~CPlane()
@ -99,6 +103,21 @@ void
CPlane::SetModelIndex(uint32 id) CPlane::SetModelIndex(uint32 id)
{ {
CVehicle::SetModelIndex(id); CVehicle::SetModelIndex(id);
#ifdef CPLANE_ROTORS
int i;
for(i = 0; i < NUM_PLANE_NODES; i++)
m_aPlaneNodes[i] = nil;
if(GetModelIndex() == MI_CHOPPER){
// This is surprisingly annoying...
RwFrame *heliNodes[NUM_HELI_NODES];
for(i = 0; i < NUM_HELI_NODES; i++)
heliNodes[i] = nil;
CClumpModelInfo::FillFrameArray(GetClump(), heliNodes);
m_aPlaneNodes[PLANE_TOPROTOR] = heliNodes[HELI_TOPROTOR];
m_aPlaneNodes[PLANE_BACKROTOR] = heliNodes[HELI_BACKROTOR];
}else
CClumpModelInfo::FillFrameArray(GetClump(), m_aPlaneNodes);
#endif
} }
void void
@ -629,6 +648,29 @@ CPlane::PreRender(void)
CCoronas::TYPE_NORMAL, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::TYPE_NORMAL, CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON,
CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f); CCoronas::LOSCHECK_OFF, CCoronas::STREAK_ON, 0.0f);
} }
#ifdef CPLANE_ROTORS
CMatrix mat;
CVector pos;
m_fRotorRotation += 3.14f/6.5f;
if(m_fRotorRotation > 6.28f)
m_fRotorRotation -= 6.28f;
if(m_aPlaneNodes[PLANE_TOPROTOR]){
mat.Attach(RwFrameGetMatrix(m_aPlaneNodes[PLANE_TOPROTOR]));
pos = mat.GetPosition();
mat.SetRotateZ(m_fRotorRotation);
mat.Translate(pos);
mat.UpdateRW();
}
if(m_aPlaneNodes[PLANE_BACKROTOR]){
mat.Attach(RwFrameGetMatrix(m_aPlaneNodes[PLANE_BACKROTOR]));
pos = mat.GetPosition();
mat.SetRotateX(m_fRotorRotation);
mat.Translate(pos);
mat.UpdateRW();
}
#endif
} }
void void

View File

@ -4,6 +4,11 @@
enum ePlaneNodes enum ePlaneNodes
{ {
#ifdef CPLANE_ROTORS
// for heli
PLANE_TOPROTOR,
PLANE_BACKROTOR,
#endif
PLANE_WHEEL_FRONT = 2, PLANE_WHEEL_FRONT = 2,
PLANE_WHEEL_READ, PLANE_WHEEL_READ,
NUM_PLANE_NODES NUM_PLANE_NODES
@ -29,6 +34,10 @@ struct CPlaneInterpolationLine
class CPlane : public CVehicle class CPlane : public CVehicle
{ {
public: public:
#ifdef CPLANE_ROTORS
RwFrame *m_aPlaneNodes[NUM_PLANE_NODES];
float m_fRotorRotation;
#endif
int16 m_nPlaneId; int16 m_nPlaneId;
int16 m_isFarAway; int16 m_isFarAway;
int16 m_nCurPathNode; int16 m_nCurPathNode;