1 /** 2 * @file 3 */ 4 5 /* 6 Copyright (C) 1997-2001 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 */ 24 25 #pragma once 26 27 #define MAX_ANIMLIST 8 28 #define MAX_ENTITY_LIGHTS 7 29 30 #include "r_light.h" 31 #include "r_lighting.h" 32 33 /** entity->flags (render flags) */ 34 #define RF_NONE 0x00000000 /**< for initialization */ 35 #define RF_TRANSLUCENT 0x00000001 36 #define RF_BOX 0x00000002 /**< actor selection box */ 37 #define RF_PATH 0x01000000 /**< pathing marker, debugging only */ 38 #define RF_ARROW 0x02000000 /**< arrow, debugging only */ 39 40 /** the following ent flags also draw entity effects */ 41 #define RF_NO_SHADOW 0x00000004 /**< shadow (when living) for this entity */ 42 #define RF_BLOOD 0x00000008 /**< blood (when dead) for this entity */ 43 #define RF_SELECTED 0x00000010 /**< selected actor */ 44 #define RF_MEMBER 0x00000020 /**< actor in the same team */ 45 #define RF_ALLIED 0x00000040 /**< actor in an allied team (controlled by another player) */ 46 #define RF_ACTOR 0x00000080 /**< this is an actor */ 47 #define RF_PULSE 0x00000100 /**< glowing entity */ 48 #define RF_IRGOGGLES 0x00000200 /**< this is visible if the actor uses ir goggles */ 49 #define RF_NEUTRAL 0x00000400 /**< actor from a neutral team */ 50 #define RF_SHADOW 0x00000800 /**< shadow (when living) for this entity */ 51 #define RF_OPPONENT 0x00001000 /**< opponent */ 52 #define RF_IRGOGGLESSHOT 0x00002000 /**< this is the actor that used an irgoggle */ 53 54 typedef struct animState_s { 55 int frame; 56 int oldframe; 57 float backlerp; /**< linear interpolation from previous frame */ 58 int time; 59 int dt; 60 int mesh; /**< the mesh index of the model to animate */ 61 62 byte list[MAX_ANIMLIST]; /**< the list of @c mAliasAnim_t array indices that should be played */ 63 byte lcur; /**< the current position in the animation list */ 64 byte ladd; 65 byte change; 66 } animState_t; 67 68 /** 69 * @brief entity transform matrix 70 */ 71 typedef struct { 72 bool done; /**< already calculated */ 73 bool processing; /**< currently doing the calculation */ 74 float matrix[16]; /**< the matrix that holds the result */ 75 } transform_t; 76 77 typedef struct entity_s { 78 struct model_s* model; 79 vec3_t angles; 80 vec3_t scale; 81 vec3_t color; 82 vec3_t origin; 83 vec3_t oldorigin; 84 AABB eBox; 85 86 /* tag positioning */ 87 struct entity_s* tagent; /**< pointer to the parent entity */ 88 const char* tagname; /**< name of the tag */ 89 90 /* misc */ 91 int skinnum; 92 float alpha; /**< ignore if RF_TRANSLUCENT isn't set */ 93 int flags; 94 float distanceFromViewOrigin; 95 96 bool isOriginBrushModel; /**< true for bmodels that have an origin set */ 97 98 animState_t as; 99 100 transform_t transform; 101 102 vec4_t shell; /**< shell color */ 103 104 const image_t* texture; 105 106 lighting_t* lighting; /**< cached static light source information */ 107 108 struct entity_s* next; /**< for chaining */ 109 initentity_s110 inline void init () { 111 OBJZERO(*this); 112 } 113 inline entity_s (int flag = RF_NONE) { 114 init(); 115 flags = flag; 116 } 117 } entity_t; 118 119 /* entity chains for rendering */ 120 extern entity_t* r_opaque_mesh_entities; 121 extern entity_t* r_blend_mesh_entities; 122 extern entity_t* r_null_entities; 123 extern entity_t* r_special_entities; 124 125 126 int R_AddEntity(const entity_t* ent); 127 entity_t* R_GetFreeEntity(void); 128 entity_t* R_GetEntity(int id); 129 void R_EntitySetOrigin(entity_t* ent, const vec3_t origin); 130 void R_EntityAddToOrigin(entity_t* ent, const vec3_t offset); 131 void R_TransformForEntity(const entity_t* e, const vec3_t in, vec3_t out); 132 133 void R_DrawEntityEffects(void); 134 void R_DrawMeshEntities(entity_t* ents); 135 void R_DrawOpaqueMeshEntities(entity_t* ents); 136 void R_DrawBlendMeshEntities(entity_t* ents); 137 void R_DrawSpecialEntities(const entity_t* ents); 138 void R_DrawNullEntities(const entity_t* ents); 139