Added more models
Fixed issue with material only parts of meshs not being rendered
@ -38,6 +38,7 @@ private:
|
||||
float _moveForwardBack;
|
||||
|
||||
float _cameraYaw;
|
||||
float _cameraYawPrev;
|
||||
float _cameraPitch;
|
||||
float _cameraRoll;
|
||||
|
||||
|
@ -7,6 +7,7 @@ ControlledMeshNode::ControlledMeshNode(wstring name, wstring modelName) : MeshNo
|
||||
void ControlledMeshNode::Update(FXMMATRIX& currentWorldTransformation)
|
||||
{
|
||||
ObjectNode::Update(_worldTransformation);
|
||||
MeshNode::Update(currentWorldTransformation);
|
||||
}
|
||||
|
||||
bool ControlledMeshNode::Initialise(void)
|
||||
|
@ -36,13 +36,23 @@ void Graphics2::CreateSceneGraph()
|
||||
//terrainNode->SetWaterColor(XMFLOAT4(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
sceneGraph->Add(terrainNode);
|
||||
|
||||
shared_ptr<ControlledSplitMeshNode> plane1Node = make_shared<ControlledSplitMeshNode>(L"Plane1", L"Models\\Plane\\Bonanza.3DS");
|
||||
shared_ptr<ControlledSplitMeshNode> plane1Node = make_shared<ControlledSplitMeshNode>(L"Plane1", L"Models\\Plane\\Bonanza.3DS");
|
||||
plane1Node->SetStartOrientation(XMMatrixRotationAxis(XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f), XM_PI) * XMMatrixRotationAxis(XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f), 0.5f * XM_PI));
|
||||
plane1Node->SetNodePosition(0.0f, 550.0f, -50.0f);
|
||||
sceneGraph->Add(plane1Node);
|
||||
|
||||
//_currentPlayerObject = plane1Node;
|
||||
//GetCamera()->SetFollowNode(plane1Node, XMFLOAT3(0.0f, 30.0f, -80.0f), false);
|
||||
shared_ptr<SceneGraph> boatGraph = make_shared<SceneGraph>(L"boatGraph");
|
||||
boatGraph->SetWorldTransform(XMMatrixScaling(0.1f, 0.1f, 0.1f) * XMMatrixTranslation(-1840.0f, 290.0f, 699.0f));
|
||||
|
||||
shared_ptr<ControlledMeshNode> boat1Node = make_shared<ControlledMeshNode>(L"Boat1", L"Models\\Boat\\Boat.FBX");
|
||||
boat1Node->SetStartOrientation(XMMatrixRotationAxis(XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f), XM_PI) * XMMatrixRotationAxis(XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f), 0.5f * XM_PI));
|
||||
boat1Node->SetNodePosition(0.0f, 0.0f, 0.0f);
|
||||
boatGraph->Add(boat1Node);
|
||||
|
||||
sceneGraph->Add(boatGraph);
|
||||
|
||||
_currentPlayerObject = plane1Node;
|
||||
GetCamera()->SetFollowNode(plane1Node, XMFLOAT3(0.0f, 30.0f, -80.0f), false);
|
||||
|
||||
SetBackgroundColour(XMFLOAT4(0.29f, 0.38f, 0.72f, 1.0f));
|
||||
//SetBackgroundColour(XMFLOAT4(SharedMethods::RGBValueToIntensity(0x89), 0, 1, 1));
|
||||
@ -52,7 +62,7 @@ void Graphics2::CreateSceneGraph()
|
||||
_currentPropRotation = 0;
|
||||
}
|
||||
|
||||
void Graphics2::UpdateSceneGraph()
|
||||
void Graphics2::GenerateClutter()
|
||||
{
|
||||
SceneGraphPointer sceneGraph = GetSceneGraph();
|
||||
shared_ptr<TerrainNode> mainTerrain = dynamic_pointer_cast<TerrainNode>(sceneGraph->Find(L"MainTerrain"));
|
||||
@ -60,22 +70,123 @@ void Graphics2::UpdateSceneGraph()
|
||||
if (!_initDone && mainTerrain != nullptr)
|
||||
{
|
||||
vector<TerrainPopNode> rngSpawnList;
|
||||
vector<TerrainPopNode> rngBushSpawnList;
|
||||
vector<TerrainPopNode> rngSnowSpawnList;
|
||||
vector<TerrainPopNode> rngDirtSpawnList;
|
||||
|
||||
TerrainPopNode treeModelA = TerrainPopNode();
|
||||
treeModelA.modelName = L"Models\\Tree\\Tree2.fbx";
|
||||
treeModelA.modelName = L"Models\\Tree\\Tree1.fbx";
|
||||
treeModelA.nodeBaseName = L"treeA";
|
||||
treeModelA.scaleFactor = 1.0f;
|
||||
treeModelA.scaleFactor = 0.5f;
|
||||
|
||||
TerrainPopNode treeModelB = TerrainPopNode();
|
||||
treeModelB.modelName = L"Models\\Tree\\Tree2.fbx";
|
||||
treeModelB.nodeBaseName = L"treeB";
|
||||
treeModelB.scaleFactor = 0.5f;
|
||||
|
||||
rngSpawnList.push_back(treeModelA);
|
||||
rngSpawnList.push_back(treeModelB);
|
||||
|
||||
shared_ptr<SceneGraph> treeGroupA = make_shared<SceneGraph>(L"TreeGroupA");
|
||||
|
||||
mainTerrain->PopulateTerrain(treeGroupA, rngSpawnList, 10, 10, 400.0f, 550.0f, 0.9f, 1.0f);
|
||||
mainTerrain->PopulateTerrain(treeGroupA, rngSpawnList, 20, 20, 500.0f, 650.0f, 0.9f, 1.0f);
|
||||
treeGroupA->Initialise();
|
||||
sceneGraph->Add(treeGroupA);
|
||||
|
||||
TerrainPopNode bushModelA = TerrainPopNode();
|
||||
bushModelA.modelName = L"Models\\Tree\\Bush1.fbx";
|
||||
bushModelA.nodeBaseName = L"bushA";
|
||||
bushModelA.scaleFactor = 0.05f;
|
||||
|
||||
TerrainPopNode bushModelB = TerrainPopNode();
|
||||
bushModelB.modelName = L"Models\\Tree\\Bush2.fbx";
|
||||
bushModelB.nodeBaseName = L"bushB";
|
||||
bushModelB.scaleFactor = 0.05f;
|
||||
|
||||
TerrainPopNode grassModelA = TerrainPopNode();
|
||||
grassModelA.modelName = L"Models\\Tree\\Grass1.fbx";
|
||||
grassModelA.nodeBaseName = L"grassA";
|
||||
grassModelA.scaleFactor = 0.005f;
|
||||
|
||||
TerrainPopNode grassModelB = TerrainPopNode();
|
||||
grassModelB.modelName = L"Models\\Tree\\Grass2.fbx";
|
||||
grassModelB.nodeBaseName = L"grassB";
|
||||
grassModelB.scaleFactor = 0.05f;
|
||||
|
||||
TerrainPopNode grassModelC = TerrainPopNode();
|
||||
grassModelC.modelName = L"Models\\Tree\\Grass3.fbx";
|
||||
grassModelC.nodeBaseName = L"grassC";
|
||||
grassModelC.scaleFactor = 0.05f;
|
||||
|
||||
rngBushSpawnList.push_back(bushModelA);
|
||||
rngBushSpawnList.push_back(bushModelB);
|
||||
rngBushSpawnList.push_back(grassModelA);
|
||||
rngBushSpawnList.push_back(grassModelB);
|
||||
rngBushSpawnList.push_back(grassModelC);
|
||||
|
||||
shared_ptr<SceneGraph> bushGroupA = make_shared<SceneGraph>(L"BushGroupA");
|
||||
|
||||
mainTerrain->PopulateTerrain(bushGroupA, rngBushSpawnList, 7, 7, 500.0f, 650.0f, 0.95f, 1.0f);
|
||||
bushGroupA->Initialise();
|
||||
sceneGraph->Add(bushGroupA);
|
||||
|
||||
TerrainPopNode treeModelSA = TerrainPopNode();
|
||||
treeModelSA.modelName = L"Models\\Tree\\Tree3.fbx";
|
||||
treeModelSA.nodeBaseName = L"treeSA";
|
||||
treeModelSA.scaleFactor = 0.1f;
|
||||
|
||||
rngSnowSpawnList.push_back(treeModelSA);
|
||||
|
||||
shared_ptr<SceneGraph> treeGroupSA = make_shared<SceneGraph>(L"TreeGroupSnowA");
|
||||
|
||||
mainTerrain->PopulateTerrain(treeGroupSA, rngSnowSpawnList, 50, 50, 750.0f, 1000.0f, 0.6f, 1.0f);
|
||||
treeGroupSA->Initialise();
|
||||
sceneGraph->Add(treeGroupSA);
|
||||
|
||||
TerrainPopNode treeModelDA = TerrainPopNode();
|
||||
treeModelDA.modelName = L"Models\\Tree\\Tree4.fbx";
|
||||
treeModelDA.nodeBaseName = L"treeDA";
|
||||
treeModelDA.scaleFactor = 0.05f;
|
||||
|
||||
TerrainPopNode rockModelA = TerrainPopNode();
|
||||
rockModelA.modelName = L"Models\\Tree\\Rock1.fbx";
|
||||
rockModelA.nodeBaseName = L"rockA";
|
||||
rockModelA.scaleFactor = 0.1f;
|
||||
|
||||
TerrainPopNode rockModelB = TerrainPopNode();
|
||||
rockModelB.modelName = L"Models\\Tree\\Rock2.fbx";
|
||||
rockModelB.nodeBaseName = L"rockB";
|
||||
rockModelB.scaleFactor = 0.1f;
|
||||
|
||||
TerrainPopNode rockModelC = TerrainPopNode();
|
||||
rockModelC.modelName = L"Models\\Tree\\Rock3.fbx";
|
||||
rockModelC.nodeBaseName = L"rockC";
|
||||
rockModelC.scaleFactor = 0.1f;
|
||||
|
||||
rngDirtSpawnList.push_back(treeModelDA);
|
||||
rngDirtSpawnList.push_back(rockModelA);
|
||||
rngDirtSpawnList.push_back(rockModelB);
|
||||
rngDirtSpawnList.push_back(rockModelC);
|
||||
|
||||
shared_ptr<SceneGraph> treeGroupDA = make_shared<SceneGraph>(L"TreeGroupDirtA");
|
||||
|
||||
mainTerrain->PopulateTerrain(treeGroupDA, rngDirtSpawnList, 10, 10, 310.0f, 410.0f, 0.9f, 1.0f);
|
||||
treeGroupDA->Initialise();
|
||||
sceneGraph->Add(treeGroupDA);
|
||||
|
||||
_initDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics2::UpdateSceneGraph()
|
||||
{
|
||||
SceneGraphPointer sceneGraph = GetSceneGraph();
|
||||
shared_ptr<TerrainNode> mainTerrain = dynamic_pointer_cast<TerrainNode>(sceneGraph->Find(L"MainTerrain"));
|
||||
|
||||
if (!_initDone && mainTerrain != nullptr)
|
||||
{
|
||||
GenerateClutter();
|
||||
}
|
||||
|
||||
GetCurrentControlInputs();
|
||||
XMVECTOR startCameraPos = GetCamera()->GetCameraPosition();
|
||||
@ -165,6 +276,7 @@ void Graphics2::UpdateSceneGraph()
|
||||
}
|
||||
|
||||
shared_ptr<ControlledSplitMeshNode> plane1 = dynamic_pointer_cast<ControlledSplitMeshNode>(sceneGraph->Find(L"Plane1"));
|
||||
shared_ptr<ControlledMeshNode> boat1 = dynamic_pointer_cast<ControlledMeshNode>(sceneGraph->Find(L"Boat1"));
|
||||
|
||||
if (plane1 != nullptr)
|
||||
{
|
||||
@ -176,6 +288,12 @@ void Graphics2::UpdateSceneGraph()
|
||||
plane1->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 (boat1 != nullptr)
|
||||
{
|
||||
boat1->SetForwardBack(10.0f);
|
||||
boat1->SetYaw(-1.0f);
|
||||
}
|
||||
|
||||
if (_currentRotation == 360)
|
||||
{
|
||||
_currentRotation = 0;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "TexturedCubeNode.h"
|
||||
#include "MeshNode.h"
|
||||
#include "SplitMeshNode.h"
|
||||
#include "ControlledMeshNode.h"
|
||||
#include "ControlledSplitMeshNode.h"
|
||||
#include "HeightMapTerrainNode.h"
|
||||
#include "PerlinTerrainNode.h"
|
||||
@ -44,5 +45,6 @@ private:
|
||||
|
||||
void GetCurrentControlInputs();
|
||||
void ResetCurrentControlInputs();
|
||||
void GenerateClutter();
|
||||
};
|
||||
|
||||
|
@ -62,10 +62,18 @@ void MeshRenderer::RenderNode(shared_ptr<Node> node, bool renderTransparent)
|
||||
_cBuffer.specularCoefficient = material->GetSpecularColour();
|
||||
_cBuffer.shininess = material->GetShininess();
|
||||
_cBuffer.opacity = opacity;
|
||||
// Update the constant buffer
|
||||
// Update the constant buffer
|
||||
_texture = material->GetTexture();
|
||||
if (_texture == nullptr)
|
||||
{
|
||||
_cBuffer.validTexture = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cBuffer.validTexture = 1;
|
||||
}
|
||||
_deviceContext->VSSetConstantBuffers(0, 1, _constantBuffer.GetAddressOf());
|
||||
_deviceContext->UpdateSubresource(_constantBuffer.Get(), 0, 0, &_cBuffer, 0, 0);
|
||||
_texture = material->GetTexture();
|
||||
_deviceContext->PSSetShaderResources(0, 1, _texture.GetAddressOf());
|
||||
_deviceContext->PSSetConstantBuffers(0, 1, _constantBuffer.GetAddressOf());
|
||||
_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
BIN
Graphics2/Models/Boat/Boat.FBX
Normal file
@ -1,27 +0,0 @@
|
||||
newmtl mat_0-default-grey.jpg
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.698039 0.698039 0.698039
|
||||
Ks 0.000000 0.000000 0.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
Ns 9.84916
|
||||
map_Kd default-grey.jpg
|
||||
|
||||
newmtl mat_1-boat_fishing02.jpg
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.698039 0.698039 0.698039
|
||||
Ks 0.000000 0.000000 0.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
Ns 9.84916
|
||||
map_Kd boat_fishing02.jpg
|
||||
|
||||
newmtl mat_2-default-grey.jpg
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.698039 0.698039 0.698039
|
||||
Ks 0.000000 0.000000 0.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
Ns 9.84916
|
||||
map_Kd default-grey.jpg
|
||||
|
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 1.1 MiB |
BIN
Graphics2/Models/Boat/textures/boat_ao.bmp
Normal file
After Width: | Height: | Size: 12 MiB |
BIN
Graphics2/Models/Boat/textures/boat_diffuse.bmp
Normal file
After Width: | Height: | Size: 12 MiB |
BIN
Graphics2/Models/Boat/textures/boat_gloss.bmp
Normal file
After Width: | Height: | Size: 12 MiB |
BIN
Graphics2/Models/Boat/textures/boat_normal.bmp
Normal file
After Width: | Height: | Size: 12 MiB |
BIN
Graphics2/Models/Boat/textures/boat_specular.bmp
Normal file
After Width: | Height: | Size: 12 MiB |
BIN
Graphics2/Models/Tree/Tree1Test.fbx
Normal file
BIN
Graphics2/Models/Tree/TreeTexture.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
@ -99,11 +99,21 @@ void ObjectNode::SetLeftRight(float leftRight)
|
||||
_moveLeftRight = leftRight;
|
||||
}
|
||||
|
||||
float ObjectNode::GetLeftRight() const
|
||||
{
|
||||
return _moveLeftRight;
|
||||
}
|
||||
|
||||
void ObjectNode::SetForwardBack(float forwardBack)
|
||||
{
|
||||
_moveForwardBack = forwardBack;
|
||||
}
|
||||
|
||||
float ObjectNode::GetForwardBack() const
|
||||
{
|
||||
return _moveForwardBack;
|
||||
}
|
||||
|
||||
XMVECTOR ObjectNode::GetNodePosition(void)
|
||||
{
|
||||
return XMLoadFloat4(&_nodeRootPosition);
|
||||
|
@ -22,7 +22,9 @@ public:
|
||||
void SetTotalRoll(float roll);
|
||||
float GetRoll() const;
|
||||
void SetLeftRight(float leftRight);
|
||||
float GetLeftRight() const;
|
||||
void SetForwardBack(float forwardBack);
|
||||
float GetForwardBack() const;
|
||||
void SetStartOrientation(FXMMATRIX originalOrientation);
|
||||
|
||||
protected:
|
||||
|
@ -14,7 +14,8 @@ struct CBUFFER
|
||||
XMFLOAT4 specularCoefficient;
|
||||
float shininess;
|
||||
float opacity;
|
||||
float padding[2];
|
||||
float validTexture;
|
||||
float padding[1];
|
||||
};
|
||||
|
||||
struct TerrainPopNode
|
||||
|
@ -63,10 +63,18 @@ void SubMeshRenderer::RenderChild(SceneNodePointer node, bool renderTransparent)
|
||||
_cBuffer.specularCoefficient = material->GetSpecularColour();
|
||||
_cBuffer.shininess = material->GetShininess();
|
||||
_cBuffer.opacity = opacity;
|
||||
// Update the constant buffer
|
||||
// Update the constant buffer
|
||||
_texture = material->GetTexture();
|
||||
if (_texture == nullptr)
|
||||
{
|
||||
_cBuffer.validTexture = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cBuffer.validTexture = 1;
|
||||
}
|
||||
_deviceContext->VSSetConstantBuffers(0, 1, _constantBuffer.GetAddressOf());
|
||||
_deviceContext->UpdateSubresource(_constantBuffer.Get(), 0, 0, &_cBuffer, 0, 0);
|
||||
_texture = material->GetTexture();
|
||||
_deviceContext->PSSetShaderResources(0, 1, _texture.GetAddressOf());
|
||||
_deviceContext->PSSetConstantBuffers(0, 1, _constantBuffer.GetAddressOf());
|
||||
_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
@ -531,7 +531,7 @@ void TerrainNode::PopulateTerrain(SceneGraphPointer currentSceneGraph, vector<Te
|
||||
float scale = (rand() % 100 * 0.01f) * nodesForPop[nodeIndex].scaleFactor;
|
||||
|
||||
float xPos = x * _cellSizeX + _terrainStartX;
|
||||
float yPos = heightValue - 1.0f;
|
||||
float yPos = heightValue;
|
||||
float zPos = (-z + 1) * _cellSizeZ + _terrainStartZ;
|
||||
|
||||
wstring nodeName = L"_" + to_wstring(z) + L"_" + to_wstring(x);
|
||||
|
@ -10,7 +10,8 @@ cbuffer ConstantBuffer
|
||||
float4 specularCoefficient; // The specular reflection cooefficient
|
||||
float shininess; // The shininess factor
|
||||
float opacity; // The opacity (transparency) of the material. 0 = fully transparent, 1 = fully opaque
|
||||
float2 padding;
|
||||
float validTexture;
|
||||
float padding;
|
||||
}
|
||||
|
||||
Texture2D Texture;
|
||||
@ -60,8 +61,18 @@ float4 PShader(PixelShaderInput input) : SV_TARGET
|
||||
// Calculate ambient lighting
|
||||
float4 ambientLight = ambientColor * diffuseCoefficient;
|
||||
|
||||
// Combine all components
|
||||
float4 color = saturate((ambientLight + diffuse + specular) * Texture.Sample(ss, input.TexCoord));
|
||||
// Combine all components
|
||||
float4 color;
|
||||
// Check if the texture is valid before trying to sample it, some meshes use materials to color them and dont export an image texture file even though the color value is stored with the vertex
|
||||
if (validTexture == 1)
|
||||
{
|
||||
color = saturate((ambientLight + diffuse + specular) * Texture.Sample(ss, input.TexCoord));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = saturate((ambientLight + diffuse + specular) * float4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
if (opacity < 1.0f)
|
||||
{
|
||||
color.a = opacity;
|
||||
|