Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/storm-devs/storm-engine
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
q4a committed Jan 18, 2022
2 parents 5cfb7cd + 877a91a commit d9ae583
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 28 deletions.
80 changes: 66 additions & 14 deletions src/libs/battle_interface/src/land/battle_man_sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ BIManSign::BIManSign(entid_t BIEntityID, VDX9RENDER *pRS)
m_nBackTextureID = -1;
m_nManStateTextureID = -1;
m_nGunChargeTextureID = -1;
m_nGunReloadTextureID = -1;
m_nBackSquareQ = 0;
m_nManStateSquareQ = 0;
m_nGunChargeSquareQ = 0;

m_nGunReloadSquareQ = 0;
m_nMaxSquareQ = 0;
m_nSquareQ = 0;

Expand All @@ -38,9 +39,9 @@ BIManSign::BIManSign(entid_t BIEntityID, VDX9RENDER *pRS)

m_bIsAlarmOn = false;
m_nAlarmTextureID = -1;
m_fAlarmTime = 0.f;
m_fAlarmUpSpeed = 1.f;
m_fAlarmDownSpeed = 1.f;
m_fAlarmTime = 0.0f;
m_fAlarmUpSpeed = 1.0f;
m_fAlarmDownSpeed = 1.0f;
}

BIManSign::~BIManSign()
Expand Down Expand Up @@ -86,6 +87,15 @@ void BIManSign::Draw()
nStartV += 4;
}

//
if (m_nGunReloadSquareQ > 0)
{
m_pRS->TextureSet(0, m_nGunReloadTextureID);
m_pRS->DrawBuffer(m_nVBufID, sizeof(BI_COLOR_VERTEX), m_nIBufID, nStartV, m_nGunReloadSquareQ * 4, nStartI,
m_nGunReloadSquareQ * 2, "battle_tex_col_Rectangle");
}
nStartV += m_nGunReloadSquareQ * 4;

//
if (m_nBackSquareQ > 0)
{
Expand Down Expand Up @@ -177,6 +187,11 @@ void BIManSign::Init(ATTRIBUTES *pRoot, ATTRIBUTES *pA)

m_nCommandListVerticalOffset = -48;

m_nGunReloadTextureID = -1;
FULLRECT(m_rGunReloadUV);
ZERROPOINT(m_pntGunReloadOffset);
FILLPOINT(m_pntGunReloadIconSize, 0, 0);

for (n = 0; n < MAX_MAN_QUANTITY; n++)
{
m_Man[n].pntPos.x = 20.f;
Expand Down Expand Up @@ -267,7 +282,22 @@ void BIManSign::Init(ATTRIBUTES *pRoot, ATTRIBUTES *pA)
m_aChargeProgress.push_back(BIUtils::GetFromStr_Float(pcTmp, 0.f));
} while (pcTmp[0]);
}

pcTmp = pA->GetAttribute("gunreloadtexturename");
if (pcTmp)
m_nGunReloadTextureID = m_pRS->TextureCreate(pcTmp);
m_dwGunReloadColor = pA->GetAttributeAsDword("gunreloadcolor", m_dwGunReloadColor);
pcTmp = pA->GetAttribute("gunreloadUV");
if (pcTmp)
sscanf(pcTmp, "%f,%f,%f,%f", &m_rGunReloadUV.left, &m_rGunReloadUV.top, &m_rGunReloadUV.right, &m_rGunReloadUV.bottom);
pcTmp = pA->GetAttribute("gunreloadoffset");
if (pcTmp)
sscanf(pcTmp, "%f,%f", &m_pntGunReloadOffset.x, &m_pntGunReloadOffset.y);
pcTmp = pA->GetAttribute("gunreloadiconsize");
if (pcTmp)
sscanf(pcTmp, "%f,%f", &m_pntGunReloadIconSize.x, &m_pntGunReloadIconSize.y);
m_dwGunReloadBackColor = pA->GetAttributeAsDword("gunreloadbackcolor", m_dwGunReloadBackColor);


m_dwManFaceColor = pA->GetAttributeAsDword("manfacecolor", m_dwManFaceColor);
pcTmp = pA->GetAttribute("manfaceoffset");
if (pcTmp)
Expand Down Expand Up @@ -409,6 +439,7 @@ void BIManSign::Release()
m_nBackSquareQ = 0;
m_nManStateSquareQ = 0;
m_nGunChargeSquareQ = 0;
m_nGunReloadSquareQ = 0;
}

int32_t BIManSign::CalculateManQuantity()
Expand All @@ -426,6 +457,7 @@ int32_t BIManSign::CalculateManQuantity()
m_Man[n].bAlarm = false;
m_Man[n].nShootMax = 4;
m_Man[n].nShootCurrent = 0;
m_Man[n].fGunProgress = 0.0f;
}

