Skip to content

Commit

Permalink
iv update
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Mar 11, 2022
1 parent 04be683 commit bbf923d
Show file tree
Hide file tree
Showing 9 changed files with 2,528 additions and 2,071 deletions.
Binary file added data/2DFXDataGrabber/iv_data.7z
Binary file not shown.
Binary file added data/2DFXDataGrabber/lcs_data.7z
Binary file not shown.
Binary file added data/2DFXDataGrabber/vcs_data.7z
Binary file not shown.
4,094 changes: 2,145 additions & 1,949 deletions data/IVLodLights/IVLodLights.dat

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions includes/CLODLightManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ void CLODLightManager::LoadDatFile()
float fOffsetX, fOffsetY, fOffsetZ;
unsigned int nRed, nGreen, nBlue, nAlpha;
float fCustomSize = 1.0f;
float fDrawDistance = 0.0f;
int nNoDistance = 0;
int nDrawSearchlight = 0;
int nCoronaShowMode = 0;
sscanf(pLine, "%d %d %d %d %f %f %f %f %d %d %d", &nRed, &nGreen, &nBlue, &nAlpha, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nCoronaShowMode, &nNoDistance, &nDrawSearchlight);
pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast<unsigned char>(nRed), static_cast<unsigned char>(nGreen), static_cast<unsigned char>(nBlue), static_cast<unsigned char>(nAlpha)), fCustomSize, nCoronaShowMode, nNoDistance, nDrawSearchlight, 0.0f)));
if (sscanf(pLine, "%3d %3d %3d %3d %f %f %f %f %f %2d %1d %1d", &nRed, &nGreen, &nBlue, &nAlpha, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &fDrawDistance, &nCoronaShowMode, &nNoDistance, &nDrawSearchlight) != 12)
sscanf(pLine, "%3d %3d %3d %3d %f %f %f %f %2d %1d %1d", &nRed, &nGreen, &nBlue, &nAlpha, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nCoronaShowMode, &nNoDistance, &nDrawSearchlight);
pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast<unsigned char>(nRed), static_cast<unsigned char>(nGreen), static_cast<unsigned char>(nBlue), static_cast<unsigned char>(nAlpha)), fCustomSize, nCoronaShowMode, nNoDistance, nDrawSearchlight, 0.0f, fDrawDistance)));
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions includes/CLODLightManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class CLamppostInfo
int nDrawSearchlight;
float fHeading;
int nCoronaShowMode;
float fObjectDrawDistance;

CLamppostInfo(const CVector& pos, const CRGBA& col, float fCustomMult, int CoronaShowMode, int nNoDistance, int nDrawSearchlight, float heading)
: vecPos(pos), colour(col), fCustomSizeMult(fCustomMult), nCoronaShowMode(CoronaShowMode), nNoDistance(nNoDistance), nDrawSearchlight(nDrawSearchlight), fHeading(heading)
CLamppostInfo(const CVector& pos, const CRGBA& col, float fCustomMult, int CoronaShowMode, int nNoDistance, int nDrawSearchlight, float heading, float ObjectDrawDistance = 0.0f)
: vecPos(pos), colour(col), fCustomSizeMult(fCustomMult), nCoronaShowMode(CoronaShowMode), nNoDistance(nNoDistance), nDrawSearchlight(nDrawSearchlight), fHeading(heading), fObjectDrawDistance(ObjectDrawDistance)
{}
};

Expand Down
38 changes: 38 additions & 0 deletions includes/Maths.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef __MATHS__H
#define __MATHS__H

#define _USE_MATH_DEFINES
#include <math.h>
#include "rwsdk\rwcore.h"

#define RAD_TO_DEG (180.0/M_PI)
#define DEG_TO_RAD (M_PI/180.0)
#define RADTODEG(x) ((x) * 180.0f / M_PI)

class CVector
{
Expand Down Expand Up @@ -502,4 +504,40 @@ inline CVector& CVector::FromMultiply3X3(const CMatrix& mat, const CVector& vec)
return *this = Multiply3x3(mat, vec);
}

static CMatrix identMat = {
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f },
};

inline RwV3d makeV3d(float x, float y, float z) { RwV3d v = { x, y, z }; return v; }
inline float dot(const RwV3d& a, const RwV3d& b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
inline RwV3d scale(const RwV3d& a, float r) { return makeV3d(a.x * r, a.y * r, a.z * r); }
inline void makeRotation(CMatrix* dst, const RwV3d* axis, float angle, const RwV3d* translation)
{
float len = dot(*axis, *axis);
if (len != 0.0f) len = 1.0f / sqrtf(len);
RwV3d v = scale(*axis, len);
angle = angle * (float)M_PI / 180.0f;
float s = sinf(angle);
float c = cosf(angle);
float t = 1.0f - c;

*dst = identMat;
dst->matrix.pos = *translation;
dst->matrix.right.x = c + v.x * v.x * t;
dst->matrix.right.y = v.x * v.y * t + v.z * s;
dst->matrix.right.z = v.z * v.x * t - v.y * s;
dst->matrix.up.x = v.x * v.y * t - v.z * s;
dst->matrix.up.y = c + v.y * v.y * t;
dst->matrix.up.z = v.y * v.z * t + v.x * s;
dst->matrix.at.x = v.z * v.x * t + v.y * s;
dst->matrix.at.y = v.y * v.z * t - v.x * s;
dst->matrix.at.z = c + v.z * v.z * t;
//dst->matrix.pos.x = 0.0;
//dst->matrix.pos.y = 0.0;
//dst->matrix.pos.z = 0.0;
}

#endif
Loading

0 comments on commit bbf923d

Please sign in to comment.