|
31 | 31 |
|
32 | 32 | DILIGENT_BEGIN_NAMESPACE(Diligent) |
33 | 33 |
|
| 34 | +#include "../../Primitives/interface/DefineRefMacro.h" |
| 35 | + |
34 | 36 | /// Geometry primitive vertex flags. |
35 | 37 | // clang-format off |
36 | 38 | DILIGENT_TYPED_ENUM(GEOMETRY_PRIMITIVE_VERTEX_FLAGS, Uint32) |
@@ -60,37 +62,105 @@ DILIGENT_TYPED_ENUM(GEOMETRY_PRIMITIVE_VERTEX_FLAGS, Uint32) |
60 | 62 | GEOMETRY_PRIMITIVE_VERTEX_FLAG_TEXCOORD, |
61 | 63 | }; |
62 | 64 | // clang-format on |
63 | | - |
64 | 65 | DEFINE_FLAG_ENUM_OPERATORS(GEOMETRY_PRIMITIVE_VERTEX_FLAGS) |
65 | 66 |
|
| 67 | +/// Geometry primitive types. |
| 68 | +// clang-format off |
| 69 | +DILIGENT_TYPED_ENUM(GEOMETRY_PRIMITIVE_TYPE, Uint32) |
| 70 | +{ |
| 71 | + /// Geometry primitive type is undefined. |
| 72 | + GEOMETRY_PRIMITIVE_TYPE_UNDEFINED = 0u, |
| 73 | + |
| 74 | + /// Cube geometry primitive type. |
| 75 | + GEOMETRY_PRIMITIVE_TYPE_CUBE = 1u, |
| 76 | + |
| 77 | + GEOMETRY_PRIMITIVE_TYPE_LAST = GEOMETRY_PRIMITIVE_TYPE_CUBE |
| 78 | +}; |
| 79 | +// clang-format on |
| 80 | + |
| 81 | +/// Geometry primitive attributes. |
| 82 | +struct GeometryPrimitiveAttributes |
| 83 | +{ |
| 84 | + /// The geometry primitive type, see Diligent::GEOMETRY_PRIMITIVE_TYPE. |
| 85 | + GEOMETRY_PRIMITIVE_TYPE Type DEFAULT_INITIALIZER(GEOMETRY_PRIMITIVE_TYPE_UNDEFINED); |
| 86 | + |
| 87 | + /// Vertex flags that specify which vertex components to include in the output vertices, |
| 88 | + /// see Diligent::GEOMETRY_PRIMITIVE_VERTEX_FLAGS. |
| 89 | + GEOMETRY_PRIMITIVE_VERTEX_FLAGS VertexFlags DEFAULT_INITIALIZER(GEOMETRY_PRIMITIVE_VERTEX_FLAG_ALL); |
| 90 | + |
| 91 | + /// The number of subdivisions. |
| 92 | + /// |
| 93 | + /// \remarks This parameter defines the fidelity of the geometry primitive. |
| 94 | + /// For example, for a cube geometry primitive, the cube faces are subdivided |
| 95 | + /// into Subdivision x Subdivision quads, producing (Subdivision + 1)^2 vertices |
| 96 | + /// per face. |
| 97 | + Uint32 NumSubdivisions DEFAULT_INITIALIZER(0); |
| 98 | + |
| 99 | +#if DILIGENT_CPP_INTERFACE |
| 100 | + GeometryPrimitiveAttributes() noexcept = default; |
| 101 | + |
| 102 | + explicit GeometryPrimitiveAttributes(GEOMETRY_PRIMITIVE_TYPE _Type, |
| 103 | + GEOMETRY_PRIMITIVE_VERTEX_FLAGS _VertexFlags = GEOMETRY_PRIMITIVE_VERTEX_FLAG_ALL, |
| 104 | + Uint32 _NumSubdivision = 1) noexcept : |
| 105 | + Type{_Type}, |
| 106 | + VertexFlags{_VertexFlags}, |
| 107 | + NumSubdivisions{_NumSubdivision} |
| 108 | + {} |
| 109 | +#endif |
| 110 | +}; |
| 111 | +typedef struct GeometryPrimitiveAttributes GeometryPrimitiveAttributes; |
| 112 | + |
| 113 | +/// Cube geometry primitive attributes. |
| 114 | +// clang-format off |
| 115 | +struct CubeGeometryPrimitiveAttributes DILIGENT_DERIVE(GeometryPrimitiveAttributes) |
| 116 | + |
| 117 | + /// The size of the cube. |
| 118 | + /// The cube is centered at (0, 0, 0) and has the size of Size x Size x Size. |
| 119 | + /// If the cube size is 1, the coordinates of the cube vertices are in the range [-0.5, 0.5]. |
| 120 | + float Size DEFAULT_INITIALIZER(1.f); |
| 121 | + |
| 122 | +#if DILIGENT_CPP_INTERFACE |
| 123 | + explicit CubeGeometryPrimitiveAttributes(float _Size = 1, |
| 124 | + GEOMETRY_PRIMITIVE_VERTEX_FLAGS _VertexFlags = GEOMETRY_PRIMITIVE_VERTEX_FLAG_ALL, |
| 125 | + Uint32 _NumSubdivision = 1) noexcept : |
| 126 | + GeometryPrimitiveAttributes{GEOMETRY_PRIMITIVE_TYPE_CUBE, _VertexFlags, _NumSubdivision}, |
| 127 | + Size{_Size} |
| 128 | + {} |
| 129 | +#endif |
| 130 | +}; |
| 131 | +// clang-format on |
| 132 | + |
| 133 | +/// Geometry primitive info. |
| 134 | +struct GeometryPrimitiveInfo |
| 135 | +{ |
| 136 | + /// The number of vertices. |
| 137 | + Uint32 NumVertices DEFAULT_INITIALIZER(0); |
| 138 | + |
| 139 | + /// The number of indices. |
| 140 | + Uint32 NumIndices DEFAULT_INITIALIZER(0); |
| 141 | + |
| 142 | + /// The size of the vertex in bytes. |
| 143 | + Uint32 VertexSize DEFAULT_INITIALIZER(0); |
| 144 | +}; |
| 145 | + |
66 | 146 | /// Returns the size of the geometry primitive vertex in bytes. |
67 | 147 | Uint32 GetGeometryPrimitiveVertexSize(GEOMETRY_PRIMITIVE_VERTEX_FLAGS VertexFlags); |
68 | 148 |
|
69 | | -/// Creates a cube geometry. |
| 149 | +/// Creates a geometry primitive |
70 | 150 | /// |
71 | | -/// \param [in] Size The size of the cube. |
72 | | -/// The cube is centered at (0, 0, 0) and has the size of Size x Size x Size. |
73 | | -/// If the cube size is 1, the coordinates of the cube vertices are in the range [-0.5, 0.5]. |
74 | | -/// \param [in] NumSubdivisions The number of subdivisions. |
75 | | -/// The cube faces are subdivided into Subdivision x Subdivision quads. |
76 | | -/// \param [in] VertexFlags Flags that specify which vertex components to include in the output vertices. |
| 151 | +/// \param [in] Attribs Geometry primitive attributes, see Diligent::GeometryPrimitiveAttributes. |
77 | 152 | /// \param [out] ppVertices Address of the memory location where the pointer to the output vertex data blob will be stored. |
78 | 153 | /// The vertex components are stored as interleaved floating-point values. |
79 | 154 | /// For example, if VertexFlags = GEOMETRY_PRIMITIVE_VERTEX_FLAG_POS_NORM, the vertex data will |
80 | 155 | /// be stored as follows: |
81 | 156 | /// P0, N0, P1, N1, ..., Pn, Nn. |
82 | 157 | /// \param [out] ppIndices Address of the memory location where the pointer to the output index data blob will be stored. |
83 | 158 | /// Index data is stored as 32-bit unsigned integers representing the triangle list. |
84 | | -/// \param [out] pNumVertices Address of the memory location where the number of vertices will be stored. |
85 | | -/// This parameter can be null. |
86 | | -/// \param [out] pNumIndices Address of the memory location where the number of indices will be stored. |
87 | | -/// This parameter can be null. |
88 | | -void DILIGENT_GLOBAL_FUNCTION(CreateCubeGeometry)(float Size, |
89 | | - Uint32 NumSubdivisions, |
90 | | - GEOMETRY_PRIMITIVE_VERTEX_FLAGS VertexFlags, |
91 | | - IDataBlob** ppVertices, |
92 | | - IDataBlob** ppIndices, |
93 | | - Uint32* pNumVertices DEFAULT_VALUE(nullptr), |
94 | | - Uint32* pNumIndices DEFAULT_VALUE(nullptr)); |
| 159 | +/// \param [out] pInfo Address of the memory location where the pointer to the output geometry primitive info will be stored. |
| 160 | +void DILIGENT_GLOBAL_FUNCTION(CreateGeometryPrimitive)(const GeometryPrimitiveAttributes REF Attribs, |
| 161 | + IDataBlob** ppVertices, |
| 162 | + IDataBlob** ppIndices, |
| 163 | + GeometryPrimitiveInfo* pInfo DEFAULT_VALUE(nullptr)); |
| 164 | +#include "../../Primitives/interface/UndefRefMacro.h" |
95 | 165 |
|
96 | 166 | DILIGENT_END_NAMESPACE // namespace Diligent |
0 commit comments