auto *pAttr = m_pARoot ? m_pARoot->GetAttributeClass("data") : nullptr;
Expand All @@ -452,11 +484,13 @@ void BIManSign::UpdateBuffers(int32_t nShipQ)
m_nBackSquareQ = nShipQ;
m_nManStateSquareQ = nShipQ * 2;
m_nGunChargeSquareQ = nShipQ * 2;
m_nGunReloadSquareQ = nShipQ;
const auto nManSquareQ = nShipQ;
const int32_t nAlarmSquareQ = (m_bIsAlarmOn && (nShipQ > 0)) ? 1 : 0;

const auto nMaxSquareQ =
BIUtils::GetMaxFromFourLong(m_nBackSquareQ, m_nManStateSquareQ, m_nGunChargeSquareQ, nManSquareQ);
std::max({m_nBackSquareQ, m_nManStateSquareQ, m_nGunChargeSquareQ, m_nGunReloadSquareQ, nManSquareQ});

if (m_nMaxSquareQ != nMaxSquareQ)
{
m_nMaxSquareQ = nMaxSquareQ;
Expand All @@ -466,14 +500,15 @@ void BIManSign::UpdateBuffers(int32_t nShipQ)
FillIndexBuffer();
}

if ((m_nBackSquareQ + m_nManStateSquareQ + m_nGunChargeSquareQ + nManSquareQ + nAlarmSquareQ) != m_nSquareQ)
if ((m_nBackSquareQ + m_nManStateSquareQ + m_nGunChargeSquareQ + m_nGunReloadSquareQ + nManSquareQ +
nAlarmSquareQ) != m_nSquareQ)
{
m_nSquareQ = m_nBackSquareQ + m_nManStateSquareQ + m_nGunChargeSquareQ + nManSquareQ + nAlarmSquareQ;
m_nSquareQ =
m_nBackSquareQ + m_nManStateSquareQ + m_nGunChargeSquareQ + m_nGunReloadSquareQ + nManSquareQ + nAlarmSquareQ;
VERTEX_BUFFER_RELEASE(m_pRS, m_nVBufID);
m_nVBufID = m_pRS->CreateVertexBuffer(BI_COLOR_VERTEX_FORMAT, m_nSquareQ * 4 * sizeof(BI_COLOR_VERTEX),
D3DUSAGE_WRITEONLY);
}
// FillVertexBuffer();
}

void BIManSign::FillIndexBuffer() const
Expand Down Expand Up @@ -512,6 +547,14 @@ void BIManSign::FillVertexBuffer()
vn += WriteSquareToVBuff(&pV[vn], m_Man[n].rUV, m_dwManFaceColor, m_Man[n].pntPos + m_pntManPicOffset,
m_pntManPicIconSize);

// Gun reload status
for (n = 0; n < m_nManQuantity; n++)
{
vn += WriteSquareToVBuffWithProgress(&pV[vn], m_rGunReloadUV, m_dwGunReloadBackColor,
m_Man[n].pntPos + m_pntGunReloadOffset, m_pntGunReloadIconSize, 0.f,
0.f, 0.f, GetProgressGunReloadBar(n));
}

