-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicShapes.h
100 lines (90 loc) · 2.97 KB
/
BasicShapes.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved
#pragma once
#include "BasicMath.h"
#include <cstdio>
#include <vector>
// Defines the vertex format for the shapes generated in the functions below.
struct BasicVertex
{
float3 pos; // position
float2 tex; // texture coordinate
float3 norm; // surface normal vector
float3 color;
float3 uTan; // texture coordinate u-tangent vector
float3 vTan; // texture coordinate v-tangent vector
};
// Defines the vertex format for all shapes generated in the functions below.
struct TangentVertex
{
float3 pos; // position
float2 tex; // texture coordinate
float3 norm; // surface normal vector
float3 color;
float3 uTan; // texture coordinate u-tangent vector
float3 vTan; // texture coordinate v-tangent vector
};
// A helper class that provides convenient functions for creating common
// geometrical shapes used by DirectX SDK samples.
ref class BasicShapes
{
internal:
BasicShapes(ID3D11Device *d3dDevice);
void CreateCube(
float a,
_Out_ ID3D11Buffer **vertexBuffer,
_Out_ ID3D11Buffer **indexBuffer,
_Out_opt_ unsigned int *vertexCount,
_Out_opt_ unsigned int *indexCount,
std::vector<short> &m_cubeIndices,
std::vector<BasicVertex> &m_cubeVertices
);
void CreateBox(
float3 radii,
_Out_ ID3D11Buffer **vertexBuffer,
_Out_ ID3D11Buffer **indexBuffer,
_Out_opt_ unsigned int *vertexCount,
_Out_opt_ unsigned int *indexCount
);
void CreateSphere(
_Out_ ID3D11Buffer **vertexBuffer,
_Out_ ID3D11Buffer **indexBuffer,
_Out_opt_ unsigned int *vertexCount,
_Out_opt_ unsigned int *indexCount
);
void CreateTangentSphere(
_Out_ ID3D11Buffer **vertexBuffer,
_Out_ ID3D11Buffer **indexBuffer,
_Out_opt_ unsigned int *vertexCount,
_Out_opt_ unsigned int *indexCount,
std::vector<short> &m_sphereIndices,
std::vector<BasicVertex> &m_sphereVertices
);
void CreateReferenceAxis(
_Out_ ID3D11Buffer **vertexBuffer,
_Out_ ID3D11Buffer **indexBuffer,
_Out_opt_ unsigned int *vertexCount,
_Out_opt_ unsigned int *indexCount
);
private:
Microsoft::WRL::ComPtr<ID3D11Device> m_d3dDevice;
void CreateVertexBuffer(
_In_ unsigned int numVertices,
_In_ BasicVertex *vertexData,
_Out_ ID3D11Buffer **vertexBuffer
);
void CreateIndexBuffer(
_In_ unsigned int numIndices,
_In_ unsigned short *indexData,
_Out_ ID3D11Buffer **indexBuffer
);
void CreateTangentVertexBuffer(
_In_ unsigned int numVertices,
_In_ TangentVertex *vertexData,
_Out_ ID3D11Buffer **vertexBuffer
);
};