Merge pull request #997 from Fire-Head/lcs

Lcs WaterCannon
This commit is contained in:
Sergeanur 2021-02-03 21:44:21 +02:00 committed by GitHub
commit 4f7793a423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 19 deletions

View File

@ -287,6 +287,7 @@ enum Config {
// Water & Particle // Water & Particle
// #define PC_WATER // #define PC_WATER
#define WATER_CHEATS #define WATER_CHEATS
//#define PSP_WATERCANNON
//#define USE_CUTSCENE_SHADOW_FOR_PED //#define USE_CUTSCENE_SHADOW_FOR_PED
#define DISABLE_CUTSCENE_SHADOWS #define DISABLE_CUTSCENE_SHADOWS

View File

@ -13,6 +13,16 @@
#include "Camera.h" #include "Camera.h"
#include "Particle.h" #include "Particle.h"
// --LCS: file done
#ifdef PSP_WATERCANNON
//PSP:
#define WATER_COLOR 255
#else
//PS2:
#define WATER_COLOR 127
#endif
#define WATERCANNONVERTS 4 #define WATERCANNONVERTS 4
#define WATERCANNONINDEXES 12 #define WATERCANNONINDEXES 12
@ -115,24 +125,34 @@ void CWaterCannon::Update_NewInput(CVector *pos, CVector *dir)
m_abUsed[m_nCur] = true; m_abUsed[m_nCur] = true;
} }
static float fWaterCannonU = 0.0f;
void CWaterCannon::Render(void) void CWaterCannon::Render(void)
{ {
extern RwRaster *gpFireHoseRaster;
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)TRUE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void *)TRUE);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpWaterRaster); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpFireHoseRaster);
float v = float(CGeneral::GetRandomNumber() & 255) / 256; fWaterCannonU += CTimer::GetTimeStepInSeconds() * 6.0f;
RwIm3DVertexSetV(&WaterCannonVertices[0], v);
RwIm3DVertexSetV(&WaterCannonVertices[1], v);
RwIm3DVertexSetV(&WaterCannonVertices[2], v);
RwIm3DVertexSetV(&WaterCannonVertices[3], v);
while ( fWaterCannonU >= 1.0f )
fWaterCannonU -= 1.0f;
RwIm3DVertexSetU(&WaterCannonVertices[0], -fWaterCannonU);
RwIm3DVertexSetV(&WaterCannonVertices[0], 0.0f);
RwIm3DVertexSetU(&WaterCannonVertices[1], -fWaterCannonU);
RwIm3DVertexSetV(&WaterCannonVertices[1], 1.0f);
RwIm3DVertexSetU(&WaterCannonVertices[2], 1.0f - fWaterCannonU);
RwIm3DVertexSetV(&WaterCannonVertices[2], 0.0f);
RwIm3DVertexSetU(&WaterCannonVertices[3], 1.0f - fWaterCannonU);
RwIm3DVertexSetV(&WaterCannonVertices[3], 1.0f);
int16 pointA = m_nCur % NUM_SEGMENTPOINTS; int16 pointA = m_nCur % NUM_SEGMENTPOINTS;
int16 pointB = pointA - 1; int16 pointB = pointA - 1;
if ( (pointA - 1) < 0 ) int16 pointC = pointA;
if ( pointB < 0 )
pointB += NUM_SEGMENTPOINTS; pointB += NUM_SEGMENTPOINTS;
bool bInit = false; bool bInit = false;
@ -142,6 +162,10 @@ void CWaterCannon::Render(void)
{ {
if ( m_abUsed[pointA] && m_abUsed[pointB] ) if ( m_abUsed[pointA] && m_abUsed[pointB] )
{ {
bool bFirst = false;
if ( i == 0 || m_abUsed[pointA] && !m_abUsed[pointC] )
bFirst = true;
if ( !bInit ) if ( !bInit )
{ {
CVector cp = CrossProduct(m_avecPos[pointB] - m_avecPos[pointA], TheCamera.GetForward()); CVector cp = CrossProduct(m_avecPos[pointB] - m_avecPos[pointA], TheCamera.GetForward());
@ -149,26 +173,25 @@ void CWaterCannon::Render(void)
bInit = true; bInit = true;
} }
float dist = float(i*i*i) / 300.0f + 1.0f;
float brightness = float(i) / NUM_SEGMENTPOINTS; float brightness = float(i) / NUM_SEGMENTPOINTS;
int32 color = (int32)((1.0f - brightness*brightness) * 255.0f); int32 color = (int32)((1.0f - brightness*brightness) * 255.0f);
CVector offset = dist * norm;
RwIm3DVertexSetRGBA(&WaterCannonVertices[0], color, color, color, color); CVector offset = (float(i)+1.0f) * norm;
RwIm3DVertexSetRGBA(&WaterCannonVertices[0], WATER_COLOR, WATER_COLOR, WATER_COLOR, bFirst ? 0 : color);
RwIm3DVertexSetPos (&WaterCannonVertices[0], m_avecPos[pointA].x - offset.x, m_avecPos[pointA].y - offset.y, m_avecPos[pointA].z - offset.z); RwIm3DVertexSetPos (&WaterCannonVertices[0], m_avecPos[pointA].x - offset.x, m_avecPos[pointA].y - offset.y, m_avecPos[pointA].z - offset.z);
RwIm3DVertexSetRGBA(&WaterCannonVertices[1], color, color, color, color); RwIm3DVertexSetRGBA(&WaterCannonVertices[1], WATER_COLOR, WATER_COLOR, WATER_COLOR, bFirst ? 0 : color);
RwIm3DVertexSetPos (&WaterCannonVertices[1], m_avecPos[pointA].x + offset.x, m_avecPos[pointA].y + offset.y, m_avecPos[pointA].z + offset.z); RwIm3DVertexSetPos (&WaterCannonVertices[1], m_avecPos[pointA].x + offset.x, m_avecPos[pointA].y + offset.y, m_avecPos[pointA].z + offset.z);
RwIm3DVertexSetRGBA(&WaterCannonVertices[2], color, color, color, color); offset = (float(i+1)+1.0f) * norm;
RwIm3DVertexSetRGBA(&WaterCannonVertices[2], WATER_COLOR, WATER_COLOR, WATER_COLOR, color);
RwIm3DVertexSetPos (&WaterCannonVertices[2], m_avecPos[pointB].x - offset.x, m_avecPos[pointB].y - offset.y, m_avecPos[pointB].z - offset.z); RwIm3DVertexSetPos (&WaterCannonVertices[2], m_avecPos[pointB].x - offset.x, m_avecPos[pointB].y - offset.y, m_avecPos[pointB].z - offset.z);
RwIm3DVertexSetRGBA(&WaterCannonVertices[3], color, color, color, color); RwIm3DVertexSetRGBA(&WaterCannonVertices[3], WATER_COLOR, WATER_COLOR, WATER_COLOR, color);
RwIm3DVertexSetPos (&WaterCannonVertices[3], m_avecPos[pointB].x + offset.x, m_avecPos[pointB].y + offset.y, m_avecPos[pointB].z + offset.z); RwIm3DVertexSetPos (&WaterCannonVertices[3], m_avecPos[pointB].x + offset.x, m_avecPos[pointB].y + offset.y, m_avecPos[pointB].z + offset.z);
LittleTest();
if ( RwIm3DTransform(WaterCannonVertices, WATERCANNONVERTS, NULL, rwIM3D_VERTEXUV) ) if ( RwIm3DTransform(WaterCannonVertices, WATERCANNONVERTS, NULL, rwIM3D_VERTEXUV) )
{ {
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, WaterCannonIndexList, WATERCANNONINDEXES); RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, WaterCannonIndexList, WATERCANNONINDEXES);
@ -176,6 +199,7 @@ void CWaterCannon::Render(void)
} }
} }
pointC = pointA;
pointA = pointB--; pointA = pointB--;
if ( pointB < 0 ) if ( pointB < 0 )
pointB += NUM_SEGMENTPOINTS; pointB += NUM_SEGMENTPOINTS;

View File

@ -14,6 +14,7 @@ public:
int32 m_nId; int32 m_nId;
int16 m_nCur; int16 m_nCur;
uint32 m_nTimeCreated; uint32 m_nTimeCreated;
int32 field_C;
CVector m_avecPos[NUM_SEGMENTPOINTS]; CVector m_avecPos[NUM_SEGMENTPOINTS];
CVector m_avecVelocity[NUM_SEGMENTPOINTS]; CVector m_avecVelocity[NUM_SEGMENTPOINTS];
bool m_abUsed[NUM_SEGMENTPOINTS]; bool m_abUsed[NUM_SEGMENTPOINTS];
@ -25,7 +26,7 @@ public:
void PushPeds(void); void PushPeds(void);
}; };
VALIDATE_SIZE(CWaterCannon, 412); VALIDATE_SIZE(CWaterCannon, 0x1A0);
class CWaterCannons class CWaterCannons
{ {