// back icon
for (n = 0; n < m_nManQuantity; n++)
vn += WriteSquareToVBuff(&pV[vn], m_rBackUV, m_dwBackColor, m_Man[n].pntPos + m_pntBackOffset,
Expand Down Expand Up @@ -557,8 +600,8 @@ int32_t BIManSign::WriteSquareToVBuff(BI_COLOR_VERTEX *pv, const FRECT &uv, uint
if (!pv)
return 0;

const auto fLeft = static_cast<float>(center.x - size.x / 2);
const auto fTop = static_cast<float>(center.y - size.y / 2);
const auto fLeft = center.x - size.x / 2;
const auto fTop = center.y - size.y / 2;
const auto fRight = fLeft + size.x;
const auto fBottom = fTop + size.y;

Expand Down Expand Up @@ -604,8 +647,8 @@ int32_t BIManSign::WriteSquareToVBuffWithProgress(BI_COLOR_VERTEX *pv, const FRE
if (!pv)
return 0;

auto fLeft = static_cast<float>(center.x - size.x / 2);
auto fTop = static_cast<float>(center.y - size.y / 2);
auto fLeft = center.x - size.x / 2;
auto fTop = center.y - size.y / 2;
auto fRight = fLeft + size.x;
auto fBottom = fTop + size.y;

Expand Down Expand Up @@ -673,7 +716,7 @@ int32_t BIManSign::GetCurrentCommandCharacterIndex() const
auto n = m_nCurrentManIndex;
if (n < 0 || n >= m_nManQuantity)
n = 0;
return static_cast<int32_t>(m_Man[n].nCharacterIndex);
return m_Man[n].nCharacterIndex;
}

int32_t BIManSign::GetCurrentCommandMode() const
Expand Down Expand Up @@ -709,6 +752,13 @@ float BIManSign::GetProgressGunCharge(int32_t nIdx)
return 1.f - GetGunProgressByIndex(m_Man[nIdx].nShootCurrent);
}

float BIManSign::GetProgressGunReloadBar(int32_t nIdx)
{
if (nIdx < 0 || nIdx >= m_nManQuantity)
return 1.0f;
return 1.0f - m_Man[nIdx].fGunProgress;
}

float BIManSign::GetGunProgressByIndex(int32_t nIdx)
{
if (nIdx < 0 || nIdx >= m_aChargeProgress.size())
Expand Down Expand Up @@ -748,6 +798,8 @@ void BIManSign::CheckDataChange()
m_bMakeVertexFill = true;
if (FRectACompare(pA, "uv", m_Man[n].rUV))
m_bMakeVertexFill = true;
if (FloatACompare(pA, "gunprogress", m_Man[n].fGunProgress))
m_bMakeVertexFill = true;
if (StringACompare(pA, "texture", m_Man[n].sTexture))
{
TEXTURE_RELEASE(m_pRS, m_Man[n].nTexture);
Expand Down
11 changes: 10 additions & 1 deletion src/libs/battle_interface/src/land/battle_man_sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BIManSign
float GetProgressManEnergy(int32_t nIdx) const;
float GetProgressGunChargeMax(int32_t nIdx);
float GetProgressGunCharge(int32_t nIdx);

float GetProgressGunReloadBar(int32_t nIdx);
float GetGunProgressByIndex(int32_t nIdx);

void CheckDataChange();
Expand Down Expand Up @@ -114,6 +114,14 @@ class BIManSign
BIFPOINT m_pntGunChargeOffset;
FPOINT m_pntGunChargeIconSize;

int32_t m_nGunReloadTextureID;
int32_t m_nGunReloadSquareQ;
uint32_t m_dwGunReloadColor;
uint32_t m_dwGunReloadBackColor;
FRECT m_rGunReloadUV;
BIFPOINT m_pntGunReloadOffset;
FPOINT m_pntGunReloadIconSize;

std::vector<float> m_aChargeProgress;

FRECT m_rManPicUV;
Expand All @@ -135,6 +143,7 @@ class BIManSign
bool bAlarm;
int32_t nShootMax;
int32_t nShootCurrent;
float fGunProgress;
} m_Man[MAX_MAN_QUANTITY];

int32_t m_nManQuantity;
Expand Down
30 changes: 17 additions & 13 deletions src/libs/location/src/location_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define LOCATIONCAMERA_DISTALPHA_MAX 1.6f // Distance from the character at which it is necessary to fade out alpha
#define LOCATIONCAMERA_DISTALPHA_MIN 0.8f // Distance from the character at which it is necessary to fade out alpha

#define LOCATIONCAMERA_PERSPECTIVE (1.57f + 1.0f) * 0.5f
#define LOCATIONCAMERA_DEFAULT_PERSPECTIVE (1.57f + 1.0f) * 0.5f

// ============================================================================================
// Construction, destruction
Expand Down Expand Up @@ -71,6 +71,8 @@ LocationCamera::LocationCamera()
dynamic_fog.isOn = false;

m_bTrackMode = false;

cameraPerspective = LOCATIONCAMERA_DEFAULT_PERSPECTIVE;
}

LocationCamera::~LocationCamera()
Expand Down Expand Up @@ -100,7 +102,7 @@ bool LocationCamera::Init()
// try to get the location
loc = EntityManager::GetEntityId("location");

rs->SetPerspective(LOCATIONCAMERA_PERSPECTIVE);
rs->SetPerspective(cameraPerspective);
// rs->SetPerspective(1.0f);

StoreRestoreDynamicFov(false);
Expand Down Expand Up @@ -404,7 +406,9 @@ uint64_t LocationCamera::ProcessMessage(MESSAGE &message)
case MSG_CAMERA_SET_RADIUS:
radius = message.Float();
return 1;

case MSG_CAMERA_SET_PERSPECTIVE:
cameraPerspective = message.Float();
return 1;
// internal
case -1: {
const auto fSpeed = message.Float();
Expand Down Expand Up @@ -611,17 +615,17 @@ void LocationCamera::Clip(PLANE *p, int32_t numPlanes, CVECTOR &cnt, float rad,
void LocationCamera::TurnOnDynamicFov(float fSpeed, float fTime, float fRelationMin, float fRelationMax,
float fAngSpeed, float fAngMax)
{
dynamic_fog.fMinFov = LOCATIONCAMERA_PERSPECTIVE * fRelationMin;
dynamic_fog.fMaxFov = LOCATIONCAMERA_PERSPECTIVE * fRelationMax;
dynamic_fog.fMinFov = cameraPerspective * fRelationMin;
dynamic_fog.fMaxFov = cameraPerspective * fRelationMax;
if (!dynamic_fog.isOn)
{
dynamic_fog.fCurFov = LOCATIONCAMERA_PERSPECTIVE;
dynamic_fog.fCurFov = cameraPerspective;
dynamic_fog.bFogUp = true;
dynamic_fog.fCurAngle = 0.f;
dynamic_fog.bAngleUp = true;
}
dynamic_fog.isOn = true;
dynamic_fog.fFogChangeSpeed = fSpeed * LOCATIONCAMERA_PERSPECTIVE;
dynamic_fog.fFogChangeSpeed = fSpeed * cameraPerspective;
dynamic_fog.fFogTimeCur = 0;
dynamic_fog.fFogTimeMax = fTime;

Expand All @@ -635,7 +639,7 @@ void LocationCamera::ProcessDynamicFov(float fDeltaTime, const CVECTOR &vFrom, c
dynamic_fog.fFogTimeCur += fDeltaTime;
if (dynamic_fog.fFogTimeMax > 0.f && dynamic_fog.fFogTimeCur >= dynamic_fog.fFogTimeMax)
{
rs->SetPerspective(LOCATIONCAMERA_PERSPECTIVE);
rs->SetPerspective(cameraPerspective);
dynamic_fog.isOn = false;
}
else
Expand Down Expand Up @@ -723,9 +727,9 @@ void LocationCamera::StoreRestoreDynamicFov(bool bStore)
dynamic_fog.isOn = pA->GetAttributeAsDword("ison", false) != 0;
if (dynamic_fog.isOn)
{
dynamic_fog.fMinFov = pA->GetAttributeAsFloat("minfov", LOCATIONCAMERA_PERSPECTIVE);
dynamic_fog.fMaxFov = pA->GetAttributeAsFloat("maxfov", LOCATIONCAMERA_PERSPECTIVE);
dynamic_fog.fCurFov = pA->GetAttributeAsFloat("curfov", LOCATIONCAMERA_PERSPECTIVE);
dynamic_fog.fMinFov = pA->GetAttributeAsFloat("minfov", cameraPerspective);
dynamic_fog.fMaxFov = pA->GetAttributeAsFloat("maxfov", cameraPerspective);
dynamic_fog.fCurFov = pA->GetAttributeAsFloat("curfov", cameraPerspective);
dynamic_fog.bFogUp = pA->GetAttributeAsDword("fogup", true) != 0;
dynamic_fog.fFogChangeSpeed = pA->GetAttributeAsFloat("speed", 0.1f);
dynamic_fog.fFogTimeCur = pA->GetAttributeAsFloat("timecur", 0.f);
Expand Down Expand Up @@ -764,7 +768,7 @@ bool LocationCamera::LoadCameraTrack(const char *pcTrackFile, float fTrackTime)
view.Inverse();
view.pos = view * -pos;
rs->SetView(*(CMatrix *)&view);
rs->SetPerspective(LOCATIONCAMERA_PERSPECTIVE);
rs->SetPerspective(cameraPerspective);

return true;
}
Expand Down Expand Up @@ -811,7 +815,7 @@ void LocationCamera::ProcessTrackCamera()
view.Inverse();
view.pos = view * -pos;
rs->SetView(*(CMatrix *)&view);
rs->SetPerspective(LOCATIONCAMERA_PERSPECTIVE);
rs->SetPerspective(cameraPerspective);
}

float LocationCamera::TrackPauseProcess()
Expand Down
2 changes: 2 additions & 0 deletions src/libs/location/src/location_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ class LocationCamera : public Entity
PathTracks m_track;

bool forcedPos = false;

float cameraPerspective;
};

inline void LocationCamera::LockFPMode(bool isLock)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/shared_headers/include/shared/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
#define MSG_CAMERA_SLEEP 30520 // "ll" stop the camera (1) or resume (0)
#define MSG_CAMERA_SET_RADIUS 30521 // "lf" set radius

#define MSG_CAMERA_SET_PERSPECTIVE 30530 // "lf" set perspective

// Blots on the ship
#define MSG_BLOTS_SETMODEL 30600 // "li" set the model, model_id
#define MSG_BLOTS_HIT 30601 // "lffffff" set point x, y, z, nx, ny, nz
Expand Down

0 comments on commit d9ae583

Please sign in to comment.