diff --git a/build/gamesource/shaders/lighting/lighting_com.ps b/build/gamesource/shaders/lighting/lighting_com.ps index 367947814c7a959d4e5c75c1a319ab54d3e631ba..ecf1d70dca692ce7f4fc9d37208e8a6c2efae0ef 100644 --- a/build/gamesource/shaders/lighting/lighting_com.ps +++ b/build/gamesource/shaders/lighting/lighting_com.ps @@ -21,7 +21,7 @@ sampler2D ShadowSampler:register(s4); half D_Get(half roughness, half NdotH) { - half a = max(0.01f, roughness * roughness); + half a = max(0.001f, roughness); half a2 = a*a; half d = ((NdotH * NdotH) * (a2 - 1.0) + 1.0); @@ -31,6 +31,7 @@ half D_Get(half roughness, half NdotH) //////////////////////// half F_Get(half f0, half HdotV) { + //return lerp(pow(1.0 - NoV, 5.0), 1,f0); return (f0 + (1.0f - f0) * pow((1.0f - HdotV), 5)) * (f0 > 0.001f ? 1 : 0); } //////////////////////////////// @@ -42,9 +43,10 @@ half G_Get(half NdotV, half NdotL, half LdotV, half NdotH,half VdotH) half GetSpecular(half4 matparam,half NdotH,half NdotV,half NdotL,half VdotL,half HdotV) { + matparam.x = lerp(0.0f,0.5f,matparam.x); half D = D_Get(matparam.x, NdotH); half G = G_Get(NdotV,NdotL,VdotL,NdotH,HdotV); - half3 F = F_Get(matparam.y, HdotV); + half3 F = F_Get(matparam.y*matparam.y, HdotV); return ((D*G)/(PI*NdotL*NdotV))*F; } diff --git a/source/GRegisterIndex.h b/source/GRegisterIndex.h index c807d3ffbc2788772764c8052e3014b087b3534c..cfb3ffe818f3dbaa26879fdce17188160112b2d1 100644 --- a/source/GRegisterIndex.h +++ b/source/GRegisterIndex.h @@ -30,7 +30,7 @@ See the license in LICENSE #define G_RI_BOOL_RENDER_WINDOWED 1 /*!< оконный рендер - true, полноэкранный - false */ //! @} -/*! @name float3 register */ +/*! @name float register */ //! @{ #define G_RI_FLOAT_OBSERVER_NEAR 0 /*!< ближняя плоскость отсечения наблюдателя */ #define G_RI_FLOAT_OBSERVER_FAR 1 /*!< дальняя плоскость отсечения наблюдателя или дальность видимости */ @@ -53,6 +53,9 @@ See the license in LICENSE #define G_RI_INT_COUNT_DIP 1 /*!< количество вызовов draw indexed primitive */ #define G_RI_INT_CURRIDLIGHT 2 /*!< текущий идентификатор источнкиа света */ #define G_RI_INT_RENDERSTATE 3 /*!< текущее состояние рендера */ + +#define G_RI_INT_TIMER_RENDER 4 /*!< время для рендера */ +#define G_RI_INT_TIMER_GAME 5 /*!< время для игры */ //! @} #endif \ No newline at end of file diff --git a/source/SkyXEngine.h b/source/SkyXEngine.h index 16824d4cc20e9b760c3f791707cba3795c051775..5773e75e65724f2615319aabdeb4339644ba703b 100644 --- a/source/SkyXEngine.h +++ b/source/SkyXEngine.h @@ -4,7 +4,6 @@ Copyright © Vitaliy Buturlin, Evgeny Danilovich, 2017 See the license in LICENSE ******************************************************/ - /*! \file Заголовочный файл движка SkyXEngine, подключает все необходимые библиотеки @@ -186,9 +185,12 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот #include <windows.h> #include <ctime> #include <gdefines.h> +#include <cdata.h> #include <common\\array.h> #include <common\\string.cpp> +//ЗАГРУЗКА БИБЛИОТЕК +//{ #if defined(_DEBUG) #pragma comment(lib, "sxcore_d.lib") #else @@ -224,7 +226,6 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот #endif #include <geom\\sxgeom.h> - #if defined(_DEBUG) #pragma comment(lib, "sxmtllight_d.lib") #else @@ -283,6 +284,8 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот #include <sxguiwinapi\\sxgui.h> #endif +//} + #include <managed_render\\gdata.h> #include <common\\string_api.cpp> #include <managed_render\\camera_update.h> @@ -311,20 +314,38 @@ QT стиль документирования (!) и QT_AUTOBRIEF - корот #include <managed_render\\level.cpp> - +//!< инициализация движка void SkyXEngine_Init() { + srand((UINT)time(0)); + InitOutLog(); GData::Pathes::InitAllPathes(); if (!Core_0IsProcessRun("sxconsole.exe")) ShellExecute(NULL, "open", "sxconsole.exe", NULL, GData::Pathes::ForExe, SW_SHOWNORMAL); SetConsoleTitle("sxconsole"); + +#if defined(SX_GAME) + GData::InitWin("SkyXEngine", "SkyXEngine"); +#endif + SSInput_0Create("sxinput", GData::Handle3D, true); SSInput_Dbg_Set(printflog); Core_0Create("sxcore", true); Core_SetOutPtr(); + G_Timer_Render_Scene = Core_TimeAdd(); + G_Timer_Game = Core_TimeAdd(); + Core_RIntSet(G_RI_INT_TIMER_RENDER, G_Timer_Render_Scene); + Core_RIntSet(G_RI_INT_TIMER_GAME, G_Timer_Game); + + tm ct = {0,0,9,27,5,2030-1900,0,0,0}; + Core_TimeUnixStartSet(G_Timer_Game, mktime(&ct)); + + Core_TimeWorkingSet(G_Timer_Render_Scene, true); + Core_TimeWorkingSet(G_Timer_Game, true); + SSCore_0Create("sxsound", GData::Handle3D, GData::Pathes::Sounds,false); SSCore_Dbg_Set(printflog); @@ -360,6 +381,7 @@ void SkyXEngine_Init() SPE_0Create("sxparticles", SGCore_GetDXDevice(), false); SPE_Dbg_Set(printflog); + Level::LoadParticles(); SPP_0Create("sxpp", SGCore_GetDXDevice(), &GData::WinSize, false); SPP_Dbg_Set(printflog); @@ -389,11 +411,11 @@ void SkyXEngine_Init() #endif #if defined(SX_LEVEL_EDITOR) || defined(SX_PARTICLES_EDITOR) - GData::ObjGrid = new Grid(); - GData::ObjGrid->Create(100, 100, D3DCOLOR_ARGB(255, 200, 200, 200)); + GData::Editors::ObjGrid = new Grid(); + GData::Editors::ObjGrid->Create(100, 100, D3DCOLOR_ARGB(255, 200, 200, 200)); - GData::ObjAxesStatic = new AxesStatic(); - GData::ObjAxesStatic->Create(1); + GData::Editors::ObjAxesStatic = new AxesStatic(); + GData::Editors::ObjAxesStatic->Create(1); GData::ObjCamera->SetPosition(&float3(0, 0.5, -2)); @@ -434,8 +456,234 @@ void SkyXEngine_Init() #endif } +//!< рендер +void SkyXEngine_Render(DWORD timeDelta) +{ + int64_t ttime; + //потеряно ли устройство или произошло изменение размеров? + if (GData::DXDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || GData::ReSize) + { + //если не свернуто окно + if (!IsIconic(GData::Handle3D) && ((GData::HandleParent3D != 0 && !IsIconic(GData::HandleParent3D)) || GData::HandleParent3D == 0)) + SXRenderFunc::ComDeviceLost(); //пытаемся восстановить + return; + } + +#ifndef SX_GAME + CameraUpdate::UpdateEditorial(timeDelta); +#endif + + SXAnim_Update(); + SXGame_Update(); + SXPhysics_Update(); + + SXAnim_Sync(); + SXPhysics_Sync(); + SXGame_Sync(); + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SGeom_ModelsMSortGroups(&GData::ConstCurrCamPos, 2); + SXRenderFunc::Delay::GeomSortGroup += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + if (GData::DefaultGeomIDArr < 0) + GData::DefaultGeomIDArr = SGeom_ModelsAddArrForCom(); + + if (GData::DefaultGreenIDArr < 0) + GData::DefaultGreenIDArr = SGeom_GreenAddArrForCom(); + + if (GData::DefaultAnimIDArr < 0) + GData::DefaultAnimIDArr = SXAnim_ModelsAddArrForCom(); + + /**/ + if (SGeom_GreenGetOccurencessLeafGrass(&float3(GData::ConstCurrCamPos - float3(0.25, 1.8, 0.25)), &float3(GData::ConstCurrCamPos + float3(0.25, 0, 0.25)), MtlPhysicType::mpt_leaf_grass)) + SXRenderFunc::Delay::FreeVal = 1; + else + SXRenderFunc::Delay::FreeVal = 0; + /**/ + + SXRenderFunc::UpdateView(); + SML_Update(timeDelta, &GData::WinSize, &GData::NearFar, &GData::ConstCurrCamPos, &GData::MCamView, GData::ProjFov); + + GData::DXDevice->BeginScene(); + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::UpdateReflection(timeDelta); + SXRenderFunc::Delay::ComReflection += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + if (GData::FinalImage == DS_RT::ds_rt_ambient_diff || GData::FinalImage == DS_RT::ds_rt_specular || GData::FinalImage == DS_RT::ds_rt_scene_light_com) + { + //рендерим глубину от света + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::UpdateShadow(timeDelta); + SXRenderFunc::Delay::UpdateShadow += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + } + + //рисуем сцену и заполняем mrt данными + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::RenderInMRT(timeDelta); + SXRenderFunc::Delay::RenderMRT += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + if (GData::FinalImage == DS_RT::ds_rt_ambient_diff || GData::FinalImage == DS_RT::ds_rt_specular || GData::FinalImage == DS_RT::ds_rt_scene_light_com) + { + //освещаем сцену + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::ComLighting(timeDelta, true); + SXRenderFunc::Delay::ComLighting += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + } + + GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); + GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE); + +#if defined(SX_GAME) + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::RenderPostProcess(timeDelta); + SXRenderFunc::Delay::PostProcess += TimeGetMcsU(G_Timer_Render_Scene) - ttime; +#endif + + SGCore_ShaderBind(ShaderType::st_vertex, GData::IDsShaders::VS::ScreenOut); + SGCore_ShaderBind(ShaderType::st_pixel, GData::IDsShaders::PS::ScreenOut); + + GData::DXDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); + +#if !defined(SX_GAME) + GData::DXDevice->SetTexture(0, SML_DSGetRT(GData::FinalImage)); +#else + GData::DXDevice->SetTexture(0, SGCore_RTGetTexture(SPP_RTGetCurrSend())); +#endif + + SGCore_ScreenQuadDraw(); + + SGCore_ShaderUnBind(); + + SXRenderFunc::RenderParticles(timeDelta); + + SXRenderFunc::RenderEditorMain(); + SXRenderFunc::RenderEditorLE(timeDelta); + + SXRenderFunc::OutputDebugInfo(timeDelta); + + SXPhysics_DebugRender(); + //SXGame_EditorRender(); + + SXRenderFunc::ShaderRegisterData(); + + GData::DXDevice->EndScene(); + + //@@@ + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::ComVisibleForCamera(); + SXRenderFunc::Delay::UpdateVisibleForCamera += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::ComVisibleReflection(); + SXRenderFunc::Delay::UpdateVisibleForReflection += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SXRenderFunc::ComVisibleForLight(); + SXRenderFunc::Delay::UpdateVisibleForLight += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + SPE_EffectVisibleComAll(GData::ObjCamera->ObjFrustum, &GData::ConstCurrCamPos); + SPE_EffectComputeAll(); + SPE_EffectComputeLightingAll(); + SXRenderFunc::Delay::UpdateParticles += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + + ttime = TimeGetMcsU(G_Timer_Render_Scene); + GData::DXDevice->Present(0, 0, 0, 0); + SXRenderFunc::Delay::Present += TimeGetMcsU(G_Timer_Render_Scene) - ttime; + +#if defined(SX_LEVEL_EDITOR) + GData::Editors::LevelEditorUpdateStatusBar(); +#endif + +#if defined(SX_PARTICLES_EDITOR) + GData::Editors::ParticlesEditorUpdateStatusBar(); +#endif +} + +//!< запуск основного цикла обработки +int SkyXEngine_CycleMain() +{ + MSG msg; + ::ZeroMemory(&msg, sizeof(MSG)); + + static DWORD lastTime = TimeGetMls(G_Timer_Render_Scene); + + while (msg.message != WM_QUIT && IsWindow(GData::Handle3D)) + { + if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + ::TranslateMessage(&msg); + +#if !defined(SX_GAME) + IMSG imsg; + imsg.lParam = msg.lParam; + imsg.wParam = msg.wParam; + imsg.message = msg.message; + + SSInput_AddMsg(imsg); +#endif + + ::DispatchMessage(&msg); + } + else + { + Core_TimesUpdate(); + Core_0ConsoleUpdate(); + SSInput_Update(); + SSCore_Update(&GData::ConstCurrCamPos, &GData::ConstCurrCamDir); + SGCore_LoadTexLoadTextures(); + + if (SSInput_GetKeyEvents(SIK_T) == InputEvents::iv_k_first) + { + Core_TimeWorkingSet(G_Timer_Render_Scene, !Core_TimeWorkingGet(G_Timer_Render_Scene)); + /*for (int i = 0; i < 1; ++i) + { + ID tmpid = SPE_EffectIdOfKey(i); + //SPE_EffectPosSet(tmpid, &float3(i, 0, k)); + SPE_EffectAlifeSet(tmpid, !SPE_EffectAlifeGet(tmpid)); + }*/ + } + + DWORD currTime = TimeGetMls(G_Timer_Render_Scene); + DWORD timeDelta = (currTime - lastTime); + +#ifdef SX_GAME + GData::ObjCamera = SXGame_GetActiveCamera(); +#endif + + if (Core_TimeWorkingGet(G_Timer_Render_Scene) && (GetForegroundWindow() == GData::Handle3D || GetForegroundWindow() == FindWindow(NULL, "sxconsole"))) + { + +#if defined(SX_LEVEL_EDITOR) + SXLevelEditor_Transform(10); +#endif + + SkyXEngine_Render(timeDelta); + } + + lastTime = currTime; + } + } + + return msg.wParam; +} + +//!< уничтожение данных движка, освобождение памяти void SkyXEngine_Kill() { +#if defined(SX_MATERIAL_EDITOR) + mem_delete(GData::Editors::SimModel); +#endif + +#if !defined(SX_GAME) + mem_delete(GData::Editors::ObjGrid); + mem_delete(GData::Editors::ObjAxesStatic); + mem_release(GData::Editors::FigureBox); + mem_release(GData::Editors::FigureSphere); + mem_release(GData::Editors::FigureCone); +#endif + SXGame_0Kill(); SXDecals_AKill(); SXPhysics_AKill(); diff --git a/source/cdata.h b/source/cdata.h new file mode 100644 index 0000000000000000000000000000000000000000..dff9d184faf1f4dffae6fa10e533d7494ca82a77 --- /dev/null +++ b/source/cdata.h @@ -0,0 +1,26 @@ + +/****************************************************** +Copyright � Vitaliy Buturlin, Evgeny Danilovich, 2017 +See the license in LICENSE +******************************************************/ + +/*! +\file +����� ������ ������������� (��� ���������) �����. +*/ + +#ifndef __cdata_h +#define __cdata_h + +#include <common/sxtypes.h> + +/*! \name �������������� �������� +@{ +*/ + +static ID G_Timer_Render_Scene = -1; //!< ������ ������� ����� +static ID G_Timer_Game = -1; //!< ������� ������ + +//!@} + +#endif \ No newline at end of file diff --git a/source/core/sxcore.cpp b/source/core/sxcore.cpp index 6b524660da5cad46c7928d6a10571f696475a71e..e78bd38013cc72b50089365ec5fa0209e7a17d26 100644 --- a/source/core/sxcore.cpp +++ b/source/core/sxcore.cpp @@ -21,7 +21,7 @@ See the license in LICENSE #include <core/concmd.cpp> #include <core/cvars.cpp> -#pragma comment(lib, "winmm.lib") +#include <core/time.cpp> char CoreName[CORE_NAME_MAX_LEN]; @@ -45,6 +45,9 @@ if (!(id >= 0 && id < CORE_REGISTRY_SIZE))\ {reportf(REPORT_MSG_LEVEL_ERROR, "[CORE] %s - unresolved index '%d' of access for registry", gen_msg_location, id); return stdval; } +TimeManager* Timers = 0; +#define CORE_TIME_PRECOND(retval) if(!Timers){reportf(-1, "%s - sxcore is not init", gen_msg_location); return retval;} + //функции обертки long Core_0GetVersion() { @@ -127,6 +130,7 @@ void Core_0Create(const char* name, bool is_unic) ConsoleConnect(); ConsoleRegisterCmds(); TaskManager = new SXTaskManager(); + Timers = new TimeManager(); } else reportf(-1, "%s - not init argument [name], sgcore", gen_msg_location); @@ -266,4 +270,88 @@ void Core_RFloat3Get(int id, float3* val) if (val) memcpy(val, &GRegistersFloat3[id], sizeof(float3)); +} + +//// + + +ID Core_TimeAdd() +{ + CORE_TIME_PRECOND(-1); + + return Timers->TimeAdd(); +} + +void Core_TimesUpdate() +{ + CORE_TIME_PRECOND(_VOID); + + Timers->Update(); +} + + +void Core_TimeSpeedSet(ID id, float speed) +{ + CORE_TIME_PRECOND(_VOID); + + Timers->TimeSpeedSet(id, speed); +} + +float Core_TimeSpeedGet(ID id) +{ + CORE_TIME_PRECOND(0); + + return Timers->TimeSpeedGet(id); +} + + +void Core_TimeWorkingSet(ID id, bool working) +{ + CORE_TIME_PRECOND(_VOID); + + Timers->TimeWorkingSet(id, working); +} + +bool Core_TimeWorkingGet(ID id) +{ + CORE_TIME_PRECOND(false); + + return Timers->TimeWorkingGet(id); +} + + +void Core_TimeUnixStartSet(ID id, int64_t start_time) +{ + CORE_TIME_PRECOND(_VOID); + + Timers->TimeUnixStartSet(id, start_time); +} + +int64_t Core_TimeUnixStartGet(ID id) +{ + CORE_TIME_PRECOND(0); + + return Timers->TimeUnixStartGet(id); +} + +int64_t Core_TimeUnixCurrGet(ID id) +{ + CORE_TIME_PRECOND(0); + + return Timers->TimeUnixCurrGet(id); +} + + +int64_t Core_TimeTotalMcsGet(ID id) +{ + CORE_TIME_PRECOND(0); + + return Timers->TimeTotalMcsGet(id); +} + +int64_t Core_TimeTotalMcsGetU(ID id) +{ + CORE_TIME_PRECOND(0); + + return Timers->TimeTotalMcsGetU(id); } \ No newline at end of file diff --git a/source/core/sxcore.h b/source/core/sxcore.h index d317bd0d9c3c3105272577a0a837d80c9bee41e8..6153e97a2f6f54735bdce84793fca187349461b8 100644 --- a/source/core/sxcore.h +++ b/source/core/sxcore.h @@ -77,7 +77,7 @@ SX_LIB_API void Core_MTaskStop(); //!< остановить все задачи //! @} /*! @name Регистры -создает потоки по количеству ядер +Массивы данных, определенных типов, доступные в любой библиотеке включающей в себя ядро */ //! @{ @@ -100,6 +100,46 @@ SX_LIB_API void Core_RFloat3Get(int id, float3* val); //!< получение з //! @} +/*! \name Таймеры + \note Для Unix даты рекомендуется использовать функции: + - localtime или localtime_s (из структуры tm в общее количество секунд), + - mktime (из общего количества секунд в структуру tm). + \note По умолчанию Unix дата используется time(NULL) в момент создания таймера + \note Все возвращаемое время вычисляется в соответсвии с коэфициентом скорости + \note Функции возвращающие время без постфикса U (update) требуют обновления, которое происходит в функции #Core_TimesUpdate +@{ +*/ + +SX_LIB_API ID Core_TimeAdd(); //!< добавление таймера + +SX_LIB_API void Core_TimesUpdate(); //!< обновление всех таймеров + +SX_LIB_API void Core_TimeSpeedSet(ID id, float speed); //!< установка скорости течения времени +SX_LIB_API float Core_TimeSpeedGet(ID id); //!< возвращает скоротечность времени для таймера + +SX_LIB_API void Core_TimeWorkingSet(ID id, bool working); //!< установка состояния запуска таймера +SX_LIB_API bool Core_TimeWorkingGet(ID id); //!< запущен ли таймер + +SX_LIB_API void Core_TimeUnixStartSet(ID id, int64_t start_time); //!< установить стартовую дату в Unix в секундах +SX_LIB_API int64_t Core_TimeUnixStartGet(ID id); //!< возвращает стартовую дату в Unix в секундах +SX_LIB_API int64_t Core_TimeUnixCurrGet(ID id); //!< возвращает текущюю дату в Unix в секундах + +SX_LIB_API int64_t Core_TimeTotalMcsGet(ID id); //!< возвращает общее время работы таймера в микросекундах (требует обновления) + +#define Core_TimeTotalMlsGet(id) Core_TimeTotalMcsGet(id)/1000 //!< возвращает общее время работы таймера в миллисекундах (требует обновления) + +#define TimeGetMls(id) Core_TimeTotalMlsGet(id) //!< возвращает общее время работы таймера в миллисекундах (требует обновления) +#define TimeGetMcs Core_TimeTotalMcsGet //!< возвращает общее время работы таймера в микросекундах (требует обновления) + +SX_LIB_API int64_t Core_TimeTotalMcsGetU(ID id); //!< возвращает общее время работы таймера в микросекундах (независимо от обновления) + +#define Core_TimeTotalMlsGetU(id) Core_TimeTotalMcsGetU(id)/1000 //!< возвращает общее время работы таймера в микросекундах (независимо от обновления) + +#define TimeGetMlsU(id) Core_TimeTotalMlsGetU(id) //!< возвращает общее время работы таймера в миллисекундах (независимо от обновления) +#define TimeGetMcsU Core_TimeTotalMcsGetU //!< возвращает общее время работы таймера в микросекундах (независимо от обновления) + +//!@} + /*! @name Режимы открытия файлов */ //! @{ #define CORE_FILE_BIN 0 /*!< двоичный */ diff --git a/source/core/time.cpp b/source/core/time.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de2e5f7e896fd71eb0d1a8b2cf9a83c322f0495f --- /dev/null +++ b/source/core/time.cpp @@ -0,0 +1,133 @@ + +#include <core\\time.h> + +TimeManager::TimeManager() +{ + +} + +TimeManager::~TimeManager() +{ + for (int i = 0; i < ArrTimes.size(); ++i) + { + mem_delete(ArrTimes[i]); + } + + ArrTimes.clear(); +} + +TimeManager::Time::Time() +{ + time_total = 0; + speed = 1.f; + working = false; + unixtime_start = time(NULL); + unixtime_curr = unixtime_start; + tp = std::chrono::high_resolution_clock::now(); + delta_fraction = 0; +} + +TimeManager::Time::~Time() +{ + +} + + + +void TimeManager::Update() +{ + time_point tcurr = std::chrono::high_resolution_clock::now(); + + Time* tobj = 0; + for (int i = 0; i < ArrTimes.size(); ++i) + { + tobj = ArrTimes[i]; + if (tobj->working) + { + tobj->delta_fraction += (long double)std::chrono::duration_cast<std::chrono::microseconds>(tcurr - tobj->tp).count() * tobj->speed; + tobj->time_total += (int64_t)tobj->delta_fraction; + tobj->delta_fraction -= (int64_t)tobj->delta_fraction; + tobj->unixtime_curr = tobj->unixtime_start + (tobj->time_total / 1000000); + } + + tobj->tp = tcurr; + } +} + +ID TimeManager::TimeAdd() +{ + Time* tobj = new Time(); + ArrTimes.push_back(tobj); + return ArrTimes.size()-1; +} + +void TimeManager::TimeSpeedSet(ID id, float speed) +{ + TIMEMANAGER_PRECOND_ID(id, _VOID); + ArrTimes[id]->speed = speed; +} + +float TimeManager::TimeSpeedGet(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, 0); + return ArrTimes[id]->speed; +} + +void TimeManager::TimeWorkingSet(ID id, bool working) +{ + TIMEMANAGER_PRECOND_ID(id, _VOID); + + if (working && !(ArrTimes[id]->working)) + ArrTimes[id]->tp = std::chrono::high_resolution_clock::now(); + + ArrTimes[id]->working = working; +} + +bool TimeManager::TimeWorkingGet(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, false); + + return ArrTimes[id]->working; +} + +void TimeManager::TimeUnixStartSet(ID id, int64_t start_time) +{ + TIMEMANAGER_PRECOND_ID(id, _VOID); + + ArrTimes[id]->unixtime_start = start_time; +} + +int64_t TimeManager::TimeUnixStartGet(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, 0); + + return ArrTimes[id]->unixtime_start; +} + +int64_t TimeManager::TimeUnixCurrGet(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, 0); + + return ArrTimes[id]->unixtime_curr; +} + +int64_t TimeManager::TimeTotalMcsGet(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, 0); + + return ArrTimes[id]->time_total; +} + +int64_t TimeManager::TimeTotalMcsGetU(ID id) +{ + TIMEMANAGER_PRECOND_ID(id, 0); + + Time* tobj = ArrTimes[id]; + + if (!tobj->working) + return tobj->time_total; + + time_point tcurr = std::chrono::high_resolution_clock::now(); + + return tobj->time_total + (int64_t)((long double)std::chrono::duration_cast<std::chrono::microseconds>(tcurr - tobj->tp).count() * tobj->speed); +} \ No newline at end of file diff --git a/source/core/time.h b/source/core/time.h new file mode 100644 index 0000000000000000000000000000000000000000..42bbfd366c9206e0d15b239360111a407769a062 --- /dev/null +++ b/source/core/time.h @@ -0,0 +1,55 @@ + +#ifndef __time_h +#define __time_h + +#include <chrono> + +typedef std::chrono::system_clock::time_point time_point; + +#define TIMEMANAGER_PRECOND_ID(id,stdval) \ +if (!(id >= 0 && id < ArrTimes.size()))\ +{reportf(REPORT_MSG_LEVEL_ERROR, "%s - time manager: unresolved index of access '%d'", gen_msg_location, id); return stdval; } + +class TimeManager +{ +public: + + TimeManager(); + ~TimeManager(); + + struct Time + { + Time(); + ~Time(); + + time_point tp; + int64_t time_total; //����� ��������� ����� � ������� ������� + long double delta_fraction; + int64_t unixtime_curr; //������� ����� � unix + int64_t unixtime_start; + float speed; + bool working; + }; + + void Update(); + + ID TimeAdd(); + + inline void TimeSpeedSet(ID id, float speed); + inline float TimeSpeedGet(ID id); + + inline void TimeWorkingSet(ID id, bool working); + inline bool TimeWorkingGet(ID id); + + inline void TimeUnixStartSet(ID id, int64_t start_time); + inline int64_t TimeUnixStartGet(ID id); + inline int64_t TimeUnixCurrGet(ID id); + + inline int64_t TimeTotalMcsGet(ID id); + inline int64_t TimeTotalMcsGetU(ID id); + +protected: + Array<Time*> ArrTimes; +}; + +#endif \ No newline at end of file diff --git a/source/gcore/camera_fly.cpp b/source/gcore/camera_fly.cpp deleted file mode 100644 index 35baa9d6770e0f53fd4f3168da6747e61f050743..0000000000000000000000000000000000000000 --- a/source/gcore/camera_fly.cpp +++ /dev/null @@ -1,217 +0,0 @@ - -#pragma once - -namespace SkyXEngine -{ -namespace Core -{ -namespace ControllMoving -{ - -CameraFly::CameraFly() -{ - ConfigFly = 0; - bfIsFly = false; - ActiveSection[0] = 0; - CurrentSection[0] = 0; - SecondSection[0] = 0; - - ActivePos = float3(0,0,0); - LastPos = float3(0,0,0); - - ActiveAngleUpDown = 0; - ActiveAngleRightLeft = 0; - ActiveAngleRoll = 0; - - LastAngleUpDown = 0; - LastAngleRightLeft = 0; - LastAngleRoll = 0; - - LerpPos = 0; - LerpAngleUpDown = 0; - LerpAngleRightLeft = 0; - LerpAngleRoll = 0; - - SecTimePos = 0; - SecTimeRot = 0; - CurrTime = 0; -} - -CameraFly::~CameraFly() -{ - ConfigFly->Release(); -} - -void CameraFly::LoadInit(const char* path) -{ - ConfigFly = new SkyXEngine::Core::Loaders::LoaderConfig(path); -} - -void CameraFly::Activate(const char* section) -{ - if(ConfigFly->SectionExists(section,true)) - { - sprintf(ActiveSection,"%s",section); - LoadSecondSection(true); - } - else - { - Core::InLog("FlyCamera: activate section not found [%s]\n",section); - bfIsFly = false; - } -} - -void CameraFly::LoadSecondSection(bool isstart) -{ - bool is_section_exists = true; - String second_section; - if(isstart) - { - if(ConfigFly->SectionExists(ActiveSection,"start_section")) - { - second_section = ConfigFly->Get(ActiveSection,"start_section"); - Core::Data::ObjCamera->GetPosition(&OldPos); - - OldAngleUpDown = Core::Data::ObjCamera->GetRotationX(); - OldAngleRightLeft = Core::Data::ObjCamera->GetRotationY(); - OldAngleRoll = Core::Data::ObjCamera->GetRotationZ(); - } - else - { - Core::InLog("FlyCamera: start section not found, active section [%s]\n",ActiveSection); - is_section_exists = false; - } - } - else - { - if(ConfigFly->SectionExists(ActiveSection,"second_section")) - second_section = ConfigFly->Get(ActiveSection,"second_section"); - else - { - Core::InLog("FlyCamera: second section not found, active section [%s]\n",ActiveSection); - is_section_exists = false; - } - } - - if(is_section_exists) - { - ActiveSection[0] = 0; - sprintf(ActiveSection,"%s",second_section.c_str()); - if(StrValidate(ActiveSection)) - { - SecTimePos = ConfigFly->Get(ActiveSection,"time_pos").ToUnsLongInt(); - SecTimeRot = ConfigFly->Get(ActiveSection,"time_rot").ToUnsLongInt(); - String strpos = ConfigFly->Get(ActiveSection,"pos"); - String strrot = ConfigFly->Get(ActiveSection,"rot"); - LerpPos = ConfigFly->Get(ActiveSection,"pos_lerp").ToBool(); - LerpAngleRoll = LerpAngleRightLeft = LerpAngleUpDown = ConfigFly->Get(ActiveSection,"rot_lerp").ToBool(); - String strsecond_section = ConfigFly->Get(ActiveSection,"second_section"); - - - if(strcmp(strpos.c_str(),"old") == 0) - { - ActivePos = OldPos; - } - else - { - char tmpstrpos[64]; - sprintf(tmpstrpos,"%s",strpos.c_str()); - char* tmppos = strtok(tmpstrpos," ,|"); - if(tmppos) - ActivePos[0] = String(tmppos).ToDouble(); - - for(int i=1;i<3 && (tmppos = strtok(0," ,|")) != NULL;i++) - { - ActivePos[i] = String(tmppos).ToDouble(); - } - } - - if(strcmp(strrot.c_str(),"old") == 0) - { - ActiveAngleUpDown = OldAngleUpDown; - ActiveAngleRightLeft = OldAngleRightLeft; - ActiveAngleRoll = OldAngleRoll; - } - else - { - char tmpstrrot[64]; - sprintf(tmpstrrot,"%s",strrot.c_str()); - char* tmprot = strtok(tmpstrrot," ,|"); - if(tmprot) - ActiveAngleUpDown = String(tmprot).ToDouble(); - - tmprot = strtok(0," ,|"); - if(tmprot) - ActiveAngleRightLeft = String(tmprot).ToDouble(); - - tmprot = strtok(0," ,|"); - if(tmprot) - ActiveAngleRoll = String(tmprot).ToDouble(); - } - - CurrTime = 0; - bfIsFly = true; - } - else - { - bfIsFly = false; - } - } - else - { - bfIsFly = false; - } -} - -inline bool CameraFly::IsFly() -{ - return bfIsFly; -} - -void CameraFly::Update(DWORD timeDelta) -{ - if(bfIsFly) - { - CurrTime += timeDelta; - float percent_pos = float(CurrTime) / float(SecTimePos); - - if((SecTimePos >= SecTimeRot && CurrTime >= SecTimePos) || (SecTimePos <= SecTimeRot && CurrTime >= SecTimeRot)) - { - Core::Data::ObjCamera->SetPosition(&ActivePos); - LastPos = ActivePos; - LastAngleUpDown = ActiveAngleUpDown; - LastAngleRightLeft = ActiveAngleRightLeft; - LastAngleRoll = ActiveAngleRoll; - LoadSecondSection(); - } - else - { - if(LerpPos) - Core::Data::ObjCamera->SetPosition(&float3(lerp(LastPos.x,ActivePos.x,percent_pos),lerp(LastPos.y,ActivePos.y,percent_pos),lerp(LastPos.z,ActivePos.z,percent_pos))); - else - Core::Data::ObjCamera->SetPosition(&ActivePos); - - if(CurrTime < SecTimeRot) - { - if(LerpAngleUpDown) - Core::Data::ObjCamera->RotUpDown((ActiveAngleUpDown - LastAngleUpDown) * ((float(timeDelta) * 0.001f) / (float(SecTimeRot) * 0.001f))); - else - Core::Data::ObjCamera->RotUpDown(ActiveAngleUpDown); - - if(LerpAngleRightLeft) - Core::Data::ObjCamera->RotRightLeft((ActiveAngleRightLeft - LastAngleRightLeft) * ((float(timeDelta) * 0.001f) / (float(SecTimeRot) * 0.001f))); - else - Core::Data::ObjCamera->RotRightLeft(ActiveAngleRightLeft); - - if(LerpAngleRoll) - Core::Data::ObjCamera->RotUpDown((ActiveAngleRoll - LastAngleRoll) * ((float(timeDelta) * 0.001f) / (float(SecTimeRot) * 0.001f))); - else - Core::Data::ObjCamera->RotUpDown(ActiveAngleRoll); - } - } - } -} - -}; -}; -}; \ No newline at end of file diff --git a/source/gcore/camera_fly.h b/source/gcore/camera_fly.h deleted file mode 100644 index feaff609551fc78a02335c5ec32794b8ad03d949..0000000000000000000000000000000000000000 --- a/source/gcore/camera_fly.h +++ /dev/null @@ -1,52 +0,0 @@ - -#pragma once - -class CameraFly -{ -public: - - SX_ALIGNED_OP_MEM - - CameraFly(); - ~CameraFly(); - - void LoadInit(const char* path); - void LoadSecondSection(bool isstart=false); - void Activate(const char* section); - void Update(DWORD timeDelta); - inline bool IsFly(); - - SkyXEngine::Core::Loaders::LoaderConfig* ConfigFly; - - char ActiveSection[32]; - char CurrentSection[32]; - char SecondSection[32]; - - //��������� ������ �� ���� ������� ��� ����� ���� ���������� - float3 OldPos; - float OldAngleUpDown; - float OldAngleRightLeft; - float OldAngleRoll; - - - float3 ActivePos; - float3 LastPos; - - float ActiveAngleUpDown; - float ActiveAngleRightLeft; - float ActiveAngleRoll; - - float LastAngleUpDown; - float LastAngleRightLeft; - float LastAngleRoll; - - bool LerpPos; - bool LerpAngleUpDown; - bool LerpAngleRightLeft; - bool LerpAngleRoll; - - DWORD SecTimePos; - DWORD SecTimeRot; - DWORD CurrTime; - bool bfIsFly; -}; \ No newline at end of file diff --git a/source/geom/green.cpp b/source/geom/green.cpp index 767a7b509bea51fefcc7c166beffb3747d9afba1..33bedaa7c02cf836391fa9452508a16c4dc3fc6a 100644 --- a/source/geom/green.cpp +++ b/source/geom/green.cpp @@ -19,7 +19,7 @@ Green::Green() Green::DXDevice->CreateVertexDeclaration(InstanceGreen, &VertexDeclarationGreen); Green::DXDevice->CreateVertexBuffer( - GREEN_MAX_ELEM_IN_DIP * sizeof(DataVertex), + GREEN_MAX_ELEM_IN_DIP * sizeof(GreenDataVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT/*D3DPOOL_MANAGED*/, @@ -164,7 +164,7 @@ void Green::OnLostDevice() void Green::OnResetDevice() { Green::DXDevice->CreateVertexBuffer( - GREEN_MAX_ELEM_IN_DIP * sizeof(DataVertex), + GREEN_MAX_ELEM_IN_DIP * sizeof(GreenDataVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT/*D3DPOOL_MANAGED*/, @@ -223,8 +223,8 @@ void Green::PreSegmentation(Model* model, float3* min_level, float3* max_level) model->SplitsTree->CountAllGreen = model->AllCountGreen; if (model->AllCountGreen > 0) { - model->SplitsTree->Data = new DataVertex[model->AllCountGreen]; - memcpy(model->SplitsTree->Data, model->AllTrans, sizeof(DataVertex)* model->AllCountGreen); + model->SplitsTree->Data = new GreenDataVertex[model->AllCountGreen]; + memcpy(model->SplitsTree->Data, model->AllTrans, sizeof(GreenDataVertex)* model->AllCountGreen); } if (model->SplitsTree->CountAllGreen > 0) @@ -327,7 +327,7 @@ void Green::Segmentation(Segment* Split, Model* mesh) if (Split->Splits[i]->CountAllGreen > 0) { - Split->Splits[i]->Data = new DataVertex[Split->Splits[i]->CountAllGreen]; + Split->Splits[i]->Data = new GreenDataVertex[Split->Splits[i]->CountAllGreen]; for (DWORD k = 0; k < ArrPoly[i].size(); k++) { Split->Splits[i]->Data[k] = Split->Data[ArrPoly[i][k]]; @@ -553,7 +553,7 @@ void Green::GPURender2(DWORD timeDelta, float3* viewpos, ID nm, int lod, ID id_t Green::DXDevice->SetStreamSourceFreq(0, (D3DSTREAMSOURCE_INDEXEDDATA | RTCountDrawObj)); Green::DXDevice->SetStreamSourceFreq(1, (D3DSTREAMSOURCE_INSTANCEDATA | 1)); - Green::DXDevice->SetStreamSource(1, TransVertBuf, 0, sizeof(DataVertex)); + Green::DXDevice->SetStreamSource(1, TransVertBuf, 0, sizeof(GreenDataVertex)); Green::DXDevice->SetStreamSource(0, ArrModels[nm]->ArrLod[lod]->model->VertexBuffer, 0, sizeof(vertex_static)); Green::DXDevice->SetIndices(ArrModels[nm]->ArrLod[lod]->model->IndexBuffer); @@ -635,7 +635,7 @@ void Green::GPURender(DWORD timeDelta, float3* viewpos, GeomGreenType type, ID i { memcpy(RTGPUArrVerteces + (RTCountDrawObj), jarrsplits[i]->Data, - jarrsplits[i]->CountAllGreen * sizeof(DataVertex)); + jarrsplits[i]->CountAllGreen * sizeof(GreenDataVertex)); RTCountDrawObj += jarrsplits[i]->CountAllGreen; } @@ -646,7 +646,7 @@ void Green::GPURender(DWORD timeDelta, float3* viewpos, GeomGreenType type, ID i { memcpy(RTGPUArrVerteces + (RTCountDrawObj), jarrsplits[i]->Data, - jarrsplits[i]->CountAllGreen * sizeof(DataVertex)); + jarrsplits[i]->CountAllGreen * sizeof(GreenDataVertex)); RTCountDrawObj += jarrsplits[i]->CountAllGreen; } @@ -661,7 +661,7 @@ void Green::GPURender(DWORD timeDelta, float3* viewpos, GeomGreenType type, ID i UINT curCP = (int)floor(k + 0.5);; if (curCP > lastCP) { - memcpy(RTGPUArrVerteces + RTCountDrawObj, jarrsplits[i]->Data + curCP, sizeof(DataVertex)); + memcpy(RTGPUArrVerteces + RTCountDrawObj, jarrsplits[i]->Data + curCP, sizeof(GreenDataVertex)); RTCountDrawObj += 1; lastCP = curCP; } @@ -725,7 +725,7 @@ void Green::GPURenderSingly(DWORD timeDelta, float3* viewpos, ID id, ID id_tex) { memcpy(RTGPUArrVerteces + (RTCountDrawObj), jarrsplits[i]->Data, - jarrsplits[i]->CountAllGreen * sizeof(DataVertex)); + jarrsplits[i]->CountAllGreen * sizeof(GreenDataVertex)); RTCountDrawObj += jarrsplits[i]->CountAllGreen; } @@ -740,7 +740,7 @@ void Green::GPURenderSingly(DWORD timeDelta, float3* viewpos, ID id, ID id_tex) UINT curCP = (int)floor(k + 0.5);; if (curCP > lastCP) { - memcpy(RTGPUArrVerteces + RTCountDrawObj, jarrsplits[i]->Data + curCP, sizeof(DataVertex)); + memcpy(RTGPUArrVerteces + RTCountDrawObj, jarrsplits[i]->Data + curCP, sizeof(GreenDataVertex)); RTCountDrawObj += 1; lastCP = curCP; } @@ -763,7 +763,7 @@ void Green::GPURenderObject(DWORD timeDelta, float3* viewpos, ID id, ID split, I RTGPUArrVerteces = 0; TransVertBuf->Lock(0, 0, (void**)&RTGPUArrVerteces, D3DLOCK_DISCARD); - memcpy(RTGPUArrVerteces, &(ArrModels[id]->SplitsArr[split]->Data[idobj]), sizeof(DataVertex)); + memcpy(RTGPUArrVerteces, &(ArrModels[id]->SplitsArr[split]->Data[idobj]), sizeof(GreenDataVertex)); TransVertBuf->Unlock(); RTCountDrawObj = 1; @@ -990,7 +990,7 @@ void Green::GenByTex(StaticGeom* geom, Model* model, ID idmask, float3* min, flo if (model->AllCountGreen <= 0) return; - model->AllTrans = new DataVertex[model->AllCountGreen]; + model->AllTrans = new GreenDataVertex[model->AllCountGreen]; for (DWORD i = 0; i<model->AllCountGreen; i++) { @@ -1071,11 +1071,11 @@ ID Green::AddObject(ID id, float3* pos) return -1; int oldlen = ArrModels[id]->SplitsArr[idsplit]->CountAllGreen; - DataVertex* tmpdv = new DataVertex[oldlen + 1]; + GreenDataVertex* tmpdv = new GreenDataVertex[oldlen + 1]; if (oldlen > 0) - memcpy(tmpdv, ArrModels[id]->SplitsArr[idsplit]->Data, oldlen * sizeof(DataVertex)); + memcpy(tmpdv, ArrModels[id]->SplitsArr[idsplit]->Data, oldlen * sizeof(GreenDataVertex)); - DataVertex tmpdvobj; + GreenDataVertex tmpdvobj; tmpdvobj.Position = *pos; tmpdvobj.TexCoord.x = 1.f + randf(0.f, GREEN_GEN_RAND_SCALE); tmpdvobj.TexCoord.y = randf(0.f, GREEN_GEN_RAND_ROTATE_Y); @@ -1083,7 +1083,7 @@ ID Green::AddObject(ID id, float3* pos) tmpdvobj.SinCosRot.x = sinf(tmpdvobj.TexCoord.y); tmpdvobj.SinCosRot.y = cosf(tmpdvobj.TexCoord.y); - memcpy(tmpdv + oldlen, &tmpdvobj, sizeof(DataVertex)); + memcpy(tmpdv + oldlen, &tmpdvobj, sizeof(GreenDataVertex)); mem_delete_a(ArrModels[id]->SplitsArr[idsplit]->Data); ArrModels[id]->SplitsArr[idsplit]->Data = tmpdv; ++(ArrModels[id]->SplitsArr[idsplit]->CountAllGreen); @@ -1099,9 +1099,9 @@ void Green::DelObject(ID id, ID idsplit, ID idobj) return; int oldlen = ArrModels[id]->SplitsArr[idsplit]->CountAllGreen; - DataVertex* tmpdv = new DataVertex[oldlen - 1]; - memcpy(tmpdv, ArrModels[id]->SplitsArr[idsplit]->Data, idobj * sizeof(DataVertex)); - memcpy(tmpdv + idobj, ArrModels[id]->SplitsArr[idsplit]->Data + idobj + 1, ((oldlen - idobj) - 1)* sizeof(DataVertex)); + GreenDataVertex* tmpdv = new GreenDataVertex[oldlen - 1]; + memcpy(tmpdv, ArrModels[id]->SplitsArr[idsplit]->Data, idobj * sizeof(GreenDataVertex)); + memcpy(tmpdv + idobj, ArrModels[id]->SplitsArr[idsplit]->Data + idobj + 1, ((oldlen - idobj) - 1)* sizeof(GreenDataVertex)); mem_delete_a(ArrModels[id]->SplitsArr[idsplit]->Data); ArrModels[id]->SplitsArr[idsplit]->Data = tmpdv; --(ArrModels[id]->SplitsArr[idsplit]->CountAllGreen); @@ -1226,7 +1226,7 @@ void Green::SaveSplit(Segment* Split, FILE* file, Array<Segment*> * queue) isexists = false; fwrite(&isexists, sizeof(int8_t), 1, file); if (Split->CountAllGreen > 0) - fwrite(Split->Data, sizeof(DataVertex), Split->CountAllGreen, file); + fwrite(Split->Data, sizeof(GreenDataVertex), Split->CountAllGreen, file); } } @@ -1423,9 +1423,9 @@ void Green::LoadSplit(Segment** Split, FILE* file, Array<Segment**> * queue) { if ((*Split)->CountAllGreen > 0) { - (*Split)->Data = new DataVertex[(*Split)->CountAllGreen]; + (*Split)->Data = new GreenDataVertex[(*Split)->CountAllGreen]; - fread((*Split)->Data, sizeof(DataVertex)*(*Split)->CountAllGreen, 1, file); + fread((*Split)->Data, sizeof(GreenDataVertex)*(*Split)->CountAllGreen, 1, file); } } } @@ -1487,8 +1487,11 @@ void Green::DelModelInArrCom(ID id_model) { GREEN_PRECOND_ARRCOMFOR_ERR_ID_MODEL(id_model); - for (long i = 0; i < ArrComFor.size(); ++i) + for (int i = 0; i < ArrComFor.size(); ++i) { + if (!(ArrComFor[i])) + continue; + mem_delete(ArrComFor[i]->arr[id_model]); ArrComFor[i]->arr.erase(id_model); } @@ -1590,10 +1593,10 @@ void Green::Clear() ArrModels.erase(0); } - while (ArrComFor.size() > 1) + while (ArrComFor.size() > 2) { - mem_delete(ArrComFor[1]); - ArrComFor.erase(1); + mem_delete(ArrComFor[2]); + ArrComFor.erase(2); } } @@ -1663,11 +1666,11 @@ void Green::SetGreenNav(ID id, const char* pathname) char tmpnametex[SXGC_LOADTEX_MAX_SIZE_DIRNAME]; for (int i = 0; i < nmesh->SubsetCount; ++i) { - sprintf(tmpnametex, "%s.dss", nmesh->ArrTextures[i]); + sprintf(tmpnametex, "%s.dds", nmesh->ArrTextures[i]); ID tmpidmtl = SGCore_MtlLoad(tmpnametex, MTL_TYPE_TREE); for (int k = 0; k < nmesh->IndexCount[i]; ++k) { - ArrModels[id]->NavigateMesh->arr_index[tmp_countindex] = pInd[nmesh->StartIndex[i] + k] + prebias; + ArrModels[id]->NavigateMesh->arr_index[tmp_countindex] = pInd[nmesh->StartIndex[i] + k] /*+ prebias*/; ArrModels[id]->NavigateMesh->arr_mtl[tmp_countindex] = tmpidmtl; ++tmp_countindex; } @@ -1677,7 +1680,7 @@ void Green::SetGreenNav(ID id, const char* pathname) mem_release_del(nmesh); } -void Green::GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, float4x4*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green) +void Green::GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, GreenDataVertex*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green) { if (ArrModels.size() <= 0) return; @@ -1701,10 +1704,10 @@ void Green::GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_v { int AllCountGreen = ArrModels[id]->AllCountGreen; int CountAllGreen = queue[0]->CountAllGreen; - DataVertex* tmpdv = new DataVertex[ArrModels[id]->AllCountGreen + queue[0]->CountAllGreen]; + GreenDataVertex* tmpdv = new GreenDataVertex[ArrModels[id]->AllCountGreen + queue[0]->CountAllGreen]; if (ArrModels[id]->AllTrans) - memcpy(tmpdv, ArrModels[id]->AllTrans, sizeof(DataVertex)* ArrModels[id]->AllCountGreen); - memcpy(tmpdv + ArrModels[id]->AllCountGreen, queue[0]->Data, sizeof(DataVertex)* queue[0]->CountAllGreen); + memcpy(tmpdv, ArrModels[id]->AllTrans, sizeof(GreenDataVertex)* ArrModels[id]->AllCountGreen); + memcpy(tmpdv + ArrModels[id]->AllCountGreen, queue[0]->Data, sizeof(GreenDataVertex)* queue[0]->CountAllGreen); mem_delete_a(ArrModels[id]->AllTrans); ArrModels[id]->AllTrans = tmpdv; ArrModels[id]->AllCountGreen += queue[0]->CountAllGreen; @@ -1736,7 +1739,7 @@ void Green::GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_v (*arr_mtl) = new ID*[count_green]; (*arr_count_index) = new int32_t[count_green]; - (*arr_transform) = new float4x4*[count_green]; + (*arr_transform) = new GreenDataVertex*[count_green]; (*arr_count_transform) = new int32_t[count_green]; int curr_model = 0; @@ -1756,11 +1759,11 @@ void Green::GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_v memcpy((*arr_mtl)[curr_model], ArrModels[i]->NavigateMesh->arr_mtl, sizeof(ID)* ArrModels[i]->NavigateMesh->count_index); (*arr_count_index)[curr_model] = ArrModels[i]->NavigateMesh->count_index; - (*arr_transform)[curr_model] = new float4x4[ArrModels[i]->AllCountGreen]; + (*arr_transform)[curr_model] = new GreenDataVertex[ArrModels[i]->AllCountGreen]; (*arr_count_transform)[curr_model] = ArrModels[i]->AllCountGreen; for (long k = 0; k < ArrModels[i]->AllCountGreen; ++k) { - (*arr_transform)[curr_model][k] = SMMatrixScaling(float3(ArrModels[i]->AllTrans[k].TexCoord.x, ArrModels[i]->AllTrans[k].TexCoord.x, ArrModels[i]->AllTrans[k].TexCoord.x)) * SMMatrixRotationY(ArrModels[i]->AllTrans[k].TexCoord.y) * SMMatrixTranslation(ArrModels[i]->AllTrans[k].Position); + (*arr_transform)[curr_model][k] = ArrModels[i]->AllTrans[k];// SMMatrixScaling(float3(ArrModels[i]->AllTrans[k].TexCoord.x, ArrModels[i]->AllTrans[k].TexCoord.x, ArrModels[i]->AllTrans[k].TexCoord.x)) * SMMatrixRotationY(ArrModels[i]->AllTrans[k].TexCoord.y) * SMMatrixTranslation(ArrModels[i]->AllTrans[k].Position); } ++curr_model; diff --git a/source/geom/green.h b/source/geom/green.h index bb46d92464a1e82474b7168dff7705f88f7df016..cbf77ace11aed3e160f0e6a221de4c079c673220 100644 --- a/source/geom/green.h +++ b/source/geom/green.h @@ -77,19 +77,11 @@ public: void SetGreenLod(ID id, int lod, const char* pathname); void SetGreenNav(ID id, const char* pathname); - void GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, float4x4*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green); + void GetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, GreenDataVertex*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green); bool GetOccurencessLeafGrass(float3* bbmin, float3* bbmax, int physic_mtl); bool TraceBeam(float3* start, float3* dir, float3* _res, ID* idgreen, ID* idsplits, ID* idobj, ID* idmtl); - //структура трансформаций растительности - struct DataVertex - { - float3_t Position; //позиция - float3_t TexCoord; //x - общий масштаб,y - поворот по оси y, z - - float2_t SinCosRot; - }; - // struct Segment { @@ -100,7 +92,7 @@ public: Segment* Splits[GREEN_COUNT_TYPE_SEGMENTATION]; //массив из 4 частей данного участка - DataVertex* Data; + GreenDataVertex* Data; DWORD CountAllGreen; //количество элементов ISXBound* BoundVolumeSys; //выравненный ограничивающий объем для равномерного деления @@ -151,7 +143,7 @@ public: Segment* SplitsTree; Array<Segment*> SplitsArr; float3 BBMax, BBMin; - DataVertex* AllTrans;// + GreenDataVertex* AllTrans;// Lod* ArrLod[GREEN_COUNT_LOD]; ID SplitsIDs; //общее количество сегментов/спилтов }; @@ -201,7 +193,7 @@ protected: void SetSplitID2(Model* model, Segment* Split, Array<Segment*, GREEN_DEFAULT_RESERVE_COM>* queue); long RTCountDrawObj; - DataVertex* RTGPUArrVerteces; + GreenDataVertex* RTGPUArrVerteces; D3DXMATRIX mat; Segment** jarrsplits; diff --git a/source/geom/static_geom.cpp b/source/geom/static_geom.cpp index df28c884566e885b57dd31b404f237a96d0e5cc6..ce42a7ce8fdb2e2cef5c3e9f6426bce16ec65b78 100644 --- a/source/geom/static_geom.cpp +++ b/source/geom/static_geom.cpp @@ -136,7 +136,7 @@ StaticGeom::IRSData::IRSData() StaticGeom::IRSData::~IRSData() { queue.clear(); - for (long i = 0; i < arr.size(); ++i) + for (int i = 0; i < arr.size(); ++i) { mem_delete(arr[i]); } @@ -2760,7 +2760,7 @@ ID StaticGeom::AddArrForCom() { IRSData* ttmpdata = new IRSData(); - for (long i = 0; i < AllModels.size(); ++i) + for (int i = 0; i < AllModels.size(); ++i) { InfoRenderSegments* tmpirs = new InfoRenderSegments(); tmpirs->Count = AllModels[i]->SplitsIDsRender; @@ -2769,8 +2769,8 @@ ID StaticGeom::AddArrForCom() ttmpdata->arr.push_back(tmpirs); } - long id_arr = -1; - for (long i = 0; i < ArrComFor.size(); ++i) + ID id_arr = -1; + for (int i = 0; i < ArrComFor.size(); ++i) { if (ArrComFor[i] == 0) { @@ -2814,8 +2814,11 @@ void StaticGeom::DelModelInArrCom(ID id_model) { STATIC_PRECOND_ARRCOMFOR_ERR_ID_MODEL(id_model, _VOID); - for (long i = 0; i < ArrComFor.size(); ++i) + for (int i = 0; i < ArrComFor.size(); ++i) { + if (!(ArrComFor[i])) + continue; + mem_delete(ArrComFor[i]->arr[id_model]); ArrComFor[i]->arr.erase(id_model); } diff --git a/source/geom/sxgeom.cpp b/source/geom/sxgeom.cpp index f7a85aca97ed2affef1f079f38ab511a5ebf3cd7..151181924b0f4314154779f3e757094bc29c6f42 100644 --- a/source/geom/sxgeom.cpp +++ b/source/geom/sxgeom.cpp @@ -536,13 +536,13 @@ void SGeom_GreenMSetNav(ID id, const char* pathname) } -void SGeom_GreenGetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, float4x4*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green) +void SGeom_GreenGetNavMeshAndTransform(float3_t*** arr_vertex, int32_t** arr_count_vertex, uint32_t*** arr_index, ID*** arr_mtl, int32_t** arr_count_index, GreenDataVertex*** arr_transform, int32_t** arr_count_transform, int32_t* arr_count_green) { GEOM_PRECOND(_VOID); GreenObj->GetNavMeshAndTransform(arr_vertex, arr_count_vertex, arr_index, arr_mtl, arr_count_index, arr_transform, arr_count_transform, arr_count_green); } -void SGeom_GreenClearNavMeshAndTransform(float3_t** arr_vertex, int32_t* arr_count_vertex, uint32_t** arr_index, ID** arr_mtl, int32_t* arr_count_index, float4x4** arr_transform, int32_t* arr_count_transform, int32_t arr_count_green) +void SGeom_GreenClearNavMeshAndTransform(float3_t** arr_vertex, int32_t* arr_count_vertex, uint32_t** arr_index, ID** arr_mtl, int32_t* arr_count_index, GreenDataVertex** arr_transform, int32_t* arr_count_transform, int32_t arr_count_green) { GEOM_PRECOND(_VOID); diff --git a/source/geom/sxgeom.h b/source/geom/sxgeom.h index 705d3b37243a63bde95e48bc4bffd029d24d912e..44a7fa7062ed218f7273c890b89b675950527787 100644 --- a/source/geom/sxgeom.h +++ b/source/geom/sxgeom.h @@ -303,6 +303,14 @@ enum GeomGreenType ggt_tree, //!< деревья }; +//! структура трансформаций растительности +struct GreenDataVertex +{ + float3_t Position; //!< позиция + float3_t TexCoord; //!< x - общий масштаб,y - поворот по оси y, z - + float2_t SinCosRot; //!< синус и косинус (угол TexCoord.y) для поворота +}; + /*! добавить единицу растительности \note path, lod1, lod2 - пути относительно стандартного пути, до модели и лодов, если lod1 и lod2 равны 0, тогда будет добавлен элемент трава, иначе элемент дерево. @@ -442,10 +450,10 @@ SX_LIB_API void SGeom_GreenGetNavMeshAndTransform( float3_t*** arr_vertex, //!< (*arr_vertex)[num_green_mesh_nav][num_vertex] - вершины модели int32_t** arr_count_vertex, //!< (*arr_count_vertex)[num_green_mesh_nav] - количество вершин для модели uint32_t*** arr_index, //!< (*arr_index)[num_green_mesh_nav][num_vertex] - индексы модели - ID*** arr_mtl, //!< (*arr_mtl)[num_green_mesh_nav][num_vertex] - материал для индекса + ID*** arr_mtl, //!< (*arr_mtl)[num_green_mesh_nav][num_vertex] - материал для индекса int32_t** arr_count_index, //!< (*arr_count_index)[num_green_mesh_nav] - количество индексов для модели - float4x4*** arr_transform, //!< (*arr_transform)[num_type_green][num_elem] - матрица для трансформации модели навигации - int32_t** arr_count_transform, //!< (*arr_count_transform)[num_type_green] - количество матриц для трансформаций + GreenDataVertex*** arr_transform,//!< (*arr_transform)[num_green_mesh_nav][num_obj] - трансформации модели навигации + int32_t** arr_count_transform, //!< (*arr_count_transform)[num_green_mesh_nav] - количество матриц для трансформаций int32_t* arr_count_green //!< (*arr_count_green) - количество единиц растительности по видам ); @@ -457,7 +465,7 @@ SX_LIB_API void SGeom_GreenClearNavMeshAndTransform( uint32_t** arr_index, //!< (*arr_index)[num_green_mesh_nav][num_vertex] - индексы модели ID** arr_mtl, //!< (*arr_mtl)[num_green_mesh_nav][num_vertex] - материал для индекса int32_t* arr_count_index, //!< (*arr_count_index)[num_green_mesh_nav] - количество индексов для модели - float4x4** arr_transform, //!< (*arr_transform)[num_type_green][num_elem] - матрица для трансформации модели навигации + GreenDataVertex** arr_transform,//!< (*arr_transform)[num_type_green][num_elem] - трансформации модели навигации int32_t* arr_count_transform, //!< (*arr_count_transform)[num_type_green] - количество матриц для трансформаций int32_t arr_count_green //!< (*arr_count_green) - количество единиц растительности по видам ); diff --git a/source/managed_render/dialogs.cpp b/source/managed_render/dialogs.cpp deleted file mode 100644 index 4c18b6b671e0f6f3e90258ecebf214461d2b8cf6..0000000000000000000000000000000000000000 --- a/source/managed_render/dialogs.cpp +++ /dev/null @@ -1,273 +0,0 @@ - -#pragma once - -void DialogSaveLevel(char* pathlevel) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "SkyX level file(.lvl)\0*.lvl\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Levels; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn) == TRUE) - { - sprintf(pathlevel,"%s",szFileName); - } - -} - -void DialogLoadLevel(char* pathlevel) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "SkyX level file(.lvl)\0*.lvl\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Levels; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE) - { - sprintf(pathlevel,"%s",szFileName); - } - -} - -void DialogLoadParticles(char* pathlevel) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "SkyX effects file(.eff)\0*.eff\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::GameSource; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE) - { - sprintf(pathlevel,"%s",szFileName); - } - -} - -void DialogSaveParticles(char* pathlevel) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "SkyX effects file(.eff)\0*.eff\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::GameSource; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn) == TRUE) - { - sprintf(pathlevel,"%s",szFileName); - } - -} - - -void DialogLoadMesh(char* path_model) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "dse file(.dse)\0*.dse\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Meshes; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE && path_model) - { - sprintf(path_model,"%s",szFileName); - } - -} - -void DialogSelectTexture(char* path_tex) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "��� �����\0*.*\0png file(.png)\0*.png\0dds file(.dds)\0*.dds\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Textures; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE && path_tex) - { - sprintf(path_tex,"%s",szFileName); - } - -} - -void DialogSelectSound(char* path_snd) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "��� �����\0*.*\0ogg file(.ogg)\0*.ogg\wave file(.wav)\0*.wav\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Sounds; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE && path_snd) - { - sprintf(path_snd,"%s",szFileName); - } - -} - -void DialogSelectVS(char* path_tex) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "vertex shader file(.vs)\0*.vs\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Shaders; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE && path_tex) - { - sprintf(path_tex,"%s",szFileName); - } - -} - -void DialogSelectPS(char* path_tex) -{ - OPENFILENAME ofn; - char szFileName[1024]; - szFileName[0] = szFileName[1] = 0; - - char szFileTitle[256]; - szFileTitle[0] = szFileTitle[1] = 0; - - ZeroMemory(&ofn,sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = GetModuleHandle(0); - ofn.hwndOwner = 0; - ofn.lpstrFilter = "pixel shader file(.ps)\0*.ps\0��� �����\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.nMaxFile = sizeof(szFileName); - ofn.lpstrInitialDir = GData::Pathes::Shaders; - - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - - ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; - - if(GetOpenFileName(&ofn) == TRUE && path_tex) - { - sprintf(path_tex,"%s",szFileName); - } - -} \ No newline at end of file diff --git a/source/managed_render/gdata.h b/source/managed_render/gdata.h index 6451817224b8913abf34ff44c9f5f7ebbc0a5543..0d9d07462b7b9b5fc31c4e1326001f3e40cf0073 100644 --- a/source/managed_render/gdata.h +++ b/source/managed_render/gdata.h @@ -43,6 +43,7 @@ See the license in LICENSE #define EDITORS_LEVEL_STATUSBAR_GREEN_POLY "Green poly: " #define EDITORS_LEVEL_STATUSBAR_LIGHT_COUNT "Count light: " +//! цвет очистки цветового буфера сцены по умолчанию #define RENDER_DEFAUL_BACKGROUND_COLOR D3DCOLOR_ARGB(0,128,128,128) //! пространство имен для хранения данных цикла рендера @@ -65,7 +66,7 @@ namespace GData float2_t WinSize = float2_t(800, 600); //!< размер окна рендера (области рендера) bool IsWindowed = true; //!<использовать ли оконный режим рендера? - ModelSim* SimModel = 0; //!< указатель симуляционной модели + DS_RT FinalImage = DS_RT::ds_rt_scene_light_com;//!< финальное изображение ISXCamera* ObjCamera = 0; //!< камера для которой будет рендер ID IDSelectTex = -1; @@ -151,19 +152,20 @@ namespace GData }; }; - Grid* ObjGrid = 0; - AxesStatic* ObjAxesStatic = 0; - ID3DXMesh* FigureBox; - ID3DXMesh* FigureSphere; - ID3DXMesh* FigureCone; - float3_t FigureConeParam; - float3 FigureConePos; - #if !defined(SX_GAME) namespace Editors { - bool RenderGrid = false; - bool RenderAxesStatic = false; + ModelSim* SimModel = 0; //!< указатель симуляционной модели + Grid* ObjGrid = 0; //!< сетка дял редакторов + AxesStatic* ObjAxesStatic = 0; //!< рендер статический осей в центре координат + ID3DXMesh* FigureBox; //!< бокс для определения ограничивающего объема для эммитера партиклов + ID3DXMesh* FigureSphere; //!< сфера для определения ограничивающего объема для эммитера партиклов + ID3DXMesh* FigureCone; //!< конус для определения ограничивающего объема для эммитера партиклов + float3_t FigureConeParam; //!< параметры для FigureCone (x - верхний радиус, y - нижний радиус, z - высота) + float3 FigureConePos; //!< позиция для FigureCone + + bool RenderGrid = false; //!< рисовать ли #ObjGrid + bool RenderAxesStatic = false; //!< рисовать ли #ObjAxesStatic #if defined(SX_LEVEL_EDITOR) int ActiveGroupType = 0; ID ActiveGreenSplit = -1; diff --git a/source/managed_render/level.cpp b/source/managed_render/level.cpp index 084a16b1adaaf2b57897766c71cac951e3b7e456..8fa991f537acab6d5a49e574445c92bc9be28a16 100644 --- a/source/managed_render/level.cpp +++ b/source/managed_render/level.cpp @@ -61,6 +61,11 @@ void Level::Load(const char* name) SGCore_LoadTexLoadTextures(); mem_release(config); + +#if defined(SX_GAME) + SXPhysics_LoadGeom(); +#endif + } void Level::Save(const char* name) diff --git a/source/managed_render/render_func.cpp b/source/managed_render/render_func.cpp index c2d0d5d53331b9d38f2ea0310e207cc369cb1803..6cd51e9b33a1a13978740e1f196988e06ee563b8 100644 --- a/source/managed_render/render_func.cpp +++ b/source/managed_render/render_func.cpp @@ -372,7 +372,7 @@ void SXRenderFunc::OutputDebugInfo(DWORD timeDelta) static char FpsStr[1024]; static char debugstr[SXGC_STR_SIZE_DBG_MSG]; - FrameCount++; + ++FrameCount; TimeElapsed += ((float)timeDelta) * 0.001f; if(TimeElapsed >= 1.0f) @@ -388,20 +388,20 @@ void SXRenderFunc::OutputDebugInfo(DWORD timeDelta) sprintf(debugstr + strlen(debugstr), "Dir camera : [%.2f, %.2f, %.2f]\n", GData::ConstCurrCamDir.x, GData::ConstCurrCamDir.y, GData::ConstCurrCamDir.z); sprintf(debugstr + strlen(debugstr), "\nDELAY:\n"); - sprintf(debugstr + strlen(debugstr), "\tUpdateShadow : %.1f\n", float(SXRenderFunc::Delay::UpdateShadow) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tRenderMRT : %.1f\n", float(SXRenderFunc::Delay::RenderMRT) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tComLighting : %.1f\n", float(SXRenderFunc::Delay::ComLighting) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tPostProcess : %.1f\n", float(SXRenderFunc::Delay::PostProcess) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tComReflection : %.1f\n", float(SXRenderFunc::Delay::ComReflection) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tGeomSortGroup : %.1f\n", float(SXRenderFunc::Delay::GeomSortGroup) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\tUpdateParticles : %.1f\n", float(SXRenderFunc::Delay::UpdateParticles) / float(FrameCount)); + sprintf(debugstr + strlen(debugstr), "\tUpdateShadow : %.3f\n", float(SXRenderFunc::Delay::UpdateShadow) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tRenderMRT : %.3f\n", float(SXRenderFunc::Delay::RenderMRT) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tComLighting : %.3f\n", float(SXRenderFunc::Delay::ComLighting) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tPostProcess : %.3f\n", float(SXRenderFunc::Delay::PostProcess) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tComReflection : %.3f\n", float(SXRenderFunc::Delay::ComReflection) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tGeomSortGroup : %.3f\n", float(SXRenderFunc::Delay::GeomSortGroup) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\tUpdateParticles : %.3f\n", float(SXRenderFunc::Delay::UpdateParticles) / float(FrameCount) * 0.001f); sprintf(debugstr + strlen(debugstr), "\n\tUpdateVisibleFor\n"); - sprintf(debugstr + strlen(debugstr), "\t\tCamera\t: %.1f\n", float(SXRenderFunc::Delay::UpdateVisibleForCamera) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\t\tLight\t: %.1f\n", float(SXRenderFunc::Delay::UpdateVisibleForLight) / float(FrameCount)); - sprintf(debugstr + strlen(debugstr), "\t\tReflection\t: %.1f\n", float(SXRenderFunc::Delay::UpdateVisibleForReflection) / float(FrameCount)); + sprintf(debugstr + strlen(debugstr), "\t\tCamera\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForCamera) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\t\tLight\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForLight) / float(FrameCount) * 0.001f); + sprintf(debugstr + strlen(debugstr), "\t\tReflection\t: %.3f\n", float(SXRenderFunc::Delay::UpdateVisibleForReflection) / float(FrameCount) * 0.001f); - sprintf(debugstr + strlen(debugstr), "\n\tPresent : %.1f\n", float(SXRenderFunc::Delay::Present) / float(FrameCount)); + sprintf(debugstr + strlen(debugstr), "\n\tPresent : %.3f\n", float(SXRenderFunc::Delay::Present) / float(FrameCount) * 0.001f); sprintf(debugstr + strlen(debugstr), "\n\FreeVal : %d\n", SXRenderFunc::Delay::FreeVal); #endif @@ -629,10 +629,10 @@ void SXRenderFunc::RenderInMRT(DWORD timeDelta) SXDecals_Render(); #else - if(SML_MtlGetTypeTransparency(GData::SimModel->GetIDMtl()) != MtlTypeTransparency::mtt_none) + if(SML_MtlGetTypeTransparency(GData::Editors::SimModel->GetIDMtl()) != MtlTypeTransparency::mtt_none) SML_MtlSetForceblyAlphaTest(true); - GData::SimModel->Render(timeDelta); - if (SML_MtlGetTypeTransparency(GData::SimModel->GetIDMtl()) != MtlTypeTransparency::mtt_none) + GData::Editors::SimModel->Render(timeDelta); + if (SML_MtlGetTypeTransparency(GData::Editors::SimModel->GetIDMtl()) != MtlTypeTransparency::mtt_none) SML_MtlSetForceblyAlphaTest(false); #endif @@ -1216,10 +1216,6 @@ void SXRenderFunc::RenderParticles(DWORD timeDelta) SetSamplerFilter(0, 3, D3DTEXF_LINEAR); SetSamplerAddress(0, 3, D3DTADDRESS_WRAP); - /*ArrEffects->EffectPosSet(0, &float3(GData::ConstCurrCamPos + GData::ConstCurrCamDir*2));*/ - - //ArrEffects->EffectDirSet(0, &GData::ConstCurrCamDir); - SPE_EffectRenderAll(timeDelta); GData::DXDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); @@ -1263,7 +1259,7 @@ void SXRenderFunc::RenderPostProcess(DWORD timeDelta) /*if (!SSInput_GetKeyState(SIK_C)) SPP_RenderNFAA(&float3_t(1, 1, 0));*/ - SPP_RenderMotionBlur(0.1, timeDelta); + //SPP_RenderMotionBlur(0.1, timeDelta); } void SXRenderFunc::ShaderRegisterData() @@ -1416,15 +1412,15 @@ void SXRenderFunc::UpdateReflection(DWORD timeDelta) } } #else - ID idmat = GData::SimModel->GetIDMtl(); + ID idmat = GData::Editors::SimModel->GetIDMtl(); MtlTypeReflect typeref = SML_MtlGetTypeReflection(idmat); D3DXPLANE plane; float3_t center; - GData::SimModel->GetCenter(¢er); + GData::Editors::SimModel->GetCenter(¢er); if (typeref == MtlTypeReflect::mtr_plane) { - GData::SimModel->GetPlane(&plane); + GData::Editors::SimModel->GetPlane(&plane); SML_MtlRefPreRenderPlane(idmat, &plane); SetSamplerFilter(0, 16, D3DTEXF_LINEAR); @@ -1483,129 +1479,27 @@ void SXRenderFunc::UpdateReflection(DWORD timeDelta) //////// -void SXRenderFunc::MainRender(DWORD timeDelta) +void SXRenderFunc::RenderEditorMain() { - DWORD ttime; - //потеряно ли устройство или произошло изменение размеров? - if (GData::DXDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || GData::ReSize) - { - //если не свернуто окно - if (!IsIconic(GData::Handle3D) && ((GData::HandleParent3D != 0 && !IsIconic(GData::HandleParent3D)) || GData::HandleParent3D == 0)) - SXRenderFunc::ComDeviceLost(); //вытаемся восстановить - return; - } - Core_0ConsoleUpdate(); - //@@@ - SSInput_Update(); - SSCore_Update(&GData::ConstCurrCamPos, &GData::ConstCurrCamDir); - //@@@ -#ifndef SX_GAME - CameraUpdate::UpdateEditorial(timeDelta); -#endif - - SXAnim_Update(); - SXGame_Update(); - SXPhysics_Update(); - - SXAnim_Sync(); - SXPhysics_Sync(); - SXGame_Sync(); - - ttime = GetTickCount(); - SGeom_ModelsMSortGroups(&GData::ConstCurrCamPos,2); - SXRenderFunc::Delay::GeomSortGroup += GetTickCount() - ttime; - - if(GData::DefaultGeomIDArr < 0) - GData::DefaultGeomIDArr = SGeom_ModelsAddArrForCom(); - - if(GData::DefaultGreenIDArr < 0) - GData::DefaultGreenIDArr = SGeom_GreenAddArrForCom(); - - if(GData::DefaultAnimIDArr < 0) - GData::DefaultAnimIDArr = SXAnim_ModelsAddArrForCom(); - - /**/ - if (SGeom_GreenGetOccurencessLeafGrass(&float3(GData::ConstCurrCamPos - float3(0.25, 1.8, 0.25)), &float3(GData::ConstCurrCamPos + float3(0.25, 0, 0.25)),MtlPhysicType::mpt_leaf_grass)) - SXRenderFunc::Delay::FreeVal = 1; - else - SXRenderFunc::Delay::FreeVal = 0; - /**/ - - //@@@ - SXRenderFunc::UpdateView(); - SML_Update(timeDelta, &GData::WinSize, &GData::NearFar, &GData::ConstCurrCamPos,&GData::MCamView, GData::ProjFov); - - GData::DXDevice->BeginScene(); - - ttime = GetTickCount(); - UpdateReflection(timeDelta); - SXRenderFunc::Delay::ComReflection += GetTickCount() - ttime; - - if (GData::FinalImage == DS_RT::ds_rt_ambient_diff || GData::FinalImage == DS_RT::ds_rt_specular || GData::FinalImage == DS_RT::ds_rt_scene_light_com) - { - //рендерим глубину от света - ttime = GetTickCount(); - UpdateShadow(timeDelta); - SXRenderFunc::Delay::UpdateShadow += GetTickCount() - ttime; - } - - //рисуем сцену и заполняем mrt данными - ttime = GetTickCount(); - RenderInMRT(timeDelta); - SXRenderFunc::Delay::RenderMRT += GetTickCount() - ttime; - - if (GData::FinalImage == DS_RT::ds_rt_ambient_diff || GData::FinalImage == DS_RT::ds_rt_specular || GData::FinalImage == DS_RT::ds_rt_scene_light_com) - { - //освещаем сцену - ttime = GetTickCount(); - ComLighting(timeDelta, true); - SXRenderFunc::Delay::ComLighting += GetTickCount() - ttime; - } - - GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); - GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE); - -#if defined(SX_GAME) - ttime = GetTickCount(); - RenderPostProcess(timeDelta); - SXRenderFunc::Delay::PostProcess += GetTickCount() - ttime; -#endif - - //GData::DXDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 128, 128, 128), 1.0f, 0); - - SGCore_ShaderBind(ShaderType::st_vertex, GData::IDsShaders::VS::ScreenOut); - SGCore_ShaderBind(ShaderType::st_pixel, GData::IDsShaders::PS::ScreenOut); - - GData::DXDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - -#if !defined(SX_GAME) - GData::DXDevice->SetTexture(0, SML_DSGetRT(GData::FinalImage)); -#else - GData::DXDevice->SetTexture(0, SGCore_RTGetTexture(SPP_RTGetCurrSend())); -#endif - - SGCore_ScreenQuadDraw(); - - SGCore_ShaderUnBind(); - - SXRenderFunc::RenderParticles(timeDelta); - #if !defined(SX_GAME) - if (GData::ObjGrid && GData::Editors::RenderGrid) + if (GData::Editors::ObjGrid && GData::Editors::RenderGrid) { GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE); - GData::ObjGrid->Render(); + GData::Editors::ObjGrid->Render(); } - if (GData::ObjAxesStatic && GData::Editors::RenderAxesStatic) + if (GData::Editors::ObjAxesStatic && GData::Editors::RenderAxesStatic) { GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE); - GData::ObjAxesStatic->Render(); + GData::Editors::ObjAxesStatic->Render(); } #endif - +} + +void SXRenderFunc::RenderEditorLE(DWORD timeDelta) +{ #if defined(SX_LEVEL_EDITOR) if (GData::Editors::SelSelection) { @@ -1614,7 +1508,7 @@ void SXRenderFunc::MainRender(DWORD timeDelta) GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE); } - else + else { GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_FALSE); @@ -1661,8 +1555,8 @@ void SXRenderFunc::MainRender(DWORD timeDelta) } } - GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); - GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE); + GData::DXDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); + GData::DXDevice->SetRenderState(D3DRS_ZWRITEENABLE, D3DZB_TRUE); if (GData::Editors::SelMesh) GData::DXDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); @@ -1671,64 +1565,9 @@ void SXRenderFunc::MainRender(DWORD timeDelta) GData::DXDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); } #endif - - SXRenderFunc::OutputDebugInfo(timeDelta); - - SXPhysics_DebugRender(); - //SXGame_EditorRender(); - - /*if (SSInput_GetKeyEvents(SIK_ENTER) == InputEvents::iv_k_first) - { - float3 start = GData::ConstCurrCamPos; - float3 end = start + (GData::ConstCurrCamDir * 1000); - btCollisionWorld::ClosestRayResultCallback cb(F3_BTVEC(start), F3_BTVEC(end)); - SXPhysics_GetDynWorld()->rayTest(F3_BTVEC(start), F3_BTVEC(end), cb); - - if (cb.hasHit()) - { - //shoot decal - SXDecals_ShootDecal(DECAL_TYPE_CONCRETE, BTVEC_F3(cb.m_hitPointWorld), BTVEC_F3(cb.m_hitNormalWorld)); - } - }*/ - - - - SXRenderFunc::ShaderRegisterData(); - - GData::DXDevice->EndScene(); - - //@@@ - ttime = GetTickCount(); - SXRenderFunc::ComVisibleForCamera(); - SXRenderFunc::Delay::UpdateVisibleForCamera += GetTickCount() - ttime; - - ttime = GetTickCount(); - SXRenderFunc::ComVisibleReflection(); - SXRenderFunc::Delay::UpdateVisibleForReflection += GetTickCount() - ttime; - - ttime = GetTickCount(); - SXRenderFunc::ComVisibleForLight(); - SXRenderFunc::Delay::UpdateVisibleForLight += GetTickCount() - ttime; - - ttime = GetTickCount(); - SPE_EffectVisibleComAll(GData::ObjCamera->ObjFrustum, &GData::ConstCurrCamPos); - SPE_EffectComputeAll(); - SPE_EffectComputeLightingAll(); - SXRenderFunc::Delay::UpdateParticles += GetTickCount() - ttime; - - ttime = GetTickCount(); - GData::DXDevice->Present(0, 0, 0, 0); - SXRenderFunc::Delay::Present += GetTickCount() - ttime; - -#if defined(SX_LEVEL_EDITOR) - GData::Editors::LevelEditorUpdateStatusBar(); -#endif - -#if defined(SX_PARTICLES_EDITOR) - GData::Editors::ParticlesEditorUpdateStatusBar(); -#endif } +/////// void SXRenderFunc::RFuncDIP(UINT type_primitive, long base_vertexIndex, UINT min_vertex_index, UINT num_vertices, UINT start_index, UINT prim_count) { diff --git a/source/managed_render/render_func.h b/source/managed_render/render_func.h index cb54032b39e67c5961beeeb7917e4fffe6408641..e3d67d636b2487326986b410e198e06d3b8996ea 100644 --- a/source/managed_render/render_func.h +++ b/source/managed_render/render_func.h @@ -82,6 +82,9 @@ namespace SXRenderFunc void RenderParticles(DWORD timeDelta); //!< отрисовка партиклов (эффектов) void RenderPostProcess(DWORD timeDelta); //!< отрисовка постпроцесса void ShaderRegisterData(); + + void RenderEditorMain(); //!< рендер основных элементов для редакторов + void RenderEditorLE(DWORD timeDelta); //!< рендер элементов для редактора уровней /*! \name Функции обертки, для передачи графическому ядру для замены стандартных @{*/ @@ -101,21 +104,21 @@ namespace SXRenderFunc //! время задержек/ожидания выполнения некоторых функций рендера namespace Delay { - DWORD UpdateVisibleForCamera = 0; - DWORD UpdateVisibleForLight = 0; - DWORD UpdateVisibleForReflection = 0; + int64_t UpdateVisibleForCamera = 0; + int64_t UpdateVisibleForLight = 0; + int64_t UpdateVisibleForReflection = 0; - DWORD UpdateShadow = 0; - DWORD UpdateParticles = 0; - DWORD RenderMRT = 0; - DWORD ComLighting = 0; - DWORD PostProcess = 0; - DWORD ComReflection = 0; - DWORD GeomSortGroup = 0; + int64_t UpdateShadow = 0; + int64_t UpdateParticles = 0; + int64_t RenderMRT = 0; + int64_t ComLighting = 0; + int64_t PostProcess = 0; + int64_t ComReflection = 0; + int64_t GeomSortGroup = 0; - DWORD Present = 0; + int64_t Present = 0; - DWORD FreeVal = 0; + int64_t FreeVal = 0; }; }; diff --git a/source/particles/emitter.cpp b/source/particles/emitter.cpp index b881be72ce078e4d840397cd94ec25c889e73103..24c33b99b721267e4170ffb94e8a7e2666f52045 100644 --- a/source/particles/emitter.cpp +++ b/source/particles/emitter.cpp @@ -246,7 +246,7 @@ void Emitter::EnableSet(bool enable) CreateParticles(); Alife = enable; - + OldTime = TimeGetMls(G_Timer_Render_Scene); Enable = enable; if (!Enable) @@ -386,7 +386,7 @@ void Emitter::CreateParticles() CountReCreate2 = 0; i = Count; if (Data.SpawnNextTime) - TimeNextSpawnParticle = GetTickCount() + Data.SpawnNextTime;//(Data.SpawnNextTime + (Data.SpawnNextTimeDisp > 0 ? rand()%Data.SpawnNextTimeDisp : 0)); + TimeNextSpawnParticle = TimeGetMls(G_Timer_Render_Scene) + Data.SpawnNextTime;//(Data.SpawnNextTime + (Data.SpawnNextTimeDisp > 0 ? rand()%Data.SpawnNextTimeDisp : 0)); } } @@ -722,7 +722,7 @@ void Emitter::Compute() CountReCreate2 = 0; if (Alife && OldTime > 0 && Data.ReCreateCount > 0 && Data.ReCreateCount <= Count - CountLifeParticle) { - if (GetTickCount() > TimeNextSpawnParticle) + if (TimeGetMls(G_Timer_Render_Scene) > TimeNextSpawnParticle) { for (int i = 0; i<Count; i++) { @@ -736,7 +736,7 @@ void Emitter::Compute() CountReCreate2 = 0; i = Count; if (Data.SpawnNextTime) - TimeNextSpawnParticle = GetTickCount() + (Data.SpawnNextTime + (Data.SpawnNextTimeDisp > 0 ? rand() % Data.SpawnNextTimeDisp : 0)); + TimeNextSpawnParticle = TimeGetMls(G_Timer_Render_Scene) + (Data.SpawnNextTime + (Data.SpawnNextTimeDisp > 0 ? rand() % Data.SpawnNextTimeDisp : 0)); } } } @@ -746,11 +746,11 @@ void Emitter::Compute() { TimeNextSpawnParticle = 0; if (TimerDeath == 0) - TimerDeath = GetTickCount(); + TimerDeath = TimeGetMls(G_Timer_Render_Scene); else { - GTransparency = 1.f - float(GetTickCount() - TimerDeath) / float(SXPARTICLES_DEADTH_TIME); - if (GetTickCount() - TimerDeath > SXPARTICLES_DEADTH_TIME) + GTransparency = 1.f - float(TimeGetMls(G_Timer_Render_Scene) - TimerDeath) / float(SXPARTICLES_DEADTH_TIME); + if (TimeGetMls(G_Timer_Render_Scene) - TimerDeath > SXPARTICLES_DEADTH_TIME) { Enable = false; GTransparency = 1.f; @@ -765,7 +765,7 @@ void Emitter::Compute() } - DWORD tmptime = GetTickCount(); + DWORD tmptime = TimeGetMls(G_Timer_Render_Scene); CountLifeParticle = 0; for (int i = 0; i<Count && OldTime != 0; i++) diff --git a/source/particles/sxparticles.cpp b/source/particles/sxparticles.cpp index cfe88256275b25b8767fa370894ae75d9a987b99..2f34afe7f10f7870c3fdc0011f56786c55ae4fb4 100644 --- a/source/particles/sxparticles.cpp +++ b/source/particles/sxparticles.cpp @@ -1,6 +1,6 @@ #include <particles/sxparticles.h> - +#include <cdata.h> #define SXPARTICLES_VERSION 1 #if !defined(DEF_STD_REPORT) @@ -38,6 +38,9 @@ namespace PESet void PESet::Init(IDirect3DDevice9* device) { + G_Timer_Render_Scene = Core_RIntGet(G_RI_INT_TIMER_RENDER); + G_Timer_Game = Core_RIntGet(G_RI_INT_TIMER_GAME); + PESet::DXDevice = device; D3DVERTEXELEMENT9 InstanceParticles[] = diff --git a/source/physics/PhyWorld.cpp b/source/physics/PhyWorld.cpp index a50f17031c532e9ecf19c0ef4827f198032a862a..64efb706264f5d4c97617e77ce61a60bb9a40c71 100644 --- a/source/physics/PhyWorld.cpp +++ b/source/physics/PhyWorld.cpp @@ -154,7 +154,7 @@ void PhyWorld::LoadGeom() uint32_t** green_arr_index; ID** green_arr_mtl; int32_t* green_arr_count_index; - float4x4** green_arr_transform; + GreenDataVertex** green_arr_transform; int32_t* green_arr_count_transform; int32_t green_arr_count_green; diff --git a/source/skyxengine.cpp b/source/skyxengine.cpp index 64aa9a98225804e1b6edd867022af6a631bf5825..c7f4e0b0097db816466d5fad8e2affb2cbde7626 100644 --- a/source/skyxengine.cpp +++ b/source/skyxengine.cpp @@ -12,14 +12,8 @@ See the license in LICENSE #include <SkyXEngine.h> - int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { - InitOutLog(); - srand((unsigned int)time(0)); - - GData::InitWin("SkyXEngine", "SkyXEngine"); - SkyXEngine_Init(); SGCore_SkyBoxLoadTex("sky_2_cube.dds"); @@ -27,31 +21,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin SGCore_SkyCloudsSetWidthHeightPos(2000, 2000, &float3(0, 0, 0)); Level::Load("stalker_atp"); - SXPhysics_LoadGeom(); SGeom_0SettGreenSetFreqGrass(30); - IAnimPlayer * pl; - pl = SXAnim_CreatePlayer("models/stalker_zombi/stalker_zombi_a.dse"); - pl->SetPos(float3(-17.18, -1.38f, -32.3)); - pl->Play("reload"); - - //TestEffect = new Effect(); - - - - char tmppathsave[1024]; - sprintf(tmppathsave, "%seff.eff", GData::Pathes::GameSource); - - SPE_EffectLoad(tmppathsave); - - //ID tmpeffid = SPE_EffectAdd("test"); - //ID tmppartid = SPE_ParticlesAdd(tmpeffid, &data); - - //SPE_ParticlesTextureSet(0, 0, "pfx_smoke_c.dds"); - //SPE_ParticlesCreate(0, 0, 0); - //SPE_EffectEnableSet(0, false); - /*for (int i = 0; i < 20; ++i) { for (int k = 0; k < 20; ++k) @@ -65,51 +37,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin ID tmpid = SPE_EffectGetByName("test"); SPE_EffectEnableSet(tmpid, true); - /*SPE_EffectCopyName("test"); - SPE_EffectCopyName("test");*/ - - - //SPE_EffectSave(tmppathsave); - - /*SPE_ParticlesSet(tmpeffid, tmppartid, SizeParticle, float2_t(2, 2));*/ - //SPE_ParticlesSet(tmpeffid, tmppartid, TransparencyCoef, 1); - //SPE_ParticlesSet(tmpeffid, tmppartid, FigureCountQuads, 10); - //SPE_ParticlesSet(tmpeffid, tmppartid, FigureRotRand, true); - //SPE_ParticlesSet(tmpeffid, tmppartid, FigureTapX, true); - //SPE_ParticlesSet(tmpeffid, tmppartid, FigureTapZ, true); - - /*SGeom_ModelsAddModel("stalker_atp.dse", 0, "stalker_atp.dse"); - - SGeom_GreenAddGreen("tree_topol", "terrain_mp_atp_mask_tree.dds", 0.3, "green\\tree_topol_lod0.dse", "green\\tree_topol_lod1.dse", "green\\tree_topol_lod2.dse", "green\\tree_topol_lod2.dse"); - SGeom_GreenAddGreen("trava_green_det2", "terrain_mp_atp_mask_grass.dds", 0.2, "green\\trava_green_det2.dse", 0, 0, 0); - - - SML_LigthsCreatePoint( - &float3(60,60,0), - LIGHTS_GLOBAL_MAX_POWER, - LIGHTS_GLOBAL_STD_RADIUS, - &float3(1,1,1), - true, - true); - SML_LigthsSetEnable(SML_LigthsGetCount() - 1, true); - SML_LigthsSetName(SML_LigthsGetCount() - 1, "sun"); - - Level::Save("stalker_atp"); */ - - char tmppathexe[1024]; - char tmppath[1024]; - GetModuleFileName(NULL, tmppath, 1024); - int len = strlen(tmppath); - while (tmppath[len--] != '\\') - { - if (tmppath[len - 1] == '\\') - { - len--; - memcpy(tmppathexe, tmppath, len); - tmppathexe[len] = 0; - } - } - SGCore_LoadTexStdPath(GData::Pathes::Textures); SGCore_LoadTexLoadTextures(); @@ -125,64 +52,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin //ms->SoundVolumeSet(tmpid, 100); } - MSG msg; - ::ZeroMemory(&msg, sizeof(MSG)); - - static DWORD lastTime = GetTickCount(); - static DWORD TimeCCadr = 0; - - while (msg.message != WM_QUIT && IsWindow(GData::Handle3D)) - { - if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - else - { - if (SSInput_GetKeyEvents(SIK_T) == InputEvents::iv_k_first) - { - for (int i = 0; i < 1; ++i) - { - ID tmpid = SPE_EffectIdOfKey(i); - //SPE_EffectPosSet(tmpid, &float3(i, 0, k)); - SPE_EffectAlifeSet(tmpid, !SPE_EffectAlifeGet(tmpid)); - } - } - static DWORD TimeStart = 0; - DWORD TimeThis = GetTickCount(); - - DWORD currTime = GetTickCount(); - DWORD timeDelta = (currTime - lastTime); - - Core_0ConsoleUpdate(); -#ifdef SX_GAME - GData::ObjCamera = SXGame_GetActiveCamera(); -#endif - if (GetActiveWindow() == GData::Handle3D || GetActiveWindow() == FindWindow(NULL,"sxconsole")) - { - SGCore_LoadTexLoadTextures(); - SXRenderFunc::MainRender(timeDelta); - } - - TimeCCadr = timeDelta; - TimeStart = TimeThis; - - lastTime = currTime; - } - } - - /* - SXGame_0Kill(); - SXPhysics_0Kill(); - SXAnim_0Kill(); - mem_release(GData::ObjCamera); - SGeom_0CreateKill(); - SML_0Kill(); - SGCore_0Kill(); - Core_AKill();*/ - + + int result = SkyXEngine_CycleMain(); SkyXEngine_Kill(); - - return msg.wParam; + return result; } \ No newline at end of file diff --git a/source/sxconsole/sxconsole.cpp b/source/sxconsole/sxconsole.cpp index 96a27d6863e2a409ae1912648ec099fe38690aa0..81a9aca6b7a68c2773c36b689a20d0ebb1c2bb8f 100644 --- a/source/sxconsole/sxconsole.cpp +++ b/source/sxconsole/sxconsole.cpp @@ -692,6 +692,8 @@ int main(void) //strcpy(str, "Some " COLOR_RED "red " COLOR_RESET "text\n"); //WriteColored(str); + SetConsoleTitle(L"sxconsole"); + while(1) { ch = (char)getch(); diff --git a/source/sxleveleditor/sxleveleditor.cpp b/source/sxleveleditor/sxleveleditor.cpp index 50e6f5f932b8d2ebf4424e666bee80cbe04dabad..5ba8c164ffae92334fd7d9f066237301586f918c 100644 --- a/source/sxleveleditor/sxleveleditor.cpp +++ b/source/sxleveleditor/sxleveleditor.cpp @@ -15,9 +15,6 @@ See the license in LICENSE int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { SXGUIRegClass::RegGroupBox(); - InitOutLog(); - srand((unsigned int)time(0)); - SXLevelEditor::InitAllElements(); GData::Handle3D = SXLevelEditor::RenderWindow->GetHWND(); @@ -48,98 +45,54 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin SGCore_LoadTexStdPath(GData::Pathes::Textures); SGCore_LoadTexLoadTextures(); - MSG msg; - ::ZeroMemory(&msg, sizeof(MSG)); - - static DWORD lastTime = GetTickCount(); - static DWORD TimeCCadr = 0; - - while (msg.message != WM_QUIT && IsWindow(GData::Handle3D)) - { - if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - ::TranslateMessage(&msg); - - IMSG imsg; - imsg.lParam = msg.lParam; - imsg.wParam = msg.wParam; - imsg.message = msg.message; - - SSInput_AddMsg(imsg); - - ::DispatchMessage(&msg); - } - else - { - static DWORD TimeStart = 0; - DWORD TimeThis = GetTickCount(); - - DWORD currTime = GetTickCount(); - DWORD timeDelta = (currTime - lastTime); - - SGCore_LoadTexLoadTextures(); - Core_0ConsoleUpdate(); - SXLevelEditor_Transform(10); - SXRenderFunc::MainRender(timeDelta); - - if (SSInput_GetKeyEvents(SIM_LBUTTON) == InputEvents::iv_k_first) - { - /*float3 start = GData::ConstCurrCamPos; - float3 end = start + (GData::ConstCurrCamDir * 1000);*/ - float3 _res; - ID idmodel; - ID idmtl; - - - float3 camDir; - float det; - SMMATRIX mat = SMMatrixInverse(&det, GData::MCamView); - POINT pt; - GetCursorPos(&pt); - ScreenToClient(GData::Handle3D, &pt); - - float3 pos = float3( - (2.0f * (float)pt.x / GData::WinSize.x - 1.0f) / GData::MCamProj._11, - -(2.0f * (float)pt.y / GData::WinSize.y - 1.0f) / GData::MCamProj._22, - 1.0f - ) * mat; - camDir = pos - GData::ConstCurrCamPos; - - ID idgreen; - ID idsplit; - ID idobj; - - /*if (pt.x <= GData::WinSize.x && pt.y <= GData::WinSize.y && SGeom_GreenTraceBeam(&GData::ConstCurrCamPos, &camDir, &_res, &idgreen, &idsplit, &idobj, &idmtl)) - { - GData::Editors::ActiveGroupType = EDITORS_LEVEL_GROUPTYPE_GREEN; - GData::Editors::ActiveElement = idgreen; - GData::Editors::ActiveGreenSplit = idsplit; - GData::Editors::ActiveGreenObject = idobj; - SGeom_GreenDelObject(idgreen, idsplit, idobj); - int qwert = 0; - }*/ - - if (pt.x <= GData::WinSize.x && pt.y <= GData::WinSize.y && SGeom_ModelsTraceBeam(&GData::ConstCurrCamPos, &camDir, &_res, &idmodel, &idmtl)) - { - /*MCInitElemsSelModel(idmodel); - GData::Editors::ActiveElement = idmodel; - GData::Editors::ActiveGroupType = EDITORS_LEVEL_GROUPTYPE_GEOM;*/ - SGeom_GreenAddObject(0, &_res); - } - } - - TimeCCadr = timeDelta; - TimeStart = TimeThis; - - lastTime = currTime; - } - } - - mem_release(GData::ObjCamera); - SGeom_AKill(); - SML_AKill(); - SGCore_AKill(); - SXLevelEditor::DeleteAllElements(); - - return msg.wParam; + /* + if (SSInput_GetKeyEvents(SIM_LBUTTON) == InputEvents::iv_k_first) + { + //float3 start = GData::ConstCurrCamPos; + //float3 end = start + (GData::ConstCurrCamDir * 1000); + float3 _res; + ID idmodel; + ID idmtl; + + + float3 camDir; + float det; + SMMATRIX mat = SMMatrixInverse(&det, GData::MCamView); + POINT pt; + GetCursorPos(&pt); + ScreenToClient(GData::Handle3D, &pt); + + float3 pos = float3( + (2.0f * (float)pt.x / GData::WinSize.x - 1.0f) / GData::MCamProj._11, + -(2.0f * (float)pt.y / GData::WinSize.y - 1.0f) / GData::MCamProj._22, + 1.0f + ) * mat; + camDir = pos - GData::ConstCurrCamPos; + + ID idgreen; + ID idsplit; + ID idobj; + + //if (pt.x <= GData::WinSize.x && pt.y <= GData::WinSize.y && SGeom_GreenTraceBeam(&GData::ConstCurrCamPos, &camDir, &_res, &idgreen, &idsplit, &idobj, &idmtl)) + //{ + //GData::Editors::ActiveGroupType = EDITORS_LEVEL_GROUPTYPE_GREEN; + //GData::Editors::ActiveElement = idgreen; + //GData::Editors::ActiveGreenSplit = idsplit; + //GData::Editors::ActiveGreenObject = idobj; + //SGeom_GreenDelObject(idgreen, idsplit, idobj); + //int qwert = 0; + //} + + if (pt.x <= GData::WinSize.x && pt.y <= GData::WinSize.y && SGeom_ModelsTraceBeam(&GData::ConstCurrCamPos, &camDir, &_res, &idmodel, &idmtl)) + { + //MCInitElemsSelModel(idmodel); + //GData::Editors::ActiveElement = idmodel; + //GData::Editors::ActiveGroupType = EDITORS_LEVEL_GROUPTYPE_GEOM; + SGeom_GreenAddObject(0, &_res); + } +}*/ + + int result = SkyXEngine_CycleMain(); + SkyXEngine_Kill(); + return result; } \ No newline at end of file diff --git a/source/sxmaterialeditor/common_callback.cpp b/source/sxmaterialeditor/common_callback.cpp index 61aebd4429e0b02dadb1227d565dd1606c02da1e..57da40fb4ab2bf41f2370a72e56088fd8b38cbe0 100644 --- a/source/sxmaterialeditor/common_callback.cpp +++ b/source/sxmaterialeditor/common_callback.cpp @@ -22,9 +22,9 @@ LRESULT ComMenuId(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (def_str_validate(tmppath)) { StrCutName(tmppath, tmpname); - SML_MtlReloadMaterial(GData::SimModel->GetIDMtl(), tmpname); + SML_MtlReloadMaterial(GData::Editors::SimModel->GetIDMtl(), tmpname); SGCore_LoadTexLoadTextures(); - SXMaterialEditor::InitMtl(GData::SimModel->GetIDMtl()); + SXMaterialEditor::InitMtl(GData::Editors::SimModel->GetIDMtl()); } } @@ -208,12 +208,12 @@ LRESULT SXMaterialEditor_JobWindow_CallWmCommand(HWND hwnd, UINT msg, WPARAM wPa HWND handle_elem = (HWND)(lParam); if (SXMaterialEditor::ComboBoxTypeModel->GetHWND() == handle_elem) { - GData::SimModel->TypeModel = (MtlTypeModel)SXMaterialEditor::ComboBoxTypeModel->GetSel(); - SML_MtlSetTypeModel(GData::SimModel->GetIDMtl(), (MtlTypeModel)SXMaterialEditor::ComboBoxTypeModel->GetSel()); + GData::Editors::SimModel->TypeModel = (MtlTypeModel)SXMaterialEditor::ComboBoxTypeModel->GetSel(); + SML_MtlSetTypeModel(GData::Editors::SimModel->GetIDMtl(), (MtlTypeModel)SXMaterialEditor::ComboBoxTypeModel->GetSel()); } else if (SXMaterialEditor::ComboBoxTestModel->GetHWND() == handle_elem) { - GData::SimModel->CurrRenderModel = SXMaterialEditor::ComboBoxTestModel->GetSel(); + GData::Editors::SimModel->CurrRenderModel = SXMaterialEditor::ComboBoxTestModel->GetSel(); } else if (SXMaterialEditor::ComboBoxTypeRefract->GetHWND() == handle_elem) { @@ -324,124 +324,124 @@ void SXMaterialEditor::Nulling() void SXMaterialEditor::InitMtl(ID id) { - GData::SimModel->TypeModel = SML_MtlGetTypeModel(id); + GData::Editors::SimModel->TypeModel = SML_MtlGetTypeModel(id); SXMaterialEditor::ComboBoxTypeModel->SetSel(SML_MtlGetTypeModel(id)); SXMaterialEditor::ComboBoxTestModel; - SXMaterialEditor::ComboBoxPhysic->SetSel(SML_MtlGetPhysicMaterial(GData::SimModel->GetIDMtl())); + SXMaterialEditor::ComboBoxPhysic->SetSel(SML_MtlGetPhysicMaterial(GData::Editors::SimModel->GetIDMtl())); char tmppath[1024]; - SML_MtlGetTexture(GData::SimModel->GetIDMtl(), tmppath); + SML_MtlGetTexture(GData::Editors::SimModel->GetIDMtl(), tmppath); SXMaterialEditor::EditTex->SetText(tmppath); - SML_MtlGetVS(GData::SimModel->GetIDMtl(), tmppath); + SML_MtlGetVS(GData::Editors::SimModel->GetIDMtl(), tmppath); SXMaterialEditor::EditVS->SetText(tmppath); - SML_MtlGetPS(GData::SimModel->GetIDMtl(), tmppath); + SML_MtlGetPS(GData::Editors::SimModel->GetIDMtl(), tmppath); SXMaterialEditor::EditPS->SetText(tmppath); - SXMaterialEditor::CheckBoxAlphaTest->SetCheck(SML_MtlGetUsingAlphaTest(GData::SimModel->GetIDMtl())); + SXMaterialEditor::CheckBoxAlphaTest->SetCheck(SML_MtlGetUsingAlphaTest(GData::Editors::SimModel->GetIDMtl())); - SXMaterialEditor::EditRoughness->SetText(String(SML_MtlGetRoughness(GData::SimModel->GetIDMtl())).c_str()); - SXMaterialEditor::EditThickness->SetText(String(SML_MtlGetThickness(GData::SimModel->GetIDMtl())).c_str()); - SXMaterialEditor::EditF0->SetText(String(SML_MtlGetF0(GData::SimModel->GetIDMtl())).c_str()); - SXMaterialEditor::EditPenetration->SetText(String(SML_MtlGetPenetration(GData::SimModel->GetIDMtl())).c_str()); + SXMaterialEditor::EditRoughness->SetText(String(SML_MtlGetRoughness(GData::Editors::SimModel->GetIDMtl())).c_str()); + SXMaterialEditor::EditThickness->SetText(String(SML_MtlGetThickness(GData::Editors::SimModel->GetIDMtl())).c_str()); + SXMaterialEditor::EditF0->SetText(String(SML_MtlGetF0(GData::Editors::SimModel->GetIDMtl())).c_str()); + SXMaterialEditor::EditPenetration->SetText(String(SML_MtlGetPenetration(GData::Editors::SimModel->GetIDMtl())).c_str()); - SXMaterialEditor::CheckBoxLighting->SetCheck(SML_MtlGetLighting(GData::SimModel->GetIDMtl())); + SXMaterialEditor::CheckBoxLighting->SetCheck(SML_MtlGetLighting(GData::Editors::SimModel->GetIDMtl())); - SXMaterialEditor::TrackBarRoughness->SetPos(SML_MtlGetRoughness(GData::SimModel->GetIDMtl())*100.f); - SXMaterialEditor::TrackBarThickness->SetPos(SML_MtlGetThickness(GData::SimModel->GetIDMtl())*100.f); - SXMaterialEditor::TrackBarF0->SetPos(SML_MtlGetF0(GData::SimModel->GetIDMtl()) * 100.f); - SXMaterialEditor::TrackBarPenetration->SetPos(SML_MtlGetPenetration(GData::SimModel->GetIDMtl()) * 100.f); + SXMaterialEditor::TrackBarRoughness->SetPos(SML_MtlGetRoughness(GData::Editors::SimModel->GetIDMtl())*100.f); + SXMaterialEditor::TrackBarThickness->SetPos(SML_MtlGetThickness(GData::Editors::SimModel->GetIDMtl())*100.f); + SXMaterialEditor::TrackBarF0->SetPos(SML_MtlGetF0(GData::Editors::SimModel->GetIDMtl()) * 100.f); + SXMaterialEditor::TrackBarPenetration->SetPos(SML_MtlGetPenetration(GData::Editors::SimModel->GetIDMtl()) * 100.f); - SML_MtlGetTextureLighting(GData::SimModel->GetIDMtl(), tmppath); + SML_MtlGetTextureLighting(GData::Editors::SimModel->GetIDMtl(), tmppath); SXMaterialEditor::EditTexLighting->SetText(tmppath); - SXMaterialEditor::CheckBoxTexLighting->SetCheck(SML_MtlGetIsTextureLighting(GData::SimModel->GetIDMtl())); + SXMaterialEditor::CheckBoxTexLighting->SetCheck(SML_MtlGetIsTextureLighting(GData::Editors::SimModel->GetIDMtl())); - SXMaterialEditor::ComboBoxTypeRefract->SetSel(SML_MtlGetTypeTransparency(GData::SimModel->GetIDMtl())); - SXMaterialEditor::ComboBoxTypeReflect->SetSel(SML_MtlGetTypeReflection(GData::SimModel->GetIDMtl())); + SXMaterialEditor::ComboBoxTypeRefract->SetSel(SML_MtlGetTypeTransparency(GData::Editors::SimModel->GetIDMtl())); + SXMaterialEditor::ComboBoxTypeReflect->SetSel(SML_MtlGetTypeReflection(GData::Editors::SimModel->GetIDMtl())); SXMaterialEditor::ComboBoxPhysic->SetSel(0); - SML_MtlGetMaskTex(GData::SimModel->GetIDMtl(), tmppath); + SML_MtlGetMaskTex(GData::Editors::SimModel->GetIDMtl(), tmppath); SXMaterialEditor::EditMask->SetText(tmppath); - SML_MtlGetMRTex(GData::SimModel->GetIDMtl(), 0, tmppath); + SML_MtlGetMRTex(GData::Editors::SimModel->GetIDMtl(), 0, tmppath); SXMaterialEditor::EditMR->SetText(tmppath); - SML_MtlGetMRTex(GData::SimModel->GetIDMtl(), 1, tmppath); + SML_MtlGetMRTex(GData::Editors::SimModel->GetIDMtl(), 1, tmppath); SXMaterialEditor::EditMG->SetText(tmppath); - SML_MtlGetMRTex(GData::SimModel->GetIDMtl(), 2, tmppath); + SML_MtlGetMRTex(GData::Editors::SimModel->GetIDMtl(), 2, tmppath); SXMaterialEditor::EditMB->SetText(tmppath); - SML_MtlGetMRTex(GData::SimModel->GetIDMtl(), 3, tmppath); + SML_MtlGetMRTex(GData::Editors::SimModel->GetIDMtl(), 3, tmppath); SXMaterialEditor::EditMA->SetText(tmppath); - SML_MtlGetDTex(GData::SimModel->GetIDMtl(), 0, tmppath); + SML_MtlGetDTex(GData::Editors::SimModel->GetIDMtl(), 0, tmppath); SXMaterialEditor::EditDR->SetText(tmppath); - SML_MtlGetDTex(GData::SimModel->GetIDMtl(), 1, tmppath); + SML_MtlGetDTex(GData::Editors::SimModel->GetIDMtl(), 1, tmppath); SXMaterialEditor::EditDG->SetText(tmppath); - SML_MtlGetDTex(GData::SimModel->GetIDMtl(), 2, tmppath); + SML_MtlGetDTex(GData::Editors::SimModel->GetIDMtl(), 2, tmppath); SXMaterialEditor::EditDB->SetText(tmppath); - SML_MtlGetDTex(GData::SimModel->GetIDMtl(), 3, tmppath); + SML_MtlGetDTex(GData::Editors::SimModel->GetIDMtl(), 3, tmppath); SXMaterialEditor::EditDA->SetText(tmppath); - SXMaterialEditor::CheckBoxDoSWVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_mat_w)); - SXMaterialEditor::CheckBoxDoSWPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_mat_w)); + SXMaterialEditor::CheckBoxDoSWVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_w)); + SXMaterialEditor::CheckBoxDoSWPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_w)); - SXMaterialEditor::CheckBoxDoSVVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_mat_v)); - SXMaterialEditor::CheckBoxDoSVPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_mat_v)); + SXMaterialEditor::CheckBoxDoSVVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_v)); + SXMaterialEditor::CheckBoxDoSVPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_v)); - SXMaterialEditor::CheckBoxDoSPVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_mat_p)); - SXMaterialEditor::CheckBoxDoSPPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_mat_p)); + SXMaterialEditor::CheckBoxDoSPVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_p)); + SXMaterialEditor::CheckBoxDoSPPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_p)); - SXMaterialEditor::CheckBoxDoSWVVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_mat_wv)); - SXMaterialEditor::CheckBoxDoSWVPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_mat_wv)); + SXMaterialEditor::CheckBoxDoSWVVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_wv)); + SXMaterialEditor::CheckBoxDoSWVPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_wv)); - SXMaterialEditor::CheckBoxDoSCamposVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_campos)); - SXMaterialEditor::CheckBoxDoSCamposPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_campos)); + SXMaterialEditor::CheckBoxDoSCamposVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_campos)); + SXMaterialEditor::CheckBoxDoSCamposPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_campos)); - SXMaterialEditor::CheckBoxDoSTimeDeltaVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_timedelta)); - SXMaterialEditor::CheckBoxDoSTimeDeltaPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_timedelta)); + SXMaterialEditor::CheckBoxDoSTimeDeltaVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_timedelta)); + SXMaterialEditor::CheckBoxDoSTimeDeltaPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_timedelta)); - SXMaterialEditor::CheckBoxDoSWVPVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_mat_wvp)); - SXMaterialEditor::CheckBoxDoSWVPPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_mat_wvp)); + SXMaterialEditor::CheckBoxDoSWVPVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_wvp)); + SXMaterialEditor::CheckBoxDoSWVPPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_mat_wvp)); - SXMaterialEditor::CheckBoxDoSWinSizeVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_winsize)); - SXMaterialEditor::CheckBoxDoSWinSizePS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_winsize)); + SXMaterialEditor::CheckBoxDoSWinSizeVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_winsize)); + SXMaterialEditor::CheckBoxDoSWinSizePS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_winsize)); - SXMaterialEditor::CheckBoxUDVS->SetCheck(SML_MtlGetSTDVS(GData::SimModel->GetIDMtl(), mtss_ud)); - SXMaterialEditor::CheckBoxUDPS->SetCheck(SML_MtlGetSTDPS(GData::SimModel->GetIDMtl(), mtss_ud)); + SXMaterialEditor::CheckBoxUDVS->SetCheck(SML_MtlGetSTDVS(GData::Editors::SimModel->GetIDMtl(), mtss_ud)); + SXMaterialEditor::CheckBoxUDPS->SetCheck(SML_MtlGetSTDPS(GData::Editors::SimModel->GetIDMtl(), mtss_ud)); // // SXMaterialEditor::CheckBoxUDVSInPS->SetCheck(false); - SXMaterialEditor::TrackBarUDVSX->SetPos(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 0) * 100.f); - SXMaterialEditor::EditUDVSX->SetText(String(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(),0)).c_str()); + SXMaterialEditor::TrackBarUDVSX->SetPos(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 0) * 100.f); + SXMaterialEditor::EditUDVSX->SetText(String(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 0)).c_str()); - SXMaterialEditor::TrackBarUDVSY->SetPos(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 1) * 100.f); - SXMaterialEditor::EditUDVSY->SetText(String(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 1)).c_str()); + SXMaterialEditor::TrackBarUDVSY->SetPos(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 1) * 100.f); + SXMaterialEditor::EditUDVSY->SetText(String(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 1)).c_str()); - SXMaterialEditor::TrackBarUDVSZ->SetPos(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 2) * 100.f); - SXMaterialEditor::EditUDVSZ->SetText(String(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 2)).c_str()); + SXMaterialEditor::TrackBarUDVSZ->SetPos(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 2) * 100.f); + SXMaterialEditor::EditUDVSZ->SetText(String(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 2)).c_str()); - SXMaterialEditor::TrackBarUDVSW->SetPos(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 3) * 100.f); - SXMaterialEditor::EditUDVSW->SetText(String(SML_MtlGetUDVS(GData::SimModel->GetIDMtl(), 3)).c_str()); + SXMaterialEditor::TrackBarUDVSW->SetPos(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 3) * 100.f); + SXMaterialEditor::EditUDVSW->SetText(String(SML_MtlGetUDVS(GData::Editors::SimModel->GetIDMtl(), 3)).c_str()); SXMaterialEditor::CheckBoxUDPSInVS->SetCheck(false); - SXMaterialEditor::TrackBarUDPSX->SetPos(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 0) * 100.f); - SXMaterialEditor::EditUDPSX->SetText(String(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 0)).c_str()); + SXMaterialEditor::TrackBarUDPSX->SetPos(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 0) * 100.f); + SXMaterialEditor::EditUDPSX->SetText(String(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 0)).c_str()); - SXMaterialEditor::TrackBarUDPSY->SetPos(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 1) * 100.f); - SXMaterialEditor::EditUDPSY->SetText(String(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 1)).c_str()); + SXMaterialEditor::TrackBarUDPSY->SetPos(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 1) * 100.f); + SXMaterialEditor::EditUDPSY->SetText(String(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 1)).c_str()); - SXMaterialEditor::TrackBarUDPSZ->SetPos(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 2) * 100.f); - SXMaterialEditor::EditUDPSZ->SetText(String(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 2)).c_str()); + SXMaterialEditor::TrackBarUDPSZ->SetPos(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 2) * 100.f); + SXMaterialEditor::EditUDPSZ->SetText(String(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 2)).c_str()); - SXMaterialEditor::TrackBarUDPSW->SetPos(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 3) * 100.f); - SXMaterialEditor::EditUDPSW->SetText(String(SML_MtlGetUDPS(GData::SimModel->GetIDMtl(), 3)).c_str()); + SXMaterialEditor::TrackBarUDPSW->SetPos(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 3) * 100.f); + SXMaterialEditor::EditUDPSW->SetText(String(SML_MtlGetUDPS(GData::Editors::SimModel->GetIDMtl(), 3)).c_str()); - SXMaterialEditor::CheckBoxUDPSInVS->SetCheck(SML_MtlGetUDPS_InVS(GData::SimModel->GetIDMtl())); - SXMaterialEditor::CheckBoxUDVSInPS->SetCheck(SML_MtlGetUDVS_InPS(GData::SimModel->GetIDMtl())); + SXMaterialEditor::CheckBoxUDPSInVS->SetCheck(SML_MtlGetUDPS_InVS(GData::Editors::SimModel->GetIDMtl())); + SXMaterialEditor::CheckBoxUDVSInPS->SetCheck(SML_MtlGetUDVS_InPS(GData::Editors::SimModel->GetIDMtl())); } void SXMaterialEditor::FinalImageUncheckedMenu() diff --git a/source/sxmaterialeditor/sxmaterialeditor.cpp b/source/sxmaterialeditor/sxmaterialeditor.cpp index 2039c99e44990c256b8aa485bbf58805c20d8670..ff529cdd26d7094847143a26110fcb1a8adf4602 100644 --- a/source/sxmaterialeditor/sxmaterialeditor.cpp +++ b/source/sxmaterialeditor/sxmaterialeditor.cpp @@ -39,11 +39,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin GData::ObjCamera->SetPosition(&float3(0, 0, -1.2*100)); - GData::SimModel = new ModelSim(); + GData::Editors::SimModel = new ModelSim(); - GData::SimModel->Add("sphere.dse"); - GData::SimModel->Add("cube.dse"); - GData::SimModel->Add("plane.dse"); + GData::Editors::SimModel->Add("sphere.dse"); + GData::Editors::SimModel->Add("cube.dse"); + GData::Editors::SimModel->Add("plane.dse"); SML_LigthsCreatePoint( &float3(10,300,0), @@ -66,8 +66,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin static DWORD lastTime = GetTickCount(); static DWORD TimeCCadr = 0; - SXMaterialEditor::InitMtl(GData::SimModel->GetIDMtl()); - SXMaterialEditor::IDMat = GData::SimModel->GetIDMtl(); + SXMaterialEditor::InitMtl(GData::Editors::SimModel->GetIDMtl()); + SXMaterialEditor::IDMat = GData::Editors::SimModel->GetIDMtl(); while (msg.message != WM_QUIT && IsWindow(GData::Handle3D)) { @@ -94,7 +94,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin SGCore_LoadTexLoadTextures(); if (SXMaterialEditor::CheckBoxModelRot->GetCheck()) - GData::SimModel->Rotation.y -= float(timeDelta) * 0.001f * 0.25; + GData::Editors::SimModel->Rotation.y -= float(timeDelta) * 0.001f * 0.25; SXRenderFunc::MainRender(timeDelta); TimeCCadr = timeDelta; @@ -104,7 +104,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLin } } - mem_delete(GData::SimModel); + mem_delete(GData::Editors::SimModel); SXMaterialEditor::DeleteAllElements(); SkyXEngine_Kill(); diff --git a/source/sxparticleseditor/callback_common.cpp b/source/sxparticleseditor/callback_common.cpp index 0b5f9ba140d0c61bb3690a6a9c1b1290ebe37d66..48fc4d1bbf2482bc880434526a111dddbd88d40b 100644 --- a/source/sxparticleseditor/callback_common.cpp +++ b/source/sxparticleseditor/callback_common.cpp @@ -365,7 +365,7 @@ LRESULT SXParticlesEditor_Edits_Enter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM else if (hwnd == SXParticlesEditor::EditTimeLife->GetHWND()) { sscanf(ttext, "%d", &tlong); - if (tlong > 0) + if (tlong >= 0) SPE_EmitterSet(SXParticlesEditor::SelEffID, SXParticlesEditor::SelEmitterID, TimeLife, tlong) else {