00001
00002 #ifndef WORLD_H
00003 #define WORLD_H
00004
00005
00006
00007 #define MAX_TEXANIMS 16
00008 #define DRAW_WORLD_NORMALS 0
00009
00010 #define REJECT_WORLD_POLY() \
00011 { \
00012 if (mp->VisiMask & CamVisiMask) continue; \
00013 if (!(mp->Type & POLY_DOUBLE)) if (Cull(mp->v0->sx, mp->v0->sy, mp->v1->sx, mp->v1->sy, mp->v2->sx, mp->v2->sy) > 0) continue; \
00014 }
00015
00016 #define REJECT_WORLD_POLY_MIRROR() \
00017 { \
00018 if (mp->VisiMask & CamVisiMask) continue; \
00019 if (!(mp->Type & POLY_DOUBLE)) if (Cull(mp->v0->sx, mp->v0->sy, mp->v1->sx, mp->v1->sy, mp->v2->sx, mp->v2->sy) < 0) continue; \
00020 }
00021
00022 #define COPY_WORLD_TRI_COLOR(_v) \
00023 { \
00024 (_v)[0].color = mp->rgb0; \
00025 (_v)[1].color = mp->rgb1; \
00026 (_v)[2].color = mp->rgb2; \
00027 }
00028
00029 #define COPY_WORLD_QUAD_COLOR(_v) \
00030 { \
00031 (_v)[0].color = mp->rgb0; \
00032 (_v)[1].color = mp->rgb1; \
00033 (_v)[2].color = mp->rgb2; \
00034 (_v)[3].color = mp->rgb3; \
00035 }
00036
00037 #define COPY_WORLD_TRI_COLOR_LIT(_v) \
00038 { \
00039 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb0, &mp->v0->r, (MODEL_RGB*)&(_v)[0].color); \
00040 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb1, &mp->v1->r, (MODEL_RGB*)&(_v)[1].color); \
00041 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb2, &mp->v2->r, (MODEL_RGB*)&(_v)[2].color); \
00042 }
00043
00044 #define COPY_WORLD_QUAD_COLOR_LIT(_v) \
00045 { \
00046 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb0, &mp->v0->r, (MODEL_RGB*)&(_v)[0].color); \
00047 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb1, &mp->v1->r, (MODEL_RGB*)&(_v)[1].color); \
00048 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb2, &mp->v2->r, (MODEL_RGB*)&(_v)[2].color); \
00049 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb3, &mp->v3->r, (MODEL_RGB*)&(_v)[3].color); \
00050 }
00051
00052 #define COPY_WORLD_TRI_COLOR_LIT_MIRROR(_v) \
00053 { \
00054 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb0, &mp->v0->RealVertex->r, (MODEL_RGB*)&(_v)[0].color); \
00055 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb1, &mp->v1->RealVertex->r, (MODEL_RGB*)&(_v)[1].color); \
00056 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb2, &mp->v2->RealVertex->r, (MODEL_RGB*)&(_v)[2].color); \
00057 }
00058
00059 #define COPY_WORLD_QUAD_COLOR_LIT_MIRROR(_v) \
00060 { \
00061 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb0, &mp->v0->RealVertex->r, (MODEL_RGB*)&(_v)[0].color); \
00062 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb1, &mp->v1->RealVertex->r, (MODEL_RGB*)&(_v)[1].color); \
00063 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb2, &mp->v2->RealVertex->r, (MODEL_RGB*)&(_v)[2].color); \
00064 ModelAddGouraudAlpha((MODEL_RGB*)&mp->rgb3, &mp->v3->RealVertex->r, (MODEL_RGB*)&(_v)[3].color); \
00065 }
00066
00067
00068
00069 typedef struct {
00070 long Tpage;
00071 float Time;
00072 float u0, v0;
00073 float u1, v1;
00074 float u2, v2;
00075 float u3, v3;
00076 } TEXANIM_FRAME;
00077
00078 typedef struct {
00079 TEXANIM_FRAME *Frame, *CurrentFrame;
00080 long FrameNum, CurrentFrameNum;
00081 float FrameTime;
00082 } TEXANIM_HEADER;
00083
00084 typedef struct {
00085 float x, y, z;
00086 float nx, ny, nz;
00087 } WORLD_VERTEX_LOAD;
00088
00089 typedef struct {
00090 short Type, Tpage;
00091 short vi0, vi1, vi2, vi3;
00092 long c0, c1, c2, c3;
00093 float u0, v0, u1, v1, u2, v2, u3, v3;
00094 } WORLD_POLY_LOAD;
00095
00096 typedef struct {
00097 float x, y, z;
00098 float x2, y2, z2;
00099 float nx, ny, nz;
00100 float sx, sy, sz, rhw;
00101 long color, specular;
00102 float tu, tv;
00103 long r, g, b, EnvRGB;
00104 float VertFog;
00105 unsigned char Clip, pad[3];
00106 } WORLD_VERTEX;
00107
00108 typedef struct {
00109 short Type, Tpage;
00110 VISIMASK VisiMask;
00111 long rgb0, rgb1, rgb2, rgb3;
00112 float tu0, tv0;
00113 float tu1, tv1;
00114 float tu2, tv2;
00115 float tu3, tv3;
00116 WORLD_VERTEX *v0, *v1, *v2, *v3;
00117 } WORLD_POLY;
00118
00119 typedef struct {
00120 float x, y, z;
00121 float x2, y2, z2;
00122 float sx, sy, sz, rhw;
00123 float VertFog;
00124 long specular;
00125 unsigned char Clip, pad[3];
00126 WORLD_VERTEX *RealVertex;
00127 } WORLD_MIRROR_VERTEX;
00128
00129 typedef struct {
00130 short Type, Tpage;
00131 VISIMASK VisiMask;
00132 long rgb0, rgb1, rgb2, rgb3;
00133 float tu0, tv0;
00134 float tu1, tv1;
00135 float tu2, tv2;
00136 float tu3, tv3;
00137 WORLD_MIRROR_VERTEX *v0, *v1, *v2, *v3;
00138 } WORLD_MIRROR_POLY;
00139
00140 typedef struct {
00141 WORLD_POLY *Poly;
00142 TEXANIM_HEADER *Anim;
00143 } WORLD_ANIM_POLY;
00144
00145 typedef struct {
00146 void *AllocPtr;
00147 short PolyNum, VertNum;
00148 short QuadNumTex, TriNumTex, QuadNumRGB, TriNumRGB;
00149 short MirrorPolyNum, MirrorVertNum;
00150 short MirrorQuadNumTex, MirrorTriNumTex, MirrorQuadNumRGB, MirrorTriNumRGB;
00151 short AnimPolyNum, EnvVertNum;
00152 WORLD_POLY *PolyPtr;
00153 WORLD_VERTEX *VertPtr;
00154 WORLD_MIRROR_POLY *MirrorPolyPtr;
00155 WORLD_MIRROR_VERTEX *MirrorVertPtr;
00156 WORLD_ANIM_POLY *AnimPolyPtr;
00157 WORLD_VERTEX **EnvVertPtr;
00158 } WORLD_MODEL;
00159
00160 typedef struct {
00161 float CentreX, CentreY, CentreZ, Radius;
00162 float Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
00163 short PolyNum, VertNum;
00164 } CUBE_HEADER_LOAD;
00165
00166 typedef struct {
00167 float CentreX, CentreY, CentreZ, Radius;
00168 float Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
00169 VISIMASK VisiMask;
00170 long Clip, z, Lit, MeshFxFlag;
00171 float MirrorHeight;
00172 WORLD_MODEL Model;
00173 } CUBE_HEADER;
00174
00175 typedef struct {
00176 float x, y, z, Radius;
00177 long CubeNum;
00178 } BIG_CUBE_HEADER_LOAD;
00179
00180 typedef struct {
00181 float x, y, z, Radius;
00182 long CubeNum;
00183 CUBE_HEADER **Cubes;
00184 } BIG_CUBE_HEADER;
00185
00186 typedef struct {
00187 long CubeNum, BigCubeNum;
00188 CUBE_HEADER *Cube, **CubeList;
00189 BIG_CUBE_HEADER *BigCube;
00190 } WORLD;
00191
00192 typedef struct {
00193 long CubeNum;
00194 } WORLD_HEADER;
00195
00196
00197
00198 extern bool LoadWorld(char *file);
00199 extern void FreeWorld(void);
00200 extern void MirrorWorldPolys(void);
00201 extern void SetWorldMirror(void);
00202 extern void DrawWorld(void);
00203 extern void DrawWorldCube(CUBE_HEADER *cube);
00204 extern void DrawWorldCubeMirror(CUBE_HEADER *cube);
00205 extern void TransCubeVertsClip(WORLD_MODEL *m);
00206 extern void TransCubeVertsFogClip(WORLD_MODEL *m);
00207 extern void TransCubeVerts(WORLD_MODEL *m);
00208 extern void TransCubeVertsFog(WORLD_MODEL *m);
00209 extern void TransCubeVertsClipNewVerts(WORLD_MODEL *m);
00210 extern void TransCubeVertsFogClipNewVerts(WORLD_MODEL *m);
00211 extern void TransCubeVertsNewVerts(WORLD_MODEL *m);
00212 extern void TransCubeVertsFogNewVerts(WORLD_MODEL *m);
00213 extern void TransCubeVertsMirror(WORLD_MODEL *m);
00214 extern void TransCubeVertsMirrorNewVerts(WORLD_MODEL *m);
00215 extern void DrawCubePolysClip(WORLD_MODEL *m, long lit);
00216 extern void DrawCubePolys(WORLD_MODEL *m, long lit);
00217 extern void DrawCubePolysMirror(WORLD_MODEL *m, long lit);
00218 extern void ProcessTextureAnimations(void);
00219
00220
00221
00222 extern WORLD World;
00223 extern short WorldBigCubeCount, WorldCubeCount, WorldPolyCount, WorldDrawnCount;
00224
00225 #endif