summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2020-12-15 15:45:06 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2020-12-15 15:45:06 +0100
commit970f84514a45e0181bd05ae02493908ec86f5683 (patch)
tree37e568870361124e7e34dfe20a7f66af254a8d39 /src/render
parentRadio scroll to prev. station & radio off text (diff)
parentfixed water.dat code (diff)
downloadre3-970f84514a45e0181bd05ae02493908ec86f5683.tar
re3-970f84514a45e0181bd05ae02493908ec86f5683.tar.gz
re3-970f84514a45e0181bd05ae02493908ec86f5683.tar.bz2
re3-970f84514a45e0181bd05ae02493908ec86f5683.tar.lz
re3-970f84514a45e0181bd05ae02493908ec86f5683.tar.xz
re3-970f84514a45e0181bd05ae02493908ec86f5683.tar.zst
re3-970f84514a45e0181bd05ae02493908ec86f5683.zip
Diffstat (limited to 'src/render')
-rw-r--r--src/render/WaterLevel.cpp367
-rw-r--r--src/render/WaterLevel.h13
2 files changed, 339 insertions, 41 deletions
diff --git a/src/render/WaterLevel.cpp b/src/render/WaterLevel.cpp
index ecfccc90..49fc3a22 100644
--- a/src/render/WaterLevel.cpp
+++ b/src/render/WaterLevel.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "main.h"
#include "FileMgr.h"
+#include "FileLoader.h"
#include "TxdStore.h"
#include "Timer.h"
#include "Weather.h"
@@ -30,8 +31,8 @@ float TEXTURE_ADDV;
int32 CWaterLevel::ms_nNoOfWaterLevels;
float CWaterLevel::ms_aWaterZs[48];
CRect CWaterLevel::ms_aWaterRects[48];
-uint8 CWaterLevel::aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE];
-uint8 CWaterLevel::aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE];
+int8 CWaterLevel::aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
+int8 CWaterLevel::aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
bool CWaterLevel::WavesCalculatedThisFrame;
RpAtomic *CWaterLevel::ms_pWavyAtomic;
RpGeometry *CWaterLevel::apGeomArray[8];
@@ -53,33 +54,163 @@ const float fGreenMult = 1.0f;
const float fBlueMult = 1.4f;
-
void
CWaterLevel::Initialise(Const char *pWaterDat)
{
ms_nNoOfWaterLevels = 0;
-
+
+#ifdef MASTER
int32 hFile = -1;
-
- do
+
+ while ((hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb")) < 0);
+#else
+ int32 hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
+#endif
+
+ if (hFile > 0)
{
- hFile = CFileMgr::OpenFile("DATA\\waterpro.dat", "rb");
+ CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
+ CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
+ CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
+ CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
+ CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+
+ CFileMgr::CloseFile(hFile);
}
- while ( hFile < 0 );
-
- if ( hFile > 0 )
+#ifndef MASTER
+ else
{
- if ( hFile >= 0 )
+ printf("Init waterlevels\n");
+
+ CFileMgr::SetDir("");
+ hFile = CFileMgr::OpenFile(pWaterDat, "r");
+
+ char *line;
+
+ while ((line = CFileLoader::LoadLine(hFile)))
{
- CFileMgr::Read(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
- CFileMgr::Read(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
- CFileMgr::Read(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
- CFileMgr::Read(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
- CFileMgr::Read(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+ if (*line && *line != ';')
+ {
+ float z, l, b, r, t;
+ sscanf(line, "%f %f %f %f %f", &z, &l, &b, &r, &t);
+ AddWaterLevel(l, b, r, t, z);
+ }
}
-
+
CFileMgr::CloseFile(hFile);
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+
+ // rasterize water rects read from file
+ for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
+ {
+ int32 l = WATER_HUGE_X(ms_aWaterRects[i].left);
+ int32 r = WATER_HUGE_X(ms_aWaterRects[i].right) + 1.0f;
+ int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
+ int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
+
+#ifdef FIX_BUGS
+ // water.dat has rects that go out of bounds
+ // which causes memory corruption
+ l = clamp(l, 0, MAX_SMALL_SECTORS - 1);
+ r = clamp(r, 0, MAX_SMALL_SECTORS - 1);
+ t = clamp(t, 0, MAX_SMALL_SECTORS - 1);
+ b = clamp(b, 0, MAX_SMALL_SECTORS - 1);
+#endif
+
+ for (int32 x = l; x <= r; x++)
+ {
+ for (int32 y = t; y <= b; y++)
+ {
+ aWaterFineBlockList[x][y] = i;
+ }
+ }
+ }
+
+ // remove tiles that are obscured by land
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ float worldX = WATER_START_X + x * SMALL_SECTOR_SIZE;
+
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] >= 0)
+ {
+ float worldY = WATER_START_Y + y * SMALL_SECTOR_SIZE;
+
+ int32 i;
+ for (i = 0; i <= 8; i++)
+ {
+ for (int32 j = 0; j <= 8; j++)
+ {
+ CVector worldPos = CVector(worldX + i * (SMALL_SECTOR_SIZE / 8), worldY + j * (SMALL_SECTOR_SIZE / 8), ms_aWaterZs[aWaterFineBlockList[x][y]]);
+
+ if ((worldPos.x > WORLD_MIN_X && worldPos.x < WORLD_MAX_X) && (worldPos.y > WORLD_MIN_Y && worldPos.y < WORLD_MAX_Y) &&
+ (!WaterLevelAccordingToRectangles(worldPos.x, worldPos.y) || TestVisibilityForFineWaterBlocks(worldPos)))
+ continue;
+
+ // at least one point in the tile wasn't blocked, so don't remove water
+ i = 1000;
+ break;
+ }
+ }
+
+ if (i < 1000)
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ RemoveIsolatedWater();
+
+ // calculate coarse tiles from fine tiles
+ for (int32 x = 0; x < MAX_LARGE_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_LARGE_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x * 2][y * 2] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2];
+ }
+ else if (aWaterFineBlockList[x * 2 + 1][y * 2] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2];
+ }
+ else if (aWaterFineBlockList[x * 2][y * 2 + 1] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2][y * 2 + 1];
+ }
+ else if (aWaterFineBlockList[x * 2 + 1][y * 2 + 1] >= 0)
+ {
+ aWaterBlockList[x][y] = aWaterFineBlockList[x * 2 + 1][y * 2 + 1];
+ }
+ else
+ {
+ aWaterBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ hFile = CFileMgr::OpenFileForWriting("data\\waterpro.dat");
+
+ if (hFile > 0)
+ {
+ CFileMgr::Write(hFile, (char *)&ms_nNoOfWaterLevels, sizeof(ms_nNoOfWaterLevels));
+ CFileMgr::Write(hFile, (char *)ms_aWaterZs, sizeof(ms_aWaterZs));
+ CFileMgr::Write(hFile, (char *)ms_aWaterRects, sizeof(ms_aWaterRects));
+ CFileMgr::Write(hFile, (char *)aWaterBlockList, sizeof(aWaterBlockList));
+ CFileMgr::Write(hFile, (char *)aWaterFineBlockList, sizeof(aWaterFineBlockList));
+
+ CFileMgr::CloseFile(hFile);
+ }
}
+#endif
CTxdStore::PushCurrentTxd();
@@ -222,6 +353,170 @@ CWaterLevel::DestroyWavyAtomic()
RwFrameDestroy(frame);
}
+#ifndef MASTER
+void
+CWaterLevel::AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel)
+{
+ ms_aWaterRects[ms_nNoOfWaterLevels] = CRect(fXLeft, fYBottom, fXRight, fYTop);
+ ms_aWaterZs[ms_nNoOfWaterLevels] = fLevel;
+ ms_nNoOfWaterLevels++;
+}
+
+bool
+CWaterLevel::WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel)
+{
+ if (ms_nNoOfWaterLevels <= 0) return false;
+
+ for (int32 i = 0; i < ms_nNoOfWaterLevels; i++)
+ {
+ if (fX >= ms_aWaterRects[i].left && fX <= ms_aWaterRects[i].right
+ && fY >= ms_aWaterRects[i].top && fY <= ms_aWaterRects[i].bottom)
+ {
+ if (pfOutLevel) *pfOutLevel = ms_aWaterZs[i];
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+CWaterLevel::TestVisibilityForFineWaterBlocks(const CVector &worldPos)
+{
+ static CVector2D tab[] =
+ {
+ { 50.0f, 50.0f },
+ { -50.0f, 50.0f },
+ { -50.0f, -50.0f },
+ { 50.0f, -50.0f },
+ { 50.0f, 0.0f },
+ { -50.0f, 0.0f },
+ { 0.0f, -50.0f },
+ { 0.0f, 50.0f },
+ };
+
+ CEntity *entity;
+ CColPoint col;
+ CVector lineStart, lineEnd;
+
+ lineStart = worldPos;
+
+ if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
+ {
+ lineStart.x += 0.4f;
+ lineStart.y += 0.4f;
+
+ if (!CWorld::ProcessVerticalLine(lineStart, lineStart.z + 100.0f, col, entity, true, false, false, false, true, false, nil))
+ {
+ return false;
+ }
+ }
+
+ for (int32 i = 0; i < ARRAY_SIZE(tab); i++)
+ {
+ lineStart = worldPos;
+ lineEnd = worldPos;
+
+ lineEnd.x += tab[i].x;
+ lineEnd.y += tab[i].y;
+ lineEnd.z += 100.0f;
+
+ if ((lineEnd.x > WORLD_MIN_X && lineEnd.x < WORLD_MAX_X) && (lineEnd.y > WORLD_MIN_Y && lineEnd.y < WORLD_MAX_Y))
+ {
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ {
+ lineStart.x += 0.4f;
+ lineStart.y += 0.4f;
+ lineEnd.x += 0.4f;
+ lineEnd.y += 0.4f;
+
+ if (!CWorld::ProcessLineOfSight(lineStart, lineEnd, col, entity, true, false, false, false, true, false, nil))
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+void
+CWaterLevel::RemoveIsolatedWater()
+{
+ bool (*isConnected)[MAX_SMALL_SECTORS] = new bool[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ isConnected[x][y] = false;
+ }
+ }
+
+ isConnected[0][0] = true;
+ bool keepGoing;
+
+ do
+ {
+ keepGoing = false;
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] < 0 || isConnected[x][y])
+ continue;
+
+ if (x > 0 && isConnected[x - 1][y])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (y > 0 && isConnected[x][y - 1])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (x + 1 < MAX_SMALL_SECTORS && isConnected[x + 1][y])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+
+ if (y + 1 < MAX_SMALL_SECTORS && isConnected[x][y + 1])
+ {
+ isConnected[x][y] = true;
+ keepGoing = true;
+ }
+ }
+ }
+ }
+ while (keepGoing);
+
+ int32 numRemoved = 0;
+
+ for (int32 x = 0; x < MAX_SMALL_SECTORS; x++)
+ {
+ for (int32 y = 0; y < MAX_SMALL_SECTORS; y++)
+ {
+ if (aWaterFineBlockList[x][y] >= 0 && !isConnected[x][y] && ms_aWaterZs[aWaterFineBlockList[x][y]] == 0.0f)
+ {
+ numRemoved++;
+ aWaterFineBlockList[x][y] = NO_WATER;
+ }
+ }
+ }
+
+ printf("Removed %d isolated patches of water\n", numRemoved);
+
+ delete[] isConnected;
+}
+#endif
+
bool
CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ)
{
@@ -231,9 +526,9 @@ CWaterLevel::GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
- uint8 nBlock = aWaterFineBlockList[x][y];
+ int8 nBlock = aWaterFineBlockList[x][y];
- if ( nBlock == 128 )
+ if ( nBlock == NO_WATER )
return false;
ASSERT( pfOutLevel != NULL );
@@ -270,9 +565,9 @@ CWaterLevel::GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLeve
ASSERT( x >= 0 && x < HUGE_SECTOR_SIZE );
ASSERT( y >= 0 && y < HUGE_SECTOR_SIZE );
- uint8 nBlock = aWaterFineBlockList[x][y];
+ int8 nBlock = aWaterFineBlockList[x][y];
- if ( nBlock == 128 )
+ if ( nBlock == NO_WATER )
return false;
ASSERT( pfOutLevel != NULL );
@@ -418,10 +713,10 @@ CWaterLevel::RenderWater()
{
for ( int32 y = nStartY; y <= nEndY; y++ )
{
- if ( !(aWaterBlockList[2*x+0][2*y+0] & 128)
- || !(aWaterBlockList[2*x+1][2*y+0] & 128)
- || !(aWaterBlockList[2*x+0][2*y+1] & 128)
- || !(aWaterBlockList[2*x+1][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+0] >= 0
+ || aWaterBlockList[2*x+1][2*y+0] >= 0
+ || aWaterBlockList[2*x+0][2*y+1] >= 0
+ || aWaterBlockList[2*x+1][2*y+1] >= 0 )
{
float fX = WATER_FROM_HUGE_SECTOR_X(x);
float fY = WATER_FROM_HUGE_SECTOR_Y(y);
@@ -443,16 +738,16 @@ CWaterLevel::RenderWater()
{
float fZ;
- if ( !(aWaterBlockList[2*x+0][2*y+0] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+0] ];
- if ( !(aWaterBlockList[2*x+1][2*y+0] & 128) )
+ if ( aWaterBlockList[2*x+1][2*y+0] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+0] ];
- if ( !(aWaterBlockList[2*x+0][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+0][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+0][2*y+1] ];
- if ( !(aWaterBlockList[2*x+1][2*y+1] & 128) )
+ if ( aWaterBlockList[2*x+1][2*y+1] >= 0 )
fZ = ms_aWaterZs[ aWaterBlockList[2*x+1][2*y+1] ];
RenderOneFlatHugeWaterPoly(fX, fY, fZ, color);
@@ -463,7 +758,7 @@ CWaterLevel::RenderWater()
{
for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
{
- if ( !(aWaterBlockList[x2][y2] & 128) )
+ if ( aWaterBlockList[x2][y2] >= 0 )
{
float fLargeX = WATER_FROM_LARGE_SECTOR_X(x2);
float fLargeY = WATER_FROM_LARGE_SECTOR_Y(y2);
@@ -498,7 +793,7 @@ CWaterLevel::RenderWater()
float fZ;
// WS
- if ( !(aWaterFineBlockList[2*x2+0][2*y2+0] & 128) )
+ if ( aWaterFineBlockList[2*x2+0][2*y2+0] >= 0 )
{
float fSmallX = fLargeX;
float fSmallY = fLargeY;
@@ -519,7 +814,7 @@ CWaterLevel::RenderWater()
}
// SE
- if ( !(aWaterFineBlockList[2*x2+1][2*y2+0] & 128) )
+ if ( aWaterFineBlockList[2*x2+1][2*y2+0] >= 0 )
{
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY;
@@ -540,7 +835,7 @@ CWaterLevel::RenderWater()
}
// WN
- if ( !(aWaterFineBlockList[2*x2+0][2*y2+1] & 128) )
+ if ( aWaterFineBlockList[2*x2+0][2*y2+1] >= 0 )
{
float fSmallX = fLargeX;
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@@ -561,7 +856,7 @@ CWaterLevel::RenderWater()
}
//NE
- if ( !(aWaterFineBlockList[2*x2+1][2*y2+1] & 128) )
+ if ( aWaterFineBlockList[2*x2+1][2*y2+1] >= 0 )
{
float fSmallX = fLargeX + (LARGE_SECTOR_SIZE/2);
float fSmallY = fLargeY + (LARGE_SECTOR_SIZE/2);
@@ -591,7 +886,7 @@ CWaterLevel::RenderWater()
}
} // if ( TheCamera.IsSphereVisible
} // if ( fLargeSectorDistToCamSqr < fHugeSectorMaxRenderDistSqr )
- } // if ( !(aWaterBlockList[x2][y2] & 128) )
+ } // if ( aWaterBlockList[x2][y2] >= 0 )
} // for ( int32 y2 = 2*y; y2 <= 2*y+1; y2++ )
} // for ( int32 x2 = 2*x; x2 <= 2*x+1; x2++ )
//
@@ -1116,7 +1411,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
{
for ( int32 y = nStartY; y <= nEndY; y++ )
{
- if ( !(aWaterFineBlockList[x][y] & 128) )
+ if ( aWaterFineBlockList[x][y] >= 0 )
{
float fSectorX = WATER_FROM_SMALL_SECTOR_X(x);
float fSectorY = WATER_FROM_SMALL_SECTOR_Y(y);
diff --git a/src/render/WaterLevel.h b/src/render/WaterLevel.h
index 269d6091..cf3537ae 100644
--- a/src/render/WaterLevel.h
+++ b/src/render/WaterLevel.h
@@ -1,9 +1,9 @@
#pragma once
-#define WATER_BLOCK_SIZE LARGE_SECTOR_SIZE
-#define WATER_FINEBLOCK_SIZE HUGE_SECTOR_SIZE
#define WATER_Z_OFFSET (1.5f)
+#define NO_WATER -128
+
#define MAX_SMALL_SECTORS 128
#define MAX_LARGE_SECTORS 64
#define MAX_HUGE_SECTORS 32
@@ -23,7 +23,6 @@
#define WATER_WIDTH ((WATER_END_X - WATER_START_X))
#define WATER_HEIGHT ((WATER_END_Y - WATER_START_Y))
-
#define WATER_UNSIGN_X(x) ( (x) + (WATER_WIDTH /2) )
#define WATER_UNSIGN_Y(y) ( (y) + (WATER_HEIGHT/2) )
#define WATER_SIGN_X(x) ( (x) - (WATER_WIDTH /2) )
@@ -72,8 +71,8 @@ class CWaterLevel
static int32 ms_nNoOfWaterLevels;
static float ms_aWaterZs[48];
static CRect ms_aWaterRects[48];
- static uint8 aWaterBlockList[WATER_BLOCK_SIZE][WATER_BLOCK_SIZE];
- static uint8 aWaterFineBlockList[WATER_FINEBLOCK_SIZE][WATER_FINEBLOCK_SIZE];
+ static int8 aWaterBlockList[MAX_LARGE_SECTORS][MAX_LARGE_SECTORS];
+ static int8 aWaterFineBlockList[MAX_SMALL_SECTORS][MAX_SMALL_SECTORS];
static bool WavesCalculatedThisFrame;
static RpAtomic *ms_pWavyAtomic;
static RpGeometry *apGeomArray[MAX_BOAT_WAKES];
@@ -84,6 +83,10 @@ public:
static void Shutdown();
static void CreateWavyAtomic();
static void DestroyWavyAtomic();
+ static void AddWaterLevel(float fXLeft, float fYBottom, float fXRight, float fYTop, float fLevel);
+ static bool WaterLevelAccordingToRectangles(float fX, float fY, float *pfOutLevel = nil);
+ static bool TestVisibilityForFineWaterBlocks(const CVector &worldPos);
+ static void RemoveIsolatedWater();
static bool GetWaterLevel(float fX, float fY, float fZ, float *pfOutLevel, bool bDontCheckZ);
static bool GetWaterLevel(CVector coors, float *pfOutLevel, bool bDontCheckZ) { return GetWaterLevel(coors.x, coors.y, coors.z, pfOutLevel, bDontCheckZ); }
static bool GetWaterLevelNoWaves(float fX, float fY, float fZ, float *pfOutLevel);