#pragma once #include "Triangle.h" #include "Bindable.h" #include "VertexBuffer.h" #include "IndexBuffer.h" #include "VertexShader.h" #include "PixelShader.h" #include "ConstantBuffer.h" #include "InputLayout.h" #include "Topology.h" #include "TransformCBuf.h" #include "Graphics.h" Triangle::Triangle(Graphics& gfx, StructVertexWithTexture vertices[], Logger& logger) { // Assign position values //for (int i = 0; i < 3; i++) //{ // for (int j = 0; j < 3; j++) // { // this->position[i][j] = position[i][j]; // } //} //// Assign color values //for (int i = 0; i < 1; i++) //{ // for (int j = 0; j < 3; j++) // { // this->color[i][j] = color[i][j]; // } //} /************************************ * 2.3 DefineVertexBuffer ************************************/ const std::vector vb = { { vertices[0] }, { vertices[1] }, { vertices[2] } }; AddBind(std::make_unique(gfx, vb, logger)); /*for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { logger.PutLog("Triangle::Triangle", std::to_string(this->position[i][j])); } }*/ /************************************ * 2.7 DefineVertexShader ************************************/ auto pVertexShader = std::make_unique(gfx, L"VertexShader.cso"); auto pvsbc = pVertexShader->GetBytecode(); AddBind(std::move(pVertexShader)); /************************************ * 2.8 DefinePixelShader ************************************/ AddBind(std::make_unique(gfx, L"PixelShader.cso")); /************************************ * 2.4 DefineIndexBuffer ************************************/ /*const std::vector indices = { 0,2,1, 2,3,1, 1,3,5, 3,7,5, 2,6,3, 3,6,7, 4,5,7, 4,7,6, 0,4,2, 2,4,6, 0,1,4, 1,5,4 };*/ const std::vector indices = { 0,1,2 }; AddIndexBuffer(std::make_unique(gfx, indices, logger)); /************************************ * 2.6 DefineColorConstBuffer(PixelConstBuf) ************************************/ /*const StructPixelConstBuf cb2 = { { { 1.0f,0.0f,1.0f }, { 1.0f,0.0f,0.0f }, { 0.0f,1.0f,0.0f }, { 0.0f,0.0f,1.0f }, { 1.0f,1.0f,0.0f }, { 0.0f,1.0f,1.0f }, } };*/ /*const StructPixelConstBuf cb2 = { { color[0][0], color[0][1], color[0][2] } }; AddBind(std::make_unique>(gfx, cb2));*/ /************************************ * 2.9 DefineInputLayout ************************************/ const std::vector ied = { { "Position",0,DXGI_FORMAT_R32G32B32_FLOAT,0,0,D3D11_INPUT_PER_VERTEX_DATA,0 }, }; AddBind(std::make_unique(gfx, ied, pvsbc)); /************************************ * 2.10 DefinePrimitiveTopology ************************************/ AddBind(std::make_unique(gfx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST)); /************************************ * 2.5 DefineTransConstBuffer ************************************/ AddBind(std::make_unique(gfx, *this)); } void Triangle::Update(float dt) noexcept { /*roll += droll * dt; pitch += dpitch * dt; yaw += dyaw * dt; theta += dtheta * dt; phi += dphi * dt; chi += dchi * dt;*/ dx = dt; dy = dt; dz = dt; } DirectX::XMMATRIX Triangle::GetTransformXM(Graphics& gfx) const noexcept { /*return DirectX::XMMatrixRotationRollPitchYaw(pitch, yaw, roll) * DirectX::XMMatrixTranslation(r, 0.0f, 0.0f) * DirectX::XMMatrixRotationRollPitchYaw(theta, phi, chi) * DirectX::XMMatrixTranslation(0.0f, 0.0f, 20.0f);*/ return DirectX::XMMatrixTranslation(0.0f, 0.0f, 4.0f) * DirectX::XMMatrixTranslation(dx, dy, dz) * gfx.getLookAtMatrix(); }