-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCylinder.cpp
More file actions
63 lines (45 loc) · 1.82 KB
/
Cylinder.cpp
File metadata and controls
63 lines (45 loc) · 1.82 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
53
54
55
56
57
58
59
60
61
62
63
#include "Cylinder.h"
#include "Prism.h"
#include "BindableBase.h"
Cylinder::Cylinder(Graphics& gfx, std::mt19937& rng,
std::uniform_real_distribution<float>& adist,
std::uniform_real_distribution<float>& ddist,
std::uniform_real_distribution<float>& odist,
std::uniform_real_distribution<float>& rdist,
std::uniform_real_distribution<float>& bdist,
std::uniform_int_distribution<int>& tdist) : TestObject(gfx, rng, adist, ddist, odist, rdist) {
namespace dx = DirectX;
if (!IsStaticInitialized()) {
auto pvs = std::make_unique<VertexShader>(gfx, L"PhongLightingVS.cso");
auto pvsbc = pvs->GetByteCode();
AddStaticBind(std::move(pvs));
AddStaticBind(std::make_unique<PixelShader>(gfx, L"IndexedPhongLightingPS.cso"));
const std::vector<D3D11_INPUT_ELEMENT_DESC> ied = {
{"Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"Normal", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
AddStaticBind(std::make_unique<InputLayout>(gfx, ied, pvsbc));
AddStaticBind(std::make_unique<Topology>(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST));
struct PSMaterialConstant {
dx::XMFLOAT3A colors[6] = {
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f},
{1.0f, 1.0f, 0.0f},
{1.0f, 0.0f, 1.0f},
{0.0f, 1.0f, 1.0f}
};
float specularIntesity = 0.6f;
float specularPower = 30.0f;
} matConst;
AddStaticBind(std::make_unique<PixelConstantBuffer<PSMaterialConstant>>(gfx, matConst, 1u));
}
struct Vertex {
dx::XMFLOAT3 pos;
dx::XMFLOAT3 norm;
};
auto model = Prism::MakeTesselatedIndependentCapNormals<Vertex>(tdist(rng));
AddBind(std::make_unique<VertexBuffer<Vertex>>(gfx, model.vertices));
AddIndexBuffer(std::make_unique<IndexBuffer>(gfx, model.indices));
AddBind(std::make_unique<TransformConstantBuffer>(gfx, *this));
}