diff options
| author | Anton Novoselov <[email protected]> | 2017-08-01 12:53:38 +0300 |
|---|---|---|
| committer | Anton Novoselov <[email protected]> | 2017-08-01 12:53:38 +0300 |
| commit | 236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch) | |
| tree | e486f2fa39dba203563895541e92c60ed3e25759 /tools/ArtistTools/source/CoreLib/Scene | |
| parent | Added screens to welcome page (diff) | |
| download | blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip | |
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'tools/ArtistTools/source/CoreLib/Scene')
7 files changed, 97 insertions, 86 deletions
diff --git a/tools/ArtistTools/source/CoreLib/Scene/Camera.cpp b/tools/ArtistTools/source/CoreLib/Scene/Camera.cpp index 74d93f4..2dba89a 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/Camera.cpp +++ b/tools/ArtistTools/source/CoreLib/Scene/Camera.cpp @@ -136,9 +136,9 @@ D3DXMATRIX * D3DXMatrixLookAtLH( D3DXVECTOR3 yaxis = gfsdk_cross(zaxis, xaxis); gfsdk_makeIdentity(*pOut); - pOut->_11 = zaxis.x; - pOut->_21 = zaxis.y; - pOut->_31 = zaxis.z; + pOut->_11 = xaxis.x; + pOut->_21 = xaxis.y; + pOut->_31 = xaxis.z; pOut->_12 = yaxis.x; pOut->_22 = yaxis.y; pOut->_32 = yaxis.z; diff --git a/tools/ArtistTools/source/CoreLib/Scene/Gamepad.cpp b/tools/ArtistTools/source/CoreLib/Scene/Gamepad.cpp index 01e3323..246ce04 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/Gamepad.cpp +++ b/tools/ArtistTools/source/CoreLib/Scene/Gamepad.cpp @@ -263,7 +263,7 @@ void ToggleSimulation() #endif // NV_ARTISTTOOLS } -void StartAnimation() +void PlaySample() { #ifndef NV_ARTISTTOOLS GlobalSettings::Inst().toggleSimulation(); @@ -282,7 +282,7 @@ void StartAnimation() // reset animation //toolbar->on_btnResetAnimation_clicked(); #else - CoreLib::Inst()->Gamepad_StartAnimation(); + CoreLib::Inst()->Gamepad_PlaySample(); #endif // NV_ARTISTTOOLS } @@ -353,7 +353,7 @@ void LoadSamples(bool bNext) continue; QString fn = t.toLower(); std::string strFN = fn.toUtf8().data(); - const char* ptest = strstr(strFN.c_str(), ".furproj"); + const char* ptest = strstr(strFN.c_str(), ".blastProj"); if (ptest) { const char* pchar = strchr(strFN.c_str(), ':'); @@ -397,7 +397,7 @@ void LoadSamples(bool bNext) if(!projectPath.isEmpty()) { QStringList filters; - filters<<QString("*.furproj"); + filters<<QString("*.blastProj"); QDirIterator dir_iterator(projectPath, filters, QDir::Files | QDir::NoSymLinks,QDirIterator::Subdirectories); while(dir_iterator.hasNext()) { @@ -1259,13 +1259,13 @@ void Gamepad::DemoModeOnOff() void Gamepad::DemoNext() { LoadSamples(true); - StartAnimation(); + PlaySample(); } void Gamepad::DemoPrev() { LoadSamples(false); - StartAnimation(); + PlaySample(); } void Gamepad::SetDemoMode(bool onOff) @@ -1278,9 +1278,6 @@ void Gamepad::SetDemoMode(bool onOff) { curentPrjIdx = -1; // make it start from first demo DemoNext(); - - // turn off FPS display - GlobalSettings::Inst().m_showFPS = false; } else { diff --git a/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.cpp b/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.cpp index 1903d32..6a826ca 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.cpp +++ b/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.cpp @@ -250,11 +250,49 @@ void GlobalSettings::setSceneUnitIndex(int i) /////////////////////////////////////////////////////////////////////////////// +bool GlobalSettings::isSupportedUnitByUnitInCm(float fUnitInCm) +{ + int unit = identifyUnitByUnitInCm(fUnitInCm); + return unit != SCENE_UNIT_UNKNOWN; +} + +int GlobalSettings::identifyUnitByUnitInCm(float fUnitInCm) +{ + float fError = 0.001f; + if (fabs(fUnitInCm - 1.0f) < fError) + { + return SCENE_UNIT_CENTIMETER; + } + if (fabs(fUnitInCm - 2.54f) < fError) + { + return SCENE_UNIT_INCH; + } + if (fabs(fUnitInCm - 100.0f) < fError) + { + return SCENE_UNIT_METER; + } + if (fabs(fUnitInCm - 10.0f) < fError) + { + return SCENE_UNIT_DECIMETER; + } + return SCENE_UNIT_UNKNOWN; // should never happen +} + +void GlobalSettings::setSceneUnitByUnitInCm(float fUnitInCm) +{ + m_sceneUnitIndex = identifyUnitByUnitInCm(fUnitInCm); +} + float GlobalSettings::getSceneUnitInCentimeters() { + return getSceneUnitInCentimeters(m_sceneUnitIndex); +} + +float GlobalSettings::getSceneUnitInCentimeters(int unitIndex) +{ float unit = 1.0f; - switch (m_sceneUnitIndex) + switch (unitIndex) { case SCENE_UNIT_CENTIMETER: unit = 1.0f; diff --git a/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.h b/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.h index c83143b..7c1e666 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.h +++ b/tools/ArtistTools/source/CoreLib/Scene/GlobalSettings.h @@ -148,7 +148,11 @@ public: bool isBindPose() { return m_animationIndex == 0; } float getSceneUnitInCentimeters(); + static float getSceneUnitInCentimeters(int unitIndex); void setSceneUnitIndex(int i); + void setSceneUnitByUnitInCm(float fUnitInCm); + static int identifyUnitByUnitInCm(float fUnitInCm); + static bool isSupportedUnitByUnitInCm(float fUnitInCm); void setTimeStep(float timeStep) { m_timeStep = timeStep; } diff --git a/tools/ArtistTools/source/CoreLib/Scene/Light.cpp b/tools/ArtistTools/source/CoreLib/Scene/Light.cpp index e18314e..5f17e66 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/Light.cpp +++ b/tools/ArtistTools/source/CoreLib/Scene/Light.cpp @@ -512,7 +512,7 @@ bool Light::SetEnvTextureFromFilePath(const char* textureFilePath) m_envTextureFilePath = (textureFilePath) ? textureFilePath : ""; SAFE_RELEASE(m_pEnvTextureSRV); - if ((!textureFilePath) && (strlen(textureFilePath) > 0)) + if ((textureFilePath) && (strlen(textureFilePath) > 0)) m_pEnvTextureSRV = RenderInterface::CreateTextureResource(textureFilePath); return true; diff --git a/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.cpp b/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.cpp index a633770..ddbf517 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.cpp +++ b/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.cpp @@ -171,8 +171,8 @@ bool SimpleScene::Initialize( HWND hWnd, int backdoor) if(!InitCameraMouse(hWnd)) return false; -// if (!SimpleRenderable::Initialize()) -// return false; + if (!SimpleRenderable::Initialize()) + return false; Light::Initialize(); @@ -189,30 +189,7 @@ bool SimpleScene::Initialize( HWND hWnd, int backdoor) SetFurModified(false); SetProjectModified(false); -#ifndef NV_ARTISTTOOLS - if (!InitializeBlastSDK(&g_logHandler, backdoor)) - return false; - - g_projectParamsContext = CreateProjectParamsContext(); - if (!g_projectParamsContext) return false; - - { - NvHair::Sdk* hairSdk = GetHairSDK(); - if (hairSdk) - { - const NvHair::BuildInfo& buildInfo = GetHairSDK()->getBuildInfo(); - - viewer_info(GetHairSDK()->getBuildInfo().m_buildString); - - char releaseVersion[100] = "Blast Release:"; - buildInfo.m_versionToStringFunc(buildInfo.m_releaseVersion, releaseVersion + strlen(releaseVersion)); - - viewer_info(releaseVersion); - } - } -#else CoreLib::Inst()->SimpleScene_Initialize(backdoor); -#endif // NV_ARTISTTOOLS AppMainWindow::Inst().updateUI(); @@ -324,22 +301,6 @@ Timer& SimpleScene::GetTimer() /////////////////////////////////////////////////////////////////////////////// void SimpleScene::Draw() { - CoreLib* pCore = CoreLib::Inst(); - pCore->D3DWidget_paintEvent(NULL); -#ifndef NV_ARTISTTOOLS -#else - //pCore->SimpleScene_Draw_DX12(); - - //RenderInterface::SwitchToDX11(); - - //pCore->SimpleScene_Draw_DX11(); - - //RenderInterface::FlushDX11(); -#endif - // present current window - //RenderInterface::PresentRenderWindow(); - return; - if (IsSceneLoading()) return; @@ -364,9 +325,6 @@ void SimpleScene::Draw() // update camera UpdateCamera(); - // draw lights - Light::DrawLights(m_pCamera); - // show ground grid if (globalSettings.m_showGrid) DrawGround(); @@ -386,23 +344,6 @@ void SimpleScene::Draw() if (GlobalSettings::Inst().m_visualizeShadowMap) Light::RenderShadowMap(); -#ifndef NV_ARTISTTOOLS - // init profiler stats - FurRenderer::ResetFrameTimer(); - // the main loop to simulate and render hairs and meshes - FurRenderer::UpdateFrame(); - FurRenderer::Render(m_pCamera); - - RenderInterface::SwitchToDX11(); - // draw bone name for first hair (hacky, needs to go into SDK) - HairInstance* pInstance = GetFurCharacter().GetFirstSelectedHairInstance(); - if (pInstance && globalSettings.m_visualizeBoneNames) - pInstance->DrawBoneNames(m_pCamera); - - // draw HUD. - FurRenderer::DrawHUD(); - RenderInterface::FlushDX11(); -#else CoreLib::Inst()->SimpleScene_Draw_DX12(); RenderInterface::SwitchToDX11(); @@ -411,7 +352,8 @@ void SimpleScene::Draw() RenderInterface::FlushDX11(); -#endif // NV_ARTISTTOOLS + // draw lights + Light::DrawLights(m_pCamera); // present current window RenderInterface::PresentRenderWindow(); @@ -512,18 +454,13 @@ SimpleScene::LoadSceneFromFbx(const char* dir, const char* fbxName) /////////////////////////////////////////////////////////////////////////////// bool SimpleScene::LoadProject(const char* dir, const char* file) { - GlobalSettings& globalSettings = GlobalSettings::Inst(); + Clear(); + GlobalSettings& globalSettings = GlobalSettings::Inst(); globalSettings.m_projectFileDir = dir; globalSettings.m_projectFileName = file; -#ifndef NV_ARTISTTOOLS - nvidia::parameterized::HairProjectParametersNS::ParametersStruct params; - if (!ProjectParamsLoad(g_projectParamsContext, globalSettings.getAbsoluteFilePath().c_str(), this)) - return false; -#else CoreLib::Inst()->SimpleScene_LoadProject(dir, file); -#endif // NV_ARTISTTOOLS SetProjectModified(false); @@ -950,18 +887,20 @@ void SimpleScene::UpdateCamera() float minZ = 1.0f; float maxZ = 10000.0f; // should calculate dynamically - +/* if (sceneUnit != 0.0f) { minZ /= sceneUnit; maxZ /= sceneUnit; } - +*/ m_pCamera->SetAspetRatio(aspect); m_pCamera->SetZFar(maxZ); m_pCamera->SetZNear(minZ); m_pCamera->Perspective(); + + CoreLib::Inst()->SimpleScene_UpdateCamera(); } void SimpleScene::FitCamera() @@ -975,7 +914,11 @@ void SimpleScene::FitCamera() if (m_pFurCharacter) m_pFurCharacter->ComputeBounds(center, extents, false); #else - CoreLib::Inst()->SimpleScene_FitCamera(center, extents); + bool valid = CoreLib::Inst()->SimpleScene_FitCamera(center, extents); + if (!valid) + { + return; + } #endif // NV_ARTISTTOOLS m_pCamera->FitBounds(center, extents); diff --git a/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.h b/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.h index 8d01970..79597d2 100644 --- a/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.h +++ b/tools/ArtistTools/source/CoreLib/Scene/SimpleScene.h @@ -34,6 +34,7 @@ #include <QtCore/QMap> #include "Camera.h" #include "Timer.h" +#include <DirectXMath.h> class FurCharacter; class DeviceManager; @@ -141,6 +142,34 @@ public: Timer& GetTimer(); + DirectX::XMMATRIX GetViewMatrix() const + { + atcore_float4x4& matrix = m_pCamera->_viewMatrix; + return DirectX::XMMATRIX( + matrix._11, matrix._12, matrix._13, matrix._14, + matrix._21, matrix._22, matrix._23, matrix._24, + matrix._31, matrix._32, matrix._33, matrix._34, + matrix._41, matrix._42, matrix._43, matrix._44); + } + DirectX::XMMATRIX GetProjMatrix() const + { + atcore_float4x4& matrix = m_pCamera->_projectionMatrix; + return DirectX::XMMATRIX( + matrix._11, matrix._12, matrix._13, matrix._14, + matrix._21, matrix._22, matrix._23, matrix._24, + matrix._31, matrix._32, matrix._33, matrix._34, + matrix._41, matrix._42, matrix._43, matrix._44); + } + DirectX::XMVECTOR GetEyePt() const + { + return DirectX::XMLoadFloat3( + reinterpret_cast<const DirectX::XMFLOAT3*>(&m_pCamera->_eye)); + } + DirectX::XMVECTOR GetLookAtPt() const + { + return DirectX::XMLoadFloat3( + reinterpret_cast<const DirectX::XMFLOAT3*>(&m_pCamera->_at)); + } private: // initialize scene components bool InitCameraMouse(HWND hAppWnd); |