Files
directx-plane-game/Graphics2/Graphics2.cpp
iDunnoDev 65255f1321 Added the ASSIMP library
Added the files provided for the tutorial
Added the SplitMeshNode and SubMeshNode classes
2022-03-18 21:26:31 +00:00

46 lines
1.6 KiB
C++

#include "Graphics2.h"
Graphics2 app;
void Graphics2::CreateSceneGraph()
{
SceneGraphPointer sceneGraph = GetSceneGraph();
// This is where you add nodes to the scene graph
//shared_ptr<TexturedCubeNode> cube = make_shared<TexturedCubeNode>(L"Body", L"Textures\\woodbox.bmp");
//cube->SetWorldTransform(XMMatrixScaling(5.0f, 8.0f, 2.5f) * XMMatrixTranslation(0, 23.0f, 0));
//sceneGraph->Add(cube);
shared_ptr<SplitMeshNode> node = make_shared<SplitMeshNode>(L"Plane1", L"Models\\Plane\\Bonanza.3DS");
node->SetWorldTransform(XMMatrixScaling(0.5f, 0.5f, 0.5f) * XMMatrixRotationAxis(XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f), 90.0f * XM_PI / 180.0f) * XMMatrixTranslation(-30.0f, 20.0f, 0));
sceneGraph->Add(node);
SetBackgroundColour(XMFLOAT4(0.29f, 0.38f, 0.72f, 1.0f));
_currentRotation = 0;
_currentSideRotation = 0;
_currentPropRotation = 0;
}
void Graphics2::UpdateSceneGraph()
{
SceneGraphPointer sceneGraph = GetSceneGraph();
sceneGraph->SetWorldTransform((SharedMethods::RotateFromPoint(30.0f, -20.0f, 0, XMMatrixRotationAxis(XMVectorSet(0.0f, 0.0f, -1.0f, 0.0f), _currentSideRotation * XM_PI / 180.0f))) * XMMatrixRotationAxis(XMVectorSet(0.0f, -1.0f, 0.0f, 0.0f), _currentRotation * XM_PI / 180.0f));
sceneGraph->Find(L"airscrew")->SetWorldTransform(SharedMethods::RotateFromPoint(0.0f, 15.471f, 14.5f, XMMatrixRotationAxis(XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f), _currentPropRotation * XM_PI / 180.0f)));
if (_currentRotation == 360)
{
_currentRotation = 0;
//_currentSideRotation = 0;
_currentPropRotation = 0;
}
else
{
_currentRotation += 1;
_currentSideRotation += 0.3;
_currentPropRotation += 100;
}
}