Commit 6a9244a9 authored by Byurrrer's avatar Byurrrer

добавил рендер полупрозрачных поверхностей в редактор материалов,исправил...

добавил рендер полупрозрачных поверхностей в редактор материалов,исправил ошибку обращения в нулевому указателю в либе света при потере/восстановлении устройства, исправил ошибку при обращении к нулевому указателю в редакторе материалов при ресайзе, исправил ошибку дефолтного положения наблюдателя в редакторе материалов, добавил отображение версии движка в редакторах уровней и материалов, изменил переменную shadow_coefficient на shadow_intensity у игровых объеков света
parent c45a1225
......@@ -293,7 +293,9 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот
#ifndef __SKYXENGINE_H
#define __SKYXENGINE_H
#define SKYXENGINE_VERSION "0.9.3"
#define SKYXENGINE_VERSION "0.10.0"
#define SKYXENGINE_VERSION4EDITORS "SkyXEngine version " ## SKYXENGINE_VERSION
#define SKYXENGINE_PREVIEW_SIZE 256
......
......@@ -19,8 +19,8 @@ BEGIN_PROPTABLE(CLightDirectional)
DEFINE_FIELD_FLOAT(m_fDist, 0, "dist", "Distance", EDITOR_TEXTFIELD)
//! Дальность дальняя
DEFINE_FIELD_FLOAT(m_fShadowDist, 0, "shadow_dist", "Shadow distance", EDITOR_TEXTFIELD)
//! Коэффициент теней - на сколько тень черная
DEFINE_FIELD_FLOAT(m_fShadowCoef, 0, "shadow_coef", "Shadow coefficient", EDITOR_TEXTFIELD)
//! Интенсивность теней
DEFINE_FIELD_FLOAT(m_fShadowIntensity, 0, "shadow_intensity", "Shadow intensity", EDITOR_TEXTFIELD)
//! Тип тени
DEFINE_FIELD_INT(m_iShadowType, 0, "shadow_type", "Shadow type", EDITOR_COMBOBOX)
......@@ -46,7 +46,7 @@ BaseClass(pMgr)
m_fDist = 10;
m_fShadowDist = m_fDist;
m_iShadowType = 1;
m_fShadowCoef = 0;
m_fShadowIntensity = 0;
m_fAngle = SM_PI * 0.4f;
m_fRadiusTop = 0.01f;
m_idLight = SLight_CreateDirection(&float3(0, 0, 0), m_fDist, &(float3)m_vColor, &SMQuaternion(-SM_PI, 'z'), m_fRadiusTop, m_fAngle, true);
......@@ -96,7 +96,7 @@ void CLightDirectional::onSync()
if (SLight_GetTypeShadowed(m_idLight) != m_iShadowType)
SLight_SetTypeShadowed(m_idLight, (LTYPE_SHADOW)m_iShadowType);
SLight_SetShadowCoef(m_idLight, m_fShadowCoef);
SLight_SetShadowCoef(m_idLight, m_fShadowIntensity);
static SMQuaternion curr_rot;
SLight_GetOrient(m_idLight, &curr_rot);
......
......@@ -39,8 +39,8 @@ public:
void setShadowType(int iShadowType) { m_iShadowType = iShadowType; };
int getShadowType() const { return m_iShadowType; };
void setShadowCoef(float fShadowCoef) { m_fShadowCoef = fShadowCoef; };
float getShadowCoef() const { return m_fShadowCoef; };
void setShadowIntensity(float fShadowIntensity) { m_fShadowIntensity = fShadowIntensity; };
float getShadowIntensity() const { return m_fShadowIntensity; };
void setEnable(bool isEnable) { m_isEnable = isEnable; };
bool getEnable() const { return m_isEnable; };
......@@ -61,7 +61,7 @@ protected:
float m_fDist;
float m_fShadowDist;
int m_iShadowType;
float m_fShadowCoef;
float m_fShadowIntensity;
bool m_isEnable;
......
......@@ -19,8 +19,8 @@ BEGIN_PROPTABLE(CLightPoint)
DEFINE_FIELD_FLOAT(m_fDist, 0, "dist", "Distance", EDITOR_TEXTFIELD)
//! Дальность дальняя
DEFINE_FIELD_FLOAT(m_fShadowDist, 0, "light_far", "Shadow far plane", EDITOR_TEXTFIELD)
//! Коэффициент теней - на сколько тень черная
DEFINE_FIELD_FLOAT(m_fShadowCoef, 0, "shadow_coef", "Shadow coefficient", EDITOR_TEXTFIELD)
//! Интенсивность теней
DEFINE_FIELD_FLOAT(m_fShadowIntensity, 0, "shadow_intensity", "Shadow intensity", EDITOR_TEXTFIELD)
//! Тип тени
DEFINE_FIELD_INT(m_iShadowType, 0, "type_shadow", "Type shadow", EDITOR_COMBOBOX)
......@@ -52,7 +52,7 @@ BaseClass(pMgr)
m_fDist = 10;
m_fShadowDist = m_fDist;
m_iShadowType = 1;
m_fShadowCoef = 0;
m_fShadowIntensity = 0;
m_idLight = SLight_CreatePoint(&float3(0, 0, 0), m_fDist, &(float3)m_vColor, false, true);
}
......@@ -88,7 +88,7 @@ void CLightPoint::onSync()
m_fShadowDist = m_fDist;
}
SLight_SetShadowCoef(m_idLight, m_fShadowCoef);
SLight_SetShadowCoef(m_idLight, m_fShadowIntensity);
if (SLight_GetShadowLocalFar(m_idLight) != m_fShadowDist)
SLight_SetShadowLocalFar(m_idLight, m_fShadowDist);
......
......@@ -38,8 +38,8 @@ public:
void setShadowDist(float fShadowDist) { m_fShadowDist = fShadowDist; };
float getShadowDist() const { return m_fShadowDist; };
void setShadowCoef(float fShadowCoef) { m_fShadowCoef = fShadowCoef; };
float getShadowCoef() const { return m_fShadowCoef; };
void setShadowIntensity(float fShadowIntensity) { m_fShadowIntensity = fShadowIntensity; };
float getShadowIntensity() const { return m_fShadowIntensity; };
void setShadowType(int iShadowType) { m_iShadowType = iShadowType; };
int getShadowType() const { return m_iShadowType; };
......@@ -57,7 +57,7 @@ protected:
float m_fShadowDist;
int m_iShadowType;
bool m_isEnable;
float m_fShadowCoef;
float m_fShadowIntensity;
void onSync();
......
......@@ -163,6 +163,9 @@ void CLights::onLostDevice()
{
for (int i = 0; i < m_aLights.size(); ++i)
{
if (!(m_aLights[i]))
continue;
if (m_aLights[i]->m_pShadowSM)
m_aLights[i]->m_pShadowSM->onLostDevice();
else if (m_aLights[i]->m_pShadowCube)
......@@ -176,6 +179,9 @@ void CLights::onResetDevice()
{
for (int i = 0; i < m_aLights.size(); ++i)
{
if (!(m_aLights[i]))
continue;
if (m_aLights[i]->m_pShadowSM)
m_aLights[i]->m_pShadowSM->onResetDevice();
else if (m_aLights[i]->m_pShadowCube)
......
......@@ -117,12 +117,12 @@ SX_LIB_API MTLTYPE_MODEL SMtrl_MtlGetTypeModel(ID id)
return ArrMaterials->getTypeModel(id);
}
SX_LIB_API UINT SMtrl_MtlGetSort(ID id)
/*SX_LIB_API UINT SMtrl_MtlGetSort(ID id)
{
ML_PRECOND(0);
return ArrMaterials->mtlGetSort(id);
}
}*/
SX_LIB_API bool SMtrl_MtlIsTransparency(ID id)
{
......
......@@ -384,7 +384,7 @@ SX_LIB_API long SMtrl_MtlGetCount();
SX_LIB_API MTLTYPE_MODEL SMtrl_MtlGetTypeModel(ID id);
//! возвращает сорт материала по id
SX_LIB_API UINT SMtrl_MtlGetSort(ID id);
//SX_LIB_API UINT SMtrl_MtlGetSort(ID id);
SX_LIB_API bool SMtrl_MtlIsTransparency(ID id);
......
......@@ -730,10 +730,10 @@ void rfunc::BuildMRT(DWORD timeDelta, bool isRenderSimulation)
mem_release_del(DepthSurf2);
//}}
if (!isRenderSimulation)
if (!isRenderSimulation || SMtrl_MtlIsTransparency(gdata::Editors::pSimModel->getIdMtl()))
{
//если есть что к отрисовке из полупрозрачной геометрии
if (SGeom_TransparencyExistsForRender())
if (SGeom_TransparencyExistsForRender() || (isRenderSimulation && SMtrl_MtlIsTransparency(gdata::Editors::pSimModel->getIdMtl())))
{
//тут такая ситуация ... есть два рабочих варианта, причем работают чутка по разному, возможно я изработался и не могу сообразить что да как ...
//первый вариант, чистим в 4, метим 3 раза начиная с нуля (первый раз 0, второй 1 третий 2 НЕ ИНКРЕМЕНТ а метка)
......@@ -804,14 +804,17 @@ void rfunc::BuildMRT(DWORD timeDelta, bool isRenderSimulation)
gdata::pDXDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_NOTEQUAL);
gdata::pDXDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_DECR);
if (SGeom_GetCountModels() > 0)
{
SMtrl_MtlSetIsIncrCountSurf(true);
SMtrl_MtlSetCurrCountSurf(RENDER_LAYER_TRANSPARENT);
SGeom_Render(timeDelta, GEOM_RENDER_TYPE_TRANSPARENCY, 0);
}
SMtrl_MtlSetIsIncrCountSurf(true);
SMtrl_MtlSetCurrCountSurf(RENDER_LAYER_TRANSPARENT);
if (isRenderSimulation)
gdata::Editors::pSimModel->render(timeDelta);
else
{
if (SGeom_GetCountModels() > 0)
SGeom_Render(timeDelta, GEOM_RENDER_TYPE_TRANSPARENCY, 0);
}
SMtrl_MtlSetForceblyAlphaTest(false);
gdata::pDXDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
......@@ -826,11 +829,7 @@ void rfunc::BuildMRT(DWORD timeDelta, bool isRenderSimulation)
}
else
{
if (SMtrl_MtlGetSort(gdata::Editors::pSimModel->getIdMtl()) != MTLSORT_OPAQUE)
SMtrl_MtlSetForceblyAlphaTest(true);
gdata::Editors::pSimModel->render(timeDelta);
if (SMtrl_MtlGetSort(gdata::Editors::pSimModel->getIdMtl()) != MTLSORT_OPAQUE)
SMtrl_MtlSetForceblyAlphaTest(false);
}
gdata::pDXDevice->SetRenderTarget(0, BackBuf);
......@@ -1329,13 +1328,7 @@ void rfunc::UnionLayers()
LPDIRECT3DSURFACE9 pBackBuf, pComLightSurf;
gdata::pDXDevice->GetRenderTarget(0, &pBackBuf);
static int iCurrCountTransparencySurf;
#if defined(SXMATERIAL_EDITOR)
iCurrCountTransparencySurf = 3;
#else
iCurrCountTransparencySurf = SMtrl_MtlGetCurrCountSurf();
#endif
int iCurrCountTransparencySurf = SMtrl_MtlGetCurrCountSurf();
if (iCurrCountTransparencySurf >= RENDER_LAYER_TRANSPARENT)
{
......@@ -1461,7 +1454,7 @@ void rfunc::RenderMainPostProcess(DWORD timeDelta)
static const bool * pp_bloom = GET_PCVAR_BOOL("pp_bloom");
if (pp_bloom && (*pp_bloom))
SPP_RenderBloom(&float3_t(1, 0.2, 1.5));
SPP_RenderBloom(&float3_t(1, 0.7, 1.2));
//**********************************************************************
......
......@@ -926,6 +926,7 @@ void SkyXEngine_Frame(DWORD timeDelta)
//рисуем сцену и заполняем mrt данными
ttime = TimeGetMcsU(Core_RIntGet(G_RI_INT_TIMER_RENDER));
Core_PStartSection(PERF_SECTION_MRT);
SRender_BuildMRT(timeDelta, isSimulationRender);
FlushCommandBuffer();
Core_PEndSection(PERF_SECTION_MRT);
......
B// Microsoft Visual C++ generated resource script.
......
......@@ -162,10 +162,10 @@ LRESULT MsgEditSize(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
static int *r_resize = (int*)GET_PCVAR_INT("r_resize");
if (!r_resize)
{
r_resize = (int*)GET_PCVAR_INT("r_resize");
if (!r_resize)
return 0;
}
*r_resize = RENDER_RESIZE_RESIZE;
return 0;
......
......@@ -126,7 +126,6 @@ void level_editor::GameSel(int iSelected)
//вставляем новую строку
int iString = level_editor::pListViewGameClass->addString((long)pPropertyData);
LibReport(0, "%d - %d\n", iCountProperties, (long)pPropertyData);
++iCountProperties;
//вставляем название в первую ячейку, а во вторую значение
......@@ -154,7 +153,6 @@ void level_editor::GameSel(int iSelected)
pEntity->getKV(pPropertyData->szKey, szVal, 256);
int iString = level_editor::pListViewGameClass->addString((long)pPropertyData);
LibReport(0, "%d - %d\n", iCountProperties, (long)pPropertyData);
++iCountProperties;
level_editor::pListViewGameClass->setItemText(szKey, 0, iString);
......@@ -207,7 +205,6 @@ void level_editor::GameSel(int iSelected)
{
int iNumStr = level_editor::pListViewGameConnections->addString((long)pPropertyData);
LibReport(0, "%d - %d\n", iCountProperties, (long)pPropertyData);
++iCountProperties;
sprintf(szKey, "%s", pPropertyData->szEdName);
......
......@@ -281,7 +281,7 @@ void level_editor::InitAllElements()
int cx = (wrect.right - MAINWIN_SIZE_X) / 2;
int cy = (wrect.bottom - MAINWIN_SIZE_Y) / 2;
level_editor::pJobWindow = SXGUICrBaseWndEx("LevelEditor", "LevelEditor", cx, cy, MAINWIN_SIZE_X, MAINWIN_SIZE_Y, 0, 0, CreateSolidBrush(RGB(220, 220, 220)), 0, CS_HREDRAW | CS_VREDRAW, WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION, 0, WndProcAllDefault);
level_editor::pJobWindow = SXGUICrBaseWndEx("LevelEditor", (String(SX_LEVEL_EDITOR_NAME) + " | " + SKYXENGINE_VERSION4EDITORS).c_str(), cx, cy, MAINWIN_SIZE_X, MAINWIN_SIZE_Y, 0, 0, CreateSolidBrush(RGB(220, 220, 220)), 0, CS_HREDRAW | CS_VREDRAW, WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION, 0, WndProcAllDefault);
//level_editor::pJobWindow->setVisible(false);
gui_func::base_handlers::InitHandlerMsg(level_editor::pJobWindow);
......@@ -464,7 +464,7 @@ void level_editor::InitAllElements()
level_editor::pGroupBoxList = SXGUICrGroupBox("GroupBoxList", 601, 28, 200, 400, level_editor::pJobWindow->getHWND(), WndProcAllDefault, 0);
level_editor::pGroupBoxList = SXGUICrGroupBox("List of objects", 601, 28, 200, 400, level_editor::pJobWindow->getHWND(), WndProcAllDefault, 0);
gui_func::base_handlers::InitHandlerMsg(level_editor::pGroupBoxList);
level_editor::pGroupBoxList->addHandler(SXLevelEditor_GroupBoxList_CallWmCommand, WM_COMMAND);
level_editor::pGroupBoxList->setFont("MS Shell Dlg",-11,0,400,0,0,0);
......@@ -2096,7 +2096,15 @@ void level_editor::LevelEditorUpdate(DWORD timeDelta)
sprintf(text, "%s%d", "Green poly: ", count_poly_green);
level_editor::pStatusBar1->setPartText(2, text);
sprintf(text, "%s%d", "Count game object: ", SXGame_EntGetCount());
int iCountGameObjects = 0;
for (int i = 0, il = SXGame_EntGetCount(); i < il; ++i)
{
if (SXGame_EntGet(i))
++iCountGameObjects;
}
sprintf(text, "%s%d", "Count game object: ", iCountGameObjects);
level_editor::pStatusBar1->setPartText(3, text);
if (level_editor::idMtl >= 0)
......@@ -2282,7 +2290,7 @@ void level_editor::LevelNew(bool mess)
SLevel_Clear();
char tmpcaption[256];
sprintf(tmpcaption, "%s: new level ** ", SX_LEVEL_EDITOR_NAME);
sprintf(tmpcaption, "%s: new level ** | %s", SX_LEVEL_EDITOR_NAME, SKYXENGINE_VERSION4EDITORS);
level_editor::pJobWindow->setText(tmpcaption);
level_editor::iActiveGroupType = 0;
level_editor::idActiveElement = -1;
......@@ -2296,6 +2304,8 @@ void level_editor::LevelNew(bool mess)
level_editor::pCheckBoxTBLevelType->setBmpFromResourse(IDB_BITMAP25);
level_editor::pCheckBoxTBLevelType->setCheck(false);
level_editor::pCheckBoxTBGLightEnable->setCheck(false);
SXLevelEditor_ButtonGeometryOpen_Click(0,0,0,0);
}
void level_editor::LevelOpen()
......@@ -2314,7 +2324,7 @@ void level_editor::LevelOpen()
{
SLevel_Load(szSelName, false);
char szCaption[256];
sprintf(szCaption, "%s: %s", SX_LEVEL_EDITOR_NAME, szSelName);
sprintf(szCaption, "%s: %s | %s", SX_LEVEL_EDITOR_NAME, szSelName, SKYXENGINE_VERSION4EDITORS);
level_editor::pJobWindow->setText(szCaption);
ID idGlobalLight = SLight_GetGlobal();
......@@ -2363,7 +2373,7 @@ void level_editor::LevelSaveAs()
{
SLevel_Save(szName);
char szCaption[256];
sprintf(szCaption, "%s: %s", "level_editor", szName);
sprintf(szCaption, "%s: %s | %s", SX_LEVEL_EDITOR_NAME, szName, SKYXENGINE_VERSION4EDITORS);
level_editor::pJobWindow->setText(szCaption);
}
}
......
......@@ -22,7 +22,7 @@ void material_editor::MtlOpen()
SGCore_LoadTexAllLoad();
char headertest[1024];
sprintf(headertest, "material_editor - %s", tmpname);
sprintf(headertest, "%s - %s | %s", SX_MATERIAL_EDITOR_NAME, tmpname, SKYXENGINE_VERSION4EDITORS);
material_editor::pJobWindow->setText(headertest);
material_editor::InitMtl(SRender_SimModelGetIDMtl());
}
......@@ -123,7 +123,7 @@ LRESULT SXMaterialEditor_ToolBar_CallWmCommand(HWND hwnd, UINT msg, WPARAM wPara
}
else if (material_editor::pButtonTBView->getHWND() == handle_elem)
{
SRender_GetCamera()->setPosition(&float3(0, 0, -1.2 * 100));
SRender_GetCamera()->setPosition(&(ME_DEFAULT_OBSERVER_POS));
SRender_GetCamera()->setOrientation(&SMQuaternion(float3(0, 0, 1), 0));
}
......@@ -177,7 +177,14 @@ LRESULT SXMaterialEditor_ToolBar_CallWmCommand(HWND hwnd, UINT msg, WPARAM wPara
LRESULT MsgEditSize(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int *r_resize = (int*)GET_PCVAR_INT("r_resize");
*r_resize = RENDER_RESIZE_RESIZE;
if (!r_resize)
{
r_resize = (int*)GET_PCVAR_INT("r_resize");
return 0;
}
//*r_resize = RENDER_RESIZE_RESIZE;
return 0;
}
......
......@@ -200,7 +200,7 @@ void material_editor::InitAllElements()
int cx = (wrect.right - MAINWIN_SIZE_X) / 2;
int cy = (wrect.bottom - MAINWIN_SIZE_Y) / 2;
material_editor::pJobWindow = SXGUICrBaseWndEx("material_editor", "material_editor", cx, cy, MAINWIN_SIZE_X, MAINWIN_SIZE_Y, 0, 0, CreateSolidBrush(RGB(220, 220, 220)), 0, CS_HREDRAW | CS_VREDRAW, WS_DLGFRAME | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION, 0, WndProcAllDefault);
material_editor::pJobWindow = SXGUICrBaseWndEx("material_editor", (String(SX_MATERIAL_EDITOR_NAME) + " | " + SKYXENGINE_VERSION4EDITORS).c_str(), cx, cy, MAINWIN_SIZE_X, MAINWIN_SIZE_Y, 0, 0, CreateSolidBrush(RGB(220, 220, 220)), 0, CS_HREDRAW | CS_VREDRAW, WS_DLGFRAME | WS_MINIMIZEBOX | WS_SYSMENU | WS_CAPTION, 0, WndProcAllDefault);
material_editor::pJobWindow->setVisible(false);
gui_func::base_handlers::InitHandlerMsg(material_editor::pJobWindow);
material_editor::pJobWindow->addHandler(SXMaterialEditor_JobWindow_CallWmCommand, WM_COMMAND);
......
......@@ -5,6 +5,11 @@
#define MAINWIN_SIZE_X 645
#define MAINWIN_SIZE_Y 700
//!
#define ME_DEFAULT_OBSERVER_POS float3(0,0,-150)
#define SX_MATERIAL_EDITOR_NAME "MaterialEditor"
#include <common/string.h>
#include <sxguiwinapi/sxgui.h>
......
......@@ -71,7 +71,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin
SGCore_SkyBoxLoadTex("sky_2_cube.dds");
material_editor::pEditSkyBox->setText("sky_2_cube.dds");
SRender_GetCamera()->setPosition(&float3(0, 0, -150));
SRender_GetCamera()->setPosition(&(ME_DEFAULT_OBSERVER_POS));
//этот код не надо удалять, при помощи него вывел данные буферов модели в текстовый файл и таким образом избавились от внешних моделей для редактора
/*
......
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