Commit 526e8543 authored by Byurrrer's avatar Byurrrer

добавил параметр title для уровня, он просто загружается и...

добавил параметр title для уровня, он просто загружается и сохраняется,материалам добавил свойство "принимать цвет", поправил соответствующие для этого функции
parent 6e454ca2
/*
mtrlgeom_base.ps
Базовый рендер геометрии
*/
#include <../struct.h>
#include <../mtrl.h>
//##########################################################################
sampler2D g_sColor:register(s0);
sampler2D g_sParameters:register(s10);
//##########################################################################
half4 g_vDestColor;
half4 g_vNearFarLayers;
//##########################################################################
PSO_Gbuffer main(VSO_SceneCommon IN)
{
ClipFar(IN.vPos.z, g_vNearFarLayers.y);
IN.vNormal = normalize(IN.vNormal);
half4 vColor = tex2D(g_sColor,IN.vTexUV);
vColor.rgb = lerp(g_vDestColor.rgb, vColor.rgb, vColor.a);
return CreateGbuffer(vColor, IN.vNormal, tex2D(g_sParameters,IN.vTexUV), IN.vPos, g_vNearFarLayers);
}
\ No newline at end of file
......@@ -18,5 +18,5 @@ half4 g_vNearFarLayers;
PSO_Gbuffer main(VSO_SceneCommon IN)
{
ClipFar(IN.vPos.z,g_vNearFarLayers.y);
return CreateGbuffer(g_vParam, half3(1.0, 1.0, 1.0), half4(0.0, 0.0, 0.0, 1.0), IN.vPos, g_vNearFarLayers);
return CreateGbuffer(g_vParam, normalize(IN.vNormal), half4(0.0, 0.0, 0.0, 1.0), IN.vPos, g_vNearFarLayers);
}
\ No newline at end of file
/*
mtrlskin_base.ps
Базовый рендер анимационных моделей
*/
#include <../struct.h>
#include <../mtrl.h>
//##########################################################################
sampler2D g_sColor:register(s0);
sampler2D g_sParameters:register(s10);
//##########################################################################
half4 g_vNearFarLayers;
//##########################################################################
PSO_Gbuffer main(VSO_SceneCommon IN)
{
ClipFar(IN.vPos.z,g_vNearFarLayers.y);
return CreateGbuffer(tex2D(g_sColor,IN.vTexUV), normalize(IN.vNormal), tex2D(g_sParameters,IN.vTexUV), IN.vPos, g_vNearFarLayers);
}
\ No newline at end of file
......@@ -539,7 +539,7 @@ void SkyXEngine_PreviewKill();
void SkyXEngine_RFuncDIP(UINT type_primitive, long base_vertexIndex, UINT min_vertex_index, UINT num_vertices, UINT start_index, UINT prim_count);
//! функция установки материала по id, world - мировая матрица
void SkyXEngine_RFuncMtlSet(ID id, float4x4* world);
void SkyXEngine_RFuncMtlSet(ID id, const float4x4 *pWorld=0, const float4 *pColor=0);
//! функция загрузки материала
ID SkyXEngine_RFuncMtlLoad(const char* name, int mtl_type);
......
......@@ -55,7 +55,7 @@ void StdDrawIndexedPrimitive(UINT type_primitive, long base_vertexIndex, UINT mi
g_pDXDevice->DrawIndexedPrimitive((D3DPRIMITIVETYPE)type_primitive, base_vertexIndex, min_vertex_index, num_vertices, start_index, prim_count);
}
void StdMtlSet(ID id, float4x4 *pWorld)
void StdMtlSet(ID id, const float4x4 *pWorld, const float4 *pColor)
{
g_pDXDevice->SetTexture(0, SGCore_LoadTexGetTex(id));
......@@ -336,10 +336,10 @@ SX_LIB_API void SGCore_DIP(UINT uiTypePrimitive, long lBaseVertexIndex, UINT uiM
g_fnDIP(uiTypePrimitive, lBaseVertexIndex, uiMinVertexIndex, uiNumVertices, uiStartIndex, uiPrimitiveCount);
}
SX_LIB_API void SGCore_MtlSet(ID id, float4x4 *pWorld)
SX_LIB_API void SGCore_MtlSet(ID id, const float4x4 *pWorld, const float4 *pColor)
{
SG_PRECOND(_VOID);
g_fnMtlSet(id, pWorld);
g_fnMtlSet(id, pWorld, pColor);
}
SX_LIB_API ID SGCore_MtlLoad(const char *szName, int iMtlType)
......
......@@ -176,9 +176,9 @@ SX_LIB_API void SGCore_SetSamplerAddress2(DWORD dwNumStart, DWORD dwCount, DWORD
typedef void(*g_func_dip) (UINT uiTypePrimitive, long lBaseVertexIndex, UINT uiMinVertexIndex, UINT uiNumVertices, UINT uiStartIndex, UINT uiPrimitiveCount);
/*! установка материала id, world - мировая матрица.
По умолчанию установка текстуры в нулевой текстурный слот, id – идентификатор материала (по умолчанию - текстуры), world – матрица трансформации модели
По умолчанию установка текстуры в нулевой текстурный слот, id – идентификатор материала (по умолчанию - текстуры), pWorld – матрица трансформации модели, pColor - цвет, если материал принимает
*/
typedef void(*g_func_mtl_set) (ID id, float4x4 *pWorld);
typedef void(*g_func_mtl_set) (ID id, const float4x4 *pWorld, const float4 *pColor);
/*! загрузка материала, szName - имя текстуры с расширением, iMtlType - тип материала на случай провала загрузки.
Загрузка материала (по умолчанию – текстуры) с именем name, iMtlType – типа материала,
......@@ -205,7 +205,7 @@ typedef bool(*g_func_mtl_group_render_is_singly) (ID id);
SX_LIB_API void SGCore_DIP(UINT uiTypePrimitive, long lBaseVertexIndex, UINT uiMinVertexIndex, UINT uiNumVertices, UINT uiStartIndex, UINT uiPrimitiveCount);
//! \copydoc g_func_mtl_set
SX_LIB_API void SGCore_MtlSet(ID id, float4x4 *pWorld);
SX_LIB_API void SGCore_MtlSet(ID id, const float4x4 *pWorld=0, const float4 *pColor=0);
//! \copydoc g_func_mtl_load
SX_LIB_API ID SGCore_MtlLoad(const char *szName, int iMtlType);
......
......@@ -12,6 +12,7 @@ CLevel::CLevel()
m_sAmbientSounds = "";
m_sWeather = "";
m_szName[0] = 0;
m_sTitle = "";
loadParticles();
m_pWeather = new CWeather();
......@@ -29,6 +30,7 @@ CLevel::~CLevel()
void CLevel::clear()
{
m_szName[0] = 0;
m_sTitle = "";
m_sWeather = "";
m_sAmbientSounds = "";
......@@ -61,6 +63,10 @@ void CLevel::load(const char *szName, bool isGame)
}
ISXConfig *pConfig = Core_OpConfig(szFullPath);
if (pConfig->keyExists("level", "title"))
m_sTitle = pConfig->getKey("level", "title");
if (pConfig->keyExists("level", "geometry"))
{
LibReport(REPORT_MSG_LEVEL_NOTICE, " load geometry\n");
......@@ -240,6 +246,7 @@ void CLevel::save(const char *szName)
file = fopen(szPathLevel, "w");
fprintf(file, "%s", "[level]\n");
fprintf(file, "title = %s\n", m_sTitle.c_str());
if (SGeom_GetCountModels() > 0)
{
......
......@@ -100,7 +100,9 @@ public:
protected:
//! текущее имя уровня
char m_szName[OBJECT_NAME_MAX_LEN];
char m_szName[OBJECT_NAME_MAX_LEN];
String m_sTitle;
String m_sAmbientSounds;
String m_sWeather;
......
......@@ -37,7 +37,9 @@ CMaterials::CMaterials()
tmpMtlDefaultLight->m_oMainGraphics.m_idMainTexture = -1;
tmpMtlDefaultLight->m_oMainGraphics.m_oDataVS.m_isTransWorldViewProjection = true;
tmpMtlDefaultLight->m_oMainGraphics.m_oDataVS.m_isTransWorld = true;
tmpMtlDefaultLight->m_oMainGraphics.m_isUnlit = true;
tmpMtlDefaultLight->m_oLightParam.m_idTexParam = -1;
tmpMtlDefaultLight->m_oLightParam.m_isTextureParam = false;
tmpMtlDefaultLight->m_oLightParam.m_idTexParamHand = createTexParamLighting(MTL_LIGHTING_DEFAULT_ROUGHNESS, MTL_LIGHTING_DEFAULT_F0, MTL_LIGHTING_DEFAULT_THICKNESS);
......@@ -58,6 +60,7 @@ CMaterials::CMaterials()
tmpumtl->m_pMtrl->m_oMainGraphics.m_idMainTexture = -1;
tmpumtl->m_pMtrl->m_oMainGraphics.m_oDataVS.m_isTransWorldViewProjection = true;
tmpumtl->m_pMtrl->m_oMainGraphics.m_oDataVS.m_isTransWorld = true;
tmpumtl->m_pMtrl->m_oLightParam.m_idTexParam = -1;
tmpumtl->m_pMtrl->m_oLightParam.m_isTextureParam = false;
......@@ -104,6 +107,27 @@ CMaterials::CMaterials()
m_idMtrlDefGrass = addUnitMaterial(tmpumtl);
addName(tmpumtl->m_pMtrl->m_sName.c_str(), m_idMtrlDefGrass);
tmpumtl = new CUnitMaterial();
tmpMtlDefaultLight = new CMaterial();
addMaterial(tmpMtlDefaultLight);
tmpumtl->m_pMtrl = tmpMtlDefaultLight;
tmpMtlDefaultLight->m_sName = String(MTL_VIRTUAL_DIR_STD_MTL) + "_skin";
tmpumtl->m_pMtrl->m_oMainGraphics.m_idShaderVS = SGCore_ShaderGetID(SHADER_TYPE_VERTEX, "mtrlskin_base.vs");
tmpumtl->m_pMtrl->m_oMainGraphics.m_idShaderPS = SGCore_ShaderGetID(SHADER_TYPE_PIXEL, "mtrlskin_base.ps");
tmpumtl->m_pMtrl->m_oMainGraphics.m_idMainTexture = -1;
tmpumtl->m_pMtrl->m_oMainGraphics.m_oDataVS.m_isTransWorldViewProjection = true;
tmpumtl->m_pMtrl->m_oMainGraphics.m_oDataVS.m_isTransWorld = true;
tmpumtl->m_pMtrl->m_oLightParam.m_idTexParam = -1;
tmpumtl->m_pMtrl->m_oLightParam.m_isTextureParam = false;
tmpumtl->m_pMtrl->m_oLightParam.m_idTexParamHand = createTexParamLighting(MTL_LIGHTING_DEFAULT_ROUGHNESS, MTL_LIGHTING_DEFAULT_F0, MTL_LIGHTING_DEFAULT_THICKNESS);
m_idMtrlDefSkin = addUnitMaterial(tmpumtl);
addName(tmpumtl->m_pMtrl->m_sName.c_str(), m_idMtrlDefSkin);
m_idBeginNonDef = m_aUnitMtrls.size();
}
......@@ -146,6 +170,7 @@ void CMaterials::CMaterial::nulling()
m_oMainGraphics.m_idMainTexture = -1;
m_oMainGraphics.m_idShaderVS = -1;
m_oMainGraphics.m_idShaderPS = -1;
m_oMainGraphics.m_useDestColor = false;
m_oMicroDetail = CMaskDetailMicroRelief();
m_oLightParam = CLightParam();
......@@ -188,6 +213,7 @@ CMaterials::CMaterial::CMainGraphics::CMainGraphics()
m_idShaderPS = -1;
m_isUnlit = false;
m_useAlphaTest = false;
m_useDestColor = false;
m_typeModel = MTLTYPE_MODEL::MTLTYPE_MODEL_DEFAULT;
m_oDataVS = CMainGraphics::СDataShader();
m_oDataPS = CMainGraphics::СDataShader();
......@@ -443,6 +469,11 @@ bool CMaterials::loadMtl(const char *szName, CMaterial **ppMtrl)
pMtrl->m_sName = sName.c_str();
if (pConfig->keyExists(sName.c_str(), "use_dest_color"))
pMtrl->m_oMainGraphics.m_useDestColor = String(pConfig->getKey(sName.c_str(), "use_dest_color")).toBool();
else
pMtrl->m_oMainGraphics.m_useDestColor = false;
if (pConfig->keyExists(sName.c_str(), "vs"))
sVS = pConfig->getKey(sName.c_str(), "vs");
......@@ -926,7 +957,8 @@ void CMaterials::mtlSave(ID id)
namebasetex[0] = '0';
namebasetex[1] = '\0';
SGCore_LoadTexGetName(mtrl->m_oMainGraphics.m_idMainTexture, namebasetex);
fprintf(file, "texture = %s\n\n", namebasetex);
fprintf(file, "texture = %s\n", namebasetex);
fprintf(file, "use_dest_color = %d\n\n", mtrl->m_oMainGraphics.m_useDestColor);
if (mtrl->m_oMicroDetail.m_idMask == -1)
{
......@@ -1145,6 +1177,11 @@ MTLTYPE_MODEL CMaterials::getTypeModel(ID id)
return m_aUnitMtrls[id]->m_pMtrl->m_oMainGraphics.m_typeModel;
}
ID CMaterials::getLightMtrl()
{
return m_idMtrlDefLight;
}
void CMaterials::setTypeModel(ID id, MTLTYPE_MODEL typeModel)
{
MTL_PRE_COND_ID(id, _VOID);
......@@ -1350,6 +1387,20 @@ void CMaterials::mtlGetTexture(ID id, char* name)
SGCore_LoadTexGetName(m_aUnitMtrls[id]->m_pMtrl->m_oMainGraphics.m_idMainTexture, name);
}
void CMaterials::mtlSetUseDestColor(ID id, bool useDestColor)
{
MTL_PRE_COND_ID(id, _VOID);
m_aUnitMtrls[id]->m_pMtrl->m_oMainGraphics.m_useDestColor = useDestColor;
}
bool CMaterials::mtlGetUseDestColor(ID id)
{
MTL_PRE_COND_ID(id, false);
return m_aUnitMtrls[id]->m_pMtrl->m_oMainGraphics.m_useDestColor;
}
ID CMaterials::mtlGetTextureID(ID id)
{
MTL_PRE_COND_ID(id, -1);
......@@ -1872,7 +1923,7 @@ void CMaterials::renderStd(MTLTYPE_MODEL type, const float4x4 *pWorld, ID idSlot
}
}
void CMaterials::render(ID id, const float4x4 *pWorld)
void CMaterials::render(ID id, const float4x4 *pWorld, const float4 *pColor)
{
MTL_PRE_COND_ID(id, _VOID);
......@@ -2054,6 +2105,9 @@ void CMaterials::render(ID id, const float4x4 *pWorld)
if (pMtrl->m_oMainGraphics.m_oDataPS.m_isTransWinSize)
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, pMtrl->m_oMainGraphics.m_idShaderPS, "g_vWinSize", &float4_t(*r_win_width, *r_win_height, 1.f / (*r_win_width), 1.f / (*r_win_height)));
if (pMtrl->m_oMainGraphics.m_useDestColor && pMtrl->m_oMainGraphics.m_idShaderPS >= 0 && pColor)
SGCore_ShaderSetVRF(SHADER_TYPE_PIXEL, pMtrl->m_oMainGraphics.m_idShaderPS, "g_vDestColor", (void*)pColor);
//если материалом назначен альфа тест и не включен принудительный
if (pMtrl->m_oMainGraphics.m_useAlphaTest && !m_useForceblyAlphaTest)
{
......
......@@ -40,7 +40,7 @@ public:
void clear(bool isClearRefDel);
void update(UINT timeDelta);
void setMainTexture(ID idSlot, ID idTexure);
void render(ID id, const float4x4 *pWorld);
void render(ID id, const float4x4 *pWorld=0, const float4 *pColor=0);
void renderStd(MTLTYPE_MODEL type, const float4x4 *pWorld, ID idSlot, ID idMtl);
void renderLight(const float4_t *pColor, const float4x4 *pWorld);
int getCount();
......@@ -61,6 +61,7 @@ public:
ID getStdMtl(MTLTYPE_MODEL typeModel);
ID exists(const char *szName);
MTLTYPE_MODEL getTypeModel(ID id);
ID getLightMtrl();
void setTypeModel(ID id, MTLTYPE_MODEL typeModel);
ID getID(const char *szName);
......@@ -77,6 +78,10 @@ public:
void mtlSetTexture(ID id, const char *szTexture);
void mtlGetTexture(ID id, char *szName);
void mtlSetUseDestColor(ID id, bool useDestColor);
bool mtlGetUseDestColor(ID id);
ID mtlGetTextureID(ID id);
void mtlSetVS(ID id, const char *szNameVS);
void mtlGetVS(ID id, char *szNamePS);
......@@ -206,6 +211,9 @@ public:
//! использовать ли альфа тест
bool m_useAlphaTest;
//! используется ли принимаемый цвет?
bool m_useDestColor;
//! тип модели для рендера
MTLTYPE_MODEL m_typeModel;
......
......@@ -117,6 +117,13 @@ SX_LIB_API MTLTYPE_MODEL SMtrl_MtlGetTypeModel(ID id)
return ArrMaterials->getTypeModel(id);
}
SX_LIB_API ID SMtrl_MtlGetLightMtrl()
{
ML_PRECOND(-1);
return ArrMaterials->getLightMtrl();
}
/*SX_LIB_API UINT SMtrl_MtlGetSort(ID id)
{
ML_PRECOND(0);
......@@ -145,10 +152,10 @@ SX_LIB_API long SMtrl_MtlGetCount()
return ArrMaterials->getCount();
}
SX_LIB_API void SMtrl_MtlRender(ID id, const float4x4 *pWorld)
SX_LIB_API void SMtrl_MtlRender(ID id, const float4x4 *pWorld, const float4 *pColor)
{
ML_PRECOND(_VOID);
ArrMaterials->render(id, pWorld);
ArrMaterials->render(id, pWorld, pColor);
}
SX_LIB_API void SMtrl_MtlRenderStd(MTLTYPE_MODEL type, const float4x4 *pWorld, ID idSlot, ID idMtl)
......@@ -387,6 +394,20 @@ SX_LIB_API ID SMtrl_MtlGetTextureID(ID id)
return ArrMaterials->mtlGetTextureID(id);
}
SX_LIB_API void SMtrl_MtlSetUseDestColor(ID id, bool useDestColor)
{
ML_PRECOND(_VOID);
ArrMaterials->mtlSetUseDestColor(id, useDestColor);
}
SX_LIB_API bool SMtrl_MtlGetUseDestColor(ID id)
{
ML_PRECOND(false);
return ArrMaterials->mtlGetUseDestColor(id);
}
SX_LIB_API void SMtrl_MtlSetVS(ID id, const char *szPath)
{
ML_PRECOND(_VOID);
......
......@@ -236,18 +236,6 @@ enum MTLSORT
/*! \name Возможные слои
@{*/
//! непрозрачные неосвещаемые
/*#define MTLTYPE_LAYER_OPAQUE_UNLIT 0.0f
//! прозрачные неосвещаемые
#define MTLTYPE_LAYER_TRANSPARENT_UNLIT 0.666667f
//! непрозрачные освещаемые
#define MTLTYPE_LAYER_OPAQUE_LIGHT 0.333333f
//! прозрачные освещаемые
#define MTLTYPE_LAYER_TRANSPARENT_LIGHT 1.0f*/
//! прозрачные неосвещаемые
#define MTLTYPE_UNLIT 0
......@@ -383,6 +371,9 @@ SX_LIB_API long SMtrl_MtlGetCount();
//! возвращает тип модели материала по id
SX_LIB_API MTLTYPE_MODEL SMtrl_MtlGetTypeModel(ID id);
//! возвращает id дефолтного материала света
SX_LIB_API ID SMtrl_MtlGetLightMtrl();
//! возвращает сорт материала по id
//SX_LIB_API UINT SMtrl_MtlGetSort(ID id);
......@@ -395,8 +386,9 @@ SX_LIB_API void SMtrl_MtlSetTypeModel(ID id, MTLTYPE_MODEL type_model);
//! установка параметров материала по id, вызывается перед DIP
SX_LIB_API void SMtrl_MtlRender(
ID id, //!< идентификатор материала
const float4x4 *pWorld //!< указатель на мировую матрицу модели, либо 0 - тогда будет принята единичная матрица
ID id, //!< идентификатор материала
const float4x4 *pWorld=0, //!< указатель на мировую матрицу модели, либо 0 - тогда будет принята единичная матрица
const float4 *pColor=0 //!< указатель на принимаемый цвет
);
//! стандартная отрисовка материала, используются стандартные шейдеры, нужно для теней, отражений и прочего
......@@ -605,7 +597,14 @@ SX_LIB_API void SMtrl_MtlSetTexture(ID id, const char *szPathTex);
SX_LIB_API void SMtrl_MtlGetTexture(ID id, char *szName);
//! возвращает id текстуры материала
SX_LIB_API ID SMtrl_MtlGetTextureID(ID id);
SX_LIB_API ID SMtrl_MtlGetTextureID(ID id);
//! установка свойства окрашивания в принимаемый цвет
SX_LIB_API void SMtrl_MtlSetUseDestColor(ID id, bool useDestColor);
//! возвращает значение свойства окрашивания в принимаемый цвет
SX_LIB_API bool SMtrl_MtlGetUseDestColor(ID id);
/*! \name Шейдеры для рендера материала
......
......@@ -1536,10 +1536,6 @@ bool SkyXEngine_CycleMainIteration()
(GetForegroundWindow() == SRender_GetHandleWin3D() || GetForegroundWindow() == (HWND)SRender_GetParentHandleWin3D() || GetForegroundWindow() == FindWindow(NULL, "sxconsole"))
)
{
#if defined(SX_LEVEL_EDITOR)
SXLevelEditor_Transform(10);
#endif
SkyXEngine_Frame(timeDelta);
}
......@@ -1671,24 +1667,24 @@ void SkyXEngine_RFuncDIP(UINT type_primitive, long base_vertexIndex, UINT min_ve
}
void SkyXEngine_RFuncMtlSet(ID id, float4x4* world)
void SkyXEngine_RFuncMtlSet(ID id, const float4x4 *pWorld, const float4 *pColor)
{
switch (Core_RIntGet(G_RI_INT_RENDERSTATE))
{
case RENDER_STATE_SHADOW:
SMtrl_MtlSetMainTexture(0, id);
SLight_ShadowSetShaderOfTypeMat(Core_RIntGet(G_RI_INT_CURRIDLIGHT), SMtrl_MtlGetTypeModel(id), world);
SLight_ShadowSetShaderOfTypeMat(Core_RIntGet(G_RI_INT_CURRIDLIGHT), SMtrl_MtlGetTypeModel(id), pWorld);
break;
case RENDER_STATE_FREE:
SMtrl_MtlSetMainTexture(0, id);
Core_RMatrixSet(G_RI_MATRIX_WORLD, &(world ? (*world) : SMMatrixIdentity()));
Core_RMatrixSet(G_RI_MATRIX_WORLD, &(pWorld ? (*pWorld) : SMMatrixIdentity()));
//SGCore_ShaderUnBind();
SMtrl_MtlRenderStd(SMtrl_MtlGetTypeModel(id), world, 0, id);
SMtrl_MtlRenderStd(SMtrl_MtlGetTypeModel(id), pWorld, 0, id);
break;
case RENDER_STATE_MATERIAL:
SMtrl_MtlRender(id, world);
SMtrl_MtlRender(id, pWorld, pColor);
break;
}
}
......
......@@ -187,6 +187,8 @@ LRESULT SXLevelEditor_RenderWindow_MouseMove(HWND hWnd, UINT uiMsg, WPARAM wPara
{
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM)
level_editor::GeomUpdateCopyPos();
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME)
level_editor::GameUpdateCopyPos();
return 0;
}
......@@ -231,6 +233,8 @@ LRESULT SXLevelEditor_RenderWindow_LClick(HWND hWnd, UINT uiMsg, WPARAM wParam,
{
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM)
level_editor::GeomCopy();
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME)
level_editor::GameCopy();
return 0;
}
......@@ -297,7 +301,7 @@ LRESULT SXLevelEditor_RenderWindow_MBUp(HWND hWnd, UINT uiMsg, WPARAM wParam, LP
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM && level_editor::idActiveElement >= 0)
level_editor::GeomTraceSetPos();
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN && level_editor::idActiveElement >= 0)
level_editor::GeomTraceSetPos();
level_editor::GreenTraceSetPos();
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GAME && level_editor::idActiveElement >= 0)
level_editor::GameTraceSetPos();
......@@ -909,226 +913,3 @@ LRESULT SXLevelEditor_GroupBoxList_CallWmCommand(HWND hWnd, UINT uiMsg, WPARAM w
return 0;
}
//##########################################################################
void SXLevelEditor_Transform(DWORD timeDelta)
{
static bool isFirstLBMTransform = false;
static bool isFirstRBMTransform = false;
static int iNumComponent = -1;
if (!SSInput_GetKeyState(SIK_LSHIFT))
return;
if (level_editor::pRadioButtonGeomPosX->getCheck() || level_editor::pRadioButtonGeomRotX->getCheck() || level_editor::pRadioButtonGeomScaleX->getCheck() || level_editor::pRadioButtonGreenSelX->getCheck())
iNumComponent = 0;
else if (level_editor::pRadioButtonGeomPosY->getCheck() || level_editor::pRadioButtonGeomRotY->getCheck() || level_editor::pRadioButtonGeomScaleY->getCheck() || level_editor::pRadioButtonGreenSelY->getCheck())
iNumComponent = 1;
else if (level_editor::pRadioButtonGeomPosZ->getCheck() || level_editor::pRadioButtonGeomRotZ->getCheck() || level_editor::pRadioButtonGeomScaleZ->getCheck() || level_editor::pRadioButtonGreenSelZ->getCheck())
iNumComponent = 2;
if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GEOM)
{
if (SGeom_GetCountModels() <= 0)
return;
int iSelected = level_editor::pListBoxList->getSel();
float3 vTransform;
ISXGUIEdit *pEditX = 0, *pEditY = 0, *pEditZ = 0;
int iTypeTransform = -1;
//
if (level_editor::pRadioButtonGeomPosX->getCheck() || level_editor::pRadioButtonGeomPosY->getCheck() || level_editor::pRadioButtonGeomPosZ->getCheck())
{
vTransform = *(SGeom_ModelGetPosition(iSelected));
pEditX = level_editor::pEditGeomPosX;
pEditY = level_editor::pEditGeomPosY;
pEditZ = level_editor::pEditGeomPosZ;
iTypeTransform = 0;
}
//
else if (level_editor::pRadioButtonGeomRotX->getCheck() || level_editor::pRadioButtonGeomRotY->getCheck() || level_editor::pRadioButtonGeomRotZ->getCheck())
{
vTransform = *(SGeom_ModelGetRotation(iSelected));
pEditX = level_editor::pEditGeomRotX;
pEditY = level_editor::pEditGeomRotY;
pEditZ = level_editor::pEditGeomRotZ;
iTypeTransform = 1;
}
//
else if (level_editor::pRadioButtonGeomScaleX->getCheck() || level_editor::pRadioButtonGeomScaleY->getCheck() || level_editor::pRadioButtonGeomScaleZ->getCheck())
{
vTransform = *(SGeom_ModelGetScale(iSelected));
pEditX = level_editor::pEditGeomScaleX;
pEditY = level_editor::pEditGeomScaleY;
pEditZ = level_editor::pEditGeomScaleZ;
iTypeTransform = 2;
}
else
return;
//
if (SSInput_GetKeyState(SIK_UP))
vTransform[iNumComponent] += timeDelta * 0.001f;
if (SSInput_GetKeyState(SIK_DOWN))
vTransform[iNumComponent] -= timeDelta * 0.001f;
//
if (SSInput_GetKeyState(SIM_LBUTTON))
{
if (isFirstRBMTransform)
{
RECT oRect;
GetWindowRect(GetForegroundWindow(), &oRect);
long lCenterX = (oRect.right + oRect.left) / 2;
long lCenterY = (oRect.bottom + oRect.top) / 2;
POINT oPoint;
GetCursorPos(&oPoint);
if (lCenterY != UINT(oPoint.y))
vTransform[iNumComponent] += timeDelta * 0.001f * float(-int(oPoint.y - lCenterY));
}
else
isFirstRBMTransform = true;
SRender_CentererCursor();
}
else
{
isFirstLBMTransform = false;
isFirstRBMTransform = false;
}
//
char szStr[32];
sprintf(szStr, "%f", vTransform.x);
pEditX->setText(szStr);
sprintf(szStr, "%f", vTransform.y);
pEditY->setText(szStr);
sprintf(szStr, "%f", vTransform.z);
pEditZ->setText(szStr);
//
if (iTypeTransform == 0)
SGeom_ModelSetPosition(iSelected, &vTransform);
else if (iTypeTransform == 1)
SGeom_ModelSetRotation(iSelected, &vTransform);
else if (iTypeTransform == 2)
SGeom_ModelSetScale(iSelected, &vTransform);
}
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_GREEN &&
(
(level_editor::pComboBoxGreenSel->getSel() == 0 && level_editor::idActiveElement >= 0 && level_editor::idActiveGreenSplit >= 0 && level_editor::idActiveGreenObject >= 0) ||
(level_editor::pComboBoxGreenSel->getSel() == 2)
)
)
{
if (SGreen_GetCount() <= 0)
return;
int iSelected = level_editor::pListBoxList->getSel();
if (level_editor::pRadioButtonGreenSelX->getCheck() || level_editor::pRadioButtonGreenSelY->getCheck() || level_editor::pRadioButtonGreenSelZ->getCheck())
{
float3 pos;
if (level_editor::pComboBoxGreenSel->getSel() == 2)
pos = level_editor::vGreenBoxWHD;
else
{
float3_t pos2;
SGreen_GetPosObject(level_editor::idActiveElement, level_editor::idActiveGreenSplit, level_editor::idActiveGreenObject, &pos2);
pos = pos2;
}
if (SSInput_GetKeyState(SIK_UP))
pos[iNumComponent] += float(timeDelta) * 0.001f;
if (SSInput_GetKeyState(SIK_DOWN))
pos[iNumComponent] -= float(timeDelta) * 0.001f;
if (SSInput_GetKeyState(SIM_LBUTTON))
{
if (isFirstRBMTransform)
{
RECT rc;
GetWindowRect(GetForegroundWindow(), &rc);
UINT cx = (rc.right + rc.left) / 2;
UINT cy = (rc.bottom + rc.top) / 2;
POINT p;
GetCursorPos(&p);
POINT centr;
centr.x = cx; centr.y = cy;
if (cy != UINT(p.y))
pos[iNumComponent] += float(timeDelta) * 0.001f * float(-int(p.y - cy));
}
else
isFirstRBMTransform = true;
SRender_CentererCursor();
}
else
{
isFirstLBMTransform = false;
isFirstRBMTransform = false;
}
char tmpPosX[32];
char tmpPosY[32];
char tmpPosZ[32];
sprintf(tmpPosX, "%f", pos.x);
sprintf(tmpPosY, "%f", pos.y);
sprintf(tmpPosZ, "%f", pos.z);
level_editor::pEditGreenSelX->setText(tmpPosX);
level_editor::pEditGreenSelY->setText(tmpPosY);
level_editor::pEditGreenSelZ->setText(tmpPosZ);
if (level_editor::pComboBoxGreenSel->getSel() == 2)
level_editor::vGreenBoxWHD = pos;
else
SGreen_SetPosObject(level_editor::idActiveElement, &level_editor::idActiveGreenSplit, &level_editor::idActiveGreenObject, &float3_t(pos));
}
}
else if (level_editor::iActiveGroupType == EDITORS_LEVEL_GROUPTYPE_AIGRID)
{
float fBiasY = 0.f;
if (SSInput_GetKeyState(SIK_UP))
fBiasY += float(timeDelta) * 0.001f;
if (SSInput_GetKeyState(SIK_DOWN))
fBiasY -= float(timeDelta) * 0.001f;
//
if (SSInput_GetKeyState(SIM_LBUTTON))
{
if (isFirstRBMTransform)
{
RECT oRect;
GetWindowRect(GetForegroundWindow(), &oRect);
long lCenterX = (oRect.right + oRect.left) / 2;
long lCenterY = (oRect.bottom + oRect.top) / 2;
POINT oPoint;
GetCursorPos(&oPoint);