2 * Implementation of IDirect3DRMMeshBuilderX and IDirect3DRMMesh interfaces
4 * Copyright 2010, 2012 Christian Costa
5 * Copyright 2011 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
26 #include "wine/debug.h"
33 #include "d3drm_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3drm
);
40 D3DRMVERTEX
* vertices
;
42 unsigned vertex_per_face
;
46 IDirect3DRMMaterial2
* material
;
47 IDirect3DRMTexture3
* texture
;
51 IDirect3DRMMesh IDirect3DRMMesh_iface
;
53 DWORD groups_capacity
;
55 struct mesh_group
*groups
;
56 } IDirect3DRMMeshImpl
;
65 IDirect3DRMMaterial2
*material
;
66 IDirect3DRMTexture3
*texture
;
70 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface
;
71 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface
;
84 IDirect3DRMMaterial2
*material
;
85 IDirect3DRMTexture3
*texture
;
87 mesh_material
*materials
;
88 DWORD
*material_indices
;
89 } IDirect3DRMMeshBuilderImpl
;
95 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
102 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
109 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
115 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
116 "array FLOAT matrix[16];"
120 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
128 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
133 "template IndexedColor"
135 "<1630B820-7842-11CF-8F52-0040333594A3>"
137 "ColorRGBA indexColor;"
141 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
146 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
150 "template MaterialWrap"
152 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
156 "template TextureFilename"
158 "<A42790E1-7810-11CF-8F52-0040333594A3>"
163 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
164 "ColorRGBA faceColor;"
166 "ColorRGB specularColor;"
167 "ColorRGB emissiveColor;"
172 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
173 "DWORD nFaceVertexIndices;"
174 "array DWORD faceVertexIndices[nFaceVertexIndices];"
176 "template MeshFaceWraps"
178 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
179 "DWORD nFaceWrapValues;"
180 "array Boolean2d faceWrapValues[nFaceWrapValues];"
182 "template MeshTextureCoords"
184 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
185 "DWORD nTextureCoords;"
186 "array Coords2d textureCoords[nTextureCoords];"
188 "template MeshMaterialList"
190 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
192 "DWORD nFaceIndexes;"
193 "array DWORD faceIndexes[nFaceIndexes];"
196 "template MeshNormals"
198 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
200 "array Vector normals[nNormals];"
201 "DWORD nFaceNormals;"
202 "array MeshFace faceNormals[nFaceNormals];"
204 "template MeshVertexColors"
206 "<1630B821-7842-11CF-8F52-0040333594A3>"
207 "DWORD nVertexColors;"
208 "array IndexedColor vertexColors[nVertexColors];"
212 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
214 "array Vector vertices[nVertices];"
216 "array MeshFace faces[nFaces];"
219 "template FrameTransformMatrix"
221 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
222 "Matrix4x4 frameMatrix;"
226 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
231 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
233 "array FLOAT values[nValues];"
235 "template TimedFloatKeys"
237 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
241 "template AnimationKey"
243 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
246 "array TimedFloatKeys keys[nKeys];"
248 "template AnimationOptions"
250 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
252 "DWORD positionquality;"
256 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
259 "template AnimationSet"
261 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
264 "template InlineData"
266 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
271 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
273 "array STRING urls[nUrls];"
275 "template ProgressiveMesh"
277 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
282 "<A42790E0-7810-11CF-8F52-0040333594A3>"
286 "array UCHAR data4[8];"
288 "template StringProperty"
290 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
294 "template PropertyBag"
296 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
299 "template ExternalVisual"
301 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
302 "Guid guidExternalVisual;"
305 "template RightHanded"
307 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
308 "DWORD bRightHanded;"
312 static inline IDirect3DRMMeshImpl
*impl_from_IDirect3DRMMesh(IDirect3DRMMesh
*iface
)
314 return CONTAINING_RECORD(iface
, IDirect3DRMMeshImpl
, IDirect3DRMMesh_iface
);
317 static inline IDirect3DRMMeshBuilderImpl
*impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2
*iface
)
319 return CONTAINING_RECORD(iface
, IDirect3DRMMeshBuilderImpl
, IDirect3DRMMeshBuilder2_iface
);
322 static inline IDirect3DRMMeshBuilderImpl
*impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3
*iface
)
324 return CONTAINING_RECORD(iface
, IDirect3DRMMeshBuilderImpl
, IDirect3DRMMeshBuilder3_iface
);
327 static void clean_mesh_builder_data(IDirect3DRMMeshBuilderImpl
*mesh_builder
)
331 HeapFree(GetProcessHeap(), 0, mesh_builder
->name
);
332 mesh_builder
->name
= NULL
;
333 HeapFree(GetProcessHeap(), 0, mesh_builder
->pVertices
);
334 mesh_builder
->pVertices
= NULL
;
335 mesh_builder
->nb_vertices
= 0;
336 HeapFree(GetProcessHeap(), 0, mesh_builder
->pNormals
);
337 mesh_builder
->pNormals
= NULL
;
338 mesh_builder
->nb_normals
= 0;
339 HeapFree(GetProcessHeap(), 0, mesh_builder
->pFaceData
);
340 mesh_builder
->pFaceData
= NULL
;
341 mesh_builder
->face_data_size
= 0;
342 mesh_builder
->nb_faces
= 0;
343 HeapFree(GetProcessHeap(), 0, mesh_builder
->pCoords2d
);
344 mesh_builder
->pCoords2d
= NULL
;
345 mesh_builder
->nb_coords2d
= 0;
346 for (i
= 0; i
< mesh_builder
->nb_materials
; i
++)
348 if (mesh_builder
->materials
[i
].material
)
349 IDirect3DRMMaterial2_Release(mesh_builder
->materials
[i
].material
);
350 if (mesh_builder
->materials
[i
].texture
)
351 IDirect3DRMTexture3_Release(mesh_builder
->materials
[i
].texture
);
353 mesh_builder
->nb_materials
= 0;
354 HeapFree(GetProcessHeap(), 0, mesh_builder
->materials
);
355 HeapFree(GetProcessHeap(), 0, mesh_builder
->material_indices
);
358 /*** IUnknown methods ***/
359 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2
* iface
,
360 REFIID riid
, void** ppvObject
)
362 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
364 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppvObject
);
368 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
369 IsEqualGUID(riid
, &IID_IDirect3DRMMeshBuilder
) ||
370 IsEqualGUID(riid
, &IID_IDirect3DRMMeshBuilder2
))
372 *ppvObject
= &This
->IDirect3DRMMeshBuilder2_iface
;
374 else if(IsEqualGUID(riid
, &IID_IDirect3DRMMeshBuilder3
))
376 *ppvObject
= &This
->IDirect3DRMMeshBuilder3_iface
;
380 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
381 return E_NOINTERFACE
;
384 IDirect3DRMMeshBuilder_AddRef(iface
);
388 static ULONG WINAPI
IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2
* iface
)
390 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
391 ULONG ref
= InterlockedIncrement(&This
->ref
);
393 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
398 static ULONG WINAPI
IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2
* iface
)
400 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
401 ULONG ref
= InterlockedDecrement(&This
->ref
);
403 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
407 clean_mesh_builder_data(This
);
409 IDirect3DRMMaterial2_Release(This
->material
);
411 IDirect3DRMTexture3_Release(This
->texture
);
412 HeapFree(GetProcessHeap(), 0, This
);
418 /*** IDirect3DRMObject methods ***/
419 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2
*iface
,
420 IUnknown
*outer
, REFIID iid
, void **out
)
422 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
427 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2
*iface
,
428 D3DRMOBJECTCALLBACK cb
, void *ctx
)
430 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
435 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2
*iface
,
436 D3DRMOBJECTCALLBACK cb
, void *ctx
)
438 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
443 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2
* iface
,
446 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
448 FIXME("(%p)->(%u): stub\n", This
, data
);
453 static DWORD WINAPI
IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2
* iface
)
455 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
457 FIXME("(%p)->(): stub\n", This
);
462 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2
*iface
, const char *name
)
464 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder2(iface
);
466 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
468 return IDirect3DRMMeshBuilder3_SetName(&mesh_builder
->IDirect3DRMMeshBuilder3_iface
, name
);
471 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2
*iface
, DWORD
*size
, char *name
)
473 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder2(iface
);
475 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
477 return IDirect3DRMMeshBuilder3_GetName(&mesh_builder
->IDirect3DRMMeshBuilder3_iface
, size
, name
);
480 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2
*iface
,
481 DWORD
*size
, char *name
)
483 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder2(iface
);
485 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
487 return IDirect3DRMMeshBuilder3_GetClassName(&mesh_builder
->IDirect3DRMMeshBuilder3_iface
, size
, name
);
490 /*** IDirect3DRMMeshBuilder2 methods ***/
491 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2
*iface
, void *filename
,
492 void *name
, D3DRMLOADOPTIONS flags
, D3DRMLOADTEXTURECALLBACK cb
, void *ctx
)
494 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder2(iface
);
496 TRACE("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p.\n",
497 iface
, filename
, name
, flags
, cb
, ctx
);
500 FIXME("Texture callback is not yet supported\n");
502 return IDirect3DRMMeshBuilder3_Load(&mesh_builder
->IDirect3DRMMeshBuilder3_iface
,
503 filename
, name
, flags
, NULL
, ctx
);
506 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2
* iface
,
507 const char *filename
, D3DRMXOFFORMAT format
,
508 D3DRMSAVEOPTIONS save
)
510 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
512 FIXME("(%p)->(%s,%d,%d): stub\n", This
, filename
, format
, save
);
517 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2
* iface
,
518 D3DVALUE sx
, D3DVALUE sy
, D3DVALUE sz
)
520 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
522 TRACE("(%p)->(%f,%f,%f)\n", This
, sx
, sy
, sz
);
524 return IDirect3DRMMeshBuilder3_Scale(&This
->IDirect3DRMMeshBuilder3_iface
, sx
, sy
, sz
);
527 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2
* iface
,
528 D3DVALUE tx
, D3DVALUE ty
, D3DVALUE tz
)
530 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
532 FIXME("(%p)->(%f,%f,%f): stub\n", This
, tx
, ty
, tz
);
537 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2
* iface
,
538 D3DRMCOLORSOURCE color
)
540 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
542 FIXME("(%p)->(%x): stub\n", This
, color
);
547 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2
* iface
,
550 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
552 FIXME("(%p)->(%p): stub\n", This
, pBox
);
557 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2
* iface
)
559 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
561 FIXME("(%p)->(): stub\n", This
);
566 static D3DRMCOLORSOURCE WINAPI
IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2
* iface
)
568 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
570 FIXME("(%p)->(): stub\n", This
);
575 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2
*iface
, IDirect3DRMMesh
*mesh
)
577 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
582 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2
*iface
,
583 IDirect3DRMMeshBuilder
*mesh_builder
)
585 FIXME("iface %p, mesh_builder %p stub!\n", iface
, mesh_builder
);
590 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2
*iface
, IDirect3DRMFrame
*frame
)
592 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
597 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2
*iface
, IDirect3DRMFace
*face
)
599 FIXME("iface %p, face %p stub!\n", iface
, face
);
604 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2
*iface
,
605 DWORD vertex_count
, D3DVECTOR
*vertices
, DWORD normal_count
, D3DVECTOR
*normals
,
606 DWORD
*face_data
, IDirect3DRMFaceArray
**array
)
608 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p, array %p stub!\n",
609 iface
, vertex_count
, vertices
, normal_count
, normals
, face_data
, array
);
614 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2
* iface
,
619 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
621 FIXME("(%p)->(%d,%d,%d): stub\n", This
, vertex_Count
, normal_count
, face_count
);
626 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2
* iface
,
627 D3DVALUE red
, D3DVALUE green
,
630 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
632 TRACE("(%p)->(%f,%f,%f)\n", This
, red
, green
, blue
);
634 return IDirect3DRMMeshBuilder3_SetColorRGB(&This
->IDirect3DRMMeshBuilder3_iface
, red
, green
, blue
);
637 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2
* iface
,
640 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
642 TRACE("(%p)->(%x)\n", This
, color
);
644 return IDirect3DRMMeshBuilder3_SetColor(&This
->IDirect3DRMMeshBuilder3_iface
, color
);
647 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2
*iface
,
648 IDirect3DRMTexture
*texture
)
650 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
651 IDirect3DRMTexture3
*texture3
= NULL
;
652 HRESULT hr
= D3DRM_OK
;
655 hr
= IDirect3DRMTexture_QueryInterface(texture
, &IID_IDirect3DRMTexture3
, (void **)&texture3
);
657 hr
= IDirect3DRMMeshBuilder3_SetTexture(&This
->IDirect3DRMMeshBuilder3_iface
, texture3
);
659 IDirect3DRMTexture3_Release(texture3
);
664 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2
*iface
,
665 IDirect3DRMMaterial
*material
)
667 IDirect3DRMMeshBuilderImpl
*d3drm
= impl_from_IDirect3DRMMeshBuilder2(iface
);
669 TRACE("iface %p, material %p.\n", iface
, material
);
671 return IDirect3DRMMeshBuilder3_SetMaterial(&d3drm
->IDirect3DRMMeshBuilder3_iface
,
672 (IDirect3DRMMaterial2
*)material
);
675 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2
* iface
,
676 BOOL wrap_u
, BOOL wrap_v
)
678 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
680 FIXME("(%p)->(%d,%d): stub\n", This
, wrap_u
, wrap_v
);
685 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2
* iface
,
686 D3DRMRENDERQUALITY quality
)
688 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
690 FIXME("(%p)->(%d): stub\n", This
, quality
);
695 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2
* iface
,
698 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
700 FIXME("(%p)->(%d): stub\n", This
, enable
);
705 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2
* iface
,
707 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
709 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
711 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
716 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2
* iface
,
718 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
720 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
722 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
727 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2
* iface
,
729 D3DVALUE u
, D3DVALUE v
)
731 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
733 TRACE("(%p)->(%u,%f,%f)\n", This
, index
, u
, v
);
735 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This
->IDirect3DRMMeshBuilder3_iface
,
739 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2
* iface
,
740 DWORD index
, D3DCOLOR color
)
742 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
744 FIXME("(%p)->(%d,%x): stub\n", This
, index
, color
);
749 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2
* iface
,
750 DWORD index
, D3DVALUE red
,
751 D3DVALUE green
, D3DVALUE blue
)
753 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
755 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This
, index
, red
, green
, blue
);
760 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2
*iface
,
761 IDirect3DRMFaceArray
**array
)
763 FIXME("iface %p, array %p stub!\n", iface
, array
);
768 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2
* iface
,
769 DWORD
*vcount
, D3DVECTOR
*vertices
,
770 DWORD
*ncount
, D3DVECTOR
*normals
,
771 DWORD
*face_data_size
,
774 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
776 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This
, vcount
, vertices
, ncount
, normals
, face_data_size
, face_data
);
778 if (vertices
&& (!vcount
|| (*vcount
< This
->nb_vertices
)))
779 return D3DRMERR_BADVALUE
;
781 *vcount
= This
->nb_vertices
;
782 if (vertices
&& This
->nb_vertices
)
783 memcpy(vertices
, This
->pVertices
, This
->nb_vertices
* sizeof(D3DVECTOR
));
785 if (normals
&& (!ncount
|| (*ncount
< This
->nb_normals
)))
786 return D3DRMERR_BADVALUE
;
788 *ncount
= This
->nb_normals
;
789 if (normals
&& This
->nb_normals
)
790 memcpy(normals
, This
->pNormals
, This
->nb_normals
* sizeof(D3DVECTOR
));
792 if (face_data
&& (!face_data_size
|| (*face_data_size
< This
->face_data_size
)))
793 return D3DRMERR_BADVALUE
;
795 *face_data_size
= This
->face_data_size
;
796 if (face_data
&& This
->face_data_size
)
797 memcpy(face_data
, This
->pFaceData
, This
->face_data_size
* sizeof(DWORD
));
802 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2
* iface
,
804 D3DVALUE
*u
, D3DVALUE
*v
)
806 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
808 TRACE("(%p)->(%u,%p,%p)\n", This
, index
, u
, v
);
810 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This
->IDirect3DRMMeshBuilder3_iface
,
814 static int WINAPI
IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2
* iface
,
815 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
817 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
819 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
824 static int WINAPI
IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2
* iface
,
825 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
827 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
829 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
834 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2
*iface
, IDirect3DRMFace
**face
)
836 TRACE("iface %p, face %p.\n", iface
, face
);
838 return Direct3DRMFace_create(&IID_IDirect3DRMFace
, (IUnknown
**)face
);
841 static D3DRMRENDERQUALITY WINAPI
IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2
* iface
)
843 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
845 FIXME("(%p)->(): stub\n", This
);
850 static BOOL WINAPI
IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2
* iface
)
852 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
854 FIXME("(%p)->(): stub\n", This
);
859 static int WINAPI
IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2
* iface
)
861 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
863 TRACE("(%p)->()\n", This
);
865 return This
->nb_faces
;
868 static int WINAPI
IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2
* iface
)
870 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
872 TRACE("(%p)->()\n", This
);
874 return This
->nb_vertices
;
877 static D3DCOLOR WINAPI
IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2
* iface
,
880 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
882 FIXME("(%p)->(%d): stub\n", This
, index
);
887 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2
*iface
, IDirect3DRMMesh
**mesh
)
889 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder2(iface
);
891 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
893 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder
->IDirect3DRMMeshBuilder3_iface
, mesh
);
896 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2
* iface
,
897 D3DVALUE crease
, DWORD dwFlags
)
899 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder2(iface
);
901 FIXME("(%p)->(%f,%u): stub\n", This
, crease
, dwFlags
);
906 static HRESULT WINAPI
IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2
*iface
,
907 DWORD index
, IDirect3DRMFace
**face
)
909 FIXME("iface %p, index %u, face %p stub!\n", iface
, index
, face
);
914 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl
=
916 /*** IUnknown methods ***/
917 IDirect3DRMMeshBuilder2Impl_QueryInterface
,
918 IDirect3DRMMeshBuilder2Impl_AddRef
,
919 IDirect3DRMMeshBuilder2Impl_Release
,
920 /*** IDirect3DRMObject methods ***/
921 IDirect3DRMMeshBuilder2Impl_Clone
,
922 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback
,
923 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback
,
924 IDirect3DRMMeshBuilder2Impl_SetAppData
,
925 IDirect3DRMMeshBuilder2Impl_GetAppData
,
926 IDirect3DRMMeshBuilder2Impl_SetName
,
927 IDirect3DRMMeshBuilder2Impl_GetName
,
928 IDirect3DRMMeshBuilder2Impl_GetClassName
,
929 /*** IDirect3DRMMeshBuilder methods ***/
930 IDirect3DRMMeshBuilder2Impl_Load
,
931 IDirect3DRMMeshBuilder2Impl_Save
,
932 IDirect3DRMMeshBuilder2Impl_Scale
,
933 IDirect3DRMMeshBuilder2Impl_Translate
,
934 IDirect3DRMMeshBuilder2Impl_SetColorSource
,
935 IDirect3DRMMeshBuilder2Impl_GetBox
,
936 IDirect3DRMMeshBuilder2Impl_GenerateNormals
,
937 IDirect3DRMMeshBuilder2Impl_GetColorSource
,
938 IDirect3DRMMeshBuilder2Impl_AddMesh
,
939 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder
,
940 IDirect3DRMMeshBuilder2Impl_AddFrame
,
941 IDirect3DRMMeshBuilder2Impl_AddFace
,
942 IDirect3DRMMeshBuilder2Impl_AddFaces
,
943 IDirect3DRMMeshBuilder2Impl_ReserveSpace
,
944 IDirect3DRMMeshBuilder2Impl_SetColorRGB
,
945 IDirect3DRMMeshBuilder2Impl_SetColor
,
946 IDirect3DRMMeshBuilder2Impl_SetTexture
,
947 IDirect3DRMMeshBuilder2Impl_SetMaterial
,
948 IDirect3DRMMeshBuilder2Impl_SetTextureTopology
,
949 IDirect3DRMMeshBuilder2Impl_SetQuality
,
950 IDirect3DRMMeshBuilder2Impl_SetPerspective
,
951 IDirect3DRMMeshBuilder2Impl_SetVertex
,
952 IDirect3DRMMeshBuilder2Impl_SetNormal
,
953 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates
,
954 IDirect3DRMMeshBuilder2Impl_SetVertexColor
,
955 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB
,
956 IDirect3DRMMeshBuilder2Impl_GetFaces
,
957 IDirect3DRMMeshBuilder2Impl_GetVertices
,
958 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates
,
959 IDirect3DRMMeshBuilder2Impl_AddVertex
,
960 IDirect3DRMMeshBuilder2Impl_AddNormal
,
961 IDirect3DRMMeshBuilder2Impl_CreateFace
,
962 IDirect3DRMMeshBuilder2Impl_GetQuality
,
963 IDirect3DRMMeshBuilder2Impl_GetPerspective
,
964 IDirect3DRMMeshBuilder2Impl_GetFaceCount
,
965 IDirect3DRMMeshBuilder2Impl_GetVertexCount
,
966 IDirect3DRMMeshBuilder2Impl_GetVertexColor
,
967 IDirect3DRMMeshBuilder2Impl_CreateMesh
,
968 /*** IDirect3DRMMeshBuilder2 methods ***/
969 IDirect3DRMMeshBuilder2Impl_GenerateNormals2
,
970 IDirect3DRMMeshBuilder2Impl_GetFace
974 /*** IUnknown methods ***/
975 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3
* iface
,
976 REFIID riid
, void** ppvObject
)
978 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
979 return IDirect3DRMMeshBuilder2_QueryInterface(&This
->IDirect3DRMMeshBuilder2_iface
, riid
, ppvObject
);
982 static ULONG WINAPI
IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3
* iface
)
984 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
985 return IDirect3DRMMeshBuilder2_AddRef(&This
->IDirect3DRMMeshBuilder2_iface
);
988 static ULONG WINAPI
IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3
* iface
)
990 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
991 return IDirect3DRMMeshBuilder2_Release(&This
->IDirect3DRMMeshBuilder2_iface
);
994 /*** IDirect3DRMObject methods ***/
995 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3
*iface
,
996 IUnknown
*outer
, REFIID iid
, void **out
)
998 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
1003 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3
*iface
,
1004 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1006 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1011 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3
*iface
,
1012 D3DRMOBJECTCALLBACK cb
, void *ctx
)
1014 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1019 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3
* iface
,
1022 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1024 FIXME("(%p)->(%u): stub\n", This
, data
);
1029 static DWORD WINAPI
IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3
* iface
)
1031 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1033 FIXME("(%p)->(): stub\n", This
);
1038 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3
*iface
, const char *name
)
1040 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1041 char *string
= NULL
;
1043 TRACE("iface %p, name %s.\n", iface
, debugstr_a(name
));
1047 string
= HeapAlloc(GetProcessHeap(), 0, strlen(name
) + 1);
1048 if (!string
) return E_OUTOFMEMORY
;
1049 strcpy(string
, name
);
1051 HeapFree(GetProcessHeap(), 0, mesh_builder
->name
);
1052 mesh_builder
->name
= string
;
1057 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3
*iface
,
1058 DWORD
*size
, char *name
)
1060 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1062 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1067 if (!mesh_builder
->name
)
1073 if (*size
< (strlen(mesh_builder
->name
) + 1))
1074 return E_INVALIDARG
;
1076 strcpy(name
, mesh_builder
->name
);
1077 *size
= strlen(mesh_builder
->name
) + 1;
1082 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3
*iface
,
1083 DWORD
*size
, char *name
)
1085 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
1087 if (!size
|| *size
< strlen("Builder") || !name
)
1088 return E_INVALIDARG
;
1090 strcpy(name
, "Builder");
1091 *size
= sizeof("Builder");
1096 HRESULT
load_mesh_data(IDirect3DRMMeshBuilder3
*iface
, IDirectXFileData
*pData
, D3DRMLOADTEXTURECALLBACK load_texture_proc
, void *arg
)
1098 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1099 IDirectXFileData
*pData2
= NULL
;
1104 HRESULT ret
= D3DRMERR_BADOBJECT
;
1105 DWORD
* faces_vertex_idx_data
= NULL
;
1106 DWORD
* faces_vertex_idx_ptr
;
1107 DWORD faces_vertex_idx_size
;
1108 DWORD
* faces_normal_idx_data
= NULL
;
1109 DWORD
* faces_normal_idx_ptr
= NULL
;
1110 DWORD
* faces_data_ptr
;
1111 DWORD faces_data_size
= 0;
1114 TRACE("(%p)->(%p)\n", This
, pData
);
1116 hr
= IDirectXFileData_GetName(pData
, NULL
, &size
);
1117 if (hr
!= DXFILE_OK
)
1121 This
->name
= HeapAlloc(GetProcessHeap(), 0, size
);
1123 return E_OUTOFMEMORY
;
1125 hr
= IDirectXFileData_GetName(pData
, This
->name
, &size
);
1126 if (hr
!= DXFILE_OK
)
1130 TRACE("Mesh name is '%s'\n", This
->name
? This
->name
: "");
1132 This
->nb_normals
= 0;
1134 hr
= IDirectXFileData_GetData(pData
, NULL
, &size
, (void**)&ptr
);
1135 if (hr
!= DXFILE_OK
)
1138 This
->nb_vertices
= *(DWORD
*)ptr
;
1139 This
->nb_faces
= *(DWORD
*)(ptr
+ sizeof(DWORD
) + This
->nb_vertices
* sizeof(D3DVECTOR
));
1140 faces_vertex_idx_size
= size
- sizeof(DWORD
) - This
->nb_vertices
* sizeof(D3DVECTOR
) - sizeof(DWORD
);
1141 faces_vertex_idx_ptr
= (DWORD
*)(ptr
+ sizeof(DWORD
) + This
->nb_vertices
* sizeof(D3DVECTOR
) + sizeof(DWORD
));
1143 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This
->nb_vertices
, This
->nb_faces
, faces_vertex_idx_size
);
1145 This
->pVertices
= HeapAlloc(GetProcessHeap(), 0, This
->nb_vertices
* sizeof(D3DVECTOR
));
1146 memcpy(This
->pVertices
, ptr
+ sizeof(DWORD
), This
->nb_vertices
* sizeof(D3DVECTOR
));
1148 faces_vertex_idx_ptr
= faces_vertex_idx_data
= HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size
);
1149 memcpy(faces_vertex_idx_data
, ptr
+ sizeof(DWORD
) + This
->nb_vertices
* sizeof(D3DVECTOR
) + sizeof(DWORD
), faces_vertex_idx_size
);
1151 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1152 This
->pFaceData
= HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size
* 2);
1153 faces_data_ptr
= (DWORD
*)This
->pFaceData
;
1157 IDirectXFileObject
*object
;
1159 hr
= IDirectXFileData_GetNextObject(pData
, &object
);
1160 if (hr
== DXFILEERR_NOMOREOBJECTS
)
1162 TRACE("No more object\n");
1165 if (hr
!= DXFILE_OK
)
1168 hr
= IDirectXFileObject_QueryInterface(object
, &IID_IDirectXFileData
, (void**)&pData2
);
1169 IDirectXFileObject_Release(object
);
1170 if (hr
!= DXFILE_OK
)
1173 hr
= IDirectXFileData_GetType(pData2
, &guid
);
1174 if (hr
!= DXFILE_OK
)
1177 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid
));
1179 if (IsEqualGUID(guid
, &TID_D3DRMMeshNormals
))
1181 DWORD nb_faces_normals
;
1182 DWORD faces_normal_idx_size
;
1184 hr
= IDirectXFileData_GetData(pData2
, NULL
, &size
, (void**)&ptr
);
1185 if (hr
!= DXFILE_OK
)
1188 This
->nb_normals
= *(DWORD
*)ptr
;
1189 nb_faces_normals
= *(DWORD
*)(ptr
+ sizeof(DWORD
) + This
->nb_normals
* sizeof(D3DVECTOR
));
1191 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This
->nb_normals
, nb_faces_normals
);
1192 if (nb_faces_normals
!= This
->nb_faces
)
1193 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals
, This
->nb_normals
);
1195 This
->pNormals
= HeapAlloc(GetProcessHeap(), 0, This
->nb_normals
* sizeof(D3DVECTOR
));
1196 memcpy(This
->pNormals
, ptr
+ sizeof(DWORD
), This
->nb_normals
* sizeof(D3DVECTOR
));
1198 faces_normal_idx_size
= size
- (2 * sizeof(DWORD
) + This
->nb_normals
* sizeof(D3DVECTOR
));
1199 faces_normal_idx_ptr
= faces_normal_idx_data
= HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size
);
1200 memcpy(faces_normal_idx_data
, ptr
+ sizeof(DWORD
) + This
->nb_normals
* sizeof(D3DVECTOR
) + sizeof(DWORD
), faces_normal_idx_size
);
1202 else if (IsEqualGUID(guid
, &TID_D3DRMMeshTextureCoords
))
1204 hr
= IDirectXFileData_GetData(pData2
, NULL
, &size
, (void**)&ptr
);
1205 if (hr
!= DXFILE_OK
)
1208 This
->nb_coords2d
= *(DWORD
*)ptr
;
1210 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This
->nb_coords2d
);
1212 This
->pCoords2d
= HeapAlloc(GetProcessHeap(), 0, This
->nb_coords2d
* sizeof(Coords2d
));
1213 memcpy(This
->pCoords2d
, ptr
+ sizeof(DWORD
), This
->nb_coords2d
* sizeof(Coords2d
));
1216 else if (IsEqualGUID(guid
, &TID_D3DRMMeshMaterialList
))
1219 DWORD nb_face_indices
;
1221 IDirectXFileObject
*child
;
1225 TRACE("Process MeshMaterialList\n");
1227 hr
= IDirectXFileData_GetData(pData2
, NULL
, &size
, (void**)&ptr
);
1228 if (hr
!= DXFILE_OK
)
1231 nb_materials
= *(DWORD
*)ptr
;
1232 nb_face_indices
= *(DWORD
*)(ptr
+ sizeof(DWORD
));
1233 data_size
= 2 * sizeof(DWORD
) + nb_face_indices
* sizeof(DWORD
);
1235 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials
, nb_face_indices
);
1237 if (size
!= data_size
)
1238 WARN("Returned size %u does not match expected one %u\n", size
, data_size
);
1240 This
->material_indices
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
->material_indices
) * nb_face_indices
);
1241 if (!This
->material_indices
)
1243 memcpy(This
->material_indices
, ptr
+ 2 * sizeof(DWORD
), sizeof(*This
->material_indices
) * nb_face_indices
),
1245 This
->materials
= HeapAlloc(GetProcessHeap(), 0, sizeof(*This
->materials
) * nb_materials
);
1246 if (!This
->materials
)
1248 HeapFree(GetProcessHeap(), 0, This
->material_indices
);
1251 This
->nb_materials
= nb_materials
;
1253 while (SUCCEEDED(hr
= IDirectXFileData_GetNextObject(pData2
, &child
)) && (i
< nb_materials
))
1255 IDirectXFileData
*data
;
1256 IDirectXFileDataReference
*reference
;
1257 IDirectXFileObject
*material_child
;
1259 hr
= IDirectXFileObject_QueryInterface(child
, &IID_IDirectXFileData
, (void **)&data
);
1262 hr
= IDirectXFileObject_QueryInterface(child
, &IID_IDirectXFileDataReference
, (void **)&reference
);
1263 IDirectXFileObject_Release(child
);
1267 hr
= IDirectXFileDataReference_Resolve(reference
, &data
);
1268 IDirectXFileDataReference_Release(reference
);
1274 IDirectXFileObject_Release(child
);
1277 hr
= Direct3DRMMaterial_create(&This
->materials
[i
].material
);
1280 IDirectXFileData_Release(data
);
1284 hr
= IDirectXFileData_GetData(data
, NULL
, &size
, (void**)&ptr
);
1285 if (hr
!= DXFILE_OK
)
1287 IDirectXFileData_Release(data
);
1292 WARN("Material size %u does not match expected one %u\n", size
, 44);
1294 values
= (float*)ptr
;
1296 This
->materials
[i
].color
= RGBA_MAKE((BYTE
)(values
[0] * 255.0f
), (BYTE
)(values
[1] * 255.0f
),
1297 (BYTE
)(values
[2] * 255.0f
), (BYTE
)(values
[3] * 255.0f
));
1299 IDirect3DRMMaterial2_SetAmbient(This
->materials
[i
].material
, values
[0], values
[1], values
[2]); /* Alpha ignored */
1300 IDirect3DRMMaterial2_SetPower(This
->materials
[i
].material
, values
[4]);
1301 IDirect3DRMMaterial2_SetSpecular(This
->materials
[i
].material
, values
[5], values
[6], values
[7]);
1302 IDirect3DRMMaterial2_SetEmissive(This
->materials
[i
].material
, values
[8], values
[9], values
[10]);
1304 This
->materials
[i
].texture
= NULL
;
1306 hr
= IDirectXFileData_GetNextObject(data
, &material_child
);
1309 IDirectXFileData
*data
;
1312 hr
= IDirectXFileObject_QueryInterface(material_child
, &IID_IDirectXFileData
, (void **)&data
);
1315 IDirectXFileDataReference
*reference
;
1317 hr
= IDirectXFileObject_QueryInterface(material_child
, &IID_IDirectXFileDataReference
, (void **)&reference
);
1321 hr
= IDirectXFileDataReference_Resolve(reference
, &data
);
1322 IDirectXFileDataReference_Release(reference
);
1327 hr
= IDirectXFileData_GetType(data
, &guid
);
1328 if (hr
!= DXFILE_OK
)
1330 if (!IsEqualGUID(guid
, &TID_D3DRMTextureFilename
))
1332 WARN("Not a texture filename\n");
1337 hr
= IDirectXFileData_GetData(data
, NULL
, &size
, (void**)&filename
);
1340 if (load_texture_proc
)
1342 IDirect3DRMTexture
*texture
;
1344 hr
= load_texture_proc(*filename
, arg
, &texture
);
1347 hr
= IDirect3DTexture_QueryInterface(texture
, &IID_IDirect3DRMTexture3
, (void**)&This
->materials
[i
].texture
);
1348 IDirect3DTexture_Release(texture
);
1355 /* If the texture file is not found, no texture is associated with the material */
1356 file
= CreateFileA(*filename
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, NULL
);
1357 if (file
!= INVALID_HANDLE_VALUE
)
1361 hr
= Direct3DRMTexture_create(&IID_IDirect3DRMTexture3
, (IUnknown
**)&This
->materials
[i
].texture
);
1364 IDirectXFileData_Release(data
);
1371 else if (hr
!= DXFILEERR_NOMOREOBJECTS
)
1377 IDirectXFileData_Release(data
);
1382 IDirectXFileObject_Release(child
);
1383 WARN("Found more sub-objects than expected\n");
1385 else if (hr
!= DXFILEERR_NOMOREOBJECTS
)
1393 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid
));
1396 IDirectXFileData_Release(pData2
);
1400 if (!This
->nb_normals
)
1402 /* Allocate normals, one per vertex */
1403 This
->pNormals
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, This
->nb_vertices
* sizeof(D3DVECTOR
));
1404 if (!This
->pNormals
)
1408 for (i
= 0; i
< This
->nb_faces
; i
++)
1411 DWORD nb_face_indexes
;
1412 D3DVECTOR face_normal
;
1414 if (faces_vertex_idx_size
< sizeof(DWORD
))
1415 WARN("Not enough data to read number of indices of face %d\n", i
);
1417 nb_face_indexes
= *(faces_data_ptr
+ faces_data_size
++) = *(faces_vertex_idx_ptr
++);
1418 faces_vertex_idx_size
--;
1419 if (faces_normal_idx_data
&& (*(faces_normal_idx_ptr
++) != nb_face_indexes
))
1420 WARN("Faces indices number mismatch\n");
1422 if (faces_vertex_idx_size
< (nb_face_indexes
* sizeof(DWORD
)))
1423 WARN("Not enough data to read all indices of face %d\n", i
);
1425 if (!This
->nb_normals
)
1427 /* Compute face normal */
1428 if (nb_face_indexes
> 2)
1432 D3DRMVectorSubtract(&a
, &This
->pVertices
[faces_vertex_idx_ptr
[2]], &This
->pVertices
[faces_vertex_idx_ptr
[1]]);
1433 D3DRMVectorSubtract(&b
, &This
->pVertices
[faces_vertex_idx_ptr
[0]], &This
->pVertices
[faces_vertex_idx_ptr
[1]]);
1434 D3DRMVectorCrossProduct(&face_normal
, &a
, &b
);
1435 D3DRMVectorNormalize(&face_normal
);
1439 face_normal
.u1
.x
= 0.0f
;
1440 face_normal
.u2
.y
= 0.0f
;
1441 face_normal
.u3
.z
= 0.0f
;
1445 for (j
= 0; j
< nb_face_indexes
; j
++)
1447 /* Copy vertex index */
1448 *(faces_data_ptr
+ faces_data_size
++) = *faces_vertex_idx_ptr
;
1449 /* Copy normal index */
1450 if (This
->nb_normals
)
1452 /* Read from x file */
1453 *(faces_data_ptr
+ faces_data_size
++) = *(faces_normal_idx_ptr
++);
1457 DWORD vertex_idx
= *faces_vertex_idx_ptr
;
1458 if (vertex_idx
>= This
->nb_vertices
)
1460 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx
, This
->nb_vertices
);
1463 *(faces_data_ptr
+ faces_data_size
++) = vertex_idx
;
1464 /* Add face normal to vertex normal */
1465 D3DRMVectorAdd(&This
->pNormals
[vertex_idx
], &This
->pNormals
[vertex_idx
], &face_normal
);
1467 faces_vertex_idx_ptr
++;
1469 faces_vertex_idx_size
-= nb_face_indexes
;
1472 /* Last DWORD must be 0 */
1473 *(faces_data_ptr
+ faces_data_size
++) = 0;
1475 /* Set size (in number of DWORD) of all faces data */
1476 This
->face_data_size
= faces_data_size
;
1478 if (!This
->nb_normals
)
1480 /* Normalize all normals */
1481 for (i
= 0; i
< This
->nb_vertices
; i
++)
1483 D3DRMVectorNormalize(&This
->pNormals
[i
]);
1485 This
->nb_normals
= This
->nb_vertices
;
1488 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1489 if (!This
->pCoords2d
)
1491 This
->nb_coords2d
= This
->nb_vertices
;
1492 This
->pCoords2d
= HeapAlloc(GetProcessHeap(), 0, This
->nb_coords2d
* sizeof(Coords2d
));
1493 for (i
= 0; i
< This
->nb_coords2d
; i
++)
1495 This
->pCoords2d
[i
].u
= 0.0f
;
1496 This
->pCoords2d
[i
].v
= 0.0f
;
1500 TRACE("Mesh data loaded successfully\n");
1506 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data
);
1507 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data
);
1512 /*** IDirect3DRMMeshBuilder3 methods ***/
1513 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3
* iface
,
1514 void *filename
, void *name
,
1515 D3DRMLOADOPTIONS loadflags
,
1516 D3DRMLOADTEXTURE3CALLBACK cb
, void *arg
)
1518 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1519 DXFILELOADOPTIONS load_options
;
1520 IDirectXFile
*dxfile
= NULL
;
1521 IDirectXFileEnumObject
*enum_object
= NULL
;
1522 IDirectXFileData
*data
= NULL
;
1525 struct d3drm_file_header
*header
;
1527 HRESULT ret
= D3DRMERR_BADOBJECT
;
1529 TRACE("iface %p, filename %p, name %p, loadflags %#x, cb %p, arg %p.\n",
1530 iface
, filename
, name
, loadflags
, cb
, arg
);
1532 clean_mesh_builder_data(This
);
1534 if (loadflags
== D3DRMLOAD_FROMMEMORY
)
1536 load_options
= DXFILELOAD_FROMMEMORY
;
1538 else if (loadflags
== D3DRMLOAD_FROMFILE
)
1540 load_options
= DXFILELOAD_FROMFILE
;
1541 TRACE("Loading from file %s\n", debugstr_a(filename
));
1545 FIXME("Load options %d not supported yet\n", loadflags
);
1549 hr
= DirectXFileCreate(&dxfile
);
1550 if (hr
!= DXFILE_OK
)
1553 hr
= IDirectXFile_RegisterTemplates(dxfile
, templates
, strlen(templates
));
1554 if (hr
!= DXFILE_OK
)
1557 hr
= IDirectXFile_CreateEnumObject(dxfile
, filename
, load_options
, &enum_object
);
1558 if (hr
!= DXFILE_OK
)
1561 hr
= IDirectXFileEnumObject_GetNextDataObject(enum_object
, &data
);
1562 if (hr
!= DXFILE_OK
)
1565 hr
= IDirectXFileData_GetType(data
, &guid
);
1566 if (hr
!= DXFILE_OK
)
1569 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid
));
1571 if (!IsEqualGUID(guid
, &TID_DXFILEHeader
))
1573 ret
= D3DRMERR_BADFILE
;
1577 hr
= IDirectXFileData_GetData(data
, NULL
, &size
, (void**)&header
);
1578 if ((hr
!= DXFILE_OK
) || (size
!= sizeof(*header
)))
1581 TRACE("Version is %u.%u, flags %#x.\n", header
->major
, header
->minor
, header
->flags
);
1583 /* Version must be 1.0.x */
1584 if ((header
->major
!= 1) || (header
->minor
!= 0))
1586 ret
= D3DRMERR_BADFILE
;
1590 IDirectXFileData_Release(data
);
1593 hr
= IDirectXFileEnumObject_GetNextDataObject(enum_object
, &data
);
1594 if (hr
!= DXFILE_OK
)
1596 ret
= D3DRMERR_NOTFOUND
;
1600 hr
= IDirectXFileData_GetType(data
, &guid
);
1601 if (hr
!= DXFILE_OK
)
1604 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid
));
1606 if (!IsEqualGUID(guid
, &TID_D3DRMMesh
))
1608 ret
= D3DRMERR_NOTFOUND
;
1612 /* We don't care about the texture interface version since we rely on QueryInterface */
1613 hr
= load_mesh_data(iface
, data
, (D3DRMLOADTEXTURECALLBACK
)cb
, arg
);
1620 IDirectXFileData_Release(data
);
1622 IDirectXFileEnumObject_Release(enum_object
);
1624 IDirectXFile_Release(dxfile
);
1626 if (ret
!= D3DRM_OK
)
1627 clean_mesh_builder_data(This
);
1632 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3
* iface
,
1633 const char* filename
, D3DRMXOFFORMAT format
,
1634 D3DRMSAVEOPTIONS save
)
1636 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1638 FIXME("(%p)->(%s,%d,%d): stub\n", This
, filename
, format
, save
);
1643 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3
* iface
,
1644 D3DVALUE sx
, D3DVALUE sy
, D3DVALUE sz
)
1646 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1649 TRACE("(%p)->(%f,%f,%f)\n", This
, sx
, sy
, sz
);
1651 for (i
= 0; i
< This
->nb_vertices
; i
++)
1653 This
->pVertices
[i
].u1
.x
*= sx
;
1654 This
->pVertices
[i
].u2
.y
*= sy
;
1655 This
->pVertices
[i
].u3
.z
*= sz
;
1658 /* Normals are not affected by Scale */
1663 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3
* iface
,
1664 D3DVALUE tx
, D3DVALUE ty
, D3DVALUE tz
)
1666 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1668 FIXME("(%p)->(%f,%f,%f): stub\n", This
, tx
, ty
, tz
);
1673 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3
* iface
,
1674 D3DRMCOLORSOURCE color
)
1676 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1678 FIXME("(%p)->(%x): stub\n", This
, color
);
1683 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3
* iface
,
1686 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1688 FIXME("(%p)->(%p): stub\n", This
, box
);
1693 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3
* iface
,
1694 D3DVALUE crease
, DWORD flags
)
1696 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1698 FIXME("(%p)->(%f,%u): stub\n", This
, crease
, flags
);
1703 static D3DRMCOLORSOURCE WINAPI
IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3
* iface
)
1705 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1707 FIXME("(%p)->(): stub\n", This
);
1712 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMMesh
*mesh
)
1714 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
1719 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3
*iface
,
1720 IDirect3DRMMeshBuilder3
*mesh_builder
, DWORD flags
)
1722 FIXME("iface %p, mesh_builder %p, flags %#x stub!\n", iface
, mesh_builder
, flags
);
1727 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMFrame3
*frame
)
1729 FIXME("iface %p, frame %p stub!\n", iface
, frame
);
1734 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMFace2
*face
)
1736 FIXME("iface %p, face %p stub!\n", iface
, face
);
1741 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3
*iface
,
1742 DWORD vertex_count
, D3DVECTOR
*vertices
, DWORD normal_count
, D3DVECTOR
*normals
,
1743 DWORD
*face_data
, IDirect3DRMFaceArray
**array
)
1745 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p array %p stub!\n",
1746 iface
, vertex_count
, vertices
, normal_count
, normals
, face_data
, array
);
1751 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3
* iface
,
1756 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1758 FIXME("(%p)->(%d,%d,%d): stub\n", This
, vertex_Count
, normal_count
, face_count
);
1763 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3
* iface
,
1764 D3DVALUE red
, D3DVALUE green
,
1767 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1769 TRACE("(%p)->(%f,%f,%f)\n", This
, red
, green
, blue
);
1771 This
->color
= RGBA_MAKE((BYTE
)(red
* 255.0f
), (BYTE
)(green
* 255.0f
), (BYTE
)(blue
* 255.0f
), 0xff);
1776 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3
* iface
,
1779 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1781 TRACE("(%p)->(%x)\n", This
, color
);
1783 This
->color
= color
;
1788 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3
*iface
,
1789 IDirect3DRMTexture3
*texture
)
1791 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1793 TRACE("(%p)->(%p)\n", This
, texture
);
1796 IDirect3DRMTexture3_AddRef(texture
);
1798 IDirect3DRMTexture3_Release(This
->texture
);
1799 This
->texture
= texture
;
1804 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3
*iface
,
1805 IDirect3DRMMaterial2
*material
)
1807 IDirect3DRMMeshBuilderImpl
*mesh_builder
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1809 TRACE("iface %p, material %p.\n", iface
, material
);
1812 IDirect3DRMTexture2_AddRef(material
);
1813 if (mesh_builder
->material
)
1814 IDirect3DRMTexture2_Release(mesh_builder
->material
);
1815 mesh_builder
->material
= material
;
1820 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3
* iface
,
1821 BOOL wrap_u
, BOOL wrap_v
)
1823 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1825 FIXME("(%p)->(%d,%d): stub\n", This
, wrap_u
, wrap_v
);
1830 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3
* iface
,
1831 D3DRMRENDERQUALITY quality
)
1833 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1835 FIXME("(%p)->(%d): stub\n", This
, quality
);
1840 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3
* iface
,
1843 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1845 FIXME("(%p)->(%d): stub\n", This
, enable
);
1850 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3
* iface
,
1852 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
1854 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1856 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
1861 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3
* iface
,
1863 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
1865 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1867 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
1872 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3
* iface
,
1873 DWORD index
, D3DVALUE u
,
1876 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1878 TRACE("(%p)->(%u,%f,%f)\n", This
, index
, u
, v
);
1880 if (index
>= This
->nb_coords2d
)
1881 return D3DRMERR_BADVALUE
;
1883 This
->pCoords2d
[index
].u
= u
;
1884 This
->pCoords2d
[index
].v
= v
;
1889 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3
* iface
,
1890 DWORD index
, D3DCOLOR color
)
1892 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1894 FIXME("(%p)->(%d,%x): stub\n", This
, index
, color
);
1899 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3
* iface
,
1901 D3DVALUE red
, D3DVALUE green
,
1904 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1906 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This
, index
, red
, green
, blue
);
1911 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3
*iface
,
1912 IDirect3DRMFaceArray
**array
)
1914 FIXME("iface %p, array %p stub!\n", iface
, array
);
1919 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3
* iface
,
1920 DWORD
* vcount
, D3DVECTOR
* vertices
,
1921 DWORD
* ncount
, D3DVECTOR
* normals
,
1922 DWORD
* face_data_size
,
1925 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1927 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This
, vcount
, vertices
, ncount
, normals
,
1928 face_data_size
, face_data
);
1933 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3
* iface
,
1934 DWORD index
, D3DVALUE
* u
,
1937 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1939 TRACE("(%p)->(%d,%p,%p)\n", This
, index
, u
, v
);
1941 if (index
>= This
->nb_coords2d
)
1942 return D3DRMERR_BADVALUE
;
1944 *u
= This
->pCoords2d
[index
].u
;
1945 *v
= This
->pCoords2d
[index
].v
;
1951 static int WINAPI
IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3
* iface
,
1952 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
1954 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1956 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
1961 static int WINAPI
IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3
* iface
,
1962 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
)
1964 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1966 FIXME("(%p)->(%f,%f,%f): stub\n", This
, x
, y
, z
);
1971 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMFace2
**face
)
1973 TRACE("iface %p, face %p.\n", iface
, face
);
1975 return Direct3DRMFace_create(&IID_IDirect3DRMFace2
, (IUnknown
**)face
);
1978 static D3DRMRENDERQUALITY WINAPI
IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3
* iface
)
1980 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1982 FIXME("(%p)->(): stub\n", This
);
1987 static BOOL WINAPI
IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3
* iface
)
1989 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
1991 FIXME("(%p)->(): stub\n", This
);
1996 static int WINAPI
IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3
* iface
)
1998 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2000 TRACE("(%p)->()\n", This
);
2002 return This
->nb_faces
;
2005 static int WINAPI
IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3
* iface
)
2007 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2009 TRACE("(%p)->()\n", This
);
2011 return This
->nb_vertices
;
2014 static D3DCOLOR WINAPI
IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3
* iface
,
2017 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2019 FIXME("(%p)->(%d): stub\n", This
, index
);
2024 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMMesh
**mesh
)
2026 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2028 D3DRMGROUPINDEX group
;
2030 TRACE("(%p)->(%p)\n", This
, mesh
);
2035 hr
= Direct3DRMMesh_create(mesh
);
2039 /* If there is mesh data, create a group and put data inside */
2040 if (This
->nb_vertices
)
2044 D3DRMVERTEX
* vertices
;
2046 vertices
= HeapAlloc(GetProcessHeap(), 0, This
->nb_vertices
* sizeof(D3DRMVERTEX
));
2049 IDirect3DRMMesh_Release(*mesh
);
2050 return E_OUTOFMEMORY
;
2052 for (i
= 0; i
< This
->nb_vertices
; i
++)
2053 vertices
[i
].position
= This
->pVertices
[i
];
2054 hr
= IDirect3DRMMesh_SetVertices(*mesh
, 0, 0, This
->nb_vertices
, vertices
);
2055 HeapFree(GetProcessHeap(), 0, vertices
);
2057 /* Groups are in reverse order compared to materials list in X file */
2058 for (k
= This
->nb_materials
- 1; k
>= 0; k
--)
2060 unsigned* face_data
;
2062 DWORD
* in_ptr
= This
->pFaceData
;
2063 ULONG vertex_per_face
= 0;
2064 BOOL
* used_vertices
;
2065 unsigned nb_vertices
= 0;
2066 unsigned nb_faces
= 0;
2068 used_vertices
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, This
->face_data_size
* sizeof(*used_vertices
));
2071 IDirect3DRMMesh_Release(*mesh
);
2072 return E_OUTOFMEMORY
;
2075 face_data
= HeapAlloc(GetProcessHeap(), 0, This
->face_data_size
* sizeof(*face_data
));
2078 HeapFree(GetProcessHeap(), 0, used_vertices
);
2079 IDirect3DRMMesh_Release(*mesh
);
2080 return E_OUTOFMEMORY
;
2082 out_ptr
= face_data
;
2084 /* If all faces have the same number of vertex, set vertex_per_face */
2085 for (i
= 0; i
< This
->nb_faces
; i
++)
2087 /* Process only faces belonging to the group */
2088 if (This
->material_indices
[i
] == k
)
2090 if (vertex_per_face
&& (vertex_per_face
!= *in_ptr
))
2092 vertex_per_face
= *in_ptr
;
2094 in_ptr
+= 1 + *in_ptr
* 2;
2096 if (i
!= This
->nb_faces
)
2097 vertex_per_face
= 0;
2099 /* Put only vertex indices */
2100 in_ptr
= This
->pFaceData
;
2101 for (i
= 0; i
< This
->nb_faces
; i
++)
2103 DWORD nb_indices
= *in_ptr
++;
2105 /* Skip faces not belonging to the group */
2106 if (This
->material_indices
[i
] != k
)
2108 in_ptr
+= 2 * nb_indices
;
2112 /* Don't put nb indices when vertex_per_face is set */
2113 if (vertex_per_face
)
2114 *out_ptr
++ = nb_indices
;
2116 for (j
= 0; j
< nb_indices
; j
++)
2118 *out_ptr
= *in_ptr
++;
2119 used_vertices
[*out_ptr
++] = TRUE
;
2120 /* Skip normal index */
2127 for (i
= 0; i
< This
->nb_vertices
; i
++)
2128 if (used_vertices
[i
])
2131 hr
= IDirect3DRMMesh_AddGroup(*mesh
, nb_vertices
, nb_faces
, vertex_per_face
, face_data
, &group
);
2132 HeapFree(GetProcessHeap(), 0, used_vertices
);
2133 HeapFree(GetProcessHeap(), 0, face_data
);
2135 hr
= IDirect3DRMMesh_SetGroupColor(*mesh
, group
, This
->materials
[k
].color
);
2137 hr
= IDirect3DRMMesh_SetGroupMaterial(*mesh
, group
,
2138 (IDirect3DRMMaterial
*)This
->materials
[k
].material
);
2139 if (SUCCEEDED(hr
) && This
->materials
[k
].texture
)
2141 IDirect3DRMTexture
*texture
;
2143 IDirect3DRMTexture3_QueryInterface(This
->materials
[k
].texture
,
2144 &IID_IDirect3DRMTexture
, (void **)&texture
);
2145 hr
= IDirect3DRMMesh_SetGroupTexture(*mesh
, group
, texture
);
2146 IDirect3DRMTexture_Release(texture
);
2150 IDirect3DRMMesh_Release(*mesh
);
2159 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3
*iface
,
2160 DWORD index
, IDirect3DRMFace2
**face
)
2162 FIXME("iface %p, index %u, face %p stub!\n", iface
, index
, face
);
2167 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3
*iface
,
2168 DWORD index
, D3DVECTOR
*vector
)
2170 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2172 FIXME("(%p)->(%u,%p): stub\n", This
, index
, vector
);
2177 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3
*iface
,
2178 DWORD index
, D3DVECTOR
*vector
)
2180 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2182 FIXME("(%p)->(%u,%p): stub\n", This
, index
, vector
);
2187 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3
* iface
,
2188 DWORD IndexFirst
, DWORD count
)
2190 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2192 FIXME("(%p)->(%u,%u): stub\n", This
, IndexFirst
, count
);
2197 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3
* iface
,
2198 DWORD IndexFirst
, DWORD count
)
2200 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2202 FIXME("(%p)->(%u,%u): stub\n", This
, IndexFirst
, count
);
2207 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3
*iface
, IDirect3DRMFace2
*face
)
2209 FIXME("iface %p, face %p stub!\n", iface
, face
);
2214 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3
* iface
, DWORD flags
)
2216 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2218 FIXME("(%p)->(%u): stub\n", This
, flags
);
2223 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3
* iface
,
2226 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2228 FIXME("(%p)->(%u): stub\n", This
, flags
);
2233 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3
* iface
,
2234 DWORD flags
, DWORD
* indices
,
2235 DWORD
* IndexFirst
, DWORD
* count
)
2237 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2239 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This
, flags
, indices
, IndexFirst
, count
);
2244 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3
*iface
, IUnknown
**mesh
)
2246 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
2251 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3
*iface
,
2252 DWORD flags
, IUnknown
**parent
)
2254 FIXME("iface %p, flags %#x, parent %p stub!\n", iface
, flags
, parent
);
2259 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3
*iface
,
2260 DWORD
*count
, IUnknown
**meshes
)
2262 FIXME("iface %p, count %p, meshes %p stub!\n", iface
, count
, meshes
);
2267 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3
*iface
, IUnknown
*mesh
)
2269 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
2274 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3
* iface
,
2277 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2279 FIXME("(%p)->(%u): stub\n", This
, index
);
2284 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3
* iface
,
2287 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2289 FIXME("(%p)->(%p): stub\n", This
, indices
);
2294 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3
*iface
,
2295 DWORD flags
, DWORD format
, DWORD vertex_count
, void *data
)
2297 FIXME("iface %p, flags %#x, format %#x, vertex_count %u, data %p stub!\n",
2298 iface
, flags
, format
, vertex_count
, data
);
2303 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3
*iface
,
2304 DWORD IndexFirst
, DWORD count
, D3DVECTOR
*vector
)
2306 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2308 FIXME("(%p)->(%u,%u,%p): stub\n", This
, IndexFirst
, count
, vector
);
2313 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3
*iface
,
2314 DWORD IndexFirst
, DWORD
*vcount
, D3DVECTOR
*vertices
)
2316 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2317 DWORD count
= This
->nb_vertices
- IndexFirst
;
2319 TRACE("(%p)->(%u,%p,%p)\n", This
, IndexFirst
, vcount
, vertices
);
2323 if (vertices
&& This
->nb_vertices
)
2324 memcpy(vertices
, This
->pVertices
+ IndexFirst
, count
* sizeof(D3DVECTOR
));
2329 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3
*iface
,
2330 DWORD IndexFirst
, DWORD count
, D3DVECTOR
*vector
)
2332 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2334 FIXME("(%p)->(%u,%u,%p): stub\n", This
, IndexFirst
, count
, vector
);
2339 static HRESULT WINAPI
IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3
*iface
,
2340 DWORD IndexFirst
, DWORD
*ncount
, D3DVECTOR
*normals
)
2342 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2343 DWORD count
= This
->nb_normals
- IndexFirst
;
2345 TRACE("(%p)->(%u,%p,%p)\n", This
, IndexFirst
, ncount
, normals
);
2349 if (normals
&& This
->nb_normals
)
2350 memcpy(normals
, This
->pNormals
+ IndexFirst
, count
* sizeof(D3DVECTOR
));
2355 static int WINAPI
IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3
* iface
)
2357 IDirect3DRMMeshBuilderImpl
*This
= impl_from_IDirect3DRMMeshBuilder3(iface
);
2359 TRACE("(%p)->()\n", This
);
2361 return This
->nb_normals
;
2364 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl
=
2366 /*** IUnknown methods ***/
2367 IDirect3DRMMeshBuilder3Impl_QueryInterface
,
2368 IDirect3DRMMeshBuilder3Impl_AddRef
,
2369 IDirect3DRMMeshBuilder3Impl_Release
,
2370 /*** IDirect3DRMObject methods ***/
2371 IDirect3DRMMeshBuilder3Impl_Clone
,
2372 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback
,
2373 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback
,
2374 IDirect3DRMMeshBuilder3Impl_SetAppData
,
2375 IDirect3DRMMeshBuilder3Impl_GetAppData
,
2376 IDirect3DRMMeshBuilder3Impl_SetName
,
2377 IDirect3DRMMeshBuilder3Impl_GetName
,
2378 IDirect3DRMMeshBuilder3Impl_GetClassName
,
2379 /*** IDirect3DRMMeshBuilder3 methods ***/
2380 IDirect3DRMMeshBuilder3Impl_Load
,
2381 IDirect3DRMMeshBuilder3Impl_Save
,
2382 IDirect3DRMMeshBuilder3Impl_Scale
,
2383 IDirect3DRMMeshBuilder3Impl_Translate
,
2384 IDirect3DRMMeshBuilder3Impl_SetColorSource
,
2385 IDirect3DRMMeshBuilder3Impl_GetBox
,
2386 IDirect3DRMMeshBuilder3Impl_GenerateNormals
,
2387 IDirect3DRMMeshBuilder3Impl_GetColorSource
,
2388 IDirect3DRMMeshBuilder3Impl_AddMesh
,
2389 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder
,
2390 IDirect3DRMMeshBuilder3Impl_AddFrame
,
2391 IDirect3DRMMeshBuilder3Impl_AddFace
,
2392 IDirect3DRMMeshBuilder3Impl_AddFaces
,
2393 IDirect3DRMMeshBuilder3Impl_ReserveSpace
,
2394 IDirect3DRMMeshBuilder3Impl_SetColorRGB
,
2395 IDirect3DRMMeshBuilder3Impl_SetColor
,
2396 IDirect3DRMMeshBuilder3Impl_SetTexture
,
2397 IDirect3DRMMeshBuilder3Impl_SetMaterial
,
2398 IDirect3DRMMeshBuilder3Impl_SetTextureTopology
,
2399 IDirect3DRMMeshBuilder3Impl_SetQuality
,
2400 IDirect3DRMMeshBuilder3Impl_SetPerspective
,
2401 IDirect3DRMMeshBuilder3Impl_SetVertex
,
2402 IDirect3DRMMeshBuilder3Impl_SetNormal
,
2403 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates
,
2404 IDirect3DRMMeshBuilder3Impl_SetVertexColor
,
2405 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB
,
2406 IDirect3DRMMeshBuilder3Impl_GetFaces
,
2407 IDirect3DRMMeshBuilder3Impl_GetGeometry
,
2408 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates
,
2409 IDirect3DRMMeshBuilder3Impl_AddVertex
,
2410 IDirect3DRMMeshBuilder3Impl_AddNormal
,
2411 IDirect3DRMMeshBuilder3Impl_CreateFace
,
2412 IDirect3DRMMeshBuilder3Impl_GetQuality
,
2413 IDirect3DRMMeshBuilder3Impl_GetPerspective
,
2414 IDirect3DRMMeshBuilder3Impl_GetFaceCount
,
2415 IDirect3DRMMeshBuilder3Impl_GetVertexCount
,
2416 IDirect3DRMMeshBuilder3Impl_GetVertexColor
,
2417 IDirect3DRMMeshBuilder3Impl_CreateMesh
,
2418 IDirect3DRMMeshBuilder3Impl_GetFace
,
2419 IDirect3DRMMeshBuilder3Impl_GetVertex
,
2420 IDirect3DRMMeshBuilder3Impl_GetNormal
,
2421 IDirect3DRMMeshBuilder3Impl_DeleteVertices
,
2422 IDirect3DRMMeshBuilder3Impl_DeleteNormals
,
2423 IDirect3DRMMeshBuilder3Impl_DeleteFace
,
2424 IDirect3DRMMeshBuilder3Impl_Empty
,
2425 IDirect3DRMMeshBuilder3Impl_Optimize
,
2426 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed
,
2427 IDirect3DRMMeshBuilder3Impl_CreateSubMesh
,
2428 IDirect3DRMMeshBuilder3Impl_GetParentMesh
,
2429 IDirect3DRMMeshBuilder3Impl_GetSubMeshes
,
2430 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh
,
2431 IDirect3DRMMeshBuilder3Impl_Enable
,
2432 IDirect3DRMMeshBuilder3Impl_GetEnable
,
2433 IDirect3DRMMeshBuilder3Impl_AddTriangles
,
2434 IDirect3DRMMeshBuilder3Impl_SetVertices
,
2435 IDirect3DRMMeshBuilder3Impl_GetVertices
,
2436 IDirect3DRMMeshBuilder3Impl_SetNormals
,
2437 IDirect3DRMMeshBuilder3Impl_GetNormals
,
2438 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2441 HRESULT
Direct3DRMMeshBuilder_create(REFIID riid
, IUnknown
** ppObj
)
2443 IDirect3DRMMeshBuilderImpl
* object
;
2445 TRACE("(%p)\n", ppObj
);
2447 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DRMMeshBuilderImpl
));
2449 return E_OUTOFMEMORY
;
2451 object
->IDirect3DRMMeshBuilder2_iface
.lpVtbl
= &Direct3DRMMeshBuilder2_Vtbl
;
2452 object
->IDirect3DRMMeshBuilder3_iface
.lpVtbl
= &Direct3DRMMeshBuilder3_Vtbl
;
2455 if (IsEqualGUID(riid
, &IID_IDirect3DRMMeshBuilder3
))
2456 *ppObj
= (IUnknown
*)&object
->IDirect3DRMMeshBuilder3_iface
;
2458 *ppObj
= (IUnknown
*)&object
->IDirect3DRMMeshBuilder2_iface
;
2463 /*** IUnknown methods ***/
2464 static HRESULT WINAPI
IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh
* iface
,
2465 REFIID riid
, void** ppvObject
)
2467 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2469 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppvObject
);
2473 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
2474 IsEqualGUID(riid
, &IID_IDirect3DRMMesh
))
2476 *ppvObject
= &This
->IDirect3DRMMesh_iface
;
2480 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
2481 return E_NOINTERFACE
;
2484 IDirect3DRMMesh_AddRef(iface
);
2488 static ULONG WINAPI
IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh
* iface
)
2490 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2491 ULONG ref
= InterlockedIncrement(&This
->ref
);
2493 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
2498 static ULONG WINAPI
IDirect3DRMMeshImpl_Release(IDirect3DRMMesh
* iface
)
2500 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2501 ULONG ref
= InterlockedDecrement(&This
->ref
);
2503 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
2509 for (i
= 0; i
< This
->nb_groups
; i
++)
2511 HeapFree(GetProcessHeap(), 0, This
->groups
[i
].vertices
);
2512 HeapFree(GetProcessHeap(), 0, This
->groups
[i
].face_data
);
2513 if (This
->groups
[i
].material
)
2514 IDirect3DRMMaterial2_Release(This
->groups
[i
].material
);
2515 if (This
->groups
[i
].texture
)
2516 IDirect3DRMTexture3_Release(This
->groups
[i
].texture
);
2518 HeapFree(GetProcessHeap(), 0, This
->groups
);
2519 HeapFree(GetProcessHeap(), 0, This
);
2525 /*** IDirect3DRMObject methods ***/
2526 static HRESULT WINAPI
IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh
*iface
,
2527 IUnknown
*outer
, REFIID iid
, void **out
)
2529 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface
, outer
, debugstr_guid(iid
), out
);
2534 static HRESULT WINAPI
IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh
*iface
,
2535 D3DRMOBJECTCALLBACK cb
, void *ctx
)
2537 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
2542 static HRESULT WINAPI
IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh
*iface
,
2543 D3DRMOBJECTCALLBACK cb
, void *ctx
)
2545 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
2550 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh
* iface
,
2553 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2555 FIXME("(%p)->(%u): stub\n", This
, data
);
2560 static DWORD WINAPI
IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh
* iface
)
2562 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2564 FIXME("(%p)->(): stub\n", This
);
2569 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh
*iface
, const char *name
)
2571 FIXME("iface %p, name %s stub!\n", iface
, debugstr_a(name
));
2576 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh
*iface
, DWORD
*size
, char *name
)
2578 FIXME("iface %p, size %p, name %p stub!\n", iface
, size
, name
);
2583 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh
*iface
, DWORD
*size
, char *name
)
2585 TRACE("iface %p, size %p, name %p.\n", iface
, size
, name
);
2587 if (!size
|| *size
< strlen("Mesh") || !name
)
2588 return E_INVALIDARG
;
2590 strcpy(name
, "Mesh");
2591 *size
= sizeof("Mesh");
2596 /*** IDirect3DRMMesh methods ***/
2597 static HRESULT WINAPI
IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh
* iface
,
2598 D3DVALUE sx
, D3DVALUE sy
, D3DVALUE sz
)
2600 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2602 FIXME("(%p)->(%f,%f,%f): stub\n", This
, sx
, sy
,sz
);
2607 static HRESULT WINAPI
IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh
* iface
,
2608 D3DVALUE tx
, D3DVALUE ty
, D3DVALUE tz
)
2610 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2612 FIXME("(%p)->(%f,%f,%f): stub\n", This
, tx
, ty
,tz
);
2617 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh
* iface
,
2620 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2622 FIXME("(%p)->(%p): stub\n", This
, box
);
2627 static HRESULT WINAPI
IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh
* iface
,
2628 unsigned vertex_count
, unsigned face_count
, unsigned vertex_per_face
,
2629 unsigned *face_data
, D3DRMGROUPINDEX
*return_id
)
2631 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2632 struct mesh_group
*group
;
2634 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This
, vertex_count
, face_count
, vertex_per_face
, face_data
, return_id
);
2636 if (!face_data
|| !return_id
)
2639 if ((This
->nb_groups
+ 1) > This
->groups_capacity
)
2641 struct mesh_group
*groups
;
2644 if (!This
->groups_capacity
)
2647 groups
= HeapAlloc(GetProcessHeap(), 0, new_capacity
* sizeof(*groups
));
2651 new_capacity
= This
->groups_capacity
* 2;
2652 groups
= HeapReAlloc(GetProcessHeap(), 0, This
->groups
, new_capacity
* sizeof(*groups
));
2656 return E_OUTOFMEMORY
;
2658 This
->groups_capacity
= new_capacity
;
2659 This
->groups
= groups
;
2662 group
= This
->groups
+ This
->nb_groups
;
2664 group
->vertices
= HeapAlloc(GetProcessHeap(), 0, vertex_count
* sizeof(D3DRMVERTEX
));
2665 if (!group
->vertices
)
2666 return E_OUTOFMEMORY
;
2667 group
->nb_vertices
= vertex_count
;
2668 group
->nb_faces
= face_count
;
2669 group
->vertex_per_face
= vertex_per_face
;
2671 if (vertex_per_face
)
2673 group
->face_data_size
= face_count
* vertex_per_face
;
2678 unsigned nb_indices
;
2679 unsigned* face_data_ptr
= face_data
;
2680 group
->face_data_size
= 0;
2682 for (i
= 0; i
< face_count
; i
++)
2684 nb_indices
= *face_data_ptr
;
2685 group
->face_data_size
+= nb_indices
+ 1;
2686 face_data_ptr
+= nb_indices
;
2690 group
->face_data
= HeapAlloc(GetProcessHeap(), 0, group
->face_data_size
* sizeof(unsigned));
2691 if (!group
->face_data
)
2693 HeapFree(GetProcessHeap(), 0 , group
->vertices
);
2694 return E_OUTOFMEMORY
;
2697 memcpy(group
->face_data
, face_data
, group
->face_data_size
* sizeof(unsigned));
2699 group
->material
= NULL
;
2700 group
->texture
= NULL
;
2702 *return_id
= This
->nb_groups
++;
2707 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh
* iface
,
2708 D3DRMGROUPINDEX id
, unsigned index
, unsigned count
,
2709 D3DRMVERTEX
*values
)
2711 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2713 TRACE("(%p)->(%u,%u,%u,%p)\n", This
, id
, index
, count
, values
);
2715 if (id
>= This
->nb_groups
)
2716 return D3DRMERR_BADVALUE
;
2718 if ((index
+ count
- 1) >= This
->groups
[id
].nb_vertices
)
2719 return D3DRMERR_BADVALUE
;
2724 memcpy(This
->groups
[id
].vertices
+ index
, values
, count
* sizeof(D3DRMVERTEX
));
2729 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh
* iface
,
2730 D3DRMGROUPINDEX id
, D3DCOLOR color
)
2732 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2734 TRACE("(%p)->(%u,%x)\n", This
, id
, color
);
2736 if (id
>= This
->nb_groups
)
2737 return D3DRMERR_BADVALUE
;
2739 This
->groups
[id
].color
= color
;
2744 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh
* iface
,
2745 D3DRMGROUPINDEX id
, D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
)
2747 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2749 TRACE("(%p)->(%u,%f,%f,%f)\n", This
, id
, red
, green
, blue
);
2751 if (id
>= This
->nb_groups
)
2752 return D3DRMERR_BADVALUE
;
2754 This
->groups
[id
].color
= RGBA_MAKE((BYTE
)(red
* 255.0f
), (BYTE
)(green
* 255.0f
), (BYTE
)(blue
* 255.0f
), 0xff);
2759 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh
* iface
,
2760 D3DRMGROUPINDEX id
, D3DRMMAPPING value
)
2762 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2764 FIXME("(%p)->(%u,%u): stub\n", This
, id
, value
);
2769 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh
* iface
,
2770 D3DRMGROUPINDEX id
, D3DRMRENDERQUALITY value
)
2772 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2774 FIXME("(%p)->(%u,%u): stub\n", This
, id
, value
);
2779 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh
*iface
,
2780 D3DRMGROUPINDEX id
, IDirect3DRMMaterial
*material
)
2782 IDirect3DRMMeshImpl
*mesh
= impl_from_IDirect3DRMMesh(iface
);
2784 TRACE("iface %p, id %#x, material %p.\n", iface
, id
, material
);
2786 if (id
>= mesh
->nb_groups
)
2787 return D3DRMERR_BADVALUE
;
2789 if (mesh
->groups
[id
].material
)
2790 IDirect3DRMMaterial2_Release(mesh
->groups
[id
].material
);
2792 mesh
->groups
[id
].material
= (IDirect3DRMMaterial2
*)material
;
2795 IDirect3DRMMaterial2_AddRef(mesh
->groups
[id
].material
);
2800 static HRESULT WINAPI
IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh
*iface
,
2801 D3DRMGROUPINDEX id
, IDirect3DRMTexture
*texture
)
2803 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2805 TRACE("(%p)->(%u,%p)\n", This
, id
, texture
);
2807 if (id
>= This
->nb_groups
)
2808 return D3DRMERR_BADVALUE
;
2810 if (This
->groups
[id
].texture
)
2811 IDirect3DRMTexture3_Release(This
->groups
[id
].texture
);
2815 This
->groups
[id
].texture
= NULL
;
2819 return IDirect3DRMTexture3_QueryInterface(texture
, &IID_IDirect3DRMTexture
, (void **)&This
->groups
[id
].texture
);
2822 static DWORD WINAPI
IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh
* iface
)
2824 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2826 TRACE("(%p)->()\n", This
);
2828 return This
->nb_groups
;
2831 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh
* iface
,
2832 D3DRMGROUPINDEX id
, unsigned *vertex_count
, unsigned *face_count
, unsigned *vertex_per_face
,
2833 DWORD
*face_data_size
, unsigned *face_data
)
2835 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2837 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This
, id
, vertex_count
, face_count
, vertex_per_face
, face_data_size
, face_data
);
2839 if (id
>= This
->nb_groups
)
2840 return D3DRMERR_BADVALUE
;
2843 *vertex_count
= This
->groups
[id
].nb_vertices
;
2845 *face_count
= This
->groups
[id
].nb_faces
;
2846 if (vertex_per_face
)
2847 *vertex_per_face
= This
->groups
[id
].vertex_per_face
;
2849 *face_data_size
= This
->groups
[id
].face_data_size
;
2851 memcpy(face_data
, This
->groups
[id
].face_data
, This
->groups
[id
].face_data_size
* sizeof(DWORD
));
2856 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh
* iface
,
2857 D3DRMGROUPINDEX id
, DWORD index
, DWORD count
, D3DRMVERTEX
*return_ptr
)
2859 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2861 TRACE("(%p)->(%u,%u,%u,%p)\n", This
, id
, index
, count
, return_ptr
);
2863 if (id
>= This
->nb_groups
)
2864 return D3DRMERR_BADVALUE
;
2866 if ((index
+ count
- 1) >= This
->groups
[id
].nb_vertices
)
2867 return D3DRMERR_BADVALUE
;
2872 memcpy(return_ptr
, This
->groups
[id
].vertices
+ index
, count
* sizeof(D3DRMVERTEX
));
2877 static D3DCOLOR WINAPI
IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh
* iface
, D3DRMGROUPINDEX id
)
2879 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2881 TRACE("(%p)->(%u)\n", This
, id
);
2883 return This
->groups
[id
].color
;
2886 static D3DRMMAPPING WINAPI
IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh
* iface
, D3DRMGROUPINDEX id
)
2888 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2890 FIXME("(%p)->(%u): stub\n", This
, id
);
2894 static D3DRMRENDERQUALITY WINAPI
IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh
* iface
, D3DRMGROUPINDEX id
)
2896 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2898 FIXME("(%p)->(%u): stub\n", This
, id
);
2903 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh
*iface
,
2904 D3DRMGROUPINDEX id
, IDirect3DRMMaterial
**material
)
2906 IDirect3DRMMeshImpl
*mesh
= impl_from_IDirect3DRMMesh(iface
);
2908 TRACE("iface %p, id %#x, material %p.\n", iface
, id
, material
);
2910 if (id
>= mesh
->nb_groups
)
2911 return D3DRMERR_BADVALUE
;
2916 if (mesh
->groups
[id
].material
)
2917 IDirect3DRMTexture_QueryInterface(mesh
->groups
[id
].material
, &IID_IDirect3DRMMaterial
, (void **)material
);
2924 static HRESULT WINAPI
IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh
*iface
,
2925 D3DRMGROUPINDEX id
, IDirect3DRMTexture
**texture
)
2927 IDirect3DRMMeshImpl
*This
= impl_from_IDirect3DRMMesh(iface
);
2929 TRACE("(%p)->(%u,%p)\n", This
, id
, texture
);
2931 if (id
>= This
->nb_groups
)
2932 return D3DRMERR_BADVALUE
;
2937 if (This
->groups
[id
].texture
)
2938 IDirect3DRMTexture_QueryInterface(This
->groups
[id
].texture
, &IID_IDirect3DRMTexture
, (void**)texture
);
2945 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl
=
2947 /*** IUnknown methods ***/
2948 IDirect3DRMMeshImpl_QueryInterface
,
2949 IDirect3DRMMeshImpl_AddRef
,
2950 IDirect3DRMMeshImpl_Release
,
2951 /*** IDirect3DRMObject methods ***/
2952 IDirect3DRMMeshImpl_Clone
,
2953 IDirect3DRMMeshImpl_AddDestroyCallback
,
2954 IDirect3DRMMeshImpl_DeleteDestroyCallback
,
2955 IDirect3DRMMeshImpl_SetAppData
,
2956 IDirect3DRMMeshImpl_GetAppData
,
2957 IDirect3DRMMeshImpl_SetName
,
2958 IDirect3DRMMeshImpl_GetName
,
2959 IDirect3DRMMeshImpl_GetClassName
,
2960 /*** IDirect3DRMMesh methods ***/
2961 IDirect3DRMMeshImpl_Scale
,
2962 IDirect3DRMMeshImpl_Translate
,
2963 IDirect3DRMMeshImpl_GetBox
,
2964 IDirect3DRMMeshImpl_AddGroup
,
2965 IDirect3DRMMeshImpl_SetVertices
,
2966 IDirect3DRMMeshImpl_SetGroupColor
,
2967 IDirect3DRMMeshImpl_SetGroupColorRGB
,
2968 IDirect3DRMMeshImpl_SetGroupMapping
,
2969 IDirect3DRMMeshImpl_SetGroupQuality
,
2970 IDirect3DRMMeshImpl_SetGroupMaterial
,
2971 IDirect3DRMMeshImpl_SetGroupTexture
,
2972 IDirect3DRMMeshImpl_GetGroupCount
,
2973 IDirect3DRMMeshImpl_GetGroup
,
2974 IDirect3DRMMeshImpl_GetVertices
,
2975 IDirect3DRMMeshImpl_GetGroupColor
,
2976 IDirect3DRMMeshImpl_GetGroupMapping
,
2977 IDirect3DRMMeshImpl_GetGroupQuality
,
2978 IDirect3DRMMeshImpl_GetGroupMaterial
,
2979 IDirect3DRMMeshImpl_GetGroupTexture
2982 HRESULT
Direct3DRMMesh_create(IDirect3DRMMesh
** obj
)
2984 IDirect3DRMMeshImpl
* object
;
2986 TRACE("(%p)\n", obj
);
2988 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DRMMeshImpl
));
2990 return E_OUTOFMEMORY
;
2992 object
->IDirect3DRMMesh_iface
.lpVtbl
= &Direct3DRMMesh_Vtbl
;
2995 *obj
= &object
->IDirect3DRMMesh_iface
;