123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- //---------------------------------------------------------------------------
- //
- // dbactor.h - This file contains the header for the Static ground object appearance class
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef BDACTOR_H
- #define BDACTOR_H
- //---------------------------------------------------------------------------
- // Include files
- #ifndef APPEAR_H
- #include "appear.h"
- #endif
- #ifndef APPRTYPE_H
- #include "apprtype.h"
- #endif
- #ifndef MOVE_H
- #include "move.h"
- #endif
- #ifndef MSL_H
- #include "msl.h"
- #endif
- #ifndef OBJECTAPPEARANCE_H
- #include "ObjectAppearance.h"
- #endif
- #include <gosFX\gosfxheaders.hpp>
- //**************************************************************************************
- #ifndef NO_ERR
- #define NO_ERR 0
- #endif
- #define MAX_BD_ANIMATIONS 10
- //***********************************************************************
- //
- // BldgAppearanceType
- //
- //***********************************************************************
- class BldgAppearanceType : public AppearanceType
- {
- public:
-
- TG_TypeMultiShapePtr bldgShape[MAX_LODS];
- float lodDistance[MAX_LODS];
-
- TG_TypeMultiShapePtr bldgShadowShape;
-
- TG_TypeMultiShapePtr bldgDmgShape;
-
- TG_TypeMultiShapePtr bldgDmgShadowShape;
-
- TG_AnimateShapePtr bdAnimData[MAX_BD_ANIMATIONS];
- bool bdAnimLoop[MAX_BD_ANIMATIONS];
- bool bdReverse[MAX_BD_ANIMATIONS];
- bool bdRandom[MAX_BD_ANIMATIONS];
- long bdStartF[MAX_BD_ANIMATIONS];
-
- char rotationalNodeId[TG_NODE_ID];
- char destructEffect[60];
-
- bool spinMe;
- bool isForestClump;
-
- DWORD terrainLightRGB;
- float terrainLightIntensity;
- float terrainLightInnerRadius;
- float terrainLightOuterRadius;
-
- long numWeaponNodes;
- NodeData *nodeData;
-
- public:
-
- void init (void)
- {
- long i=0;
- for (i=0;i<MAX_LODS;i++)
- {
- bldgShape[i] = NULL;
- lodDistance[i] = 0.0f;
- }
- bldgShadowShape = NULL;
- bldgDmgShape = NULL;
- bldgDmgShadowShape = NULL;
-
- for (i=0;i<MAX_BD_ANIMATIONS;i++)
- bdAnimData[i] = NULL;
-
- destructEffect[0] = 0;
-
- spinMe = false;
- }
-
- BldgAppearanceType (void)
- {
- init();
- }
- ~BldgAppearanceType (void)
- {
- destroy();
- }
- void setAnimation (TG_MultiShapePtr shape, DWORD animationNum);
-
- long getNumFrames (long animationNum)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- return bdAnimData[animationNum]->GetNumFrames();
- return 0.0f;
- }
- float getFrameRate (long animationNum)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- return bdAnimData[animationNum]->GetFrameRate();
- return 0.0f;
- }
- void setFrameRate (long animationNum, float nFrameRate)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- bdAnimData[animationNum]->SetFrameRate(nFrameRate);
- }
- bool isReversed (long animationNum)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- return bdReverse[animationNum];
- return false;
- }
-
- bool isLooped (long animationNum)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- return bdAnimLoop[animationNum];
- return false;
- }
-
- bool isRandom (long animationNum)
- {
- if ((animationNum >= 0) && (animationNum < MAX_BD_ANIMATIONS) && (bdAnimData[animationNum]))
- return bdRandom[animationNum];
- return false;
- }
-
- virtual void init (char *fileName);
-
- virtual void destroy (void);
- };
- //***********************************************************************
- //
- // BldgAppearance
- //
- //***********************************************************************
- class BldgAppearance : public ObjectAppearance
- {
- public:
- BldgAppearanceType* appearType;
- TG_MultiShapePtr bldgShape;
- TG_MultiShapePtr bldgShadowShape;
-
- long bdAnimationState;
- float currentFrame;
- float bdFrameRate;
- bool isReversed;
- bool isLooping;
- bool setFirstFrame;
- bool canTransition;
-
- float turretYaw;
- float turretPitch;
-
- float hazeFactor;
-
- long status;
-
- gosFX::Effect *destructFX;
- gosFX::Effect *activity;
- gosFX::Effect *activity1;
- bool isActivitying;
-
- float OBBRadius;
- float highZ;
-
- float SpinAngle;
-
- float flashDuration;
- float duration;
- float currentFlash;
- bool drawFlash;
- DWORD flashColor;
-
- long currentLOD;
-
- long *nodeUsed; //Used to stagger the weapon nodes for firing.
- float *nodeRecycle; //Used for ripple fire to find out if the node has fired recently.
-
- TG_LightPtr pointLight;
- DWORD lightId;
- bool forceLightsOut;
- bool beenInView;
-
- bool fogLightSet;
- DWORD lightRGB;
- DWORD fogRGB;
- long rotationalNodeId;
- long hitNodeId;
- long activityNodeId;
- long activityNode1Id;
- public:
- virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
- virtual AppearanceTypePtr getAppearanceType (void)
- {
- return appearType;
- }
- BldgAppearance (void)
- {
- init();
- }
- virtual long update (bool animate = true);
- virtual long render (long depthFixup = 0);
- virtual long renderShadows (void);
- virtual void destroy (void);
- ~BldgAppearance (void)
- {
- destroy();
- }
- virtual bool recalcBounds (void);
-
- virtual bool getInTransition (void)
- {
- return (canTransition == false);
- }
- void setFadeTable (MemoryPtr fTable)
- {
- fadeTable = fTable;
- }
- virtual void setGesture (unsigned long gestureId);
-
- virtual long getCurrentGestureId (void)
- {
- return bdAnimationState;
- }
- virtual unsigned long getAppearanceClass (void)
- {
- return BUILDING_APPR_TYPE;
- }
-
- virtual void setObjectNameId (long objId)
- {
- objectNameId = objId;
- }
- virtual bool isMouseOver (float px, float py);
-
- virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long alignment, long homeRelations);
-
- virtual void setMoverParameters (float turretRot, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
-
- virtual void setObjStatus (long oStatus);
-
- virtual long calcCellsCovered (Stuff::Vector3D& pos, short* cellList);
- virtual void markTerrain(_ScenarioMapCellInfo* pInfo, int type, int counter);
-
- virtual long markMoveMap (bool passable, long* lineOfSightRect, bool useheight = false, short* cellList = NULL);
- virtual void markLOS (bool clearIt = false);
-
- void calcAdjCell (long& row, long& col);
- virtual void scale (float scaleFactor)
- {
- bldgShape->ScaleShape(scaleFactor);
- }
-
- virtual bool playDestruction (void);
-
- virtual float getRadius (void)
- {
- return OBBRadius;
- }
-
- virtual void flashBuilding (float duration, float flashDuration, DWORD color);
- virtual float getTopZ (void)
- {
- return highZ;
- }
-
- virtual void setWeaponNodeUsed (long nodeId);
-
- virtual long getWeaponNode (long weapontype);
-
- virtual float getWeaponNodeRecycle (long node);
-
- virtual Stuff::Vector3D getWeaponNodePosition (long node);
- virtual bool isSelectable()
- {
- return !appearType->spinMe;
- }
- virtual void setFilterState (bool state)
- {
- bldgShape->GetMultiType()->SetFilter(state);
- }
-
- virtual void setIsHudElement (void)
- {
- bldgShape->SetIsHudElement();
- }
-
- virtual bool getIsLit (void)
- {
- return (appearType->terrainLightRGB != 0xffffffff);
- }
-
- virtual void setLightsOut (bool lightFlag)
- {
- forceLightsOut = lightFlag;
- }
- virtual bool PerPolySelect (long mouseX, long mouseY);
- virtual bool isForestClump (void)
- {
- return appearType->isForestClump;
- }
-
- virtual Stuff::Point3D getRootNodeCenter (void)
- {
- Stuff::Point3D result = bldgShape->GetRootNodeCenter();
- return result;
- }
-
- virtual Stuff::Vector3D getNodeNamePosition (char *nodeName);
-
- virtual void startActivity (long effectId, bool loop);
- virtual void stopActivity (void);
- virtual Stuff::Vector3D getHitNode (void);
- virtual bool hasAnimationData (long gestureId)
- {
- return (appearType->bdAnimData[gestureId] != NULL);
- }
- virtual Stuff::Vector3D getNodeIdPosition (long nodeId);
- };
- //***************************************************************************
- //***********************************************************************
- //
- // TreeAppearanceType
- //
- //***********************************************************************
- class TreeAppearanceType : public AppearanceType
- {
- public:
-
- TG_TypeMultiShapePtr treeShape[MAX_LODS];
- float lodDistance[MAX_LODS];
-
- TG_TypeMultiShapePtr treeShadowShape;
-
- TG_TypeMultiShapePtr treeDmgShape;
-
- TG_TypeMultiShapePtr treeDmgShadowShape;
-
- TG_AnimateShapePtr treeAnimData[MAX_BD_ANIMATIONS];
- bool isForestClump;
-
- public:
-
- void init (void)
- {
- long i=0;
- for (i=0;i<MAX_LODS;i++)
- {
- treeShape[i] = NULL;
- lodDistance[i] = 0.0f;
- }
- for (i=0;i<MAX_BD_ANIMATIONS;i++)
- treeAnimData[i] = NULL;
-
- treeShadowShape = NULL;
-
- treeDmgShape = NULL;
- treeDmgShadowShape = NULL;
- }
-
- TreeAppearanceType (void)
- {
- init();
- }
- ~TreeAppearanceType (void)
- {
- destroy();
- }
- virtual void init (char *fileName);
-
- virtual void destroy (void);
- };
- //***********************************************************************
- //
- // TreeAppearance
- //
- //***********************************************************************
- class TreeAppearance : public ObjectAppearance
- {
- public:
- TreeAppearanceType* appearType;
- TG_MultiShapePtr treeShape;
- TG_MultiShapePtr treeShadowShape;
-
- float hazeFactor;
- float pitch;
- float yaw;
- long status;
-
- float OBBRadius;
-
- long currentLOD;
-
- bool forceLightsOut;
- bool beenInView;
- bool fogLightSet;
- DWORD lightRGB;
- DWORD fogRGB;
- public:
- virtual void init (AppearanceTypePtr tree = NULL, GameObjectPtr obj = NULL);
- virtual AppearanceTypePtr getAppearanceType (void)
- {
- return appearType;
- }
- TreeAppearance (void)
- {
- init();
- }
- virtual long update (bool animate = true);
- virtual long render (long depthFixup = 0);
- virtual long renderShadows (void);
- virtual void destroy (void);
- ~TreeAppearance (void)
- {
- destroy();
- }
- virtual unsigned long getAppearanceClass (void)
- {
- return TREE_APPR_TYPE;
- }
- virtual bool recalcBounds (void);
-
- void setFadeTable (MemoryPtr fTable)
- {
- fadeTable = fTable;
- }
-
- virtual void setObjectNameId (long objId)
- {
- objectNameId = objId;
- }
- virtual bool isMouseOver (float px, float py);
-
- virtual void setObjectParameters (Stuff::Vector3D &pos, float rot, long selected, long alignment, long homeRelations);
-
- virtual void setMoverParameters (float pitchAngle, float lArmRot = 0.0f, float rArmRot = 0.0f, bool isAirborne = false);
-
- virtual void setObjStatus (long oStatus);
- virtual void scale (float scaleFactor)
- {
- treeShape->ScaleShape(scaleFactor);
- }
-
- virtual float getRadius (void)
- {
- return OBBRadius;
- }
-
- virtual void setLightsOut (bool lightFlag)
- {
- forceLightsOut = lightFlag;
- }
-
- virtual bool isForestClump (void)
- {
- return appearType->isForestClump;
- }
-
- virtual void markTerrain(_ScenarioMapCellInfo* pInfo, int type, int counter);
- virtual Stuff::Point3D getRootNodeCenter (void)
- {
- Stuff::Point3D result = treeShape->GetRootNodeCenter();
- return result;
- }
- virtual void markLOS (bool clearIt = false);
- };
- //***************************************************************************
- #endif
|