14 return reinterpret_cast<void*
>(&m_data);
19 unsigned long faceCount,
20 unsigned long vertexCount,
21 float (*pPositions)[3],
23 float (*pTextureCoordinates)[2],
24 unsigned long (*pFaceIndices)[3],
25 unsigned long (*pTextureIndices)[3],
59 IDirect3DRMMesh* pD3DRM,
60 unsigned long faceCount,
61 unsigned long vertexCount,
62 float (*pPositions)[3],
64 float (*pTextureCoordinates)[2],
65 unsigned long (*pFaceIndices)[3],
66 unsigned long (*pTextureIndices)[3],
71 unsigned long* faceIndices = (
unsigned long*) pFaceIndices;
73 int count = faceCount * 3;
76 unsigned int* fData =
new unsigned int[count];
79 memset(vertices, 0,
sizeof(*vertices) * vertexCount);
84 for (
int i = 0; i < count; i++) {
85 if ((*((
unsigned short*) &faceIndices[i] + 1) >> 0x0f) & 0x01) {
86 unsigned long j = *(
unsigned short*) &faceIndices[i];
87 vertices[index].
position.
x = pPositions[j][0];
88 vertices[index].
position.
y = pPositions[j][1];
89 vertices[index].
position.
z = pPositions[j][2];
90 j = *((
unsigned short*) &faceIndices[i] + 1) & MAXSHORT;
91 vertices[index].
normal.
x = pNormals[j][0];
92 vertices[index].
normal.
y = pNormals[j][1];
93 vertices[index].
normal.
z = pNormals[j][2];
95 if (pTextureIndices !=
NULL && pTextureCoordinates !=
NULL) {
96 j = ((
unsigned long*) pTextureIndices)[i];
97 vertices[index].
tu = pTextureCoordinates[j][0];
98 vertices[index].
tv = pTextureCoordinates[j][1];
105 fData[i] = *(
unsigned short*) &faceIndices[i];
110 result =
ResultVal(pD3DRM->AddGroup(vertexCount, faceCount, 3, fData, &groupIndex));
114 result =
ResultVal(pD3DRM->SetVertices(groupIndex, 0, vertexCount, vertices));
131 if (vertices !=
NULL) {
138inline Result MeshBuilderImpl::CreateMeshImpl(
140 unsigned long faceCount,
141 unsigned long vertexCount,
142 float (*pPositions)[3],
143 float (*pNormals)[3],
144 float (*pTextureCoordinates)[2],
145 unsigned long (*pFaceIndices)[3],
146 unsigned long (*pTextureIndices)[3],
193 int ret = m_data->Clone(0, IID_IDirect3DRMMesh, (
void**) &mesh->m_data);
[AI] Implements Tgl::MeshBuilder, manages mesh construction and provides the interface for creating g...
Mesh * CreateMesh(unsigned long faceCount, unsigned long vertexCount, float(*pPositions)[3], float(*pNormals)[3], float(*pTextureCoordinates)[2], unsigned long(*pFaceIndices)[3], unsigned long(*pTextureIndices)[3], ShadingModel shadingModel) override
Creates a mesh from arrays of data (positions, normals, etc.) [AI].
Result GetBoundingBox(float min[3], float max[3]) const override
Gets the bounding box of the constructed mesh [AI].
MeshBuilder * Clone() override
Clones the mesh builder [AI].
void * ImplementationDataPtr() override
Returns mesh builder implementation pointer [AI].
MeshBuilderImpl()
[AI] Initializes mesh builder to null [AI]
[AI] Implementation of Tgl::Mesh, manages a mesh object and geometry data with group index [AI]
const MeshDataType & ImplementationData() const
Gets mesh implementation data (const) [AI].
[AI] Builder class for assembling mesh data and extracting mesh objects.
[AI] Represents a renderable 3D mesh.
#define DECOMP_SIZE_ASSERT(T, S)
#define NULL
[AI] Null pointer value (C/C++ semantics).
Result MeshBuilderGetBoundingBox(IDirect3DRMMesh *pMesh, float min[3], float max[3])
Result CreateMesh(IDirect3DRMMesh *pD3DRM, unsigned long faceCount, unsigned long vertexCount, float(*pPositions)[3], float(*pNormals)[3], float(*pTextureCoordinates)[2], unsigned long(*pFaceIndices)[3], unsigned long(*pTextureIndices)[3], ShadingModel shadingModel, MeshImpl::MeshDataType &rpMesh)
Result MeshSetTextureMappingMode(MeshImpl::MeshData *pMesh, TextureMappingMode mode)
[AI] Forward declaration for Direct3DRMTexture interface [AI]
Result ResultVal(HRESULT result)
Returns a Tgl Result value for HRESULT [AI].
int Succeeded(Result result)
[AI] Returns whether a Tgl::Result indicates success.
ShadingModel
[AI] Represents shading models available for rendering geometry.
TextureMappingMode
[AI] Methods for mapping textures onto geometry.
@ PerspectiveCorrect
[AI] Perspective-correct mapping (higher quality). [AI]
Result
[AI] Result type used throughout the Tgl API to report operation success or failure.
@ Error
[AI] Operation failed. [AI]
[AI] Holds D3DRMMesh pointer and group index for referencing geometry [AI]
D3DRMGROUPINDEX groupIndex
[AI] Index within mesh group [AI]
IDirect3DRMMesh * groupMesh
[AI] D3DRM mesh pointer [AI]