Commit c068534b authored by D-AIRY's avatar D-AIRY

Model glow; option to disable lights in editor; minor fixes

parent 526e8543
......@@ -61,6 +61,7 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sxanim", "..\..\sxanim\vs2013\sxanim.vcxproj", "{709D8A7A-D3E0-4070-A493-EFDF7A8E9D73}"
ProjectSection(ProjectDependencies) = postProject
{AEECC2DB-C7C7-4089-9262-A69794DF834D} = {AEECC2DB-C7C7-4089-9262-A69794DF834D}
{8144D5F8-07D0-4663-AAAE-11053614FAC5} = {8144D5F8-07D0-4663-AAAE-11053614FAC5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sxwincreator", "..\..\sxwincreator\vs2013\sxwincreator.vcxproj", "{AFBF200A-9260-4469-AE64-DCB42C796DD6}"
......
......@@ -9,6 +9,7 @@ See the license in LICENSE
#include <cstdio>
#include <common/sxtypes.h>
#include <gcore/sxgcore.h>
#include <mtrl/sxmtrl.h>
/**
*
......@@ -136,7 +137,7 @@ void ModelFile::Load(const char * name)
{
fread(m_iMaterials[j][i].szName, 1, MODEL_MAX_NAME, fp);
m_iMaterials[j][i].iMat = m_pMgr->getMaterial(m_iMaterials[j][i].szName, m_hdr.iFlags & MODEL_FLAG_STATIC); //3
m_iMaterials[j][i].iMat = m_pMgr->getMaterial(m_iMaterials[j][i].szName, (m_hdr.iFlags & MODEL_FLAG_STATIC) != 0); //3
}
}
......@@ -200,7 +201,7 @@ void ModelFile::Load(const char * name)
vertex_static *pSource = new vertex_static[m_pLods[i].pSubLODmeshes[j].iVectexCount];
fread(pSource, sizeof(vertex_static), m_pLods[i].pSubLODmeshes[j].iVectexCount, fp);
vertex_static_ex *pTarget = (vertex_static_ex*)m_pLods[i].pSubLODmeshes[j].pVertices;
for(int vi = 0; vi < m_pLods[i].pSubLODmeshes[j].iVectexCount; ++vi)
for(uint32_t vi = 0; vi < m_pLods[i].pSubLODmeshes[j].iVectexCount; ++vi)
{
memcpy(&(pTarget[vi]), &(pSource[vi]), sizeof(vertex_static));
}
......@@ -219,7 +220,7 @@ void ModelFile::Load(const char * name)
vertex_animated *pSource = new vertex_animated[m_pLods[i].pSubLODmeshes[j].iVectexCount];
fread(pSource, sizeof(vertex_animated), m_pLods[i].pSubLODmeshes[j].iVectexCount, fp);
vertex_animated_ex *pTarget = (vertex_animated_ex*)m_pLods[i].pSubLODmeshes[j].pVertices;
for(int vi = 0; vi < m_pLods[i].pSubLODmeshes[j].iVectexCount; ++vi)
for(uint32_t vi = 0; vi < m_pLods[i].pSubLODmeshes[j].iVectexCount; ++vi)
{
memcpy(&(pTarget[vi]), &(pSource[vi]), sizeof(vertex_static)); //!< Copy only first three fields
memcpy(pTarget[vi].BoneIndices, pSource[vi].BoneIndices, sizeof(pSource[vi].BoneIndices));
......@@ -402,7 +403,7 @@ UINT ModelFile::GetControllersCount() const
return(m_hdr2.iControllersCount);
}
#ifndef _SERVER
void ModelFile::render(SMMATRIX * mWorld, UINT nSkin, UINT nLod, ID idOverrideMaterial)
void ModelFile::render(SMMATRIX * mWorld, UINT nSkin, UINT nLod, ID idOverrideMaterial, const float3_t *pGlowColor, bool bUseGlow)
{
if(nSkin >= m_hdr.iSkinCount)
{
......@@ -428,13 +429,23 @@ void ModelFile::render(SMMATRIX * mWorld, UINT nSkin, UINT nLod, ID idOverrideMa
m_pMgr->setVertexDeclaration(vtype);
ID idMat;
for(UINT i = 0; i < m_pLods[nLod].iSubMeshCount; i++)
{
//m_pMgr->SetMaterial(m_iMaterials[nSkin][m_pLods[nLod].pSubLODmeshes[i].iMaterialID].iMat);
idMat = ID_VALID(idOverrideMaterial) ? idOverrideMaterial : m_iMaterials[nSkin][m_pLods[nLod].pSubLODmeshes[i].iMaterialID].iMat;
SGCore_MtlSet(ID_VALID(idOverrideMaterial) ? idOverrideMaterial : m_iMaterials[nSkin][m_pLods[nLod].pSubLODmeshes[i].iMaterialID].iMat, mWorld);
if(SMtrl_MtlGetUseDestColor(idMat))
{
if(bUseGlow)
{
SMtrl_MtlSetLighting(idMat, false);
}
else
{
SMtrl_MtlSetLighting(idMat, true);
}
}
SGCore_MtlSet(idMat, mWorld, pGlowColor ? &float4(*pGlowColor, 1.0f) : 0);
SGCore_DIP(
D3DPT_TRIANGLELIST,
m_pLods[nLod].pSubLODmeshes[i].iStartVertex,
......@@ -629,7 +640,7 @@ void ModelFile::BuildMeshBuffers()
UINT * pIndices = new UINT[iStartIndex];
model_vertex * pVertices;
bool isStatic = m_hdr.iFlags & MODEL_FLAG_STATIC;
bool isStatic = (m_hdr.iFlags & MODEL_FLAG_STATIC) != 0;
if(isStatic)
{
pVertices = new vertex_static_ex[iStartVertex];
......@@ -930,7 +941,7 @@ SMMATRIX Animation::getBoneTransform(UINT _id, bool bWithScale)
{
//id *= 2;
int id = m_FinalBones[_id].pid;
if(id < 0 || id >= m_pMdl->m_hdr2.iBoneTableCount)
if(id < 0 || (uint32_t)id >= m_pMdl->m_hdr2.iBoneTableCount)
{
return(SMMatrixIdentity());
}
......@@ -1693,7 +1704,16 @@ void Animation::render()
m_pMgr->m_pd3dDevice->SetVertexShaderConstantF(16, (float*)m_pBoneMatrixRender, sizeof(ModelBoneShader)* m_iBoneCount / sizeof(float) / 4);
}
m_pMdl->render(&(getWorldTM()), m_iCurrentSkin, 0, m_idOverrideMaterial);
m_pMdl->render(&(getWorldTM()), m_iCurrentSkin, 0, m_idOverrideMaterial, &m_vGlowColor, m_isGlowEnabled);
}
void Animation::setGlowColor(const float3_t &vColor)
{
m_vGlowColor = vColor;
}
void Animation::setGlowEnabled(bool isEnabled)
{
m_isGlowEnabled = isEnabled;
}
void Animation::setOverrideMaterial(const char *name)
......@@ -1943,7 +1963,7 @@ void Animation::assembly()
vszMats.push_back(mdl->m_iMaterials[0][ii].szName);
}
}
bool isStatic = mdl->m_hdr.iFlags & MODEL_FLAG_STATIC;
bool isStatic = (mdl->m_hdr.iFlags & MODEL_FLAG_STATIC) != 0;
if(isStatic)
{
m_pMdl->m_hdr.iFlags |= MODEL_FLAG_STATIC;
......
......@@ -43,7 +43,7 @@ public:
bool Save(const char * name);
#ifndef _SERVER
void render(SMMATRIX * mWorld, UINT nSkin, UINT nLod=0, ID idOverrideMaterial=-1);
void render(SMMATRIX * mWorld, UINT nSkin, UINT nLod=0, ID idOverrideMaterial=-1, const float3_t *pGlowColor=NULL, bool bUseGlow=false);
#endif
void BuildMeshBuffers();
......@@ -231,6 +231,9 @@ public:
virtual bool isVisibleFor(ID id);
virtual void setGlowColor(const float3_t &vColor);
virtual void setGlowEnabled(bool isEnabled);
//static void AssemblyMdl(ModelFile * pOut, const Array<ModelPart*> & mMdls);
protected:
......@@ -315,6 +318,9 @@ protected:
bool m_isMdlManaged;
bool m_isGlowEnabled = false;
float3_t m_vGlowColor;
private:
ISXBound * m_pBoundBox;
void AppendMesh(ModelLoDSubset * to, ModelLoDSubset * from, Array<int> & bone_relink, bool isStatic=false);
......
......@@ -51,8 +51,10 @@ See the license in LICENSE
#if defined(_DEBUG)
#pragma comment(lib, "sxgcore_d.lib")
#pragma comment(lib, "sxmtrl_d.lib")
#else
#pragma comment(lib, "sxgcore.lib")
#pragma comment(lib, "sxmtrl.lib")
#endif
class IAnimPlayer;
......@@ -296,6 +298,9 @@ public:
virtual void setRagdoll(IAnimRagdoll * pRagdoll) = 0;
virtual bool isVisibleFor(ID id) = 0;
virtual void setGlowColor(const float3_t &vColor) = 0;
virtual void setGlowEnabled(bool isEnabled) = 0;
};
//! \name Функции управления анимацией
......
......@@ -20,6 +20,11 @@ BEGIN_PROPTABLE(CBaseAnimating)
//! Масштаб модели
DEFINE_FIELD_FLOAT(m_fBaseScale, 0, "scale", "Scale", EDITOR_TEXTFIELD)
//! Объект референса для цвета свечения
DEFINE_FIELD_ENTITY(m_pEntColorRef, 0, "glow_color_ref", "Glow color reference", EDITOR_TEXTFIELD)
//! Цвет свечения
DEFINE_FIELD_VECTOR(m_vGlowColor, 0, "glow_color", "Glow color", EDITOR_TEXTFIELD)
DEFINE_FIELD_BOOLFN(m_isStatic, 0, "is_static", "Is static", onIsStaticChange, EDITOR_COMBOBOX)
COMBO_OPTION("Yes", "1")
COMBO_OPTION("No", "0")
......@@ -159,6 +164,11 @@ void CBaseAnimating::onSync()
m_pAnimPlayer->setScale(m_fBaseScale);
m_pAnimPlayer->setPos(getPos());
m_pAnimPlayer->setOrient(getOrient());
float3_t vGlowColor = m_vGlowColor;
bool isGlowEnabled = m_pEntColorRef ? m_pEntColorRef->getMainColor(&vGlowColor) : m_vGlowColor.x != 0.0f || m_vGlowColor.y != 0.0f || m_vGlowColor.z != 0.0f;
m_pAnimPlayer->setGlowColor(vGlowColor);
m_pAnimPlayer->setGlowEnabled(isGlowEnabled);
}
}
......
......@@ -73,6 +73,9 @@ protected:
float m_fBaseScale;
bool m_isStatic;
CBaseEntity *m_pEntColorRef = NULL;
float3_t m_vGlowColor;
virtual void initPhysics();
virtual void releasePhysics();
virtual void createPhysBody();
......
......@@ -331,6 +331,7 @@ bool CBaseEntity::setKV(const char * name, const char * value)
UINT * f = &(this->*((UINT ThisClass::*)field->pField));
*f &= 0xFFFF;
*f |= d & 0xFFFF0000;
updateFlags();
return(true);
}
return(false);
......@@ -553,6 +554,7 @@ void CBaseEntity::onSync()
void CBaseEntity::onPostLoad()
{
updateOutputs();
updateFlags();
}
float3 CBaseEntity::getAttachmentPos(int id)
......
......@@ -126,6 +126,14 @@ public:
return(false);
}
virtual bool getMainColor(float3_t *pOut)
{
return(false);
}
//! Обновляет действие флагов в режиме редактора уровня
virtual void updateFlags(){}
private:
void setClassName(const char * name);
void setDefaults();
......
......@@ -185,17 +185,17 @@ void CHUDcontroller::fadeScreenDmg()
void CHUDcontroller::chatMsg(const char *msg)
{
static const float *s_fChatTime = GET_PCVAR_FLOAT("hud_chat_time");
static const int *s_fChatLines = GET_PCVAR_INT("hud_chat_lines");
static const int *s_iChatLines = GET_PCVAR_INT("hud_chat_lines");
if(m_pChatLog)
{
m_pChatLog->appendHTML(StringW(L"<div>")+StringW(String(msg))+L"</div>");
while(m_pChatLog->getChilds()->size() > *s_fChatLines)
while((int)m_pChatLog->getChilds()->size() > *s_iChatLines)
{
m_pChatLog->removeChild(m_pChatLog->getChilds()[0][0]);
}
m_pChatLog->removePseudoclass(0x00004);
m_i64TimeHideChat = TimeGetMcsU(Core_RIntGet(G_RI_INT_TIMER_RENDER)) + *s_fChatTime * 1000000.0f;
m_i64TimeHideChat = TimeGetMcsU(Core_RIntGet(G_RI_INT_TIMER_RENDER)) + (int64_t)(*s_fChatTime * 1000000.0f);
}
}
......
......@@ -34,6 +34,8 @@ BEGIN_PROPTABLE(CLightDirectional)
//! Верхний радиус
DEFINE_FIELD_FLOAT(m_fRadiusTop, 0, "radius_top", "Radius top", EDITOR_TEXTFIELD)
//! Изначально выключена
DEFINE_FLAG(LIGHT_INITIALLY_DARK, "Initially dark")
END_PROPTABLE()
REGISTER_ENTITY(CLightDirectional, light_directional);
......@@ -110,3 +112,21 @@ void CLightDirectional::onSync()
if (SLight_GetTopRadius(m_idLight) != m_fRadiusTop)
SLight_SetTopRadius(m_idLight, m_fRadiusTop);
}
bool CLightDirectional::getMainColor(float3_t *pOut)
{
if(pOut)
{
*pOut = m_vColor;
}
return(m_isEnable);
}
void CLightDirectional::updateFlags()
{
BaseClass::updateFlags();
m_isEnable = !(getFlags() & LIGHT_INITIALLY_DARK);
}
......@@ -14,6 +14,10 @@ See the license in LICENSE
#include "PointEntity.h"
#ifndef LIGHT_INITIALLY_DARK
#define LIGHT_INITIALLY_DARK ENT_FLAG_0
#endif
/*! Направленный свет
\ingroup clight
*/
......@@ -51,6 +55,10 @@ public:
void setRadiusTop(float fRadiusTop) { m_fRadiusTop = fRadiusTop; };
float getRadiusTop() const { return m_fRadiusTop; };
bool getMainColor(float3_t *pOut);
void updateFlags();
protected:
void onSync();
......
......@@ -130,9 +130,18 @@ void CLightPoint::setEnable(bool isEnable)
}
}
void CLightPoint::onPostLoad()
void CLightPoint::updateFlags()
{
BaseClass::updateFlags();
m_isEnable = !(getFlags() & LIGHT_INITIALLY_DARK);
}
BaseClass::onPostLoad();
bool CLightPoint::getMainColor(float3_t *pOut)
{
if(pOut)
{
*pOut = m_vColor;
}
return(m_isEnable);
}
......@@ -47,11 +47,13 @@ public:
void setEnable(bool isEnable);
bool getEnable() const { return m_isEnable; };
bool getMainColor(float3_t *pOut);
void updateFlags();
protected:
ID m_idLight;
void onPostLoad();
float3_t m_vColor;
float m_fDist;
float m_fShadowDist;
......
......@@ -131,9 +131,9 @@ void CPropButton::toggle(inputdata_t * pInputdata)
void CPropButton::onPostLoad()
{
m_isEnabled = !(getFlags() & BUTTON_START_DISABLED);
m_isToggleable = (getFlags() & BUTTON_TOGGLEABLE);
m_bState = (getFlags() & BUTTON_START_PRESSED);
m_isEnabled = (getFlags() & BUTTON_START_DISABLED) == 0;
m_isToggleable = (getFlags() & BUTTON_TOGGLEABLE) != 0;
m_bState = (getFlags() & BUTTON_START_PRESSED) != 0;
BaseClass::onPostLoad();
}
......
......@@ -79,8 +79,8 @@ CPropDoor::~CPropDoor()
void CPropDoor::onPostLoad()
{
m_isLocked = (getFlags() & DOOR_START_LOCKED);
m_bState = (getFlags() & DOOR_START_OPENED);
m_isLocked = (getFlags() & DOOR_START_LOCKED) != 0;
m_bState = (getFlags() & DOOR_START_OPENED) != 0;
BaseClass::onPostLoad();
......
......@@ -69,12 +69,13 @@ enum PDF_FLAG
enum ENT_FLAG
{
EF_NONE = 0x0000,
EF_EXPORT = 0x0001,
EF_LEVEL = 0x0002,
EF_REMOVED = 0x0004,
EF_NONE = 0x0000,
EF_EXPORT = 0x0001,
EF_LEVEL = 0x0002,
EF_REMOVED = 0x0004,
EF_NO_WORLD_LOOKUP = 0x0008,
EF_LAST = 0x8000
EF_LAST = 0x8000
};
typedef int CBaseEntity::*fieldtype;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment