summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-21 22:37:05 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commitabd1c6857950797fb4e4bd4113ace12a73f71e37 (patch)
treeaaaad58ea1a5fc7a21d6022ac3e0efd3f7addf01
parentfe15141c2fe25af72bd93968a19150977a2166d2 (diff)
Removed some unused code.
Added some of the level drawing hacks (water, rain).
-rw-r--r--Makefile1
-rw-r--r--src/kshape.c228
-rw-r--r--src/main.c6
-rw-r--r--src/opengl.c2770
-rw-r--r--src/stubs.c20
5 files changed, 2672 insertions, 353 deletions
diff --git a/Makefile b/Makefile
index e866469..981cbe0 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ CXX = gcc
#CXX = gcc-3.0
NASM = nasm
+#CFLAGS = -g -Wall -pipe -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets
CFLAGS = -g -Wall -pipe -O2 -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets
#CFLAGS = -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentiumpro -mcpu=pentiumpro -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets
CXXFLAGS = $(CFLAGS)
diff --git a/src/kshape.c b/src/kshape.c
index 33ebda4..2287b49 100644
--- a/src/kshape.c
+++ b/src/kshape.c
@@ -5705,133 +5705,7 @@ void OutputTranslucentPolyList(void)
}
-
-
-#if 0
-int CuboidPolyVertexList[][4] =
-{
- {0,1,2,3}, //+ve x
- {0,3,7,4}, //+ve y
- {6,7,3,2}, //+ve z
-
- {6,7,4,5}, //-ve x
- {6,5,1,2}, //-ve y
- {0,1,5,4}, //-ve z
-};
-EULER CubeOrient = {0,0,0};
-void CubeOMatic(void)
-{
- #define CUBESCALE 128
- VECTORCH vertices[8]=
- {
- {+CUBESCALE,+CUBESCALE,-CUBESCALE},
- {+CUBESCALE,-CUBESCALE,-CUBESCALE},
- {+CUBESCALE,-CUBESCALE,+CUBESCALE},
- {+CUBESCALE,+CUBESCALE,+CUBESCALE},
- {-CUBESCALE,+CUBESCALE,-CUBESCALE},
- {-CUBESCALE,-CUBESCALE,-CUBESCALE},
- {-CUBESCALE,-CUBESCALE,+CUBESCALE},
- {-CUBESCALE,+CUBESCALE,+CUBESCALE},
- };
- VECTORCH translatedPts[8];
-
- POLYHEADER fakeHeader;
- int polyNumber;
- MATRIXCH matrix;
- CreateEulerMatrix(&CubeOrient,&matrix);
- TransposeMatrixCH(&matrix);
-
- CubeOrient.EulerX += MUL_FIXED(NormalFrameTime,128*4);
- CubeOrient.EulerX &=4095;
- CubeOrient.EulerY += MUL_FIXED(NormalFrameTime,256*4);
- CubeOrient.EulerY &=4095;
- CubeOrient.EulerZ += MUL_FIXED(NormalFrameTime,128*4);
- CubeOrient.EulerZ &=4095;
-
- fakeHeader.PolyFlags = iflag_transparent;
-
- {
-
- int i = 7;
- do
- {
- translatedPts[i] = vertices[i];
- RotateVector(&translatedPts[i],&matrix);
- translatedPts[i].vy = MUL_FIXED(translatedPts[i].vy,87381);
- }
- while(i--);
- }
-
-
- for(polyNumber=0; polyNumber<6; polyNumber++)
- {
- {
- int i;
- for (i=0; i<4; i++)
- {
- int v = CuboidPolyVertexList[polyNumber][i];
- VerticesBuffer[i].A = 128;
- VerticesBuffer[i].X = translatedPts[v].vx-400;
- VerticesBuffer[i].Y = translatedPts[v].vy+300;
- VerticesBuffer[i].Z = translatedPts[v].vz+900;
- VerticesBuffer[i].Y = MUL_FIXED(VerticesBuffer[i].Y,87381);
-
- {
- int brightness = -(translatedPts[v].vz*2);
-
- if (brightness<0) brightness=0;
- if (brightness>255) brightness=255;
- VerticesBuffer[i].R = brightness;
- }
- VerticesBuffer[i].G = 0;
- VerticesBuffer[i].B = 0;
- }
- RenderPolygon.NumberOfVertices=4;
- }
- {
- int outcode = QuadWithinFrustrum();
-
- if (outcode)
- {
- if (outcode!=2)
- {
- GouraudPolygon_ClipWithZ();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudPolygon_ClipWithNegativeX();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudPolygon_ClipWithPositiveY();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudPolygon_ClipWithNegativeY();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudPolygon_ClipWithPositiveX();
- if(RenderPolygon.NumberOfVertices<3) continue;
- D3D_ZBufferedGouraudPolygon_Output(&fakeHeader,RenderPolygon.Vertices);
- }
- else D3D_ZBufferedGouraudPolygon_Output(&fakeHeader,VerticesBuffer);
- }
- }
- }
-}
-#endif
-int CuboidPolyVertexList[][4] =
-{
- {0,3,7,4}, //+ve y
-#if 0
- {0,1,2,3}, //+ve x
- {0,1,5,4}, //-ve z
-
- {6,7,4,5}, //-ve x
- {6,7,3,2}, //+ve z
-#else
- {6,7,3,2}, //+ve z
- {6,7,4,5}, //-ve x
-
- {0,1,5,4}, //-ve z
- {0,1,2,3}, //+ve x
-#endif
-};
-EULER CubeOrient = {0,0,0};
-int CuboidPolyVertexU[][4] =
+static const int CuboidPolyVertexU[][4] =
{
{1,1,1,1},
@@ -5841,7 +5715,7 @@ int CuboidPolyVertexU[][4] =
{127,127,0,0},
{128,128,255,255},
};
-int CuboidPolyVertexV[][4] =
+static const int CuboidPolyVertexV[][4] =
{
{1,1,1,1},
@@ -5851,104 +5725,6 @@ int CuboidPolyVertexV[][4] =
{128,255,255,128},
};
-#include "chnktexi.h"
-
-void CubeSky(void)
-{
- #define CUBESCALE 1024
- VECTORCH vertices[8]=
- {
- #if 0
- {+CUBESCALE,-CUBESCALE,-CUBESCALE},
- {+CUBESCALE,CUBESCALE,-CUBESCALE},
- {+CUBESCALE,CUBESCALE,+CUBESCALE},
- {+CUBESCALE,-CUBESCALE,+CUBESCALE},
- {-CUBESCALE,-CUBESCALE,-CUBESCALE},
- {-CUBESCALE,CUBESCALE,-CUBESCALE},
- {-CUBESCALE,CUBESCALE,+CUBESCALE},
- {-CUBESCALE,-CUBESCALE,+CUBESCALE},
- #else
- {+CUBESCALE,-CUBESCALE*2,-CUBESCALE},
- {+CUBESCALE,0,-CUBESCALE},
- {+CUBESCALE,0,+CUBESCALE},
- {+CUBESCALE,-CUBESCALE*2,+CUBESCALE},
- {-CUBESCALE,-CUBESCALE*2,-CUBESCALE},
- {-CUBESCALE,0,-CUBESCALE},
- {-CUBESCALE,0,+CUBESCALE},
- {-CUBESCALE,-CUBESCALE*2,+CUBESCALE},
- #endif
- };
- VECTORCH translatedPts[8];
-
- POLYHEADER fakeHeader;
- int polyNumber;
-
- #if 1
- {
- extern int BackdropImage;
- fakeHeader.PolyFlags = 0;
- fakeHeader.PolyColour =BackdropImage;
- }
-
- {
-
- int i = 7;
- do
- {
- translatedPts[i] = vertices[i];
- RotateVector(&translatedPts[i],&(Global_VDB_Ptr->VDB_Mat));
- translatedPts[i].vy = MUL_FIXED(translatedPts[i].vy,87381);
- }
- while(i--);
- }
- #endif
-
- for(polyNumber=0; polyNumber<5; polyNumber++)
- {
- {
- int i;
- for (i=0; i<4; i++)
- {
- int v = CuboidPolyVertexList[polyNumber][i];
- VerticesBuffer[i].A = 0;
- VerticesBuffer[i].X = translatedPts[v].vx;
- VerticesBuffer[i].Y = translatedPts[v].vy;
- VerticesBuffer[i].Z = translatedPts[v].vz;
- VerticesBuffer[i].U = CuboidPolyVertexU[polyNumber][i]<<16;
- VerticesBuffer[i].V = CuboidPolyVertexV[polyNumber][i]<<16;
-
-
- VerticesBuffer[i].R = 127;
- VerticesBuffer[i].G = 127;
- VerticesBuffer[i].B = 127;
- }
- RenderPolygon.NumberOfVertices=4;
- }
- {
- int outcode = QuadWithinFrustrum();
-
- if (outcode)
- {
- if (outcode!=2)
- {
- GouraudTexturedPolygon_ClipWithZ();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudTexturedPolygon_ClipWithNegativeX();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudTexturedPolygon_ClipWithPositiveY();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudTexturedPolygon_ClipWithNegativeY();
- if(RenderPolygon.NumberOfVertices<3) continue;
- GouraudTexturedPolygon_ClipWithPositiveX();
- if(RenderPolygon.NumberOfVertices<3) continue;
- D3D_BackdropPolygon_Output(&fakeHeader,RenderPolygon.Vertices);
- }
- else D3D_BackdropPolygon_Output(&fakeHeader,VerticesBuffer);
- }
- }
- }
-}
-
void RenderMirrorSurface(void)
{
diff --git a/src/main.c b/src/main.c
index b34c8c1..f7bc518 100644
--- a/src/main.c
+++ b/src/main.c
@@ -624,10 +624,12 @@ int main(int argc, char *argv[])
#else
// AvP.PlayerType = I_Alien;
// SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */
+// SetLevelToLoad(AVP_ENVIRONMENT_INVASION_A);
AvP.PlayerType = I_Marine;
- SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
-
+// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
+ SetLevelToLoad(AVP_ENVIRONMENT_COLONY);
+
// AvP.PlayerType = I_Predator;
// SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */
diff --git a/src/opengl.c b/src/opengl.c
index 375262f..acaff4f 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -16,6 +16,7 @@
#include "krender.h"
#include "kshape.h"
#include "prototyp.h"
+#include "frustum.h"
#include "lighting.h"
#include "bh_types.h"
#include "showcmds.h"
@@ -35,6 +36,8 @@ extern int SpecialFXImageNumber;
extern int StaticImageNumber;
extern int PredatorNumbersImageNumber;
extern int BurningImageNumber;
+extern int ChromeImageNumber;
+extern int WaterShaftImageNumber;
extern int HUDFontsImageNumber;
extern int AAFontImageNumber;
@@ -149,27 +152,62 @@ static void CheckTranslucencyModeIsCorrect(enum TRANSLUCENCY_TYPE mode)
CurrentTranslucencyMode = mode;
}
-#define TA_MAXVERTICES 8
-typedef struct TriangleArray
+#define TA_MAXVERTICES 500
+#define TA_MAXTRIANGLES 500
+
+typedef struct VertexArray
{
- int elements;
-
- GLfloat v[TA_MAXVERTICES*4];
+ GLfloat v[4];
- GLfloat t[TA_MAXVERTICES*4];
+ GLfloat t[3]; /* 3rd float is padding */
- GLubyte c[TA_MAXVERTICES*4];
+ GLubyte c[4];
+} VertexArray;
+
+typedef struct TriangleArray
+{
+ int a;
+ int b;
+ int c;
} TriangleArray;
-TriangleArray tarr;
+static VertexArray tarr[TA_MAXVERTICES];
+static TriangleArray tris[TA_MAXTRIANGLES];
+
+static void DrawTriangleArray_T2F_C4UB_V4F(int len)
+{
+ int i;
+
+#define OUTPUT_VERTEX(d) \
+{ \
+ glColor4ubv (tarr[(d)].c); \
+ glTexCoord2fv (tarr[(d)].t); \
+ glVertex4fv (tarr[(d)].v); \
+}
+#define OUTPUT_TRIANGLE(a, b, c) \
+{ \
+ OUTPUT_VERTEX((a)); \
+ OUTPUT_VERTEX((b)); \
+ OUTPUT_VERTEX((c)); \
+}
+
+ glBegin(GL_TRIANGLES);
+ for (i = 0; i < len; i++) {
+ OUTPUT_TRIANGLE(tris[i].a, tris[i].b, tris[i].c);
+ }
+ glEnd();
+
+#undef OUTPUT_TRIANGLE
+#undef OUTPUT_VERTEX
+}
-static void DrawTriangles_T2F_C4UB_V4F()
+static void DrawTriangles_T2F_C4UB_V4F(int vertices)
{
#define OUTPUT_VERTEX(d) \
{ \
- glColor4ubv (&tarr.c[(d) * 4]); \
- glTexCoord2fv (&tarr.t[(d) * 4]); \
- glVertex4fv (&tarr.v[(d) * 4]); \
+ glColor4ubv (tarr[(d)].c); \
+ glTexCoord2fv (tarr[(d)].t); \
+ glVertex4fv (tarr[(d)].v); \
}
#define OUTPUT_TRIANGLE(a, b, c) \
{ \
@@ -179,7 +217,7 @@ static void DrawTriangles_T2F_C4UB_V4F()
}
glBegin(GL_TRIANGLES);
- switch(tarr.elements) {
+ switch(vertices) {
case 3:
OUTPUT_TRIANGLE(0, 2, 1);
break;
@@ -200,7 +238,7 @@ static void DrawTriangles_T2F_C4UB_V4F()
OUTPUT_TRIANGLE(0, 1, 2);
break;
default:
- fprintf(stderr, "DrawTriangles_T2F_C4UB_V4F: tarr.elements = %d\n", tarr.elements);
+ fprintf(stderr, "DrawTriangles_T2F_C4UB_V4F: vertices = %d\n", vertices);
}
glEnd();
@@ -208,12 +246,12 @@ static void DrawTriangles_T2F_C4UB_V4F()
#undef OUTPUT_VERTEX
}
-static void DrawTriangles_T2F_V4F()
+static void DrawTriangles_T2F_V4F(int vertices)
{
#define OUTPUT_VERTEX(d) \
{ \
- glTexCoord2fv (&tarr.t[(d) * 4]); \
- glVertex4fv (&tarr.v[(d) * 4]); \
+ glTexCoord2fv (tarr[(d)].t); \
+ glVertex4fv (tarr[(d)].v); \
}
#define OUTPUT_TRIANGLE(a, b, c) \
{ \
@@ -223,7 +261,7 @@ static void DrawTriangles_T2F_V4F()
}
glBegin(GL_TRIANGLES);
- switch(tarr.elements) {
+ switch(vertices) {
case 3:
OUTPUT_TRIANGLE(0, 2, 1);
break;
@@ -244,7 +282,7 @@ static void DrawTriangles_T2F_V4F()
OUTPUT_TRIANGLE(0, 1, 2);
break;
default:
- fprintf(stderr, "DrawTriangles_T2F_V4F: tarr.elements = %d\n", tarr.elements);
+ fprintf(stderr, "DrawTriangles_T2F_V4F: vertices = %d\n", vertices);
}
glEnd();
@@ -252,12 +290,12 @@ static void DrawTriangles_T2F_V4F()
#undef OUTPUT_VERTEX
}
-static void DrawTriangles_C4UB_V4F()
+static void DrawTriangles_C4UB_V4F(int vertices)
{
#define OUTPUT_VERTEX(d) \
{ \
- glColor4ubv (&tarr.c[(d) * 4]); \
- glVertex4fv (&tarr.v[(d) * 4]); \
+ glColor4ubv (tarr[(d)].c); \
+ glVertex4fv (tarr[(d)].v); \
}
#define OUTPUT_TRIANGLE(a, b, c) \
{ \
@@ -267,7 +305,7 @@ static void DrawTriangles_C4UB_V4F()
}
glBegin(GL_TRIANGLES);
- switch(tarr.elements) {
+ switch(vertices) {
case 3:
OUTPUT_TRIANGLE(0, 2, 1);
break;
@@ -288,7 +326,7 @@ static void DrawTriangles_C4UB_V4F()
OUTPUT_TRIANGLE(0, 1, 2);
break;
default:
- fprintf(stderr, "DrawTriangles_C4UB_V4F: tarr.elements = %d\n", tarr.elements);
+ fprintf(stderr, "DrawTriangles_C4UB_V4F: vertices = %d\n", vertices);
}
glEnd();
@@ -508,22 +546,21 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER
z = 1.0 - 2*ZNear/zvalue;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.t[4*i+0] = s;
- tarr.t[4*i+1] = t;
+ tarr[i].t[0] = s;
+ tarr[i].t[1] = t;
- tarr.c[4*i+0] = GammaValues[vertices->R];
- tarr.c[4*i+1] = GammaValues[vertices->G];
- tarr.c[4*i+2] = GammaValues[vertices->B];
- tarr.c[4*i+3] = vertices->A;
+ tarr[i].c[0] = GammaValues[vertices->R];
+ tarr[i].c[1] = GammaValues[vertices->G];
+ tarr[i].c[2] = GammaValues[vertices->B];
+ tarr[i].c[3] = vertices->A;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_T2F_C4UB_V4F();
+ DrawTriangles_T2F_C4UB_V4F(RenderPolygon.NumberOfVertices);
CheckBoundTextureIsCorrect(NULL);
@@ -532,12 +569,12 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
RENDERVERTEX *vertices = &renderVerticesPtr[i];
- tarr.c[4*i+0] = GammaValues[vertices->SpecularR];
- tarr.c[4*i+1] = GammaValues[vertices->SpecularG];
- tarr.c[4*i+2] = GammaValues[vertices->SpecularB];
- tarr.c[4*i+3] = 255;
+ tarr[i].c[0] = GammaValues[vertices->SpecularR];
+ tarr[i].c[1] = GammaValues[vertices->SpecularG];
+ tarr[i].c[2] = GammaValues[vertices->SpecularB];
+ tarr[i].c[3] = 255;
}
- DrawTriangles_C4UB_V4F();
+ DrawTriangles_C4UB_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_SkyPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
@@ -552,7 +589,6 @@ void D3D_SkyPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVertice
CurrTextureHandle = TextureHandle;
-
if (TextureHandle->w == 128) {
RecipW = (1.0f / 128.0f) / 65536.0f;
} else {
@@ -605,22 +641,21 @@ void D3D_SkyPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVertice
z = 1.0f;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.t[4*i+0] = s;
- tarr.t[4*i+1] = t;
+ tarr[i].t[0] = s;
+ tarr[i].t[1] = t;
- tarr.c[4*i+0] = vertices->R;
- tarr.c[4*i+1] = vertices->G;
- tarr.c[4*i+2] = vertices->B;
- tarr.c[4*i+3] = vertices->A;
+ tarr[i].c[0] = vertices->R;
+ tarr[i].c[1] = vertices->G;
+ tarr[i].c[2] = vertices->B;
+ tarr[i].c[3] = vertices->A;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_T2F_C4UB_V4F();
+ DrawTriangles_T2F_C4UB_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_ZBufferedCloakedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
@@ -639,6 +674,7 @@ void D3D_ZBufferedCloakedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *
texoffset = (inputPolyPtr->PolyColour & ClrTxDefn);
TextureHandle = ImageHeaderArray[texoffset].D3DTexture;
+ CurrTextureHandle = TextureHandle;
CheckBoundTextureIsCorrect(TextureHandle);
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
@@ -696,24 +732,21 @@ void D3D_ZBufferedCloakedPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *
zvalue = vertices->Z+HeadUpDisplayZOffset;
z = 1.0 - 2*ZNear/zvalue;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.t[4*i+0] = s;
- tarr.t[4*i+1] = t;
+ tarr[i].t[0] = s;
+ tarr[i].t[1] = t;
- tarr.c[4*i+0] = vertices->R;
- tarr.c[4*i+1] = vertices->G;
- tarr.c[4*i+2] = vertices->B;
- tarr.c[4*i+3] = vertices->A;
+ tarr[i].c[0] = vertices->R;
+ tarr[i].c[1] = vertices->G;
+ tarr[i].c[2] = vertices->B;
+ tarr[i].c[3] = vertices->A;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_T2F_C4UB_V4F();
-
- CurrTextureHandle = TextureHandle;
+ DrawTriangles_T2F_C4UB_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_Decal_Output(DECAL *decalPtr, RENDERVERTEX *renderVerticesPtr)
@@ -820,17 +853,16 @@ void D3D_Decal_Output(DECAL *decalPtr, RENDERVERTEX *renderVerticesPtr)
zvalue = vertices->Z+HeadUpDisplayZOffset;
z = 1.0 - 2*ZNear/zvalue;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.t[4*i+0] = s;
- tarr.t[4*i+1] = t;
+ tarr[i].t[0] = s;
+ tarr[i].t[1] = t;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_T2F_V4F();
+ DrawTriangles_T2F_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
@@ -953,17 +985,16 @@ void D3D_Particle_Output(PARTICLE *particlePtr, RENDERVERTEX *renderVerticesPtr)
z = 1.0 - 2.0*ZNear/((float)vertices->Z); /* currently maps [ZNear, inf) to [-1, 1], probably could be more precise with a ZFar */
}
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.t[4*i+0] = s;
- tarr.t[4*i+1] = t;
+ tarr[i].t[0] = s;
+ tarr[i].t[1] = t;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_T2F_V4F();
+ DrawTriangles_T2F_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_PredatorThermalVisionPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
@@ -1008,19 +1039,18 @@ void D3D_PredatorThermalVisionPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVER
rhw = 1.0/(float)vertices->Z;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.c[4*i+0] = vertices->R;
- tarr.c[4*i+1] = vertices->G;
- tarr.c[4*i+2] = vertices->B;
- tarr.c[4*i+3] = vertices->A;
+ tarr[i].c[0] = vertices->R;
+ tarr[i].c[1] = vertices->G;
+ tarr[i].c[2] = vertices->B;
+ tarr[i].c[3] = vertices->A;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_C4UB_V4F();
+ DrawTriangles_C4UB_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_ZBufferedGouraudPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *renderVerticesPtr)
@@ -1067,22 +1097,21 @@ void D3D_ZBufferedGouraudPolygon_Output(POLYHEADER *inputPolyPtr, RENDERVERTEX *
rhw = 1.0/(float)vertices->Z;
- tarr.v[4*i+0] = x/rhw;
- tarr.v[4*i+1] = y/rhw;
- tarr.v[4*i+2] = z/rhw;
- tarr.v[4*i+3] = 1/rhw;
+ tarr[i].v[0] = x/rhw;
+ tarr[i].v[1] = y/rhw;
+ tarr[i].v[2] = z/rhw;
+ tarr[i].v[3] = 1/rhw;
- tarr.c[4*i+0] = vertices->R;
- tarr.c[4*i+1] = vertices->G;
- tarr.c[4*i+2] = vertices->B;
+ tarr[i].c[0] = vertices->R;
+ tarr[i].c[1] = vertices->G;
+ tarr[i].c[2] = vertices->B;
if (flags & iflag_transparent)
- tarr.c[4*i+3] = vertices->A;
+ tarr[i].c[3] = vertices->A;
else
- tarr.c[4*i+3] = 255;
+ tarr[i].c[3] = 255;
}
- tarr.elements = RenderPolygon.NumberOfVertices;
- DrawTriangles_C4UB_V4F();
+ DrawTriangles_C4UB_V4F(RenderPolygon.NumberOfVertices);
}
void D3D_PlayerOnFireOverlay()
@@ -1895,6 +1924,2537 @@ void D3D_DrawBackdrop()
}
}
+/* ** */
+
+/* Hacked in special effects */
+
+extern int sine[];
+extern int cosine[];
+
+void UpdateForceField(void);
+void D3D_DrawForceField(int xOrigin, int yOrigin, int zOrigin, int fieldType);
+
+void UpdateWaterFall(void);
+void D3D_DrawWaterFall(int xOrigin, int yOrigin, int zOrigin);
+void D3D_DrawPowerFence(int xOrigin, int yOrigin, int zOrigin, int xScale, int yScale, int zScale);
+void D3D_DrawExplosion(int xOrigin, int yOrigin, int zOrigin, int size);
+
+void D3D_DrawWaterPatch(int xOrigin, int yOrigin, int zOrigin);
+
+void D3D_DrawWaterOctagonPatch(int xOrigin, int yOrigin, int zOrigin, int xOffset, int zOffset);
+
+int LightSourceWaterPoint(VECTORCH *pointPtr,int offset);
+void D3D_DrawWaterMesh_Unclipped(void);
+void D3D_DrawWaterMesh_Clipped(void);
+
+
+void D3D_DrawMoltenMetal(int xOrigin, int yOrigin, int zOrigin);
+void D3D_DrawMoltenMetalMesh_Unclipped(void);
+void D3D_DrawMoltenMetalMesh_Clipped(void);
+
+int MeshXScale;
+int MeshZScale;
+int WaterFallBase;
+
+int WaterXOrigin;
+int WaterZOrigin;
+float WaterUScale;
+float WaterVScale;
+
+void D3D_DrawParticle_Rain(PARTICLE *particlePtr,VECTORCH *prevPositionPtr)
+{
+ VECTORCH vertices[3];
+ float ZNear;
+
+ vertices[0] = *prevPositionPtr;
+
+ /* translate second vertex into view space */
+ TranslatePointIntoViewspace(&vertices[0]);
+
+ /* is particle within normal view frustrum ? */
+ if((-vertices[0].vx <= vertices[0].vz)
+ &&(vertices[0].vx <= vertices[0].vz)
+ &&(-vertices[0].vy <= vertices[0].vz)
+ &&(vertices[0].vy <= vertices[0].vz))
+ {
+
+ vertices[1] = particlePtr->Position;
+ vertices[2] = particlePtr->Position;
+ vertices[1].vx += particlePtr->Offset.vx;
+ vertices[2].vx -= particlePtr->Offset.vx;
+ vertices[1].vz += particlePtr->Offset.vz;
+ vertices[2].vz -= particlePtr->Offset.vz;
+
+ /* translate particle into view space */
+ TranslatePointIntoViewspace(&vertices[1]);
+ TranslatePointIntoViewspace(&vertices[2]);
+
+ ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
+
+ {
+ int i = 3;
+ VECTORCH *verticesPtr = vertices;
+ do
+ {
+ GLfloat xf, yf, zf, rhw;
+
+ int x = (verticesPtr->vx*(Global_VDB_Ptr->VDB_ProjX))/verticesPtr->vz+Global_VDB_Ptr->VDB_CentreX;
+ int y = (verticesPtr->vy*(Global_VDB_Ptr->VDB_ProjY))/verticesPtr->vz+Global_VDB_Ptr->VDB_CentreY;
+
+ if (x<Global_VDB_Ptr->VDB_ClipLeft)
+ {
+ x=Global_VDB_Ptr->VDB_ClipLeft;
+ }
+ else if (x>Global_VDB_Ptr->VDB_ClipRight)
+ {
+ x=Global_VDB_Ptr->VDB_ClipRight;
+ }
+
+ if (y<Global_VDB_Ptr->VDB_ClipUp)
+ {
+ y=Global_VDB_Ptr->VDB_ClipUp;
+ }
+ else if (y>Global_VDB_Ptr->VDB_ClipDown)
+ {
+ y=Global_VDB_Ptr->VDB_ClipDown;
+ }
+
+ xf = ((float)x - (float)ScreenDescriptorBlock.SDB_CentreX - 0.5f)/((float)ScreenDescriptorBlock.SDB_CentreX - 0.5f);
+ yf = -((float)y - (float)ScreenDescriptorBlock.SDB_CentreY - 0.5f)/((float)ScreenDescriptorBlock.SDB_CentreY - 0.5f);
+
+ zf = 1.0f - 2.0f*ZNear/(float)verticesPtr->vz;
+ rhw = 1.0f / (float)verticesPtr->vz;
+
+ tarr[3-i].v[0] = xf/rhw;
+ tarr[3-i].v[1] = yf/rhw;
+ tarr[3-i].v[2] = zf/rhw;
+ tarr[3-i].v[3] = 1.0f/rhw;
+
+ if (i == 3) {
+ tarr[3-i].c[0] = 0;
+ tarr[3-i].c[1] = 255;
+ tarr[3-i].c[2] = 255;
+ tarr[3-i].c[3] = 32;
+ } else {
+ tarr[3-i].c[0] = 255;
+ tarr[3-i].c[1] = 255;
+ tarr[3-i].c[2] = 255;
+ tarr[3-i].c[3] = 32;
+ }
+
+ verticesPtr++;
+ }
+ while(--i);
+ }
+
+ CheckBoundTextureIsCorrect(NULL);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+
+ DrawTriangles_C4UB_V4F(3); /* single triangle */
+ }
+}
+
+void PostLandscapeRendering()
+{
+ extern int NumOnScreenBlocks;
+ extern DISPLAYBLOCK *OnScreenBlockList[];
+ int numOfObjects = NumOnScreenBlocks;
+
+ extern char LevelName[];
+
+#if 0 /* not yet */
+ if (!strcmp(LevelName,"fall")||!strcmp(LevelName,"fall_m"))
+ {
+ char drawWaterFall = 0;
+ char drawStream = 0;
+
+ while(numOfObjects)
+ {
+ DISPLAYBLOCK *objectPtr = OnScreenBlockList[--numOfObjects];
+ MODULE *modulePtr = objectPtr->ObMyModule;
+
+ /* if it's a module, which isn't inside another module */
+ if (modulePtr && modulePtr->name)
+ {
+ if( (!strcmp(modulePtr->name,"fall01"))
+ ||(!strcmp(modulePtr->name,"well01"))
+ ||(!strcmp(modulePtr->name,"well02"))
+ ||(!strcmp(modulePtr->name,"well03"))
+ ||(!strcmp(modulePtr->name,"well04"))
+ ||(!strcmp(modulePtr->name,"well05"))
+ ||(!strcmp(modulePtr->name,"well06"))
+ ||(!strcmp(modulePtr->name,"well07"))
+ ||(!strcmp(modulePtr->name,"well08"))
+ ||(!strcmp(modulePtr->name,"well")))
+ {
+ drawWaterFall = 1;
+ }
+ else if( (!strcmp(modulePtr->name,"stream02"))
+ ||(!strcmp(modulePtr->name,"stream03"))
+ ||(!strcmp(modulePtr->name,"watergate")))
+ {
+ drawStream = 1;
+ }
+ }
+ }
+
+ if (drawWaterFall)
+ {
+ // Turn OFF texturing if it is on...
+ if (CurrTextureHandle != NULL)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, NULL, ExecBufInstPtr);
+ CurrTextureHandle = NULL;
+ }
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ //STATE_DATA(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_ZWRITEENABLE, FALSE, ExecBufInstPtr);
+
+ //UpdateWaterFall();
+ WaterFallBase = 109952;
+
+ MeshZScale = (66572-51026)/15;
+ MeshXScale = (109952+3039)/45;
+
+ D3D_DrawWaterFall(175545,-3039,51026);
+// MeshZScale = -(538490-392169);
+// MeshXScale = 55000;
+ // D3D_DrawWaterPatch(-100000, WaterFallBase, 538490);
+
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ //STATE_DATA(D3DRENDERSTATE_ZFUNC, D3DCMP_LESSEQUAL, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_ZWRITEENABLE, TRUE, ExecBufInstPtr);
+ }
+ if (drawStream)
+ {
+ int x = 68581;
+ int y = 12925;
+ int z = 93696;
+ MeshXScale = (87869-68581);
+ MeshZScale = (105385-93696);
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x, x+MeshXScale, z, z+MeshZScale, y);
+ }
+
+ WaterXOrigin=x;
+ WaterZOrigin=z;
+ WaterUScale = 4.0f/(float)MeshXScale;
+ WaterVScale = 4.0f/(float)MeshZScale;
+ MeshXScale/=4;
+ MeshZScale/=2;
+
+ // Turn OFF texturing if it is on...
+ D3DTEXTUREHANDLE TextureHandle = (D3DTEXTUREHANDLE)ImageHeaderArray[ChromeImageNumber].D3DHandle;
+ if (CurrTextureHandle != TextureHandle)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, TextureHandle, ExecBufInstPtr);
+ CurrTextureHandle = TextureHandle;
+ }
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ D3D_DrawWaterPatch(x, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale);
+ }
+ }
+#endif /* not yet */
+ #if 0
+ else if ( (!__stricmp(LevelName,"e3demo")) || (!__stricmp(LevelName,"e3demosp")) )
+ {
+ int drawOctagonPool = -1;
+ int drawFMV = -1;
+ int drawPredatorFMV = -1;
+ int drawSwirlyFMV = -1;
+ int drawSwirlyFMV2 = -1;
+ int drawSwirlyFMV3 = -1;
+ while(numOfObjects)
+ {
+ DISPLAYBLOCK *objectPtr = OnScreenBlockList[--numOfObjects];
+ MODULE *modulePtr = objectPtr->ObMyModule;
+
+ /* if it's a module, which isn't inside another module */
+ if (modulePtr && modulePtr->name)
+ {
+ if(!__stricmp(modulePtr->name,"water1"))
+ {
+ drawOctagonPool = modulePtr->m_index;
+ }
+ else if(!__stricmp(modulePtr->name,"marine01b"))
+ {
+ drawFMV = modulePtr->m_index;
+ }
+ else if(!_stricmp(modulePtr->name,"predator01"))
+ {
+ drawPredatorFMV = modulePtr->m_index;
+ }
+ else if(!_stricmp(modulePtr->name,"toptopgr01"))
+ {
+ drawSwirlyFMV = modulePtr->m_index;
+ }
+ else if(!_stricmp(modulePtr->name,"grille04"))
+ {
+ drawSwirlyFMV2 = modulePtr->m_index;
+ }
+ #if 0
+ else if(!_stricmp(modulePtr->name,"marine05"))
+ {
+ drawSwirlyFMV3 = modulePtr->m_index;
+ }
+ #endif
+ }
+ }
+ #if FMV_ON
+// UpdateFMVTextures(3);
+
+
+ if (drawFMV!=-1)
+ {
+ DECAL fmvDecal =
+ {
+ DECAL_FMV,
+ };
+ fmvDecal.ModuleIndex = drawFMV;
+ fmvDecal.UOffset = 0;
+
+ UpdateFMVTextures(4);
+
+ for (int z=0; z<6; z++)
+ {
+ for (int y=0; y<3; y++)
+ {
+ fmvDecal.Vertices[0].vx = -149;
+ fmvDecal.Vertices[1].vx = -149;
+ fmvDecal.Vertices[2].vx = -149;
+ fmvDecal.Vertices[3].vx = -149;
+
+ fmvDecal.Vertices[0].vy = -3254+y*744;
+ fmvDecal.Vertices[1].vy = -3254+y*744;
+ fmvDecal.Vertices[2].vy = -3254+y*744+744;
+ fmvDecal.Vertices[3].vy = -3254+y*744+744;
+
+ fmvDecal.Vertices[0].vz = 49440+z*993;
+ fmvDecal.Vertices[1].vz = 49440+z*993+993;
+ fmvDecal.Vertices[2].vz = 49440+z*993+993;
+ fmvDecal.Vertices[3].vz = 49440+z*993;
+ fmvDecal.Centre.vx = ((z+y)%3)+1;
+ RenderDecal(&fmvDecal);
+ }
+ }
+ }
+ if (drawPredatorFMV!=-1)
+ {
+ DECAL fmvDecal =
+ {
+ DECAL_FMV,
+ };
+ fmvDecal.ModuleIndex = drawPredatorFMV;
+ fmvDecal.UOffset = 0;
+
+ UpdateFMVTextures(4);
+
+ for (int z=0; z<12; z++)
+ {
+ for (int y=0; y<7; y++)
+ {
+ fmvDecal.Vertices[0].vx = -7164;
+ fmvDecal.Vertices[1].vx = -7164;
+ fmvDecal.Vertices[2].vx = -7164;
+ fmvDecal.Vertices[3].vx = -7164;
+
+ fmvDecal.Vertices[0].vy = -20360+y*362;
+ fmvDecal.Vertices[1].vy = -20360+y*362;
+ fmvDecal.Vertices[2].vy = -20360+y*362+362;
+ fmvDecal.Vertices[3].vy = -20360+y*362+362;
+
+ fmvDecal.Vertices[0].vz = 1271+z*483+483;
+ fmvDecal.Vertices[1].vz = 1271+z*483;
+ fmvDecal.Vertices[2].vz = 1271+z*483;
+ fmvDecal.Vertices[3].vz = 1271+z*483+483;
+ fmvDecal.Centre.vx = (z+y)%3;
+ RenderDecal(&fmvDecal);
+ }
+ }
+ }
+
+ #endif
+
+ if (drawSwirlyFMV!=-1)
+ {
+ UpdateFMVTextures(1);
+ D3D_DrawSwirlyFMV(30000,-12500,0);
+ }
+ if (drawSwirlyFMV2!=-1)
+ {
+ UpdateFMVTextures(1);
+ D3D_DrawSwirlyFMV(2605,-6267-2000,17394-3200);
+ }
+
+ if (drawSwirlyFMV3!=-1)
+ {
+// UpdateFMVTextures(1);
+ D3D_DrawSwirlyFMV(5117,3456-3000,52710-2000);
+ }
+ if (drawOctagonPool!=-1)
+ {
+ #if FMV_ON
+ UpdateFMVTextures(1);
+
+ MeshXScale = (3000);
+ MeshZScale = (4000);
+ D3D_DrawFMVOnWater(-1000,3400,22000);
+ {
+ DECAL fmvDecal =
+ {
+ DECAL_FMV,
+ {
+ {0,-2500,29000},
+ {2000,-2500,29000},
+ {2000,-2500+750*2,29000},
+ {0,-2500+750*2,29000}
+ },
+ 0
+ };
+ fmvDecal.ModuleIndex = drawOctagonPool;
+ fmvDecal.Centre.vx = 0;
+ fmvDecal.UOffset = 0;
+
+ RenderDecal(&fmvDecal);
+ }
+ #endif
+
+ int highDetailRequired = 1;
+ int x = 1023;
+ int y = 3400;
+ int z = 27536;
+
+ {
+ int dx = Player->ObWorld.vx - x;
+ if (dx< -8000 || dx > 8000)
+ {
+ highDetailRequired = 0;
+ }
+ else
+ {
+ int dz = Player->ObWorld.vz - z;
+ if (dz< -8000 || dz > 8000)
+ {
+ highDetailRequired = 0;
+ }
+ }
+ }
+ MeshXScale = 7700;
+ MeshZScale = 7700;
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x-MeshXScale, x+MeshXScale, z-MeshZScale, z+MeshZScale, y);
+ }
+
+ MeshXScale /=15;
+ MeshZScale /=15;
+
+ // Turn OFF texturing if it is on...
+ D3DTEXTUREHANDLE TextureHandle = NULL;
+ if (CurrTextureHandle != TextureHandle)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, TextureHandle, ExecBufInstPtr);
+ CurrTextureHandle = TextureHandle;
+ }
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ if (highDetailRequired)
+ {
+ MeshXScale /= 2;
+ MeshZScale /= 2;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,0,15);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,15);
+ MeshXScale = -MeshXScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,0,15);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,15);
+ MeshZScale = -MeshZScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,0,15);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,15);
+ MeshXScale = -MeshXScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,0);
+ D3D_DrawWaterOctagonPatch(x,y,z,0,15);
+ D3D_DrawWaterOctagonPatch(x,y,z,15,15);
+ }
+ else
+ {
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ MeshXScale = -MeshXScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ MeshZScale = -MeshZScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ MeshXScale = -MeshXScale;
+ D3D_DrawWaterOctagonPatch(x,y,z,0,0);
+ }
+
+ }
+ }
+ #endif
+#if 0 /* not yet */
+ else if (!_stricmp(LevelName,"hangar"))
+ {
+ #if FMV_ON
+ #if WIBBLY_FMV_ON
+ UpdateFMVTextures(1);
+ D3D_DrawFMV(FmvPosition.vx,FmvPosition.vy,FmvPosition.vz);
+ #endif
+ #endif
+ #if 0
+ {
+ VECTORCH v = {49937,-4000,-37709}; // hangar
+ D3D_DrawCable(&v);
+ }
+ #endif
+ }
+ else
+#endif /* not yet */
+ if (!strcasecmp(LevelName,"invasion_a"))
+ {
+ char drawWater = 0;
+ char drawEndWater = 0;
+
+ while(numOfObjects)
+ {
+ DISPLAYBLOCK *objectPtr = OnScreenBlockList[--numOfObjects];
+ MODULE *modulePtr = objectPtr->ObMyModule;
+
+ /* if it's a module, which isn't inside another module */
+ if (modulePtr && modulePtr->name)
+ {
+ if( (!strcmp(modulePtr->name,"hivepool"))
+ ||(!strcmp(modulePtr->name,"hivepool04")))
+ {
+ drawWater = 1;
+ break;
+ }
+ else
+ {
+ if(!strcmp(modulePtr->name,"shaftbot"))
+ {
+ drawEndWater = 1;
+ }
+ if((!strcasecmp(modulePtr->name,"shaft01"))
+ ||(!strcasecmp(modulePtr->name,"shaft02"))
+ ||(!strcasecmp(modulePtr->name,"shaft03"))
+ ||(!strcasecmp(modulePtr->name,"shaft04"))
+ ||(!strcasecmp(modulePtr->name,"shaft05"))
+ ||(!strcasecmp(modulePtr->name,"shaft06")))
+ {
+ extern void HandleRainShaft(MODULE *modulePtr, int bottomY, int topY, int numberOfRaindrops);
+ HandleRainShaft(modulePtr, -11726,-107080,10);
+ drawEndWater = 1;
+ break;
+ }
+ }
+ }
+
+ }
+
+ if (drawWater)
+ {
+ int x = 20767;
+ int y = -36000+200;
+ int z = 30238;
+ MeshXScale = (36353-20767);
+ MeshZScale = (41927-30238);
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x, x+MeshXScale, z, z+MeshZScale, y);
+ }
+
+ WaterXOrigin=x;
+ WaterZOrigin=z;
+ WaterUScale = 4.0f/(float)MeshXScale;
+ WaterVScale = 4.0f/(float)MeshZScale;
+ MeshXScale/=4;
+ MeshZScale/=2;
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z);
+
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale);
+ }
+ else if (drawEndWater)
+ {
+ int x = -15471;
+ int y = -11720-500;
+ int z = -55875;
+ MeshXScale = (15471-1800);
+ MeshZScale = (55875-36392);
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x, x+MeshXScale, z, z+MeshZScale, y);
+ }
+ WaterXOrigin=x;
+ WaterZOrigin=z;
+ WaterUScale = 4.0f/(float)(MeshXScale+1800-3782);
+ WaterVScale = 4.0f/(float)MeshZScale;
+ MeshXScale/=4;
+ MeshZScale/=2;
+
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[WaterShaftImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale);
+ }
+ }
+ else
+ if (!strcasecmp(LevelName, "derelict"))
+ {
+ char drawMirrorSurfaces = 0;
+ char drawWater = 0;
+
+ while(numOfObjects)
+ {
+ DISPLAYBLOCK *objectPtr = OnScreenBlockList[--numOfObjects];
+ MODULE *modulePtr = objectPtr->ObMyModule;
+
+ /* if it's a module, which isn't inside another module */
+ if (modulePtr && modulePtr->name)
+ {
+ if( (!strcasecmp(modulePtr->name,"start-en01"))
+ ||(!strcasecmp(modulePtr->name,"start")))
+ {
+ drawMirrorSurfaces = 1;
+ }
+ else if (!strcasecmp(modulePtr->name,"water-01"))
+ {
+ extern void HandleRainShaft(MODULE *modulePtr, int bottomY, int topY, int numberOfRaindrops);
+ drawWater = 1;
+ HandleRainShaft(modulePtr, 32000, 0, 16);
+ }
+ }
+ }
+
+ if (drawMirrorSurfaces)
+ {
+ extern void RenderMirrorSurface(void);
+ extern void RenderMirrorSurface2(void);
+ extern void RenderParticlesInMirror(void);
+ RenderParticlesInMirror();
+ RenderMirrorSurface();
+ RenderMirrorSurface2();
+ }
+ if (drawWater)
+ {
+ int x = -102799;
+ int y = 32000;
+ int z = -200964;
+ MeshXScale = (102799-87216);
+ MeshZScale = (200964-180986);
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x, x+MeshXScale, z, z+MeshZScale, y);
+ }
+
+ WaterXOrigin=x;
+ WaterZOrigin=z;
+ WaterUScale = 4.0f/(float)MeshXScale;
+ WaterVScale = 4.0f/(float)MeshZScale;
+ MeshXScale/=2;
+ MeshZScale/=2;
+
+
+ /* TODO: this is a hack for the 2 pass specular color because it changes the texture/blend func */
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+
+ CurrTextureHandle = ImageHeaderArray[ChromeImageNumber].D3DTexture;
+ CheckBoundTextureIsCorrect(CurrTextureHandle);
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+ }
+
+ }
+ else if (!strcasecmp(LevelName,"genshd1"))
+ {
+ while(numOfObjects)
+ {
+ DISPLAYBLOCK *objectPtr = OnScreenBlockList[--numOfObjects];
+ MODULE *modulePtr = objectPtr->ObMyModule;
+
+ /* if it's a module, which isn't inside another module */
+ if (modulePtr && modulePtr->name)
+ {
+ if( (!strcasecmp(modulePtr->name,"largespace"))
+ ||(!strcasecmp(modulePtr->name,"proc13"))
+ ||(!strcasecmp(modulePtr->name,"trench01"))
+ ||(!strcasecmp(modulePtr->name,"trench02"))
+ ||(!strcasecmp(modulePtr->name,"trench03"))
+ ||(!strcasecmp(modulePtr->name,"trench04"))
+ ||(!strcasecmp(modulePtr->name,"trench05"))
+ ||(!strcasecmp(modulePtr->name,"trench06"))
+ ||(!strcasecmp(modulePtr->name,"trench07"))
+ ||(!strcasecmp(modulePtr->name,"trench08"))
+ ||(!strcasecmp(modulePtr->name,"trench09")))
+ {
+ extern void HandleRain(int numberOfRaindrops);
+ HandleRain(999);
+ break;
+ }
+ }
+
+ }
+ }
+}
+
+void D3D_DrawWaterTest(MODULE *testModulePtr)
+{
+#if 0 /* not yet */
+ extern char LevelName[];
+ if (!strcmp(LevelName,"genshd1"))
+ {
+ extern DISPLAYBLOCK *Player;
+
+// DISPLAYBLOCK *objectPtr = OnScreenBlockList[numOfObjects];
+ MODULE *modulePtr = testModulePtr;//objectPtr->ObMyModule;
+#if 0
+ if (testModulePtr && testModulePtr->name)
+ if(!strcmp(testModulePtr->name,"LargeSpace"))
+ {
+ extern void HandleRain(int numberOfRaindrops);
+ HandleRain(999);
+ }
+#endif
+ if (modulePtr && modulePtr->name)
+ {
+ if (!strcmp(modulePtr->name,"05"))
+ {
+ int y = modulePtr->m_maxy+modulePtr->m_world.vy-500;
+ int x = modulePtr->m_minx+modulePtr->m_world.vx;
+ int z = modulePtr->m_minz+modulePtr->m_world.vz;
+ MeshXScale = (7791 - -7794);
+ MeshZScale = (23378 - 7793);
+ {
+ extern void CheckForObjectsInWater(int minX, int maxX, int minZ, int maxZ, int averageY);
+ CheckForObjectsInWater(x, x+MeshXScale, z, z+MeshZScale, y);
+ }
+ D3DTEXTUREHANDLE TextureHandle = (D3DTEXTUREHANDLE)ImageHeaderArray[WaterShaftImageNumber].D3DHandle;
+ if (CurrTextureHandle != TextureHandle)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, TextureHandle, ExecBufInstPtr);
+ CurrTextureHandle = TextureHandle;
+ }
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ WaterXOrigin=x;
+ WaterZOrigin=z;
+ WaterUScale = 4.0f/(float)(MeshXScale);
+ WaterVScale = 4.0f/(float)MeshZScale;
+ #if 1
+ MeshXScale/=2;
+ MeshZScale/=2;
+ D3D_DrawWaterPatch(x, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+
+ extern void HandleRainShaft(MODULE *modulePtr, int bottomY, int topY, int numberOfRaindrops);
+ HandleRainShaft(modulePtr, y,-21000,1);
+ #else
+ MeshXScale/=4;
+ MeshZScale/=4;
+ D3D_DrawWaterPatch(x, y, z);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale*2);
+ D3D_DrawWaterPatch(x, y, z+MeshZScale*3);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale*2);
+ D3D_DrawWaterPatch(x+MeshXScale, y, z+MeshZScale*3);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale*2);
+ D3D_DrawWaterPatch(x+MeshXScale*2, y, z+MeshZScale*3);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale*2);
+ D3D_DrawWaterPatch(x+MeshXScale*3, y, z+MeshZScale*3);
+ HandleRainDrops(modulePtr,2);
+ #endif
+ }
+ }
+ }
+ #if 0
+ else if ( (!_stricmp(LevelName,"e3demo")) || (!_stricmp(LevelName,"e3demosp")) )
+ {
+ if (testModulePtr && testModulePtr->name)
+ {
+ #if 0
+ if(!_stricmp(testModulePtr->name,"watermid"))
+ {
+ DECAL fmvDecal =
+ {
+ DECAL_FMV,
+ {
+ {0,-2500,29000},
+ {2000,-2500,29000},
+ {2000,-2500+750*2,29000},
+ {0,-2500+750*2,29000}
+ },
+ 0
+ };
+ fmvDecal.ModuleIndex = testModulePtr->m_index;
+ fmvDecal.Centre.vx = 0;
+ fmvDecal.UOffset = 0;
+
+ RenderDecal(&fmvDecal);
+ }
+ #endif
+ if(!_stricmp(testModulePtr->name,"lowlowlo03"))
+ {
+ VECTORCH position = {6894,469,-13203};
+ VECTORCH disp = position;
+ int i,d;
+
+ disp.vx -= Player->ObWorld.vx;
+ disp.vy -= Player->ObWorld.vy;
+ disp.vz -= Player->ObWorld.vz;
+ d = ONE_FIXED - Approximate3dMagnitude(&disp)*2;
+ if (d<0) d = 0;
+
+ i = MUL_FIXED(10,d);
+ while(i--)
+ {
+ VECTORCH velocity;
+ velocity.vx = ((FastRandom()&1023) - 512);
+ velocity.vy = ((FastRandom()&1023) - 512)+2000;
+ velocity.vz = (1000+(FastRandom()&255))*2;
+ MakeParticle(&(position),&(velocity),PARTICLE_STEAM);
+ }
+ }
+ }
+ }
+ #endif
+#endif /* not yet */
+}
+
+
+/* TODO: doubled this from 256 to 512 because of overflows in DrawMoltenMetal_Clipped */
+VECTORCH MeshVertex[512];
+#define TEXTURE_WATER 0
+
+VECTORCH MeshWorldVertex[512];
+unsigned int MeshVertexColour[512];
+unsigned int MeshVertexSpecular[512];
+char MeshVertexOutcode[512];
+
+void D3D_DrawWaterPatch(int xOrigin, int yOrigin, int zOrigin)
+{
+ int i=0;
+ int x;
+ int offset;
+
+ for (x=0; x<16; x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+
+ point->vx = xOrigin+(x*MeshXScale)/15;
+ point->vz = zOrigin+(z*MeshZScale)/15;
+
+
+ offset=0;
+
+ #if 1
+ /* basic noise ripples */
+// offset = MUL_FIXED(32,GetSin( (point->vx+point->vz+CloakingPhase)&4095 ) );
+// offset += MUL_FIXED(16,GetSin( (point->vx-point->vz*2+CloakingPhase/2)&4095 ) );
+
+ {
+ offset += EffectOfRipples(point);
+ }
+ #endif
+ // if (offset>450) offset = 450;
+ // if (offset<-450) offset = -450;
+ point->vy = yOrigin+offset;
+
+ #if 0
+ MeshVertexColour[i] = LightSourceWaterPoint(point,offset);
+ #else
+ {
+ int alpha = 128-offset/4;
+ // if (alpha>255) alpha = 255;
+ // if (alpha<128) alpha = 128;
+ switch (CurrentVisionMode)
+ {
+ default:
+ case VISION_MODE_NORMAL:
+ {
+// MeshVertexColour[i] = RGBALIGHT_MAKE(10,51,28,alpha);
+ MeshVertexColour[i] = RGBA_MAKE(255,255,255,alpha);
+ #if 0
+ #if 1
+ VECTORCH pos = {24087,yOrigin,39165};
+ int c = (8191-VectorDistance(&pos,point));
+ if (c<0) c=0;
+ else
+ {
+ int s = GetSin((CloakingPhase/2)&4095);
+ s = MUL_FIXED(s,s)/64;
+ c = MUL_FIXED(s,c);
+ }
+ MeshVertexSpecular[i] = (c<<16)+(((c/4)<<8)&0xff00) + (c/4);
+ #else
+ if (!(FastRandom()&1023))
+ {
+ MeshVertexSpecular[i] = 0xc04040;
+ }
+ else
+ {
+ MeshVertexSpecular[i] = 0;
+ }
+ #endif
+ #endif
+ break;
+ }
+ case VISION_MODE_IMAGEINTENSIFIER:
+ {
+ MeshVertexColour[i] = RGBA_MAKE(0,51,0,alpha);
+ break;
+ }
+ case VISION_MODE_PRED_THERMAL:
+ case VISION_MODE_PRED_SEEALIENS:
+ case VISION_MODE_PRED_SEEPREDTECH:
+ {
+ MeshVertexColour[i] = RGBA_MAKE(0,0,28,alpha);
+ break;
+ }
+ }
+
+ }
+ #endif
+
+ #if 1
+ MeshWorldVertex[i].vx = ((point->vx-WaterXOrigin)/4+MUL_FIXED(GetSin((point->vy*16)&4095),128));
+ MeshWorldVertex[i].vy = ((point->vz-WaterZOrigin)/4+MUL_FIXED(GetSin((point->vy*16+200)&4095),128));
+ #endif
+
+ #if 1
+ TranslatePointIntoViewspace(point);
+ #else
+ point->vx -= Global_VDB_Ptr->VDB_World.vx;
+ point->vy -= Global_VDB_Ptr->VDB_World.vy;
+ point->vz -= Global_VDB_Ptr->VDB_World.vz;
+ RotateVector(point,&(Global_VDB_Ptr->VDB_Mat));
+ point->vy = MUL_FIXED(point->vy,87381);
+
+ #endif
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawMoltenMetalMesh_Unclipped();
+// D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawMoltenMetalMesh_Clipped();
+// D3D_DrawWaterMesh_Clipped();
+ }
+
+
+}
+
+#if 0 /* not yet */
+
+void D3D_DrawWaterMesh_Unclipped(void)
+{
+ float ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
+
+ /* OUTPUT VERTICES TO EXECUTE BUFFER */
+ {
+ D3DTLVERTEX *vertexPtr = &((LPD3DTLVERTEX)ExecuteBufferDataArea)[NumVertices];
+ VECTORCH *point = MeshVertex;
+ #if TEXTURE_WATER
+ VECTORCH *pointWS = MeshWorldVertex;
+ #endif
+ int i;
+ for (i=0; i<256; i++)
+ {
+
+ if (point->vz<=1) point->vz = 1;
+ int x = (point->vx*(Global_VDB_Ptr->VDB_ProjX))/point->vz+Global_VDB_Ptr->VDB_CentreX;
+ int y = (point->vy*(Global_VDB_Ptr->VDB_ProjY))/point->vz+Global_VDB_Ptr->VDB_CentreY;
+ // textprint("%d, %d\n",x,y);
+ #if 1
+ {
+ if (x<Global_VDB_Ptr->VDB_ClipLeft)
+ {
+ x=Global_VDB_Ptr->VDB_ClipLeft;
+ }
+ else if (x>Global_VDB_Ptr->VDB_ClipRight)
+ {
+ x=Global_VDB_Ptr->VDB_ClipRight;
+ }
+
+ vertexPtr->sx=x;
+ }
+ {
+ if (y<Global_VDB_Ptr->VDB_ClipUp)
+ {
+ y=Global_VDB_Ptr->VDB_ClipUp;
+ }
+ else if (y>Global_VDB_Ptr->VDB_ClipDown)
+ {
+ y=Global_VDB_Ptr->VDB_ClipDown;
+ }
+ vertexPtr->sy=y;
+ }
+ #else
+ vertexPtr->sx=x;
+ vertexPtr->sy=y;
+ #endif
+ #if FOG_ON
+ {
+ int fog = (point->vz)/FOG_SCALE;
+ if (fog<0) fog=0;
+ if (fog>254) fog=254;
+ fog=255-fog;
+ vertexPtr->specular=RGBALIGHT_MAKE(0,0,0,fog);
+ }
+ #endif
+ point->vz+=HeadUpDisplayZOffset;
+ float oneOverZ = ((float)(point->vz)-ZNear)/(float)(point->vz);
+ //vertexPtr->color = RGBALIGHT_MAKE(66,70,0,127+(FastRandom()&63));
+ vertexPtr->color = MeshVertexColour[i];
+ vertexPtr->sz = oneOverZ;
+ #if TEXTURE_WATER
+ vertexPtr->tu = pointWS->vx/128.0;
+ vertexPtr->tv = pointWS->vz/128.0;
+ #endif
+
+
+ NumVertices++;
+ vertexPtr++;
+ point++;
+ #if TEXTURE_WATER
+ pointWS++;
+ #endif
+ }
+ }
+ // textprint("numvertices %d\n",NumVertices);
+
+
+ /*
+ * Make sure that the triangle data (not OP) will be QWORD aligned
+ */
+ if (QWORD_ALIGNED(ExecBufInstPtr))
+ {
+ OP_NOP(ExecBufInstPtr);
+ }
+
+ OP_TRIANGLE_LIST(450, ExecBufInstPtr);
+ /* CONSTRUCT POLYS */
+ {
+ int x;
+ for (x=0; x<15; x++)
+ {
+ int y;
+ for(y=0; y<15; y++)
+ {
+ OUTPUT_TRIANGLE(0+x+(16*y),1+x+(16*y),16+x+(16*y), 256);
+ OUTPUT_TRIANGLE(1+x+(16*y),17+x+(16*y),16+x+(16*y), 256);
+ }
+ }
+ }
+ #if 1
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ #endif
+}
+void D3D_DrawWaterMesh_Clipped(void)
+{
+ float ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
+
+ /* OUTPUT VERTICES TO EXECUTE BUFFER */
+ {
+ D3DTLVERTEX *vertexPtr = &((LPD3DTLVERTEX)ExecuteBufferDataArea)[NumVertices];
+ VECTORCH *point = MeshVertex;
+ #if TEXTURE_WATER
+ VECTORCH *pointWS = MeshWorldVertex;
+ #endif
+ int i;
+ for (i=0; i<256; i++)
+ {
+ {
+ if (point->vz<=1) point->vz = 1;
+ int x = (point->vx*(Global_VDB_Ptr->VDB_ProjX))/point->vz+Global_VDB_Ptr->VDB_CentreX;
+ int y = (point->vy*(Global_VDB_Ptr->VDB_ProjY))/point->vz+Global_VDB_Ptr->VDB_CentreY;
+ #if 1
+ {
+ if (x<Global_VDB_Ptr->VDB_ClipLeft)
+ {
+ x=Global_VDB_Ptr->VDB_ClipLeft;
+ }
+ else if (x>Global_VDB_Ptr->VDB_ClipRight)
+ {
+ x=Global_VDB_Ptr->VDB_ClipRight;
+ }
+
+ vertexPtr->sx=x;
+ }
+ {
+ if (y<Global_VDB_Ptr->VDB_ClipUp)
+ {
+ y=Global_VDB_Ptr->VDB_ClipUp;
+ }
+ else if (y>Global_VDB_Ptr->VDB_ClipDown)
+ {
+ y=Global_VDB_Ptr->VDB_ClipDown;
+ }
+ vertexPtr->sy=y;
+ }
+ #else
+ vertexPtr->sx=x;
+ vertexPtr->sy=y;
+ #endif
+ #if FOG_ON
+ {
+ int fog = ((point->vz)/FOG_SCALE);
+ if (fog<0) fog=0;
+ if (fog>254) fog=254;
+ fog=255-fog;
+ vertexPtr->specular=RGBALIGHT_MAKE(0,0,0,fog);
+ }
+ #endif
+ #if TEXTURE_WATER
+ vertexPtr->tu = pointWS->vx/128.0;
+ vertexPtr->tv = pointWS->vz/128.0;
+ #endif
+ point->vz+=HeadUpDisplayZOffset;
+ float oneOverZ = ((float)(point->vz)-ZNear)/(float)(point->vz);
+ // vertexPtr->color = RGBALIGHT_MAKE(66,70,0,127+(FastRandom()&63));
+ vertexPtr->color = MeshVertexColour[i];
+ vertexPtr->sz = oneOverZ;
+ }
+ NumVertices++;
+ vertexPtr++;
+ point++;
+ #if TEXTURE_WATER
+ pointWS++;
+ #endif
+ }
+ }
+// textprint("numvertices %d\n",NumVertices);
+ /* CONSTRUCT POLYS */
+ {
+ int x;
+ for (x=0; x<15; x++)
+ {
+ int y;
+ for(y=0; y<15; y++)
+ {
+ #if 1
+ int p1 = 0+x+(16*y);
+ int p2 = 1+x+(16*y);
+ int p3 = 16+x+(16*y);
+ int p4 = 17+x+(16*y);
+
+ if (MeshVertexOutcode[p1]||MeshVertexOutcode[p2]||MeshVertexOutcode[p3])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p1,p2,p3, 256);
+ }
+ if (MeshVertexOutcode[p2]||MeshVertexOutcode[p3]||MeshVertexOutcode[p4])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p2,p4,p3, 256);
+ }
+ #else
+ int p2 = 1+x+(16*y);
+ int p3 = 16+x+(16*y);
+
+ if (MeshVertexOutcode[p2]&&MeshVertexOutcode[p3])
+ {
+ int p1 = 0+x+(16*y);
+ int p4 = 17+x+(16*y);
+ if (MeshVertexOutcode[p1])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p1,p2,p3, 256);
+ }
+ if (MeshVertexOutcode[p4])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p2,p4,p3, 256);
+ }
+ }
+ #endif
+ }
+ }
+ }
+ #if 1
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ #endif
+}
+
+signed int ForceFieldPointDisplacement[15*3+1][16];
+signed int ForceFieldPointDisplacement2[15*3+1][16];
+signed int ForceFieldPointVelocity[15*3+1][16];
+unsigned char ForceFieldPointColour1[15*3+1][16];
+unsigned char ForceFieldPointColour2[15*3+1][16];
+
+int Phase=0;
+int ForceFieldPhase=0;
+void InitForceField(void)
+{
+ for (int x=0; x<15*3+1; x++)
+ for (int y=0; y<16; y++)
+ {
+ ForceFieldPointDisplacement[x][y]=0;
+ ForceFieldPointDisplacement2[x][y]=0;
+ ForceFieldPointVelocity[x][y]=0;
+ }
+ ForceFieldPhase=0;
+}
+#if 1
+
+void UpdateForceField(void)
+{
+ #if 1
+ Phase+=NormalFrameTime>>6;
+ ForceFieldPhase+=NormalFrameTime>>5;
+ int x;
+ for (x=1; x<15*3; x++)
+ {
+ int y;
+ for (y=1; y<15; y++)
+ {
+
+ int acceleration =32*(-8*ForceFieldPointDisplacement[x][y]
+ +ForceFieldPointDisplacement[x-1][y-1]
+ +ForceFieldPointDisplacement[x-1][y]
+ +ForceFieldPointDisplacement[x-1][y+1]
+ +ForceFieldPointDisplacement[x][y-1]
+ +ForceFieldPointDisplacement[x][y+1]
+#if 0
+ )
+#else
+
+ +ForceFieldPointDisplacement[x+1][y-1]
+ +ForceFieldPointDisplacement[x+1][y]
+ +ForceFieldPointDisplacement[x+1][y+1])
+#endif
+ -(ForceFieldPointVelocity[x][y]*5);
+
+ ForceFieldPointVelocity[x][y] += MUL_FIXED(acceleration,NormalFrameTime);
+ ForceFieldPointDisplacement2[x][y] += MUL_FIXED(ForceFieldPointVelocity[x][y],NormalFrameTime);
+#if 1
+ if(ForceFieldPointDisplacement2[x][y]>200) ForceFieldPointDisplacement2[x][y]=200;
+ if(ForceFieldPointDisplacement2[x][y]<-200) ForceFieldPointDisplacement2[x][y]=-200;
+#else
+ if(ForceFieldPointDisplacement2[x][y]>512) ForceFieldPointDisplacement2[x][y]=512;
+ if(ForceFieldPointDisplacement2[x][y]<-512) ForceFieldPointDisplacement2[x][y]=-512;
+
+#endif
+ {
+ int offset = ForceFieldPointDisplacement2[x][y];
+ int colour = ForceFieldPointVelocity[x][y]/4;
+
+ if (offset<0) offset =-offset;
+ if (colour<0) colour =-colour;
+ colour=(colour+offset)/2;
+
+ if(colour>255) colour=255;
+ colour++;
+
+ ForceFieldPointColour1[x][y]=FastRandom()%colour;
+ ForceFieldPointColour2[x][y]=FastRandom()%colour;
+ }
+ }
+
+ }
+ for (x=1; x<15*3; x++)
+ {
+ int y;
+ for (y=1; y<15; y++)
+ {
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement2[x][y];
+ }
+ }
+ {
+ #if 1
+ if(ForceFieldPhase>1000)
+ {
+ ForceFieldPhase=0;
+ int x = 1+(FastRandom()%(15*3-2));
+ int y = 1+(FastRandom()%13);
+ ForceFieldPointVelocity[x][y] = 10000;
+ ForceFieldPointVelocity[x][y+1] = 10000;
+ ForceFieldPointVelocity[x+1][y] = 10000;
+ ForceFieldPointVelocity[x+1][y+1] = 10000;
+ }
+ #else
+ // if(ForceFieldPhase>1000)
+ {
+ ForceFieldPhase=0;
+ int x = 1+(FastRandom()%(15*3-2));
+ int y = 1+(FastRandom()%13);
+ ForceFieldPointVelocity[x][y] = (FastRandom()&16383)+8192;
+ }
+ #endif
+ }
+ #else
+ int x;
+ int y;
+ for (y=0; y<=15; y++)
+ {
+ ForceFieldPointDisplacement[0][y] += (FastRandom()&127)-64;
+ if(ForceFieldPointDisplacement[0][y]>512) ForceFieldPointDisplacement[0][y]=512;
+ if(ForceFieldPointDisplacement[0][y]<-512) ForceFieldPointDisplacement[0][y]=-512;
+ ForceFieldPointVelocity[0][y] = (FastRandom()&16383)-8192;
+ }
+ for (x=15*3-1; x>0; x--)
+ {
+ for (y=0; y<=15; y++)
+ {
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ ForceFieldPointVelocity[x][y] = ForceFieldPointVelocity[x-1][y];
+ }
+
+ }
+ for (x=15*3-1; x>1; x--)
+ {
+ y = FastRandom()&15;
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ y = (FastRandom()&15)-1;
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ }
+ #endif
+}
+void UpdateWaterFall(void)
+{
+ int x;
+ int y;
+ for (y=0; y<=15; y++)
+ {
+ ForceFieldPointDisplacement[0][y] += (FastRandom()&127)-64;
+ if(ForceFieldPointDisplacement[0][y]>512) ForceFieldPointDisplacement[0][y]=512;
+ if(ForceFieldPointDisplacement[0][y]<-512) ForceFieldPointDisplacement[0][y]=-512;
+ ForceFieldPointVelocity[0][y] = (FastRandom()&16383)-8192;
+ }
+ for (x=15*3-1; x>0; x--)
+ {
+ for (y=0; y<=15; y++)
+ {
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ ForceFieldPointVelocity[x][y] = ForceFieldPointVelocity[x-1][y];
+ }
+
+ }
+ for (x=15*3-1; x>1; x--)
+ {
+ y = FastRandom()&15;
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ y = (FastRandom()&15)-1;
+ ForceFieldPointDisplacement[x][y] = ForceFieldPointDisplacement[x-1][y];
+ }
+}
+
+#endif
+void D3D_DrawForceField(int xOrigin, int yOrigin, int zOrigin, int fieldType)
+{
+ MeshXScale = 4096/16;
+ MeshZScale = 4096/16;
+
+ for (int field=0; field<3; field++)
+ {
+ int i=0;
+ int x;
+ for (x=(0+field*15); x<(16+field*15); x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+ int offset = ForceFieldPointDisplacement[x][z];
+
+ switch(fieldType)
+ {
+ case 0:
+ {
+ point->vx = xOrigin+(x*MeshXScale);
+ point->vy = yOrigin+(z*MeshZScale);
+ point->vz = zOrigin+offset;
+ break;
+ }
+ case 1:
+ {
+
+ int theta = (z*4095)/15;
+ int u = (x*65536)/45;
+
+ int b = MUL_FIXED(2*u,(65536-u));
+ int c = MUL_FIXED(u,u);
+ int phi = (Phase&4095);
+ int x3 = (GetSin(phi))/64;
+ int y3 = 5000-(GetCos((phi*3+1000)&4095)/128);
+ int z3 = (GetSin((3*phi+1324)&4095))/32;
+ int x2 = -x3/2;
+ int y2 = 3000;
+ int z2 = -z3/4;
+ int innerRadius = 100;//GetSin(u/32)/16+offset;
+
+ point->vx = xOrigin+(b*x2+c*x3)/65536+MUL_FIXED(innerRadius,GetSin(theta));
+ point->vy = yOrigin-5000+(b*y2+c*y3)/65536;
+ point->vz = zOrigin+(b*z2+c*z3)/65536+MUL_FIXED(innerRadius,GetCos(theta));
+ break;
+ }
+ case 2:
+ {
+ int theta = (z*4095)/15;
+ int phi = (x*4095)/45;
+ int innerRadius = 1000+offset;
+ int outerRadius = 4000;
+
+
+ point->vx = xOrigin+MUL_FIXED(outerRadius-MUL_FIXED(innerRadius,GetSin(theta)),GetCos(phi));
+ point->vy = yOrigin+MUL_FIXED(innerRadius,GetCos(theta));
+ point->vz = zOrigin+MUL_FIXED(outerRadius-MUL_FIXED(innerRadius,GetSin(theta)),GetSin(phi));
+ break;
+ }
+ case 3:
+ {
+
+ int theta = (x*4095)/45;
+ int radius = offset+2000;
+ point->vx = xOrigin+MUL_FIXED(radius,GetCos(theta));
+ point->vy = yOrigin+(z*MeshZScale);
+ point->vz = zOrigin+MUL_FIXED(radius,GetSin(theta));
+ break;
+ }
+ }
+
+ if (offset<0) offset =-offset;
+ offset+=16;
+
+// offset-=32;
+// if (offset<0) offset = 0;
+
+ if(offset>255) offset=255;
+
+ MeshVertexColour[i] = RGBALIGHT_MAKE(ForceFieldPointColour1[x][z],ForceFieldPointColour2[x][z],255,offset);
+ #if TEXTURE_WATER
+ MeshWorldVertex[i].vx = point->vx;
+ MeshWorldVertex[i].vz = point->vz;
+ #endif
+
+ TranslatePointIntoViewspace(point);
+
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+ //textprint("\n");
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawWaterMesh_Clipped();
+ }
+ }
+}
+
+
+void D3D_DrawPowerFence(int xOrigin, int yOrigin, int zOrigin, int xScale, int yScale, int zScale)
+{
+ for (int field=0; field<3; field++)
+ {
+ int i=0;
+ int x;
+ for (x=(0+field*15); x<(16+field*15); x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+ int offset = ForceFieldPointDisplacement[x][z];
+
+ point->vx = xOrigin+(x*xScale);
+ point->vy = yOrigin+(z*yScale);
+ point->vz = zOrigin+(x*zScale);
+
+ if (offset<0) offset =-offset;
+ offset+=16;
+
+ if(offset>255) offset=255;
+
+ MeshVertexColour[i] = RGBALIGHT_MAKE(ForceFieldPointColour1[x][z],ForceFieldPointColour2[x][z],255,offset);
+
+ /* translate particle into view space */
+ TranslatePointIntoViewspace(point);
+
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+ //textprint("\n");
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawWaterMesh_Clipped();
+ }
+ }
+}
+
+void D3D_DrawWaterFall(int xOrigin, int yOrigin, int zOrigin)
+{
+ {
+ int noRequired = MUL_FIXED(250,NormalFrameTime);
+ for (int i=0; i<noRequired; i++)
+ {
+ VECTORCH velocity;
+ VECTORCH position;
+ position.vx = xOrigin;
+ position.vy = yOrigin-(FastRandom()&511);//+45*MeshXScale;
+ position.vz = zOrigin+(FastRandom()%(15*MeshZScale));
+
+ velocity.vy = (FastRandom()&511)+512;//-((FastRandom()&1023)+2048)*8;
+ velocity.vx = ((FastRandom()&511)+256)*2;
+ velocity.vz = 0;//-((FastRandom()&511))*8;
+ MakeParticle(&(position), &velocity, PARTICLE_WATERFALLSPRAY);
+ }
+ #if 0
+ noRequired = MUL_FIXED(200,NormalFrameTime);
+ for (i=0; i<noRequired; i++)
+ {
+ VECTORCH velocity;
+ VECTORCH position;
+ position.vx = xOrigin+(FastRandom()%(15*MeshZScale));
+ position.vy = yOrigin+45*MeshXScale;
+ position.vz = zOrigin;
+
+ velocity.vy = -((FastRandom()&16383)+4096);
+ velocity.vx = ((FastRandom()&4095)-2048);
+ velocity.vz = -((FastRandom()&2047)+1048);
+ MakeParticle(&(position), &velocity, PARTICLE_WATERFALLSPRAY);
+ }
+ #endif
+ }
+ {
+ extern void RenderWaterFall(int xOrigin, int yOrigin, int zOrigin);
+ //RenderWaterFall(xOrigin, yOrigin-500, zOrigin+50);
+ }
+ return;
+ for (int field=0; field<3; field++)
+ {
+ int i=0;
+ int x;
+ for (x=(0+field*15); x<(16+field*15); x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+ int offset = ForceFieldPointDisplacement[x][z];
+
+ #if 1
+ int u = (x*65536)/45;
+
+ int b = MUL_FIXED(2*u,(65536-u));
+ int c = MUL_FIXED(u,u);
+ int y3 = 45*MeshXScale;
+ int x3 = 5000;
+ int y2 = 1*MeshXScale;
+ int x2 = GetSin(CloakingPhase&4095)+GetCos((CloakingPhase*3+399)&4095);
+ x2 = MUL_FIXED(x2,x2)/128;
+
+ if (offset<0) offset =-offset;
+ point->vx = xOrigin+MUL_FIXED(b,x2)+MUL_FIXED(c,x3)+offset;
+ point->vy = yOrigin+MUL_FIXED(b,y2)+MUL_FIXED(c,y3);
+ point->vz = zOrigin+(z*MeshZScale);
+
+ if (point->vy>4742)
+ {
+ if (z<=4)
+ {
+ point->vy-=MeshXScale;
+ if (point->vy<4742) point->vy=4742;
+ if (point->vx<179427) point->vx=179427;
+ }
+ else if (z<=8)
+ {
+ point->vx+=(8-z)*1000;
+ }
+ }
+
+ #else
+ if (offset<0) offset =-offset;
+ point->vx = xOrigin-offset;
+ point->vy = yOrigin+(x*MeshXScale);
+ point->vz = zOrigin+(z*MeshZScale);
+ #endif
+
+
+
+
+ offset= (offset/4)+127;
+
+// offset-=32;
+// if (offset<0) offset = 0;
+
+ if(offset>255) offset=255;
+
+ MeshVertexColour[i] = RGBALIGHT_MAKE(offset,offset,255,offset/2);
+ #if TEXTURE_WATER
+ MeshWorldVertex[i].vx = point->vx;
+ MeshWorldVertex[i].vz = point->vz;
+ #endif
+
+ /* translate particle into view space */
+ TranslatePointIntoViewspace(point);
+
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+ //textprint("\n");
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawWaterMesh_Clipped();
+ }
+ }
+}
+
+void D3D_DrawMoltenMetal(int xOrigin, int yOrigin, int zOrigin)
+{
+ int i=0;
+ int x;
+ for (x=0; x<16; x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+
+ point->vx = xOrigin+(x*MeshXScale)/15;
+ point->vz = zOrigin+(z*MeshZScale)/15;
+ #if 0
+
+ int offset=0;
+
+ offset = MUL_FIXED(32,GetSin( (point->vx+point->vz+CloakingPhase)&4095 ) );
+ offset += MUL_FIXED(16,GetSin( (point->vx-point->vz*2+CloakingPhase/2)&4095 ) );
+ {
+ float dx=point->vx-22704;
+ float dz=point->vz+20652;
+ float a = dx*dx+dz*dz;
+ a=sqrt(a);
+
+ offset+= MUL_FIXED(200,GetSin( (((int)a-CloakingPhase)&4095) ));
+ }
+ #endif
+ #if 1
+ int offset=0;
+
+ /* basic noise ripples */
+ offset = MUL_FIXED(128,GetSin( ((point->vx+point->vz)/16+CloakingPhase)&4095 ) );
+ offset += MUL_FIXED(64,GetSin( ((point->vx-point->vz*2)/4+CloakingPhase/2)&4095 ) );
+ offset += MUL_FIXED(64,GetSin( ((point->vx*5-point->vz)/32+CloakingPhase/5)&4095 ) );
+
+ #endif
+ if (offset>450) offset = 450;
+ if (offset<-1000) offset = -1000;
+ point->vy = yOrigin+offset;
+
+ {
+ int shade = 191+(offset+256)/8;
+ MeshVertexColour[i] = RGBLIGHT_MAKE(shade,shade,shade);
+ }
+
+ #if 1
+ TranslatePointIntoViewspace(point);
+ #else
+ point->vx -= Global_VDB_Ptr->VDB_World.vx;
+ point->vy -= Global_VDB_Ptr->VDB_World.vy;
+ point->vz -= Global_VDB_Ptr->VDB_World.vz;
+ MeshWorldVertex[i] = *point;
+ RotateVector(point,&(Global_VDB_Ptr->VDB_Mat));
+ point->vy = MUL_FIXED(point->vy,87381);
+
+ #endif
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ #if 0
+ {
+ // v
+ MeshWorldVertex[i].vy = (offset+256)*4;
+ // u
+ MeshWorldVertex[i].vx = ((MeshWorldVertex[i].vx)&4095);
+
+ }
+ #else
+ {
+ Normalise(&MeshWorldVertex[i]);
+ // v
+ int theta = (MeshWorldVertex[i].vy+offset);
+ if (theta<0) theta=0;
+ if (theta>ONE_FIXED) theta=ONE_FIXED;
+
+ // u
+ int arctan = ((atan2((double)MeshWorldVertex[i].vx,(double)MeshWorldVertex[i].vz)/ 6.28318530718))*4095;
+ MeshWorldVertex[i].vx = (arctan+offset)&4095;
+
+ MeshWorldVertex[i].vy = ArcCos(theta);
+
+ }
+ #endif
+
+
+ i++;
+ }
+ }
+
+ D3DTEXTUREHANDLE TextureHandle = (D3DTEXTUREHANDLE)ImageHeaderArray[StaticImageNumber].D3DHandle;
+ if (CurrTextureHandle != TextureHandle)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, TextureHandle, ExecBufInstPtr);
+ CurrTextureHandle = TextureHandle;
+ }
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_OFF);
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawMoltenMetalMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawMoltenMetalMesh_Clipped();
+ }
+
+
+}
+
+#endif /* not yet */
+
+void D3D_DrawMoltenMetalMesh_Unclipped(void)
+{
+ float ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
+
+ VECTORCH *point = MeshVertex;
+ VECTORCH *pointWS = MeshWorldVertex;
+
+ int i, x, y, z;
+ int tc;
+
+ for (i=0; i<256; i++) {
+ GLfloat xf, yf, zf;
+ GLfloat sf, tf, rhw;
+ int r, g, b, a;
+
+ if (point->vz < 1) point->vz = 1;
+
+ x = (point->vx*(Global_VDB_Ptr->VDB_ProjX+1))/point->vz+Global_VDB_Ptr->VDB_CentreX;
+ y = (point->vy*(Global_VDB_Ptr->VDB_ProjY+1))/point->vz+Global_VDB_Ptr->VDB_CentreY;
+
+ if (x<Global_VDB_Ptr->VDB_ClipLeft) {
+ x=Global_VDB_Ptr->VDB_ClipLeft;
+ } else if (x>Global_VDB_Ptr->VDB_ClipRight) {
+ x=Global_VDB_Ptr->VDB_ClipRight;
+ }
+
+ if (y<Global_VDB_Ptr->VDB_ClipUp) {
+ y=Global_VDB_Ptr->VDB_ClipUp;
+ } else if (y>Global_VDB_Ptr->VDB_ClipDown) {
+ y=Global_VDB_Ptr->VDB_ClipDown;
+ }
+
+ sf = pointWS->vx*WaterUScale+(1.0f/256.0f);
+ tf = pointWS->vy*WaterVScale+(1.0f/256.0f);
+
+ z = point->vz + HeadUpDisplayZOffset;
+ rhw = 1.0f / (float)point->vz;
+
+ b = (MeshVertexColour[i] >> 0) & 0xFF;
+ g = (MeshVertexColour[i] >> 8) & 0xFF;
+ r = (MeshVertexColour[i] >> 16) & 0xFF;
+ a = (MeshVertexColour[i] >> 24) & 0xFF;
+
+ xf = ((float)x - (float)ScreenDescriptorBlock.SDB_CentreX - 0.5f) / ((float)ScreenDescriptorBlock.SDB_CentreX - 0.5f);
+ yf = -((float)y - (float)ScreenDescriptorBlock.SDB_CentreY - 0.5f) / ((float)ScreenDescriptorBlock.SDB_CentreY - 0.5f);
+ zf = 1.0f - 2.0f*ZNear/(float)z;
+
+ tarr[i].v[0] = xf/rhw;
+ tarr[i].v[1] = yf/rhw;
+ tarr[i].v[2] = zf/rhw;
+ tarr[i].v[3] = 1.0f/rhw;
+
+ tarr[i].t[0] = sf;
+ tarr[i].t[1] = tf;
+
+ tarr[i].c[0] = r;
+ tarr[i].c[1] = g;
+ tarr[i].c[2] = b;
+ tarr[i].c[3] = a;
+
+ point++;
+ pointWS++;
+ }
+
+ /* CONSTRUCT POLYS */
+
+ tc = 0;
+ for (x = 0; x < 15; x++) {
+ for(y = 0; y < 15; y++) {
+// OUTPUT_TRIANGLE(0+x+(16*y),1+x+(16*y),16+x+(16*y), 256);
+// OUTPUT_TRIANGLE(1+x+(16*y),17+x+(16*y),16+x+(16*y), 256);
+ if ((16+x+(16*y)) < 256) {
+ tris[tc+0].a = 0+x+(16*y);
+ tris[tc+0].b = 1+x+(16*y);
+ tris[tc+0].c = 16+x+(16*y);
+ tris[tc+1].a = 1+x+(16*y);
+ tris[tc+1].b = 17+x+(16*y);
+ tris[tc+1].c = 16+x+(16*y);
+
+ tc += 2;
+ }
+ }
+ }
+ DrawTriangleArray_T2F_C4UB_V4F(tc);
+}
+
+void D3D_DrawMoltenMetalMesh_Clipped(void)
+{
+ int i, x, y, z;
+
+ float ZNear = (float) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
+
+ {
+ VECTORCH *point = MeshVertex;
+ VECTORCH *pointWS = MeshWorldVertex;
+
+ for (i=0; i<256; i++)
+ {
+ GLfloat xf, yf, zf;
+ GLfloat sf, tf, rhw;
+ int r, g, b, a;
+
+ if (point->vz < 1) point->vz = 1;
+
+ x = (point->vx*(Global_VDB_Ptr->VDB_ProjX+1))/point->vz+Global_VDB_Ptr->VDB_CentreX;
+ y = (point->vy*(Global_VDB_Ptr->VDB_ProjY+1))/point->vz+Global_VDB_Ptr->VDB_CentreY;
+
+ if (x<Global_VDB_Ptr->VDB_ClipLeft) {
+ x=Global_VDB_Ptr->VDB_ClipLeft;
+ } else if (x>Global_VDB_Ptr->VDB_ClipRight) {
+ x=Global_VDB_Ptr->VDB_ClipRight;
+ }
+
+ if (y<Global_VDB_Ptr->VDB_ClipUp) {
+ y=Global_VDB_Ptr->VDB_ClipUp;
+ } else if (y>Global_VDB_Ptr->VDB_ClipDown) {
+ y=Global_VDB_Ptr->VDB_ClipDown;
+ }
+
+ sf = pointWS->vx*WaterUScale+(1.0f/256.0f);
+ tf = pointWS->vy*WaterVScale+(1.0f/256.0f);
+
+ z = point->vz + HeadUpDisplayZOffset;
+ rhw = 1.0f / (float)point->vz;
+
+ b = (MeshVertexColour[i] >> 0) & 0xFF;
+ g = (MeshVertexColour[i] >> 8) & 0xFF;
+ r = (MeshVertexColour[i] >> 16) & 0xFF;
+ a = (MeshVertexColour[i] >> 24) & 0xFF;
+
+ xf = ((float)x - (float)ScreenDescriptorBlock.SDB_CentreX - 0.5f) / ((float)ScreenDescriptorBlock.SDB_CentreX - 0.5f);
+ yf = -((float)y - (float)ScreenDescriptorBlock.SDB_CentreY - 0.5f) / ((float)ScreenDescriptorBlock.SDB_CentreY - 0.5f);
+ zf = 1.0f - 2.0f*ZNear/(float)z;
+
+ tarr[i].v[0] = xf/rhw;
+ tarr[i].v[1] = yf/rhw;
+ tarr[i].v[2] = zf/rhw;
+ tarr[i].v[3] = 1.0f/rhw;
+
+ tarr[i].t[0] = sf;
+ tarr[i].t[1] = tf;
+
+ tarr[i].c[0] = r;
+ tarr[i].c[1] = g;
+ tarr[i].c[2] = b;
+ tarr[i].c[3] = a;
+
+ point++;
+ pointWS++;
+ }
+ }
+
+ /* CONSTRUCT POLYS */
+ {
+ int tc = 0;
+
+ for (x=0; x<15; x++)
+ {
+ for(y=0; y<15; y++)
+ {
+ int p1 = 0+x+(16*y);
+ int p2 = 1+x+(16*y);
+ int p3 = 16+x+(16*y);
+ int p4 = 17+x+(16*y);
+
+ if (p3 > 255)
+ continue;
+#if 0
+ #if 0
+ if (MeshVertexOutcode[p1]&&MeshVertexOutcode[p2]&&MeshVertexOutcode[p3])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p1,p2,p3, 256);
+ }
+ if (MeshVertexOutcode[p2]&&MeshVertexOutcode[p3]&&MeshVertexOutcode[p4])
+ {
+ OP_TRIANGLE_LIST(1, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p2,p4,p3, 256);
+ }
+ #else
+ if (MeshVertexOutcode[p1]&&MeshVertexOutcode[p2]&&MeshVertexOutcode[p3]&&MeshVertexOutcode[p4])
+ {
+ OP_TRIANGLE_LIST(2, ExecBufInstPtr);
+ OUTPUT_TRIANGLE(p1,p2,p3, 256);
+ OUTPUT_TRIANGLE(p2,p4,p3, 256);
+ }
+
+ #endif
+#endif
+ if (MeshVertexOutcode[p1]&&MeshVertexOutcode[p2]&&MeshVertexOutcode[p3]&&MeshVertexOutcode[p4]) {
+ tris[tc+0].a = p1;
+ tris[tc+0].b = p2;
+ tris[tc+0].c = p3;
+ tris[tc+1].a = p2;
+ tris[tc+1].b = p4;
+ tris[tc+1].c = p3;
+ tc += 2;
+ }
+ }
+ }
+ DrawTriangleArray_T2F_C4UB_V4F(tc);
+ }
+ {
+ POLYHEADER fakeHeader;
+
+ fakeHeader.PolyFlags = 0;
+ fakeHeader.PolyColour = 0;
+ RenderPolygon.TranslucencyMode = TRANSLUCENCY_NORMAL;
+
+ for (x=0; x<15; x++)
+ {
+ for(y=0; y<15; y++)
+ {
+ int p[4];
+ p[0] = 0+x+(16*y);
+ p[1] = 1+x+(16*y);
+ p[2] = 17+x+(16*y);
+ p[3] = 16+x+(16*y);
+
+ if (p[3] > 255)
+ continue;
+
+ if (!(MeshVertexOutcode[p[0]]&&MeshVertexOutcode[p[1]]&&MeshVertexOutcode[p[2]]&&MeshVertexOutcode[p[3]]))
+ {
+ for (i=0; i<4; i++)
+ {
+ VerticesBuffer[i].X = MeshVertex[p[i]].vx;
+ VerticesBuffer[i].Y = MeshVertex[p[i]].vy;
+ VerticesBuffer[i].Z = MeshVertex[p[i]].vz;
+ VerticesBuffer[i].U = MeshWorldVertex[p[i]].vx*(WaterUScale*128.0f*65536.0f);
+ VerticesBuffer[i].V = MeshWorldVertex[p[i]].vy*(WaterVScale*128.0f*65536.0f);
+
+ VerticesBuffer[i].A = (MeshVertexColour[p[i]]&0xff000000)>>24;
+ VerticesBuffer[i].R = (MeshVertexColour[p[i]]&0x00ff0000)>>16;
+ VerticesBuffer[i].G = (MeshVertexColour[p[i]]&0x0000ff00)>>8;
+ VerticesBuffer[i].B = MeshVertexColour[p[i]]&0x000000ff;
+ VerticesBuffer[i].SpecularR = 0;
+ VerticesBuffer[i].SpecularG = 0;
+ VerticesBuffer[i].SpecularB = 0;
+ RenderPolygon.NumberOfVertices=4;
+
+ }
+ if (QuadWithinFrustrum())
+ {
+ GouraudTexturedPolygon_ClipWithZ();
+ if(RenderPolygon.NumberOfVertices<3) continue;
+ GouraudTexturedPolygon_ClipWithNegativeX();
+ if(RenderPolygon.NumberOfVertices<3) continue;
+ GouraudTexturedPolygon_ClipWithPositiveY();
+ if(RenderPolygon.NumberOfVertices<3) continue;
+ GouraudTexturedPolygon_ClipWithNegativeY();
+ if(RenderPolygon.NumberOfVertices<3) continue;
+ GouraudTexturedPolygon_ClipWithPositiveX();
+ if(RenderPolygon.NumberOfVertices<3) continue;
+ // D3D_ZBufferedGouraudPolygon_Output(&fakeHeader,RenderPolygon.Vertices);
+ D3D_ZBufferedGouraudTexturedPolygon_Output(&fakeHeader,RenderPolygon.Vertices);
+ }
+ }
+ }
+ }
+ }
+}
+
+#if 0 /* not yet */
+
+void D3D_DrawWaterOctagonPatch(int xOrigin, int yOrigin, int zOrigin, int xOffset, int zOffset)
+{
+ float grad = 2.414213562373;
+ int i=0;
+ int x;
+ for (x=xOffset; x<16+xOffset; x++)
+ {
+ int z;
+ for(z=zOffset; z<16+zOffset; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+
+ if (x>z)
+ {
+ float m,xs;
+ if (x!=0)
+ {
+ m = (float)(z)/(float)(x);
+ xs = grad/(grad+m);
+ }
+ else
+ {
+ xs = 0;
+ }
+ #if 1
+ f2i(point->vx , xs*x*MeshXScale);
+ f2i(point->vz , (grad-grad*xs)*x*MeshZScale);
+ #else
+ point->vx = xs*x*MeshXScale;
+ point->vz = (grad-grad*xs)*x*MeshZScale;
+ #endif
+ }
+ else
+ {
+ float m,xs;
+ if (z!=0)
+ {
+ m = (float)(x)/(float)(z);
+ xs = grad/(grad+m);
+ }
+ else
+ {
+ xs = 0;
+ }
+ #if 1
+ f2i(point->vz , xs*z*MeshZScale);
+ f2i(point->vx , (grad-grad*xs)*z*MeshXScale);
+ #else
+ point->vz = xs*z*MeshZScale;
+ point->vx = (grad-grad*xs)*z*MeshXScale;
+ #endif
+ }
+
+ point->vx += xOrigin;
+ point->vz += zOrigin;
+
+ int offset = EffectOfRipples(point);
+
+ point->vy = yOrigin+offset;
+
+ #if 0
+ MeshVertexColour[i] = LightSourceWaterPoint(point,offset);
+ #else
+ {
+ int alpha = 128-offset/4;
+ // if (alpha>255) alpha = 255;
+ // if (alpha<128) alpha = 128;
+ switch (CurrentVisionMode)
+ {
+ default:
+ case VISION_MODE_NORMAL:
+ {
+ MeshVertexColour[i] = RGBALIGHT_MAKE(10,51,28,alpha);
+ break;
+ }
+ case VISION_MODE_IMAGEINTENSIFIER:
+ {
+ MeshVertexColour[i] = RGBALIGHT_MAKE(0,51,0,alpha);
+ break;
+ }
+ case VISION_MODE_PRED_THERMAL:
+ case VISION_MODE_PRED_SEEALIENS:
+ case VISION_MODE_PRED_SEEPREDTECH:
+ {
+ MeshVertexColour[i] = RGBALIGHT_MAKE(0,0,28,alpha);
+ break;
+ }
+ }
+
+ }
+ #endif
+ TranslatePointIntoViewspace(point);
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawWaterMesh_Clipped();
+ }
+
+
+}
+
+void D3D_DrawCable(VECTORCH *centrePtr, MATRIXCH *orientationPtr)
+{
+ {
+ // Turn OFF texturing if it is on...
+ if (CurrTextureHandle != NULL)
+ {
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_TEXTUREHANDLE, NULL, ExecBufInstPtr);
+ CurrTextureHandle = NULL;
+ }
+
+ CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
+
+ if (NumVertices)
+ {
+ WriteEndCodeToExecuteBuffer();
+ UnlockExecuteBufferAndPrepareForUse();
+ ExecuteBuffer();
+ LockExecuteBuffer();
+ }
+
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_ZWRITEENABLE, FALSE, ExecBufInstPtr);
+
+ }
+ MeshXScale = 4096/16;
+ MeshZScale = 4096/16;
+
+ for (int field=0; field<3; field++)
+ {
+ int i=0;
+ int x;
+ for (x=(0+field*15); x<(16+field*15); x++)
+ {
+ int z;
+ for(z=0; z<16; z++)
+ {
+ VECTORCH *point = &MeshVertex[i];
+ {
+ int innerRadius = 20;
+ VECTORCH radius;
+ int theta = ((4096*z)/15)&4095;
+ int rOffset = GetSin((x*64+theta/32-CloakingPhase)&4095);
+ rOffset = MUL_FIXED(rOffset,rOffset)/512;
+
+
+ radius.vx = MUL_FIXED(innerRadius+rOffset/8,GetSin(theta));
+ radius.vy = MUL_FIXED(innerRadius+rOffset/8,GetCos(theta));
+ radius.vz = 0;
+
+ RotateVector(&radius,orientationPtr);
+
+ point->vx = centrePtr[x].vx+radius.vx;
+ point->vy = centrePtr[x].vy+radius.vy;
+ point->vz = centrePtr[x].vz+radius.vz;
+
+ MeshVertexColour[i] = RGBALIGHT_MAKE(0,rOffset,255,128);
+
+ }
+
+ TranslatePointIntoViewspace(point);
+
+ /* is particle within normal view frustrum ? */
+ if(AvP.PlayerType==I_Alien) /* wide frustrum */
+ {
+ if(( (-point->vx <= point->vz*2)
+ &&(point->vx <= point->vz*2)
+ &&(-point->vy <= point->vz*2)
+ &&(point->vy <= point->vz*2) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+ else
+ {
+ if(( (-point->vx <= point->vz)
+ &&(point->vx <= point->vz)
+ &&(-point->vy <= point->vz)
+ &&(point->vy <= point->vz) ))
+ {
+ MeshVertexOutcode[i]=1;
+ }
+ else
+ {
+ MeshVertexOutcode[i]=0;
+ }
+ }
+
+ i++;
+ }
+ }
+ //textprint("\n");
+ if ((MeshVertexOutcode[0]&&MeshVertexOutcode[15]&&MeshVertexOutcode[240]&&MeshVertexOutcode[255]))
+ {
+ D3D_DrawMoltenMetalMesh_Unclipped();
+ // D3D_DrawWaterMesh_Unclipped();
+ }
+ else
+// else if (MeshVertexOutcode[0]||MeshVertexOutcode[15]||MeshVertexOutcode[240]||MeshVertexOutcode[255])
+ {
+ D3D_DrawMoltenMetalMesh_Clipped();
+ // D3D_DrawWaterMesh_Clipped();
+ }
+ }
+ OP_STATE_RENDER(1, ExecBufInstPtr);
+ STATE_DATA(D3DRENDERSTATE_ZWRITEENABLE, TRUE, ExecBufInstPtr);
+}
+
+#endif
+
#if 0
/* ** menu-type stuff that should be moved later ** */
#include "avp_menugfx.hpp"
diff --git a/src/stubs.c b/src/stubs.c
index c1e70a2..f31916a 100644
--- a/src/stubs.c
+++ b/src/stubs.c
@@ -271,11 +271,6 @@ void InitForceField()
fprintf(stderr, "InitForceField()\n");
}
-void PostLandscapeRendering()
-{
- fprintf(stderr, "PostLandscapeRendering()\n");
-}
-
void SetFogDistance(int fogDistance)
{
fprintf(stderr, "SetFontDistance(%d)\n", fogDistance);
@@ -339,26 +334,11 @@ BOOL EndD3DScene()
return FALSE;
}
-void D3D_DrawWaterTest(MODULE *testModulePtr)
-{
- fprintf(stderr, "D3D_DrawWaterTest(%p)\n", testModulePtr);
-}
-
-void D3D_DrawParticle_Rain(PARTICLE *particlePtr,VECTORCH *prevPositionPtr)
-{
- fprintf(stderr, "D3D_DrawParticle_Rain(%p, %p)\n", particlePtr, prevPositionPtr);
-}
-
void D3D_DrawCable(VECTORCH *centrePtr, MATRIXCH *orientationPtr)
{
fprintf(stderr, "D3D_DrawCable(%p, %p)\n", centrePtr, orientationPtr);
}
-void D3D_BackdropPolygon_Output(POLYHEADER *inputPolyPtr,RENDERVERTEX *renderVerticesPtr)
-{
- fprintf(stderr, "D3D_BackdropPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
-}
-
/* dd_func.cpp */
long BackBufferPitch;