📄 constants.h
字号:
GROUP_MODE, TURN_MODE, REAL_TIME_MODE, CLOSE_LABEL, DROP_ITEM_LABEL, OPEN_CONTAINER_LABEL, EXPLAIN_DRAG_AND_DROP, PLAY_MISSION_LABEL, EXIT_MISSION_LABEL, TELEPORT_TO_BASE_LABEL, OK_LABEL, CANCEL_LABEL, YES_LABEL, NO_LABEL, LEVEL_UP_ERROR, OUT_OF_POINTS_ERROR, NO_SKILL_ERROR, SCOURGE_DIALOG, USE_GATE_LABEL, DEAD_CHARACTER_ERROR, HP_LABEL, AC_LABEL, SPELL_FAILED_MESSAGE, ITEM_ACL_VIOLATION, // last one MESSAGE_COUNT }; static char *messages[][80]; static int messageCount[]; // skills enum { SWORD_WEAPON = 0, AXE_WEAPON, BOW_WEAPON, HAND_TO_HAND_COMBAT, SPEED, COORDINATION, POWER, IQ, LEADERSHIP, LUCK, PIETY, LORE, SHIELD_DEFEND, ARMOR_DEFEND, WEAPON_DEFEND, HAND_DEFEND, NATURE_MAGIC, AWARENESS_MAGIC, LIFE_AND_DEATH_MAGIC, HISTORY_MAGIC, DECEIT_MAGIC, CONFRONTATION_MAGIC, OPEN_LOCK, FIND_TRAP, MOVE_UNDETECTED, SKILL_0, SKILL_1, SKILL_2, SKILL_3, SKILL_4, SKILL_5, SKILL_6, SKILL_7, SKILL_8, SKILL_9, SKILL_COUNT }; static const char *SKILL_NAMES[]; static int getSkillByName(char *p); // other things potions can act on: enum { HP=0, MP, AC, POTION_SKILL_COUNT }; static const char *POTION_SKILL_NAMES[]; // return -1 on failure, or (-2 - i) on success static int getPotionSkillByName(char *p); enum { blessed=0, empowered, enraged, ac_protected, magic_protected, drunk, poisoned, cursed, possessed, blinded, charmed, changed, overloaded, dead, leveled, // must be last STATE_MOD_COUNT }; static const char *STATE_NAMES[]; // special effect names enum { EFFECT_FLAMES=0, EFFECT_GLOW, EFFECT_TELEPORT, EFFECT_GREEN, EFFECT_EXPLOSION, EFFECT_SWIRL, EFFECT_CAST_SPELL, EFFECT_RING, // must be last EFFECT_COUNT }; static const int DAMAGE_DURATION = 500; static const char *EFFECT_NAMES[]; inline static int getEffectByName(char *s) { for(int i = 0; i < EFFECT_COUNT; i++) if(!strcmp(s, EFFECT_NAMES[i])) return i; return EFFECT_FLAMES; } // glColor for texts enum { RED_COLOR=0, BLUE_COLOR, YELLOW_COLOR, DEFAULT_COLOR // must be last for textColor[][] }; //static float textColor[][4]; static bool multitexture; enum { NO_SHADOWS=0, OBJECT_SHADOWS, ALL_SHADOWS }; enum { ACTION_NO_ACTION=-1, ACTION_EAT_DRINK=0, ACTION_CAST_SPELL, // this must be the last one ACTION_COUNT }; // the speed when hand fighting is used instead of a weapon static const int HAND_WEAPON_SPEED = 10; static const float MIN_DISTANCE = 1.0f; Constants(); ~Constants(); static char *getMessage(int index); // shortest distance between two rectangles static float distance(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2); // read until EOL into line. Exclude EOL from LINE. // returns the next char after the EOL. static int readLine(char *line, FILE *fp); inline static float toRadians(float angle) { return 3.14159 * (angle / 180.0f); } inline static float toAngle(float rad) { return (180.0f * rad) / 3.14159; }};// This is our 3D point class. This will be used to store the vertices of our model.class CVector3 {public: float x, y, z;};// This is our 2D point class. This will be used to store the UV coordinates.class CVector2 {public: float x, y;};// Math functionsextern CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2);// This adds 2 vectors together and returns the resultextern CVector3 AddVector(CVector3 vVector1, CVector3 vVector2);// This divides a vector by a single number (scalar) and returns the resultextern CVector3 DivideVectorByScaler(CVector3 vVector1, float Scaler);// This returns the cross product between 2 vectorsextern CVector3 Cross(CVector3 vVector1, CVector3 vVector2);extern CVector3 Normalize(CVector3 vNormal);// This file includes all of the model structures that are needed to load// in a .Md2 file. When it comes to skeletal animation, we need to add quite// a bit more variables to these structures. Not all of the data will be used// because Quake2 models don't have such a need. I decided to keep the structures// the same as the rest of the model loaders on our site so that we could eventually// use a base class in the future for a library.//typedef unsigned char BYTE;#define MAX_TEXTURES 100 // The maximum amount of textures to load// This is our face structure. This is is used for indexing into the vertex// and texture coordinate arrays. From this information we know which vertices// from our vertex array go to which face, along with the correct texture coordinates.struct tFace{ int vertIndex[3]; // indicies for the verts that make up this triangle int coordIndex[3]; // indicies for the tex coords to texture this face};// This holds the information for a material. It may be a texture map of a color.// Some of these are not used, but I left them because you will want to eventually// read in the UV tile ratio and the UV tile offset for some models.struct tMaterialInfo{ char strName[255]; // The texture name char strFile[255]; // The texture file name (If this is set it's a texture map) BYTE color[3]; // The color of the object (R, G, B) int texureId; // the texture ID float uTile; // u tiling of texture (Currently not used) float vTile; // v tiling of texture (Currently not used) float uOffset; // u offset of texture (Currently not used) float vOffset; // v offset of texture (Currently not used)} ;// This holds all the information for our model/scene.// You should eventually turn into a robust class that// has loading/drawing/querying functions like:// LoadModel(...); DrawObject(...); DrawModel(...); DestroyModel(...);struct t3DObject{ int numOfVerts; // The number of verts in the model int numOfFaces; // The number of faces in the model int numTexVertex; // The number of texture coordinates int numGlCommands; // The number of glCommands int materialID; // The texture ID to use, which is the index into our texture array bool bHasTexture; // This is TRUE if there is a texture map for this object char strName[255]; // The name of the object CVector3 *pVerts; // The object's vertices CVector3 *pNormals; // The object's normals float *shadingColorDelta; // 1 per normal CVector2 *pTexVerts; // The texture's UV coordinates tFace *pFaces; // The faces information of the object };// This holds our information for each animation of the Quake model.// A STL vector list of this structure is created in our t3DModel structure below.struct tAnimationInfo{ char strName[255]; // This stores the name of the animation (Jump, Pain, etc..) int startFrame; // This stores the first frame number for this animation int endFrame; // This stores the last frame number for this animation};typedef float vect3d[3];// We added 4 new variables to our model structure. These will help us handle// the current animation. As of now, the current animation will continue to loop// from it's start from to it's end frame until we right click and change animations.struct t3DModel { int numOfObjects; // The number of objects in the model int numOfMaterials; // The number of materials for the model int numOfAnimations; // The number of animations in this model float movex; // Needed to draw the model float movey; float movez; vector<tAnimationInfo> pAnimations; // The list of animations vector<tMaterialInfo> pMaterials; // The list of material information (Textures and colors) vector<t3DObject> pObject; // The object list for our model (frames) vect3d *vertices; // All vertices for every frame of the model int numVertices; // The number of vertices (constant for each frame) int *pGlCommands; // The glCommands used to draw the model faster};typedef unsigned char byte;extern void ComputeNormals(t3DModel *pModel);extern void CreateTexture(GLuint textureArray[],char *strFileName,int textureID);extern void swap(unsigned char & a, unsigned char & b);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -