-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolidSphere.cpp
More file actions
52 lines (41 loc) · 1.53 KB
/
SolidSphere.cpp
File metadata and controls
52 lines (41 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "SolidSphere.h"
#include "VoxaNovusBindableBase.h"
#include "VoxaNovusGfxExceptionMacros.h"
#include "Sphere.h"
SolidSphere::SolidSphere(Graphics& gfx, float radius) {
namespace dx = DirectX;
if (!IsStaticInitialized()) {
struct Vertex {
dx::XMFLOAT3 pos;
};
auto model = Sphere::Make<Vertex>();
model.Transform(dx::XMMatrixScaling(radius, radius, radius));
AddBind(std::make_unique<VertexBuffer>(gfx, model.vertices));
AddIndexBuffer(std::make_unique<IndexBuffer>(gfx, model.indices));
auto pvs = std::make_unique<VertexShader>(gfx, L"SolidVS.cso");
auto pvsbc = pvs->GetBytecode();
AddStaticBind(std::move(pvs));
AddStaticBind(std::make_unique<PixelShader>(gfx, L"SolidPS.cso"));
struct PSColorConstant {
dx::XMFLOAT3 color = { 1.0f,1.0f,1.0f };
float padding;
} colorConst;
AddStaticBind(std::make_unique<PixelConstantBuffer<PSColorConstant>>(gfx, colorConst));
const std::vector<D3D11_INPUT_ELEMENT_DESC> ied =
{
{ "Position",0,DXGI_FORMAT_R32G32B32_FLOAT,0,0,D3D11_INPUT_PER_VERTEX_DATA,0 },
};
AddStaticBind(std::make_unique<InputLayout>(gfx, ied, pvsbc));
AddStaticBind(std::make_unique<Topology>(gfx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST));
}
else
SetIndexFromStatic();
AddBind(std::make_unique<TransformCbuf>(gfx, *this));
}
void SolidSphere::Update(float dt) noexcept {}
void SolidSphere::SetPos(DirectX::XMFLOAT3 pos) noexcept {
this->pos = pos;
}
DirectX::XMMATRIX SolidSphere::GetTransformXM() const noexcept {
return DirectX::XMMatrixTranslation(pos.x, pos.y, pos.z);
}