From a3ba67e3c29d3db57b0f53552f691c417cf30ed0 Mon Sep 17 00:00:00 2001 From: lanariel Date: Mon, 10 Feb 2014 13:59:45 +0100 Subject: [PATCH] Fixed release compile and basic anim --- Code/Misc/Misc.vcxproj | 8 ++++-- Code/OysterGraphics/Core/Core.h | 3 ++- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 23 +++++++++------- Code/OysterGraphics/DllInterfaces/GFXAPI.h | 2 +- Code/OysterGraphics/Model/Model.h | 7 +---- Code/OysterGraphics/OysterGraphics.vcxproj | 13 +++++----- .../OysterGraphics/Render/DefaultRenderer.cpp | 13 +++++----- Code/OysterGraphics/Render/DefaultRenderer.h | 2 +- Code/Tester/MainTest.cpp | 26 +++++++------------ 9 files changed, 48 insertions(+), 49 deletions(-) diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 5989b04a..2d9392a3 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -153,7 +153,9 @@ false - true + false + false + false @@ -173,7 +175,9 @@ false - true + false + false + false diff --git a/Code/OysterGraphics/Core/Core.h b/Code/OysterGraphics/Core/Core.h index eb420c04..644d9f0d 100644 --- a/Code/OysterGraphics/Core/Core.h +++ b/Code/OysterGraphics/Core/Core.h @@ -7,7 +7,8 @@ #include "Dx11Includes.h" #include #include "OysterMath.h" -#include "../Misc/Resource/ResourceManager.h" +//#include "../Misc/Resource/ResourceManager.h" +#include "../../Misc/Resource/ResourceManager.h" //#include namespace Oyster diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index fe75e982..04795f31 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -18,7 +18,7 @@ namespace Oyster Math::Float4x4 View; Math::Float4x4 Projection; std::vector Lights; - float dt=0; + float deltaTime; } API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion) @@ -61,12 +61,12 @@ namespace Oyster void API::RenderScene(Model::Model models[], int count) { - Render::DefaultRenderer::RenderScene(models,count, View, Projection); + Render::DefaultRenderer::RenderScene(models,count, View, Projection, deltaTime); } - void API::RenderModel(Model::Model& m) + void API::RenderModel(Model::Model* m) { - Render::DefaultRenderer::RenderScene(&m,1, View, Projection); + Render::DefaultRenderer::RenderScene(m,1, View, Projection, deltaTime); } void API::EndFrame() @@ -87,7 +87,7 @@ namespace Oyster Model::Model* m = new Model::Model(); m->WorldMatrix = Oyster::Math::Float4x4::identity; m->Visible = true; - m->Animation.data.AnimationPlaying = NULL; + m->Animation.AnimationPlaying = NULL; m->info = (Model::ModelInfo*)Core::loader.LoadResource((Core::modelPath + filename).c_str(),Oyster::Graphics::Loading::LoadDAN, Oyster::Graphics::Loading::UnloadDAN); Model::ModelInfo* mi = (Model::ModelInfo*)m->info; @@ -177,10 +177,15 @@ namespace Oyster float API::PlayAnimation(Model::Model* m, std::wstring name,bool looping) { - m->Animation.data.AnimationPlaying = &(*m->info->Animations.find(name)).second; - m->Animation.data.AnimationTime=0; - m->Animation.data.LoopAnimation = looping; - return m->Animation.data.AnimationPlaying->duration; + m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second; + m->Animation.AnimationTime=0; + m->Animation.LoopAnimation = looping; + return m->Animation.AnimationPlaying->duration; + } + + void API::Update(float dt) + { + deltaTime = dt; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 2a664ecf..1c489dc8 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -51,7 +51,7 @@ namespace Oyster //! @brief Renders a list of models static void RenderScene(Oyster::Graphics::Model::Model models[], int count); //! @brief Renders a single model - static void RenderModel(Oyster::Graphics::Model::Model& model); + static void RenderModel(Oyster::Graphics::Model::Model* model); //! @brief Configures Renderer to process 2D graphics, data will be passed in to EndFrame() static void StartGuiRender(); diff --git a/Code/OysterGraphics/Model/Model.h b/Code/OysterGraphics/Model/Model.h index 2f97a441..590d7d6a 100644 --- a/Code/OysterGraphics/Model/Model.h +++ b/Code/OysterGraphics/Model/Model.h @@ -19,17 +19,12 @@ namespace Oyster float AnimationTime; bool LoopAnimation; }; - struct AnimationPlayer - { - AnimationData data; - ModelInfo* info; - }; struct Model { ModelInfo* info; Oyster::Math::Float4x4 WorldMatrix; bool Visible; - AnimationPlayer Animation; + AnimationData Animation; }; } diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index ca2e776b..c19e073f 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -78,6 +78,7 @@ $(ProjectName)_$(PlatformShortName) C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + true $(SolutionDir)..\Bin\DLL\ @@ -246,21 +247,21 @@ Compute 5.0 Compute - 4.0 + 5.0 Compute - 4.0 + 5.0 Compute - 4.0 + 5.0 Compute 5.0 Compute - 4.0 + 5.0 Compute - 4.0 + 5.0 Compute - 4.0 + 5.0 Compute diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index aaec7473..754197e8 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -49,7 +49,7 @@ namespace Oyster Resources::Post::Data.Unmap(); } - void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection) + void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float deltaTime) { for(int i = 0; i < count; ++i) { @@ -64,8 +64,9 @@ namespace Oyster Model::ModelInfo* info = models[i].info; Definitions::AnimationData am; //final - if(info->Animated && models[i].Animation.data.AnimationPlaying != NULL) + if(info->Animated && models[i].Animation.AnimationPlaying != NULL) { + models[i].Animation.AnimationTime += deltaTime; cube->WorldMatrix = Math::Matrix::identity; ////store inverse absolut transform Math::Matrix SkinTransform[100]; @@ -91,11 +92,11 @@ namespace Oyster cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3]; } int b = 0; - Model::Animation A = *models[i].Animation.data.AnimationPlaying; - while(models[i].Animation.data.AnimationTime>A.duration) - models[i].Animation.data.AnimationTime -= (float)A.duration; + Model::Animation A = *models[i].Animation.AnimationPlaying; + while(models[i].Animation.AnimationTime>A.duration) + models[i].Animation.AnimationTime -= (float)A.duration; - float position = models[i].Animation.data.AnimationTime; + float position = models[i].Animation.AnimationTime; for(int b = 0; b < A.Bones;++b) { //find current frame diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h index 5402f310..54075a3f 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.h +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -14,7 +14,7 @@ namespace Oyster { public: static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights); - static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection); + static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0); static void EndFrame(); static Model::Model* cube; diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index 4b7ca697..1f6e33e3 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -168,13 +168,11 @@ HRESULT InitDirect3D() Oyster::Graphics::API::SetOptions(o); m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); - m2 = Oyster::Graphics::API::CreateModel(L"T_reskinned.dan"); + m2 = Oyster::Graphics::API::CreateModel(L"char_bindpose.dan"); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); Oyster::Graphics::API::PlayAnimation(m2, L"Bend",true); - //m3 = Oyster::Graphics::API::CreateModel(L"box_2.dan"); - //m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null); - t = Oyster::Graphics::API::CreateTexture(L"white.png"); + t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -198,15 +196,10 @@ float angle = 0; HRESULT Update(float deltaTime) { angle += Oyster::Math::pi/16 * deltaTime; - //m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle); - //m->WorldMatrix = m->WorldMatrix * Oyster::Math3D::RotationMatrix_AxisX(-Oyster::Math::pi/2); - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-Oyster::Math::pi/2,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); - Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; - //ma *= 50; - //ma.m44 = 1; - //m2->WorldMatrix = m2->WorldMatrix * ma; - m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; - //m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); + //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; + Oyster::Graphics::API::Update(deltaTime); + //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; } @@ -215,10 +208,9 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::SetView(V); Oyster::Graphics::API::NewFrame(); - Oyster::Graphics::API::RenderModel(*m); - Oyster::Graphics::API::RenderModel(*m2); - //Oyster::Graphics::API::RenderModel(*m3); - //Oyster::Graphics::API::StartGuiRender(); + Oyster::Graphics::API::RenderModel(m); + Oyster::Graphics::API::RenderModel(m2); + Oyster::Graphics::API::StartGuiRender(); Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.2f,0.2f)); Oyster::Graphics::API::EndFrame();