gphoto2.ds: Set supported groups.
[wine.git] / dlls / d3drm / meshbuilder.c
blobc95cb46df14be320b00b705ef16d15b165f55693
1 /*
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 #include "config.h"
23 #include "wine/port.h"
25 #include "d3drm_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
29 struct coords_2d
31 D3DVALUE u;
32 D3DVALUE v;
35 struct mesh_material
37 D3DCOLOR color;
38 IDirect3DRMMaterial2 *material;
39 IDirect3DRMTexture3 *texture;
42 char templates[] = {
43 "xof 0302txt 0064"
44 "template Header"
45 "{"
46 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
47 "WORD major;"
48 "WORD minor;"
49 "DWORD flags;"
50 "}"
51 "template Vector"
52 "{"
53 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
54 "FLOAT x;"
55 "FLOAT y;"
56 "FLOAT z;"
57 "}"
58 "template Coords2d"
59 "{"
60 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
61 "FLOAT u;"
62 "FLOAT v;"
63 "}"
64 "template Matrix4x4"
65 "{"
66 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
67 "array FLOAT matrix[16];"
68 "}"
69 "template ColorRGBA"
70 "{"
71 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
72 "FLOAT red;"
73 "FLOAT green;"
74 "FLOAT blue;"
75 "FLOAT alpha;"
76 "}"
77 "template ColorRGB"
78 "{"
79 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
80 "FLOAT red;"
81 "FLOAT green;"
82 "FLOAT blue;"
83 "}"
84 "template IndexedColor"
85 "{"
86 "<1630B820-7842-11CF-8F52-0040333594A3>"
87 "DWORD index;"
88 "ColorRGBA indexColor;"
89 "}"
90 "template Boolean"
91 "{"
92 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
93 "DWORD truefalse;"
94 "}"
95 "template Boolean2d"
96 "{"
97 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
98 "Boolean u;"
99 "Boolean v;"
101 "template MaterialWrap"
103 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
104 "Boolean u;"
105 "Boolean v;"
107 "template TextureFilename"
109 "<A42790E1-7810-11CF-8F52-0040333594A3>"
110 "STRING filename;"
112 "template Material"
114 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
115 "ColorRGBA faceColor;"
116 "FLOAT power;"
117 "ColorRGB specularColor;"
118 "ColorRGB emissiveColor;"
119 "[...]"
121 "template MeshFace"
123 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
124 "DWORD nFaceVertexIndices;"
125 "array DWORD faceVertexIndices[nFaceVertexIndices];"
127 "template MeshFaceWraps"
129 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
130 "DWORD nFaceWrapValues;"
131 "array Boolean2d faceWrapValues[nFaceWrapValues];"
133 "template MeshTextureCoords"
135 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
136 "DWORD nTextureCoords;"
137 "array Coords2d textureCoords[nTextureCoords];"
139 "template MeshMaterialList"
141 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
142 "DWORD nMaterials;"
143 "DWORD nFaceIndexes;"
144 "array DWORD faceIndexes[nFaceIndexes];"
145 "[Material]"
147 "template MeshNormals"
149 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
150 "DWORD nNormals;"
151 "array Vector normals[nNormals];"
152 "DWORD nFaceNormals;"
153 "array MeshFace faceNormals[nFaceNormals];"
155 "template MeshVertexColors"
157 "<1630B821-7842-11CF-8F52-0040333594A3>"
158 "DWORD nVertexColors;"
159 "array IndexedColor vertexColors[nVertexColors];"
161 "template Mesh"
163 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
164 "DWORD nVertices;"
165 "array Vector vertices[nVertices];"
166 "DWORD nFaces;"
167 "array MeshFace faces[nFaces];"
168 "[...]"
170 "template FrameTransformMatrix"
172 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
173 "Matrix4x4 frameMatrix;"
175 "template Frame"
177 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
178 "[...]"
180 "template FloatKeys"
182 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
183 "DWORD nValues;"
184 "array FLOAT values[nValues];"
186 "template TimedFloatKeys"
188 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
189 "DWORD time;"
190 "FloatKeys tfkeys;"
192 "template AnimationKey"
194 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
195 "DWORD keyType;"
196 "DWORD nKeys;"
197 "array TimedFloatKeys keys[nKeys];"
199 "template AnimationOptions"
201 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
202 "DWORD openclosed;"
203 "DWORD positionquality;"
205 "template Animation"
207 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
208 "[...]"
210 "template AnimationSet"
212 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
213 "[Animation]"
215 "template InlineData"
217 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
218 "[BINARY]"
220 "template Url"
222 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
223 "DWORD nUrls;"
224 "array STRING urls[nUrls];"
226 "template ProgressiveMesh"
228 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
229 "[Url,InlineData]"
231 "template Guid"
233 "<A42790E0-7810-11CF-8F52-0040333594A3>"
234 "DWORD data1;"
235 "WORD data2;"
236 "WORD data3;"
237 "array UCHAR data4[8];"
239 "template StringProperty"
241 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
242 "STRING key;"
243 "STRING value;"
245 "template PropertyBag"
247 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
248 "[StringProperty]"
250 "template ExternalVisual"
252 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
253 "Guid guidExternalVisual;"
254 "[...]"
256 "template RightHanded"
258 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
259 "DWORD bRightHanded;"
263 BOOL d3drm_array_reserve(void **elements, SIZE_T *capacity, SIZE_T element_count, SIZE_T element_size)
265 SIZE_T new_capacity, max_capacity;
266 void *new_elements;
268 if (element_count <= *capacity)
269 return TRUE;
271 max_capacity = ~(SIZE_T)0 / element_size;
272 if (max_capacity < element_count)
273 return FALSE;
275 new_capacity = max(*capacity, 4);
276 while (new_capacity < element_count && new_capacity <= max_capacity / 2)
277 new_capacity *= 2;
279 if (new_capacity < element_count)
280 new_capacity = max_capacity;
282 if (*elements)
283 new_elements = HeapReAlloc(GetProcessHeap(), 0, *elements, new_capacity * element_size);
284 else
285 new_elements = HeapAlloc(GetProcessHeap(), 0, new_capacity * element_size);
287 if (!new_elements)
288 return FALSE;
290 *elements = new_elements;
291 *capacity = new_capacity;
292 return TRUE;
295 static inline struct d3drm_mesh *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
297 return CONTAINING_RECORD(iface, struct d3drm_mesh, IDirect3DRMMesh_iface);
300 static inline struct d3drm_mesh_builder *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
302 return CONTAINING_RECORD(iface, struct d3drm_mesh_builder, IDirect3DRMMeshBuilder2_iface);
305 static inline struct d3drm_mesh_builder *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
307 return CONTAINING_RECORD(iface, struct d3drm_mesh_builder, IDirect3DRMMeshBuilder3_iface);
310 static inline struct d3drm_wrap *impl_from_IDirect3DRMWrap(IDirect3DRMWrap *iface)
312 return CONTAINING_RECORD(iface, struct d3drm_wrap, IDirect3DRMWrap_iface);
315 static void clean_mesh_builder_data(struct d3drm_mesh_builder *mesh_builder)
317 DWORD i;
319 IDirect3DRMMeshBuilder3_SetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, NULL);
320 HeapFree(GetProcessHeap(), 0, mesh_builder->vertices);
321 mesh_builder->vertices = NULL;
322 mesh_builder->nb_vertices = 0;
323 mesh_builder->vertices_size = 0;
324 HeapFree(GetProcessHeap(), 0, mesh_builder->normals);
325 mesh_builder->normals = NULL;
326 mesh_builder->nb_normals = 0;
327 mesh_builder->normals_size = 0;
328 HeapFree(GetProcessHeap(), 0, mesh_builder->pFaceData);
329 mesh_builder->pFaceData = NULL;
330 mesh_builder->face_data_size = 0;
331 mesh_builder->nb_faces = 0;
332 HeapFree(GetProcessHeap(), 0, mesh_builder->pCoords2d);
333 mesh_builder->pCoords2d = NULL;
334 mesh_builder->nb_coords2d = 0;
335 for (i = 0; i < mesh_builder->nb_materials; i++)
337 if (mesh_builder->materials[i].material)
338 IDirect3DRMMaterial2_Release(mesh_builder->materials[i].material);
339 if (mesh_builder->materials[i].texture)
340 IDirect3DRMTexture3_Release(mesh_builder->materials[i].texture);
342 mesh_builder->nb_materials = 0;
343 HeapFree(GetProcessHeap(), 0, mesh_builder->materials);
344 mesh_builder->materials = NULL;
345 HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices);
346 mesh_builder->material_indices = NULL;
349 static HRESULT WINAPI d3drm_mesh_builder2_QueryInterface(IDirect3DRMMeshBuilder2 *iface, REFIID riid, void **out)
351 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
353 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
355 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2)
356 || IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder)
357 || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
358 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
359 || IsEqualGUID(riid, &IID_IUnknown))
361 *out = &mesh_builder->IDirect3DRMMeshBuilder2_iface;
363 else if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
365 *out = &mesh_builder->IDirect3DRMMeshBuilder3_iface;
367 else
369 *out = NULL;
370 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
371 return E_NOINTERFACE;
374 IUnknown_AddRef((IUnknown *)*out);
375 return S_OK;
378 static ULONG WINAPI d3drm_mesh_builder2_AddRef(IDirect3DRMMeshBuilder2 *iface)
380 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
381 ULONG refcount = InterlockedIncrement(&mesh_builder->ref);
383 TRACE("%p increasing refcount to %u.\n", mesh_builder, refcount);
385 return refcount;
388 static ULONG WINAPI d3drm_mesh_builder2_Release(IDirect3DRMMeshBuilder2 *iface)
390 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
391 ULONG refcount = InterlockedDecrement(&mesh_builder->ref);
393 TRACE("%p decreasing refcount to %u.\n", mesh_builder, refcount);
395 if (!refcount)
397 d3drm_object_cleanup((IDirect3DRMObject *)iface, &mesh_builder->obj);
398 clean_mesh_builder_data(mesh_builder);
399 if (mesh_builder->material)
400 IDirect3DRMMaterial2_Release(mesh_builder->material);
401 if (mesh_builder->texture)
402 IDirect3DRMTexture3_Release(mesh_builder->texture);
403 IDirect3DRM_Release(mesh_builder->d3drm);
404 HeapFree(GetProcessHeap(), 0, mesh_builder);
407 return refcount;
410 static HRESULT WINAPI d3drm_mesh_builder2_Clone(IDirect3DRMMeshBuilder2 *iface,
411 IUnknown *outer, REFIID iid, void **out)
413 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
415 return E_NOTIMPL;
418 static HRESULT WINAPI d3drm_mesh_builder2_AddDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
419 D3DRMOBJECTCALLBACK cb, void *ctx)
421 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
423 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
425 return IDirect3DRMMeshBuilder3_AddDestroyCallback(&mesh_builder->IDirect3DRMMeshBuilder3_iface, cb, ctx);
428 static HRESULT WINAPI d3drm_mesh_builder2_DeleteDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
429 D3DRMOBJECTCALLBACK cb, void *ctx)
431 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
433 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
435 return IDirect3DRMMeshBuilder3_DeleteDestroyCallback(&mesh_builder->IDirect3DRMMeshBuilder3_iface, cb, ctx);
438 static HRESULT WINAPI d3drm_mesh_builder3_SetAppData(IDirect3DRMMeshBuilder3 *iface, DWORD data)
440 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
442 TRACE("iface %p, data %#x.\n", iface, data);
444 mesh_builder->obj.appdata = data;
446 return D3DRM_OK;
449 static HRESULT WINAPI d3drm_mesh_builder2_SetAppData(IDirect3DRMMeshBuilder2 *iface, DWORD data)
451 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
453 TRACE("iface %p, data %#x.\n", iface, data);
455 return d3drm_mesh_builder3_SetAppData(&mesh_builder->IDirect3DRMMeshBuilder3_iface, data);
458 static DWORD WINAPI d3drm_mesh_builder3_GetAppData(IDirect3DRMMeshBuilder3 *iface)
460 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
462 TRACE("iface %p.\n", iface);
464 return mesh_builder->obj.appdata;
467 static DWORD WINAPI d3drm_mesh_builder2_GetAppData(IDirect3DRMMeshBuilder2 *iface)
469 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
471 TRACE("iface %p.\n", iface);
473 return d3drm_mesh_builder3_GetAppData(&mesh_builder->IDirect3DRMMeshBuilder3_iface);
476 static HRESULT WINAPI d3drm_mesh_builder2_SetName(IDirect3DRMMeshBuilder2 *iface, const char *name)
478 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
480 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
482 return IDirect3DRMMeshBuilder3_SetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, name);
485 static HRESULT WINAPI d3drm_mesh_builder2_GetName(IDirect3DRMMeshBuilder2 *iface, DWORD *size, char *name)
487 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
489 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
491 return IDirect3DRMMeshBuilder3_GetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
494 static HRESULT WINAPI d3drm_mesh_builder2_GetClassName(IDirect3DRMMeshBuilder2 *iface, DWORD *size, char *name)
496 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
498 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
500 return IDirect3DRMMeshBuilder3_GetClassName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
503 static HRESULT WINAPI d3drm_mesh_builder2_Load(IDirect3DRMMeshBuilder2 *iface, void *filename,
504 void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURECALLBACK cb, void *ctx)
506 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
508 TRACE("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p.\n",
509 iface, filename, name, flags, cb, ctx);
511 if (cb)
512 FIXME("Texture callback is not yet supported\n");
514 return IDirect3DRMMeshBuilder3_Load(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
515 filename, name, flags, NULL, ctx);
518 static HRESULT WINAPI d3drm_mesh_builder2_Save(IDirect3DRMMeshBuilder2 *iface,
519 const char *filename, D3DRMXOFFORMAT format, D3DRMSAVEOPTIONS flags)
521 FIXME("iface %p, filename %s, format %#x, flags %#x stub!\n",
522 iface, debugstr_a(filename), format, flags);
524 return E_NOTIMPL;
527 static HRESULT WINAPI d3drm_mesh_builder2_Scale(IDirect3DRMMeshBuilder2 *iface,
528 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
530 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
532 TRACE("iface %p, sx %.8e, sy %.8e, sz %.8e.\n", iface, sx, sy, sz);
534 return IDirect3DRMMeshBuilder3_Scale(&mesh_builder->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
537 static HRESULT WINAPI d3drm_mesh_builder2_Translate(IDirect3DRMMeshBuilder2 *iface,
538 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
540 FIXME("iface %p, tx %.8e, ty %.8e, tz %.8e stub!\n", iface, tx, ty, tz);
542 return E_NOTIMPL;
545 static HRESULT WINAPI d3drm_mesh_builder2_SetColorSource(IDirect3DRMMeshBuilder2 *iface, D3DRMCOLORSOURCE source)
547 FIXME("iface %p, source %#x stub!\n", iface, source);
549 return E_NOTIMPL;
552 static HRESULT WINAPI d3drm_mesh_builder2_GetBox(IDirect3DRMMeshBuilder2 *iface, D3DRMBOX *box)
554 FIXME("iface %p, box %p stub!\n", iface, box);
556 return E_NOTIMPL;
559 static HRESULT WINAPI d3drm_mesh_builder2_GenerateNormals(IDirect3DRMMeshBuilder2 *iface)
561 FIXME("iface %p stub!\n", iface);
563 return E_NOTIMPL;
566 static D3DRMCOLORSOURCE WINAPI d3drm_mesh_builder2_GetColorSource(IDirect3DRMMeshBuilder2 *iface)
568 FIXME("iface %p stub!\n", iface);
570 return E_NOTIMPL;
573 static HRESULT WINAPI d3drm_mesh_builder2_AddMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh *mesh)
575 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
577 return E_NOTIMPL;
580 static HRESULT WINAPI d3drm_mesh_builder2_AddMeshBuilder(IDirect3DRMMeshBuilder2 *iface,
581 IDirect3DRMMeshBuilder *mesh_builder)
583 FIXME("iface %p, mesh_builder %p stub!\n", iface, mesh_builder);
585 return E_NOTIMPL;
588 static HRESULT WINAPI d3drm_mesh_builder2_AddFrame(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFrame *frame)
590 FIXME("iface %p, frame %p stub!\n", iface, frame);
592 return E_NOTIMPL;
595 static HRESULT WINAPI d3drm_mesh_builder2_AddFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace *face)
597 FIXME("iface %p, face %p stub!\n", iface, face);
599 return E_NOTIMPL;
602 static HRESULT WINAPI d3drm_mesh_builder2_AddFaces(IDirect3DRMMeshBuilder2 *iface,
603 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
604 DWORD *face_data, IDirect3DRMFaceArray **array)
606 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p, array %p stub!\n",
607 iface, vertex_count, vertices, normal_count, normals, face_data, array);
609 return E_NOTIMPL;
612 static HRESULT WINAPI d3drm_mesh_builder2_ReserveSpace(IDirect3DRMMeshBuilder2 *iface,
613 DWORD vertex_count, DWORD normal_count, DWORD face_count)
615 FIXME("iface %p, vertex_count %u, normal_count %u, face_count %u stub!\n",
616 iface, vertex_count, normal_count, face_count);
618 return E_NOTIMPL;
621 static HRESULT WINAPI d3drm_mesh_builder2_SetColorRGB(IDirect3DRMMeshBuilder2 *iface,
622 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
624 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
626 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
628 return IDirect3DRMMeshBuilder3_SetColorRGB(&mesh_builder->IDirect3DRMMeshBuilder3_iface, red, green, blue);
631 static HRESULT WINAPI d3drm_mesh_builder2_SetColor(IDirect3DRMMeshBuilder2 *iface, D3DCOLOR color)
633 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
635 TRACE("iface %p, color 0x%08x.\n", iface, color);
637 return IDirect3DRMMeshBuilder3_SetColor(&mesh_builder->IDirect3DRMMeshBuilder3_iface, color);
640 static HRESULT WINAPI d3drm_mesh_builder2_SetTexture(IDirect3DRMMeshBuilder2 *iface,
641 IDirect3DRMTexture *texture)
643 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
644 IDirect3DRMTexture3 *texture3 = NULL;
645 HRESULT hr = D3DRM_OK;
647 TRACE("iface %p, texture %p.\n", iface, texture);
649 if (texture)
650 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void **)&texture3);
651 if (SUCCEEDED(hr))
652 hr = IDirect3DRMMeshBuilder3_SetTexture(&mesh_builder->IDirect3DRMMeshBuilder3_iface, texture3);
653 if (texture3)
654 IDirect3DRMTexture3_Release(texture3);
656 return hr;
659 static HRESULT WINAPI d3drm_mesh_builder2_SetMaterial(IDirect3DRMMeshBuilder2 *iface,
660 IDirect3DRMMaterial *material)
662 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
664 TRACE("iface %p, material %p.\n", iface, material);
666 return IDirect3DRMMeshBuilder3_SetMaterial(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
667 (IDirect3DRMMaterial2 *)material);
670 static HRESULT WINAPI d3drm_mesh_builder2_SetTextureTopology(IDirect3DRMMeshBuilder2 *iface,
671 BOOL wrap_u, BOOL wrap_v)
673 FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);
675 return E_NOTIMPL;
678 static HRESULT WINAPI d3drm_mesh_builder2_SetQuality(IDirect3DRMMeshBuilder2 *iface,
679 D3DRMRENDERQUALITY quality)
681 FIXME("iface %p, quality %#x stub!\n", iface, quality);
683 return E_NOTIMPL;
686 static HRESULT WINAPI d3drm_mesh_builder2_SetPerspective(IDirect3DRMMeshBuilder2 *iface, BOOL enable)
688 FIXME("iface %p, enable %#x stub!\n", iface, enable);
690 return E_NOTIMPL;
693 static HRESULT WINAPI d3drm_mesh_builder2_SetVertex(IDirect3DRMMeshBuilder2 *iface,
694 DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z)
696 FIXME("iface %p, index %u, x %.8e, y %.8e, z %.8e stub!\n", iface, index, x, y, z);
698 return E_NOTIMPL;
701 static HRESULT WINAPI d3drm_mesh_builder2_SetNormal(IDirect3DRMMeshBuilder2 *iface,
702 DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z)
704 FIXME("iface %p, index %u, x %.8e, y %.8e, z %.8e stub!\n", iface, index, x, y, z);
706 return E_NOTIMPL;
709 static HRESULT WINAPI d3drm_mesh_builder2_SetTextureCoordinates(IDirect3DRMMeshBuilder2 *iface,
710 DWORD index, D3DVALUE u, D3DVALUE v)
712 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
714 TRACE("iface %p, index %u, u %.8e, v %.8e.\n", iface, index, u, v);
716 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
717 index, u, v);
720 static HRESULT WINAPI d3drm_mesh_builder2_SetVertexColor(IDirect3DRMMeshBuilder2 *iface,
721 DWORD index, D3DCOLOR color)
723 FIXME("iface %p, index %u, color 0x%08x stub!\n", iface, index, color);
725 return E_NOTIMPL;
728 static HRESULT WINAPI d3drm_mesh_builder2_SetVertexColorRGB(IDirect3DRMMeshBuilder2 *iface,
729 DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
731 FIXME("iface %p, index %u, red %.8e, green %.8e, blue %.8e stub!\n",
732 iface, index, red, green, blue);
734 return E_NOTIMPL;
737 static HRESULT WINAPI d3drm_mesh_builder2_GetFaces(IDirect3DRMMeshBuilder2 *iface,
738 IDirect3DRMFaceArray **array)
740 FIXME("iface %p, array %p stub!\n", iface, array);
742 return E_NOTIMPL;
745 static HRESULT WINAPI d3drm_mesh_builder2_GetVertices(IDirect3DRMMeshBuilder2 *iface,
746 DWORD *vertex_count, D3DVECTOR *vertices, DWORD *normal_count, D3DVECTOR *normals,
747 DWORD *face_data_size, DWORD *face_data)
749 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
751 TRACE("iface %p, vertex_count %p, vertices %p, normal_count %p, normals %p, face_data_size %p, face_data %p.\n",
752 iface, vertex_count, vertices, normal_count, normals, face_data_size, face_data);
754 if (vertices && (!vertex_count || (*vertex_count < mesh_builder->nb_vertices)))
755 return D3DRMERR_BADVALUE;
756 if (vertex_count)
757 *vertex_count = mesh_builder->nb_vertices;
758 if (vertices && mesh_builder->nb_vertices)
759 memcpy(vertices, mesh_builder->vertices, mesh_builder->nb_vertices * sizeof(*vertices));
761 if (normals && (!normal_count || (*normal_count < mesh_builder->nb_normals)))
762 return D3DRMERR_BADVALUE;
763 if (normal_count)
764 *normal_count = mesh_builder->nb_normals;
765 if (normals && mesh_builder->nb_normals)
766 memcpy(normals, mesh_builder->normals, mesh_builder->nb_normals * sizeof(*normals));
768 if (face_data && (!face_data_size || (*face_data_size < mesh_builder->face_data_size)))
769 return D3DRMERR_BADVALUE;
770 if (face_data_size)
771 *face_data_size = mesh_builder->face_data_size;
772 if (face_data && mesh_builder->face_data_size)
773 memcpy(face_data, mesh_builder->pFaceData, mesh_builder->face_data_size * sizeof(*face_data));
775 return D3DRM_OK;
778 static HRESULT WINAPI d3drm_mesh_builder2_GetTextureCoordinates(IDirect3DRMMeshBuilder2 *iface,
779 DWORD index, D3DVALUE *u, D3DVALUE *v)
781 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
783 TRACE("iface %p, index %u, u %p, v %p.\n", iface, index, u, v);
785 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
786 index, u, v);
789 static int WINAPI d3drm_mesh_builder2_AddVertex(IDirect3DRMMeshBuilder2 *iface,
790 D3DVALUE x, D3DVALUE y, D3DVALUE z)
792 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
794 TRACE("iface %p, x %.8e, y %.8e, z %.8e.\n", iface, x, y, z);
796 return IDirect3DRMMeshBuilder3_AddVertex(&mesh_builder->IDirect3DRMMeshBuilder3_iface, x, y, z);
799 static int WINAPI d3drm_mesh_builder2_AddNormal(IDirect3DRMMeshBuilder2 *iface,
800 D3DVALUE x, D3DVALUE y, D3DVALUE z)
802 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
804 TRACE("iface %p, x %.8e, y %.8e, z %.8e.\n", iface, x, y, z);
806 return IDirect3DRMMeshBuilder3_AddNormal(&mesh_builder->IDirect3DRMMeshBuilder3_iface, x, y, z);
809 static HRESULT WINAPI d3drm_mesh_builder2_CreateFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace **face)
811 struct d3drm_face *object;
812 HRESULT hr;
814 TRACE("iface %p, face %p.\n", iface, face);
816 if (FAILED(hr = d3drm_face_create(&object)))
817 return hr;
819 *face = &object->IDirect3DRMFace_iface;
821 return S_OK;
824 static D3DRMRENDERQUALITY WINAPI d3drm_mesh_builder2_GetQuality(IDirect3DRMMeshBuilder2 *iface)
826 FIXME("iface %p stub!\n", iface);
828 return 0;
831 static BOOL WINAPI d3drm_mesh_builder2_GetPerspective(IDirect3DRMMeshBuilder2 *iface)
833 FIXME("iface %p stub!\n", iface);
835 return FALSE;
838 static int WINAPI d3drm_mesh_builder2_GetFaceCount(IDirect3DRMMeshBuilder2 *iface)
840 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
842 TRACE("iface %p.\n", iface);
844 return mesh_builder->nb_faces;
847 static int WINAPI d3drm_mesh_builder2_GetVertexCount(IDirect3DRMMeshBuilder2 *iface)
849 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
851 TRACE("iface %p.\n", iface);
853 return mesh_builder->nb_vertices;
856 static D3DCOLOR WINAPI d3drm_mesh_builder2_GetVertexColor(IDirect3DRMMeshBuilder2 *iface, DWORD index)
858 FIXME("iface %p, index %u stub!\n", iface, index);
860 return 0;
863 static HRESULT WINAPI d3drm_mesh_builder2_CreateMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh **mesh)
865 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
867 TRACE("iface %p, mesh %p.\n", iface, mesh);
869 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder->IDirect3DRMMeshBuilder3_iface, mesh);
872 static HRESULT WINAPI d3drm_mesh_builder2_GenerateNormals2(IDirect3DRMMeshBuilder2 *iface,
873 D3DVALUE crease, DWORD flags)
875 FIXME("iface %p, crease %.8e, flags %#x stub!\n", iface, crease, flags);
877 return E_NOTIMPL;
880 static HRESULT WINAPI d3drm_mesh_builder2_GetFace(IDirect3DRMMeshBuilder2 *iface,
881 DWORD index, IDirect3DRMFace **face)
883 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
885 return E_NOTIMPL;
888 static const struct IDirect3DRMMeshBuilder2Vtbl d3drm_mesh_builder2_vtbl =
890 d3drm_mesh_builder2_QueryInterface,
891 d3drm_mesh_builder2_AddRef,
892 d3drm_mesh_builder2_Release,
893 d3drm_mesh_builder2_Clone,
894 d3drm_mesh_builder2_AddDestroyCallback,
895 d3drm_mesh_builder2_DeleteDestroyCallback,
896 d3drm_mesh_builder2_SetAppData,
897 d3drm_mesh_builder2_GetAppData,
898 d3drm_mesh_builder2_SetName,
899 d3drm_mesh_builder2_GetName,
900 d3drm_mesh_builder2_GetClassName,
901 d3drm_mesh_builder2_Load,
902 d3drm_mesh_builder2_Save,
903 d3drm_mesh_builder2_Scale,
904 d3drm_mesh_builder2_Translate,
905 d3drm_mesh_builder2_SetColorSource,
906 d3drm_mesh_builder2_GetBox,
907 d3drm_mesh_builder2_GenerateNormals,
908 d3drm_mesh_builder2_GetColorSource,
909 d3drm_mesh_builder2_AddMesh,
910 d3drm_mesh_builder2_AddMeshBuilder,
911 d3drm_mesh_builder2_AddFrame,
912 d3drm_mesh_builder2_AddFace,
913 d3drm_mesh_builder2_AddFaces,
914 d3drm_mesh_builder2_ReserveSpace,
915 d3drm_mesh_builder2_SetColorRGB,
916 d3drm_mesh_builder2_SetColor,
917 d3drm_mesh_builder2_SetTexture,
918 d3drm_mesh_builder2_SetMaterial,
919 d3drm_mesh_builder2_SetTextureTopology,
920 d3drm_mesh_builder2_SetQuality,
921 d3drm_mesh_builder2_SetPerspective,
922 d3drm_mesh_builder2_SetVertex,
923 d3drm_mesh_builder2_SetNormal,
924 d3drm_mesh_builder2_SetTextureCoordinates,
925 d3drm_mesh_builder2_SetVertexColor,
926 d3drm_mesh_builder2_SetVertexColorRGB,
927 d3drm_mesh_builder2_GetFaces,
928 d3drm_mesh_builder2_GetVertices,
929 d3drm_mesh_builder2_GetTextureCoordinates,
930 d3drm_mesh_builder2_AddVertex,
931 d3drm_mesh_builder2_AddNormal,
932 d3drm_mesh_builder2_CreateFace,
933 d3drm_mesh_builder2_GetQuality,
934 d3drm_mesh_builder2_GetPerspective,
935 d3drm_mesh_builder2_GetFaceCount,
936 d3drm_mesh_builder2_GetVertexCount,
937 d3drm_mesh_builder2_GetVertexColor,
938 d3drm_mesh_builder2_CreateMesh,
939 d3drm_mesh_builder2_GenerateNormals2,
940 d3drm_mesh_builder2_GetFace,
943 static HRESULT WINAPI d3drm_mesh_builder3_QueryInterface(IDirect3DRMMeshBuilder3 *iface, REFIID riid, void **out)
945 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
947 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
949 return d3drm_mesh_builder2_QueryInterface(&mesh_builder->IDirect3DRMMeshBuilder2_iface, riid, out);
952 static ULONG WINAPI d3drm_mesh_builder3_AddRef(IDirect3DRMMeshBuilder3 *iface)
954 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
956 TRACE("iface %p.\n", iface);
958 return d3drm_mesh_builder2_AddRef(&mesh_builder->IDirect3DRMMeshBuilder2_iface);
961 static ULONG WINAPI d3drm_mesh_builder3_Release(IDirect3DRMMeshBuilder3 *iface)
963 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
965 TRACE("iface %p.\n", iface);
967 return d3drm_mesh_builder2_Release(&mesh_builder->IDirect3DRMMeshBuilder2_iface);
970 static HRESULT WINAPI d3drm_mesh_builder3_Clone(IDirect3DRMMeshBuilder3 *iface,
971 IUnknown *outer, REFIID iid, void **out)
973 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
975 return E_NOTIMPL;
978 static HRESULT WINAPI d3drm_mesh_builder3_AddDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
979 D3DRMOBJECTCALLBACK cb, void *ctx)
981 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
983 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
985 return d3drm_object_add_destroy_callback(&mesh_builder->obj, cb, ctx);
988 static HRESULT WINAPI d3drm_mesh_builder3_DeleteDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
989 D3DRMOBJECTCALLBACK cb, void *ctx)
991 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
993 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
995 return d3drm_object_delete_destroy_callback(&mesh_builder->obj, cb, ctx);
998 static HRESULT WINAPI d3drm_mesh_builder3_SetName(IDirect3DRMMeshBuilder3 *iface, const char *name)
1000 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1002 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1004 return d3drm_object_set_name(&mesh_builder->obj, name);
1007 static HRESULT WINAPI d3drm_mesh_builder3_GetName(IDirect3DRMMeshBuilder3 *iface,
1008 DWORD *size, char *name)
1010 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1012 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1014 return d3drm_object_get_name(&mesh_builder->obj, size, name);
1017 static HRESULT WINAPI d3drm_mesh_builder3_GetClassName(IDirect3DRMMeshBuilder3 *iface,
1018 DWORD *size, char *name)
1020 struct d3drm_mesh_builder *meshbuilder = impl_from_IDirect3DRMMeshBuilder3(iface);
1022 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1024 return d3drm_object_get_class_name(&meshbuilder->obj, size, name);
1027 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData,
1028 D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
1030 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1031 IDirectXFileData *pData2 = NULL;
1032 const GUID* guid;
1033 DWORD size;
1034 BYTE *ptr;
1035 HRESULT hr;
1036 HRESULT ret = D3DRMERR_BADOBJECT;
1037 DWORD* faces_vertex_idx_data = NULL;
1038 DWORD* faces_vertex_idx_ptr;
1039 DWORD faces_vertex_idx_size;
1040 DWORD* faces_normal_idx_data = NULL;
1041 DWORD* faces_normal_idx_ptr = NULL;
1042 DWORD* faces_data_ptr;
1043 DWORD faces_data_size = 0;
1044 DWORD i;
1046 TRACE("(%p)->(%p)\n", mesh_builder, pData);
1048 hr = IDirectXFileData_GetName(pData, NULL, &size);
1049 if (hr != DXFILE_OK)
1050 return hr;
1051 if (size)
1053 char *name = HeapAlloc(GetProcessHeap(), 0, size);
1054 if (!name)
1055 return E_OUTOFMEMORY;
1057 if (SUCCEEDED(hr = IDirectXFileData_GetName(pData, name, &size)))
1058 IDirect3DRMMeshBuilder3_SetName(iface, name);
1059 HeapFree(GetProcessHeap(), 0, name);
1060 if (hr != DXFILE_OK)
1061 return hr;
1064 TRACE("Mesh name is %s\n", debugstr_a(mesh_builder->obj.name));
1066 mesh_builder->nb_normals = 0;
1068 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1069 if (hr != DXFILE_OK)
1070 goto end;
1072 mesh_builder->nb_vertices = *(DWORD*)ptr;
1073 mesh_builder->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + mesh_builder->nb_vertices * sizeof(D3DVECTOR));
1074 faces_vertex_idx_size = size - sizeof(DWORD) - mesh_builder->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1076 TRACE("Mesh: nb_vertices = %lu, nb_faces = %d, faces_vertex_idx_size = %d\n", mesh_builder->nb_vertices,
1077 mesh_builder->nb_faces, faces_vertex_idx_size);
1079 if (!d3drm_array_reserve((void **)&mesh_builder->vertices, &mesh_builder->vertices_size, mesh_builder->nb_vertices,
1080 sizeof(*mesh_builder->vertices)))
1082 hr = E_OUTOFMEMORY;
1083 goto end;
1085 memcpy(mesh_builder->vertices, ptr + sizeof(DWORD), mesh_builder->nb_vertices * sizeof(D3DVECTOR));
1087 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1088 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + mesh_builder->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD),
1089 faces_vertex_idx_size);
1091 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1092 mesh_builder->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2);
1093 faces_data_ptr = (DWORD*)mesh_builder->pFaceData;
1095 while (1)
1097 IDirectXFileObject *object;
1099 hr = IDirectXFileData_GetNextObject(pData, &object);
1100 if (hr == DXFILEERR_NOMOREOBJECTS)
1102 TRACE("No more object\n");
1103 break;
1105 if (hr != DXFILE_OK)
1106 goto end;
1108 hr = IDirectXFileObject_QueryInterface(object, &IID_IDirectXFileData, (void**)&pData2);
1109 IDirectXFileObject_Release(object);
1110 if (hr != DXFILE_OK)
1111 goto end;
1113 hr = IDirectXFileData_GetType(pData2, &guid);
1114 if (hr != DXFILE_OK)
1115 goto end;
1117 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1119 if (IsEqualGUID(guid, &TID_D3DRMMeshNormals))
1121 DWORD nb_faces_normals;
1122 DWORD faces_normal_idx_size;
1124 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1125 if (hr != DXFILE_OK)
1126 goto end;
1128 mesh_builder->nb_normals = *(DWORD*)ptr;
1129 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR));
1131 TRACE("MeshNormals: nb_normals = %lu, nb_faces_normals = %d\n", mesh_builder->nb_normals, nb_faces_normals);
1132 if (nb_faces_normals != mesh_builder->nb_faces)
1133 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, mesh_builder->nb_faces);
1135 if (!d3drm_array_reserve((void **)&mesh_builder->normals, &mesh_builder->normals_size,
1136 mesh_builder->nb_normals, sizeof(*mesh_builder->normals)))
1138 hr = E_OUTOFMEMORY;
1139 goto end;
1141 memcpy(mesh_builder->normals, ptr + sizeof(DWORD), mesh_builder->nb_normals * sizeof(D3DVECTOR));
1143 faces_normal_idx_size = size - (2 * sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR));
1144 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1145 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + mesh_builder->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1147 else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords))
1149 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1150 if (hr != DXFILE_OK)
1151 goto end;
1153 mesh_builder->nb_coords2d = *(DWORD*)ptr;
1155 TRACE("MeshTextureCoords: nb_coords2d = %d\n", mesh_builder->nb_coords2d);
1157 mesh_builder->pCoords2d = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d));
1158 memcpy(mesh_builder->pCoords2d, ptr + sizeof(DWORD), mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d));
1160 else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList))
1162 DWORD nb_materials;
1163 DWORD nb_face_indices;
1164 DWORD data_size;
1165 IDirectXFileObject *child;
1166 DWORD i = 0;
1167 float* values;
1168 struct d3drm_texture *texture_object;
1170 TRACE("Process MeshMaterialList\n");
1172 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1173 if (hr != DXFILE_OK)
1174 goto end;
1176 nb_materials = *(DWORD*)ptr;
1177 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1178 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1180 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1182 if (size != data_size)
1183 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1185 mesh_builder->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*mesh_builder->material_indices) * nb_face_indices);
1186 if (!mesh_builder->material_indices)
1187 goto end;
1188 memcpy(mesh_builder->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*mesh_builder->material_indices) * nb_face_indices),
1190 mesh_builder->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*mesh_builder->materials) * nb_materials);
1191 if (!mesh_builder->materials)
1193 HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices);
1194 goto end;
1196 mesh_builder->nb_materials = nb_materials;
1198 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1200 IDirectXFileData *data;
1201 IDirectXFileDataReference *reference;
1202 IDirectXFileObject *material_child;
1203 struct d3drm_material *object;
1205 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1206 if (FAILED(hr))
1208 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1209 IDirectXFileObject_Release(child);
1210 if (FAILED(hr))
1211 goto end;
1213 hr = IDirectXFileDataReference_Resolve(reference, &data);
1214 IDirectXFileDataReference_Release(reference);
1215 if (FAILED(hr))
1216 goto end;
1218 else
1220 IDirectXFileObject_Release(child);
1223 hr = d3drm_material_create(&object, mesh_builder->d3drm);
1224 if (FAILED(hr))
1226 IDirectXFileData_Release(data);
1227 goto end;
1229 mesh_builder->materials[i].material = &object->IDirect3DRMMaterial2_iface;
1231 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1232 if (hr != DXFILE_OK)
1234 IDirectXFileData_Release(data);
1235 goto end;
1238 if (size != 44)
1239 WARN("Material size %u does not match expected one %u\n", size, 44);
1241 values = (float*)ptr;
1243 d3drm_set_color(&mesh_builder->materials[i].color, values[0], values[1], values[2], values[3]);
1245 IDirect3DRMMaterial2_SetAmbient(mesh_builder->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
1246 IDirect3DRMMaterial2_SetPower(mesh_builder->materials[i].material, values[4]);
1247 IDirect3DRMMaterial2_SetSpecular(mesh_builder->materials[i].material, values[5], values[6], values[7]);
1248 IDirect3DRMMaterial2_SetEmissive(mesh_builder->materials[i].material, values[8], values[9], values[10]);
1250 mesh_builder->materials[i].texture = NULL;
1252 hr = IDirectXFileData_GetNextObject(data, &material_child);
1253 if (hr == S_OK)
1255 IDirectXFileData *data;
1256 char **filename;
1258 if (FAILED(hr = IDirectXFileObject_QueryInterface(material_child,
1259 &IID_IDirectXFileData, (void **)&data)))
1261 IDirectXFileDataReference *reference;
1263 if (SUCCEEDED(IDirectXFileObject_QueryInterface(material_child,
1264 &IID_IDirectXFileDataReference, (void **)&reference)))
1266 hr = IDirectXFileDataReference_Resolve(reference, &data);
1267 IDirectXFileDataReference_Release(reference);
1270 IDirectXFileObject_Release(material_child);
1271 if (FAILED(hr))
1272 goto end;
1274 hr = IDirectXFileData_GetType(data, &guid);
1275 if (hr != DXFILE_OK)
1276 goto end;
1277 if (!IsEqualGUID(guid, &TID_D3DRMTextureFilename))
1279 WARN("Not a texture filename\n");
1280 goto end;
1283 size = 4;
1284 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1285 if (SUCCEEDED(hr))
1287 if (load_texture_proc)
1289 IDirect3DRMTexture *texture;
1291 hr = load_texture_proc(*filename, arg, &texture);
1292 if (SUCCEEDED(hr))
1294 hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3,
1295 (void **)&mesh_builder->materials[i].texture);
1296 IDirect3DTexture_Release(texture);
1299 else
1301 HANDLE file;
1303 /* If the texture file is not found, no texture is associated with the material */
1304 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1305 if (file != INVALID_HANDLE_VALUE)
1307 CloseHandle(file);
1308 if (FAILED(hr = d3drm_texture_create(&texture_object, NULL)))
1310 IDirectXFileData_Release(data);
1311 goto end;
1313 mesh_builder->materials[i].texture = &texture_object->IDirect3DRMTexture3_iface;
1317 IDirectXFileData_Release(data);
1319 else if (hr != DXFILEERR_NOMOREOBJECTS)
1321 goto end;
1323 hr = S_OK;
1325 IDirectXFileData_Release(data);
1326 i++;
1328 if (hr == S_OK)
1330 IDirectXFileObject_Release(child);
1331 WARN("Found more sub-objects than expected\n");
1333 else if (hr != DXFILEERR_NOMOREOBJECTS)
1335 goto end;
1337 hr = S_OK;
1339 else
1341 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid));
1344 IDirectXFileData_Release(pData2);
1345 pData2 = NULL;
1348 if (!mesh_builder->nb_normals)
1350 /* Allocate normals, one per vertex */
1351 if (!d3drm_array_reserve((void **)&mesh_builder->normals, &mesh_builder->normals_size,
1352 mesh_builder->nb_vertices, sizeof(*mesh_builder->normals)))
1353 goto end;
1354 memset(mesh_builder->normals, 0, mesh_builder->nb_vertices * sizeof(*mesh_builder->normals));
1357 for (i = 0; i < mesh_builder->nb_faces; i++)
1359 DWORD j;
1360 DWORD nb_face_indexes;
1361 D3DVECTOR face_normal;
1363 if (faces_vertex_idx_size < sizeof(DWORD))
1364 WARN("Not enough data to read number of indices of face %d\n", i);
1366 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1367 faces_vertex_idx_size--;
1368 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1369 WARN("Faces indices number mismatch\n");
1371 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1372 WARN("Not enough data to read all indices of face %d\n", i);
1374 if (!mesh_builder->nb_normals)
1376 /* Compute face normal */
1377 if (nb_face_indexes > 2
1378 && faces_vertex_idx_ptr[0] < mesh_builder->nb_vertices
1379 && faces_vertex_idx_ptr[1] < mesh_builder->nb_vertices
1380 && faces_vertex_idx_ptr[2] < mesh_builder->nb_vertices)
1382 D3DVECTOR a, b;
1384 D3DRMVectorSubtract(&a, &mesh_builder->vertices[faces_vertex_idx_ptr[2]], &mesh_builder->vertices[faces_vertex_idx_ptr[1]]);
1385 D3DRMVectorSubtract(&b, &mesh_builder->vertices[faces_vertex_idx_ptr[0]], &mesh_builder->vertices[faces_vertex_idx_ptr[1]]);
1386 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1387 D3DRMVectorNormalize(&face_normal);
1389 else
1391 face_normal.u1.x = 0.0f;
1392 face_normal.u2.y = 0.0f;
1393 face_normal.u3.z = 0.0f;
1397 for (j = 0; j < nb_face_indexes; j++)
1399 /* Copy vertex index */
1400 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1401 /* Copy normal index */
1402 if (mesh_builder->nb_normals)
1404 /* Read from x file */
1405 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1407 else
1409 DWORD vertex_idx = *faces_vertex_idx_ptr;
1410 if (vertex_idx >= mesh_builder->nb_vertices)
1412 WARN("Found vertex index %u but only %lu vertices available => use index 0\n", vertex_idx,
1413 mesh_builder->nb_vertices);
1414 vertex_idx = 0;
1416 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1417 /* Add face normal to vertex normal */
1418 D3DRMVectorAdd(&mesh_builder->normals[vertex_idx], &mesh_builder->normals[vertex_idx], &face_normal);
1420 faces_vertex_idx_ptr++;
1422 faces_vertex_idx_size -= nb_face_indexes;
1425 /* Last DWORD must be 0 */
1426 *(faces_data_ptr + faces_data_size++) = 0;
1428 /* Set size (in number of DWORD) of all faces data */
1429 mesh_builder->face_data_size = faces_data_size;
1431 if (!mesh_builder->nb_normals)
1433 /* Normalize all normals */
1434 for (i = 0; i < mesh_builder->nb_vertices; i++)
1436 D3DRMVectorNormalize(&mesh_builder->normals[i]);
1438 mesh_builder->nb_normals = mesh_builder->nb_vertices;
1441 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1442 if (!mesh_builder->pCoords2d)
1444 mesh_builder->nb_coords2d = mesh_builder->nb_vertices;
1445 mesh_builder->pCoords2d = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_coords2d * sizeof(*mesh_builder->pCoords2d));
1446 for (i = 0; i < mesh_builder->nb_coords2d; i++)
1448 mesh_builder->pCoords2d[i].u = 0.0f;
1449 mesh_builder->pCoords2d[i].v = 0.0f;
1453 TRACE("Mesh data loaded successfully\n");
1455 ret = D3DRM_OK;
1457 end:
1459 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1460 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1462 return ret;
1465 static HRESULT WINAPI d3drm_mesh_builder3_Load(IDirect3DRMMeshBuilder3 *iface, void *filename,
1466 void *name, D3DRMLOADOPTIONS loadflags, D3DRMLOADTEXTURE3CALLBACK cb, void *arg)
1468 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1469 DXFILELOADOPTIONS load_options;
1470 IDirectXFile *dxfile = NULL;
1471 IDirectXFileEnumObject *enum_object = NULL;
1472 IDirectXFileData *data = NULL;
1473 const GUID* guid;
1474 DWORD size;
1475 struct d3drm_file_header *header;
1476 HRESULT hr;
1477 HRESULT ret = D3DRMERR_BADOBJECT;
1479 TRACE("iface %p, filename %p, name %p, loadflags %#x, cb %p, arg %p.\n",
1480 iface, filename, name, loadflags, cb, arg);
1482 clean_mesh_builder_data(mesh_builder);
1484 if (loadflags == D3DRMLOAD_FROMMEMORY)
1486 load_options = DXFILELOAD_FROMMEMORY;
1488 else if (loadflags == D3DRMLOAD_FROMFILE)
1490 load_options = DXFILELOAD_FROMFILE;
1491 TRACE("Loading from file %s\n", debugstr_a(filename));
1493 else
1495 FIXME("Load options %d not supported yet\n", loadflags);
1496 return E_NOTIMPL;
1499 hr = DirectXFileCreate(&dxfile);
1500 if (hr != DXFILE_OK)
1501 goto end;
1503 hr = IDirectXFile_RegisterTemplates(dxfile, templates, strlen(templates));
1504 if (hr != DXFILE_OK)
1505 goto end;
1507 hr = IDirectXFile_CreateEnumObject(dxfile, filename, load_options, &enum_object);
1508 if (hr != DXFILE_OK)
1509 goto end;
1511 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1512 if (hr != DXFILE_OK)
1513 goto end;
1515 hr = IDirectXFileData_GetType(data, &guid);
1516 if (hr != DXFILE_OK)
1517 goto end;
1519 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1521 if (!IsEqualGUID(guid, &TID_DXFILEHeader))
1523 ret = D3DRMERR_BADFILE;
1524 goto end;
1527 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&header);
1528 if ((hr != DXFILE_OK) || (size != sizeof(*header)))
1529 goto end;
1531 TRACE("Version is %u.%u, flags %#x.\n", header->major, header->minor, header->flags);
1533 /* Version must be 1.0.x */
1534 if ((header->major != 1) || (header->minor != 0))
1536 ret = D3DRMERR_BADFILE;
1537 goto end;
1540 IDirectXFileData_Release(data);
1541 data = NULL;
1543 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1544 if (hr != DXFILE_OK)
1546 ret = D3DRMERR_NOTFOUND;
1547 goto end;
1550 hr = IDirectXFileData_GetType(data, &guid);
1551 if (hr != DXFILE_OK)
1552 goto end;
1554 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1556 if (!IsEqualGUID(guid, &TID_D3DRMMesh))
1558 ret = D3DRMERR_NOTFOUND;
1559 goto end;
1562 /* We don't care about the texture interface version since we rely on QueryInterface */
1563 hr = load_mesh_data(iface, data, (D3DRMLOADTEXTURECALLBACK)cb, arg);
1564 if (hr == S_OK)
1565 ret = D3DRM_OK;
1567 end:
1569 if (data)
1570 IDirectXFileData_Release(data);
1571 if (enum_object)
1572 IDirectXFileEnumObject_Release(enum_object);
1573 if (dxfile)
1574 IDirectXFile_Release(dxfile);
1576 if (ret != D3DRM_OK)
1577 clean_mesh_builder_data(mesh_builder);
1579 return ret;
1582 static HRESULT WINAPI d3drm_mesh_builder3_Save(IDirect3DRMMeshBuilder3 *iface,
1583 const char *filename, D3DRMXOFFORMAT format, D3DRMSAVEOPTIONS flags)
1585 FIXME("iface %p, filename %s, format %#x, flags %#x stub!\n",
1586 iface, debugstr_a(filename), format, flags);
1588 return E_NOTIMPL;
1591 static HRESULT WINAPI d3drm_mesh_builder3_Scale(IDirect3DRMMeshBuilder3 *iface,
1592 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1594 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1595 DWORD i;
1597 TRACE("iface %p, sx %.8e, sy %.8e, sz %.8e.\n", iface, sx, sy, sz);
1599 for (i = 0; i < mesh_builder->nb_vertices; ++i)
1601 mesh_builder->vertices[i].u1.x *= sx;
1602 mesh_builder->vertices[i].u2.y *= sy;
1603 mesh_builder->vertices[i].u3.z *= sz;
1606 /* Normals are not affected by Scale */
1608 return D3DRM_OK;
1611 static HRESULT WINAPI d3drm_mesh_builder3_Translate(IDirect3DRMMeshBuilder3 *iface,
1612 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1614 FIXME("iface %p, tx %.8e, ty %.8e, tz %.8e stub!\n", iface, tx, ty, tz);
1616 return E_NOTIMPL;
1619 static HRESULT WINAPI d3drm_mesh_builder3_SetColorSource(IDirect3DRMMeshBuilder3 *iface,
1620 D3DRMCOLORSOURCE source)
1622 FIXME("iface %p, source %#x stub!\n", iface, source);
1624 return E_NOTIMPL;
1627 static HRESULT WINAPI d3drm_mesh_builder3_GetBox(IDirect3DRMMeshBuilder3 *iface, D3DRMBOX *box)
1629 FIXME("iface %p, box %p stub!\n", iface, box);
1631 return E_NOTIMPL;
1634 static HRESULT WINAPI d3drm_mesh_builder3_GenerateNormals(IDirect3DRMMeshBuilder3 *iface,
1635 D3DVALUE crease, DWORD flags)
1637 FIXME("iface %p, crease %.8e, flags %#x stub!\n", iface, crease, flags);
1639 return E_NOTIMPL;
1642 static D3DRMCOLORSOURCE WINAPI d3drm_mesh_builder3_GetColorSource(IDirect3DRMMeshBuilder3 *iface)
1644 FIXME("iface %p stub!\n", iface);
1646 return E_NOTIMPL;
1649 static HRESULT WINAPI d3drm_mesh_builder3_AddMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh *mesh)
1651 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1653 return E_NOTIMPL;
1656 static HRESULT WINAPI d3drm_mesh_builder3_AddMeshBuilder(IDirect3DRMMeshBuilder3 *iface,
1657 IDirect3DRMMeshBuilder3 *mesh_builder, DWORD flags)
1659 FIXME("iface %p, mesh_builder %p, flags %#x stub!\n", iface, mesh_builder, flags);
1661 return E_NOTIMPL;
1664 static HRESULT WINAPI d3drm_mesh_builder3_AddFrame(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFrame3 *frame)
1666 FIXME("iface %p, frame %p stub!\n", iface, frame);
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI d3drm_mesh_builder3_AddFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
1673 FIXME("iface %p, face %p stub!\n", iface, face);
1675 return E_NOTIMPL;
1678 static HRESULT WINAPI d3drm_mesh_builder3_AddFaces(IDirect3DRMMeshBuilder3 *iface,
1679 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
1680 DWORD *face_data, IDirect3DRMFaceArray **array)
1682 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p array %p stub!\n",
1683 iface, vertex_count, vertices, normal_count, normals, face_data, array);
1685 return E_NOTIMPL;
1688 static HRESULT WINAPI d3drm_mesh_builder3_ReserveSpace(IDirect3DRMMeshBuilder3 *iface,
1689 DWORD vertex_count, DWORD normal_count, DWORD face_count)
1691 FIXME("iface %p, vertex_count %u, normal_count %u, face_count %u stub!\n",
1692 iface, vertex_count, normal_count, face_count);
1694 return E_NOTIMPL;
1697 static HRESULT WINAPI d3drm_mesh_builder3_SetColorRGB(IDirect3DRMMeshBuilder3 *iface,
1698 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
1700 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1702 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
1704 d3drm_set_color(&mesh_builder->color, red, green, blue, 1.0f);
1706 return D3DRM_OK;
1709 static HRESULT WINAPI d3drm_mesh_builder3_SetColor(IDirect3DRMMeshBuilder3 *iface, D3DCOLOR color)
1711 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1713 TRACE("iface %p, color 0x%08x.\n", iface, color);
1715 mesh_builder->color = color;
1717 return D3DRM_OK;
1720 static HRESULT WINAPI d3drm_mesh_builder3_SetTexture(IDirect3DRMMeshBuilder3 *iface,
1721 IDirect3DRMTexture3 *texture)
1723 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1725 TRACE("iface %p, texture %p.\n", iface, texture);
1727 if (texture)
1728 IDirect3DRMTexture3_AddRef(texture);
1729 if (mesh_builder->texture)
1730 IDirect3DRMTexture3_Release(mesh_builder->texture);
1731 mesh_builder->texture = texture;
1733 return D3DRM_OK;
1736 static HRESULT WINAPI d3drm_mesh_builder3_SetMaterial(IDirect3DRMMeshBuilder3 *iface,
1737 IDirect3DRMMaterial2 *material)
1739 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1741 TRACE("iface %p, material %p.\n", iface, material);
1743 if (material)
1744 IDirect3DRMTexture2_AddRef(material);
1745 if (mesh_builder->material)
1746 IDirect3DRMTexture2_Release(mesh_builder->material);
1747 mesh_builder->material = material;
1749 return D3DRM_OK;
1752 static HRESULT WINAPI d3drm_mesh_builder3_SetTextureTopology(IDirect3DRMMeshBuilder3 *iface,
1753 BOOL wrap_u, BOOL wrap_v)
1755 FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);
1757 return E_NOTIMPL;
1760 static HRESULT WINAPI d3drm_mesh_builder3_SetQuality(IDirect3DRMMeshBuilder3 *iface,
1761 D3DRMRENDERQUALITY quality)
1763 FIXME("iface %p, quality %#x stub!\n", iface, quality);
1765 return E_NOTIMPL;
1768 static HRESULT WINAPI d3drm_mesh_builder3_SetPerspective(IDirect3DRMMeshBuilder3 *iface,
1769 BOOL enable)
1771 FIXME("iface %p, enable %#x stub!\n", iface, enable);
1773 return E_NOTIMPL;
1776 static HRESULT WINAPI d3drm_mesh_builder3_SetVertex(IDirect3DRMMeshBuilder3 *iface,
1777 DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z)
1779 FIXME("iface %p, index %u, x %.8e, y %.8e, z %.8e stub!\n", iface, index, x, y, z);
1781 return E_NOTIMPL;
1784 static HRESULT WINAPI d3drm_mesh_builder3_SetNormal(IDirect3DRMMeshBuilder3 *iface,
1785 DWORD index, D3DVALUE x, D3DVALUE y, D3DVALUE z)
1787 FIXME("iface %p, index %u, x %.8e, y %.8e, z %.8e stub!\n", iface, index, x, y, z);
1789 return E_NOTIMPL;
1792 static HRESULT WINAPI d3drm_mesh_builder3_SetTextureCoordinates(IDirect3DRMMeshBuilder3 *iface,
1793 DWORD index, D3DVALUE u, D3DVALUE v)
1795 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1797 TRACE("iface %p, index %u, u %.8e, v %.8e.\n", iface, index, u, v);
1799 if (index >= mesh_builder->nb_coords2d)
1800 return D3DRMERR_BADVALUE;
1802 mesh_builder->pCoords2d[index].u = u;
1803 mesh_builder->pCoords2d[index].v = v;
1805 return D3DRM_OK;
1808 static HRESULT WINAPI d3drm_mesh_builder3_SetVertexColor(IDirect3DRMMeshBuilder3 *iface,
1809 DWORD index, D3DCOLOR color)
1811 FIXME("iface %p, index %u, color 0x%08x stub!\n", iface, index, color);
1813 return E_NOTIMPL;
1816 static HRESULT WINAPI d3drm_mesh_builder3_SetVertexColorRGB(IDirect3DRMMeshBuilder3 *iface,
1817 DWORD index, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
1819 FIXME("iface %p, index %u, red %.8e, green %.8e, blue %.8e stub!\n",
1820 iface, index, red, green, blue);
1822 return E_NOTIMPL;
1825 static HRESULT WINAPI d3drm_mesh_builder3_GetFaces(IDirect3DRMMeshBuilder3 *iface,
1826 IDirect3DRMFaceArray **array)
1828 FIXME("iface %p, array %p stub!\n", iface, array);
1830 return E_NOTIMPL;
1833 static HRESULT WINAPI d3drm_mesh_builder3_GetGeometry(IDirect3DRMMeshBuilder3 *iface,
1834 DWORD *vertex_count, D3DVECTOR *vertices, DWORD *normal_count, D3DVECTOR *normals,
1835 DWORD *face_data_size, DWORD *face_data)
1837 FIXME("iface %p, vertex_count %p, vertices %p, normal_count %p, normals %p, "
1838 "face_data_size %p, face_data %p stub!\n",
1839 iface, vertex_count, vertices, normal_count, normals, face_data_size, face_data);
1841 return E_NOTIMPL;
1844 static HRESULT WINAPI d3drm_mesh_builder3_GetTextureCoordinates(IDirect3DRMMeshBuilder3 *iface,
1845 DWORD index, D3DVALUE *u, D3DVALUE *v)
1847 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1849 TRACE("iface %p, index %u, u %p, v %p.\n", iface, index, u, v);
1851 if (index >= mesh_builder->nb_coords2d)
1852 return D3DRMERR_BADVALUE;
1854 *u = mesh_builder->pCoords2d[index].u;
1855 *v = mesh_builder->pCoords2d[index].v;
1857 return D3DRM_OK;
1860 static int WINAPI d3drm_mesh_builder3_AddVertex(IDirect3DRMMeshBuilder3 *iface,
1861 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1863 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1865 TRACE("iface %p, x %.8e, y %.8e, z %.8e.\n", iface, x, y, z);
1867 if (!d3drm_array_reserve((void **)&mesh_builder->vertices, &mesh_builder->vertices_size,
1868 mesh_builder->nb_vertices + 1, sizeof(*mesh_builder->vertices)))
1869 return 0;
1871 mesh_builder->vertices[mesh_builder->nb_vertices].u1.x = x;
1872 mesh_builder->vertices[mesh_builder->nb_vertices].u2.y = y;
1873 mesh_builder->vertices[mesh_builder->nb_vertices].u3.z = z;
1875 return mesh_builder->nb_vertices++;
1878 static int WINAPI d3drm_mesh_builder3_AddNormal(IDirect3DRMMeshBuilder3 *iface,
1879 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1881 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1883 TRACE("iface %p, x %.8e, y %.8e, z %.8e.\n", iface, x, y, z);
1885 if (!d3drm_array_reserve((void **)&mesh_builder->normals, &mesh_builder->normals_size,
1886 mesh_builder->nb_normals + 1, sizeof(*mesh_builder->normals)))
1887 return 0;
1889 mesh_builder->normals[mesh_builder->nb_normals].u1.x = x;
1890 mesh_builder->normals[mesh_builder->nb_normals].u2.y = y;
1891 mesh_builder->normals[mesh_builder->nb_normals].u3.z = z;
1893 return mesh_builder->nb_normals++;
1896 static HRESULT WINAPI d3drm_mesh_builder3_CreateFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 **face)
1898 struct d3drm_face *object;
1899 HRESULT hr;
1901 TRACE("iface %p, face %p.\n", iface, face);
1903 if (FAILED(hr = d3drm_face_create(&object)))
1904 return hr;
1906 *face = &object->IDirect3DRMFace2_iface;
1908 return S_OK;
1911 static D3DRMRENDERQUALITY WINAPI d3drm_mesh_builder3_GetQuality(IDirect3DRMMeshBuilder3 *iface)
1913 FIXME("iface %p stub!\n", iface);
1915 return 0;
1918 static BOOL WINAPI d3drm_mesh_builder3_GetPerspective(IDirect3DRMMeshBuilder3 *iface)
1920 FIXME("iface %p stub!\n", iface);
1922 return FALSE;
1925 static int WINAPI d3drm_mesh_builder3_GetFaceCount(IDirect3DRMMeshBuilder3 *iface)
1927 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1929 TRACE("iface %p.\n", iface);
1931 return mesh_builder->nb_faces;
1934 static int WINAPI d3drm_mesh_builder3_GetVertexCount(IDirect3DRMMeshBuilder3 *iface)
1936 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1938 TRACE("iface %p.\n", iface);
1940 return mesh_builder->nb_vertices;
1943 static D3DCOLOR WINAPI d3drm_mesh_builder3_GetVertexColor(IDirect3DRMMeshBuilder3 *iface,
1944 DWORD index)
1946 FIXME("iface %p, index %u stub!\n", iface, index);
1948 return 0;
1951 static HRESULT WINAPI d3drm_mesh_builder3_CreateMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh **mesh)
1953 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1954 HRESULT hr;
1955 D3DRMGROUPINDEX group;
1957 TRACE("iface %p, mesh %p.\n", iface, mesh);
1959 if (!mesh)
1960 return E_POINTER;
1962 hr = IDirect3DRM_CreateMesh(mesh_builder->d3drm, mesh);
1963 if (FAILED(hr))
1964 return hr;
1966 /* If there is mesh data, create a group and put data inside */
1967 if (mesh_builder->nb_vertices)
1969 DWORD i, j;
1970 int k;
1971 D3DRMVERTEX* vertices;
1973 vertices = HeapAlloc(GetProcessHeap(), 0, mesh_builder->nb_vertices * sizeof(D3DRMVERTEX));
1974 if (!vertices)
1976 IDirect3DRMMesh_Release(*mesh);
1977 return E_OUTOFMEMORY;
1979 for (i = 0; i < mesh_builder->nb_vertices; i++)
1980 vertices[i].position = mesh_builder->vertices[i];
1981 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, mesh_builder->nb_vertices, vertices);
1982 HeapFree(GetProcessHeap(), 0, vertices);
1984 /* Groups are in reverse order compared to materials list in X file */
1985 for (k = mesh_builder->nb_materials - 1; k >= 0; k--)
1987 unsigned* face_data;
1988 unsigned* out_ptr;
1989 DWORD* in_ptr = mesh_builder->pFaceData;
1990 ULONG vertex_per_face = 0;
1991 BOOL* used_vertices;
1992 unsigned nb_vertices = 0;
1993 unsigned nb_faces = 0;
1995 used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mesh_builder->face_data_size * sizeof(*used_vertices));
1996 if (!used_vertices)
1998 IDirect3DRMMesh_Release(*mesh);
1999 return E_OUTOFMEMORY;
2002 face_data = HeapAlloc(GetProcessHeap(), 0, mesh_builder->face_data_size * sizeof(*face_data));
2003 if (!face_data)
2005 HeapFree(GetProcessHeap(), 0, used_vertices);
2006 IDirect3DRMMesh_Release(*mesh);
2007 return E_OUTOFMEMORY;
2009 out_ptr = face_data;
2011 /* If all faces have the same number of vertex, set vertex_per_face */
2012 for (i = 0; i < mesh_builder->nb_faces; i++)
2014 /* Process only faces belonging to the group */
2015 if (mesh_builder->material_indices[i] == k)
2017 if (vertex_per_face && (vertex_per_face != *in_ptr))
2018 break;
2019 vertex_per_face = *in_ptr;
2021 in_ptr += 1 + *in_ptr * 2;
2023 if (i != mesh_builder->nb_faces)
2024 vertex_per_face = 0;
2026 /* Put only vertex indices */
2027 in_ptr = mesh_builder->pFaceData;
2028 for (i = 0; i < mesh_builder->nb_faces; i++)
2030 DWORD nb_indices = *in_ptr++;
2032 /* Skip faces not belonging to the group */
2033 if (mesh_builder->material_indices[i] != k)
2035 in_ptr += 2 * nb_indices;
2036 continue;
2039 /* Don't put nb indices when vertex_per_face is set */
2040 if (vertex_per_face)
2041 *out_ptr++ = nb_indices;
2043 for (j = 0; j < nb_indices; j++)
2045 *out_ptr = *in_ptr++;
2046 used_vertices[*out_ptr++] = TRUE;
2047 /* Skip normal index */
2048 in_ptr++;
2051 nb_faces++;
2054 for (i = 0; i < mesh_builder->nb_vertices; i++)
2055 if (used_vertices[i])
2056 nb_vertices++;
2058 hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group);
2059 HeapFree(GetProcessHeap(), 0, used_vertices);
2060 HeapFree(GetProcessHeap(), 0, face_data);
2061 if (SUCCEEDED(hr))
2062 hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, mesh_builder->materials[k].color);
2063 if (SUCCEEDED(hr))
2064 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, group,
2065 (IDirect3DRMMaterial *)mesh_builder->materials[k].material);
2066 if (SUCCEEDED(hr) && mesh_builder->materials[k].texture)
2068 IDirect3DRMTexture *texture;
2070 IDirect3DRMTexture3_QueryInterface(mesh_builder->materials[k].texture,
2071 &IID_IDirect3DRMTexture, (void **)&texture);
2072 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, group, texture);
2073 IDirect3DRMTexture_Release(texture);
2075 if (FAILED(hr))
2077 IDirect3DRMMesh_Release(*mesh);
2078 return hr;
2083 return D3DRM_OK;
2086 static HRESULT WINAPI d3drm_mesh_builder3_GetFace(IDirect3DRMMeshBuilder3 *iface,
2087 DWORD index, IDirect3DRMFace2 **face)
2089 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
2091 return E_NOTIMPL;
2094 static HRESULT WINAPI d3drm_mesh_builder3_GetVertex(IDirect3DRMMeshBuilder3 *iface,
2095 DWORD index, D3DVECTOR *vector)
2097 FIXME("iface %p, index %u, vector %p stub!\n", iface, index, vector);
2099 return E_NOTIMPL;
2102 static HRESULT WINAPI d3drm_mesh_builder3_GetNormal(IDirect3DRMMeshBuilder3 *iface,
2103 DWORD index, D3DVECTOR *vector)
2105 FIXME("iface %p, index %u, vector %p stub!\n", iface, index, vector);
2107 return E_NOTIMPL;
2110 static HRESULT WINAPI d3drm_mesh_builder3_DeleteVertices(IDirect3DRMMeshBuilder3 *iface,
2111 DWORD start_idx, DWORD count)
2113 FIXME("iface %p, start_idx %u, count %u stub!\n", iface, start_idx, count);
2115 return E_NOTIMPL;
2118 static HRESULT WINAPI d3drm_mesh_builder3_DeleteNormals(IDirect3DRMMeshBuilder3 *iface,
2119 DWORD start_idx, DWORD count)
2121 FIXME("iface %p, start_idx %u, count %u stub!\n", iface, start_idx, count);
2123 return E_NOTIMPL;
2126 static HRESULT WINAPI d3drm_mesh_builder3_DeleteFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
2128 FIXME("iface %p, face %p stub!\n", iface, face);
2130 return E_NOTIMPL;
2133 static HRESULT WINAPI d3drm_mesh_builder3_Empty(IDirect3DRMMeshBuilder3 *iface, DWORD flags)
2135 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2137 return E_NOTIMPL;
2140 static HRESULT WINAPI d3drm_mesh_builder3_Optimize(IDirect3DRMMeshBuilder3 *iface, DWORD flags)
2142 FIXME("iface %p, flags %#x stub!\n", iface, flags);
2144 return E_NOTIMPL;
2147 static HRESULT WINAPI d3drm_mesh_builder3_AddFacesIndexed(IDirect3DRMMeshBuilder3 *iface,
2148 DWORD flags, DWORD *indices, DWORD *start_idx, DWORD *count)
2150 FIXME("iface %p, flags %#x, indices %p, start_idx %p, count %p stub!\n",
2151 iface, flags, indices, start_idx, count);
2153 return E_NOTIMPL;
2156 static HRESULT WINAPI d3drm_mesh_builder3_CreateSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown **mesh)
2158 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2160 return E_NOTIMPL;
2163 static HRESULT WINAPI d3drm_mesh_builder3_GetParentMesh(IDirect3DRMMeshBuilder3 *iface,
2164 DWORD flags, IUnknown **parent)
2166 FIXME("iface %p, flags %#x, parent %p stub!\n", iface, flags, parent);
2168 return E_NOTIMPL;
2171 static HRESULT WINAPI d3drm_mesh_builder3_GetSubMeshes(IDirect3DRMMeshBuilder3 *iface,
2172 DWORD *count, IUnknown **meshes)
2174 FIXME("iface %p, count %p, meshes %p stub!\n", iface, count, meshes);
2176 return E_NOTIMPL;
2179 static HRESULT WINAPI d3drm_mesh_builder3_DeleteSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown *mesh)
2181 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2183 return E_NOTIMPL;
2186 static HRESULT WINAPI d3drm_mesh_builder3_Enable(IDirect3DRMMeshBuilder3 *iface, DWORD index)
2188 FIXME("iface %p, index %u stub!\n", iface, index);
2190 return E_NOTIMPL;
2193 static HRESULT WINAPI d3drm_mesh_builder3_GetEnable(IDirect3DRMMeshBuilder3 *iface, DWORD *indices)
2195 FIXME("iface %p, indices %p stub!\n", iface, indices);
2197 return E_NOTIMPL;
2200 static HRESULT WINAPI d3drm_mesh_builder3_AddTriangles(IDirect3DRMMeshBuilder3 *iface,
2201 DWORD flags, DWORD format, DWORD vertex_count, void *data)
2203 FIXME("iface %p, flags %#x, format %#x, vertex_count %u, data %p stub!\n",
2204 iface, flags, format, vertex_count, data);
2206 return E_NOTIMPL;
2209 static HRESULT WINAPI d3drm_mesh_builder3_SetVertices(IDirect3DRMMeshBuilder3 *iface,
2210 DWORD start_idx, DWORD count, D3DVECTOR *vector)
2212 FIXME("iface %p, start_idx %u, count %u, vector %p stub!\n", iface, start_idx, count, vector);
2214 return E_NOTIMPL;
2217 static HRESULT WINAPI d3drm_mesh_builder3_GetVertices(IDirect3DRMMeshBuilder3 *iface,
2218 DWORD start_idx, DWORD *vertex_count, D3DVECTOR *vertices)
2220 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
2221 DWORD count = mesh_builder->nb_vertices - start_idx;
2223 TRACE("iface %p, start_idx %u, vertex_count %p, vertices %p.\n",
2224 iface, start_idx, vertex_count, vertices);
2226 if (vertex_count)
2227 *vertex_count = count;
2228 if (vertices && mesh_builder->nb_vertices)
2229 memcpy(vertices, mesh_builder->vertices + start_idx, count * sizeof(*vertices));
2231 return D3DRM_OK;
2234 static HRESULT WINAPI d3drm_mesh_builder3_SetNormals(IDirect3DRMMeshBuilder3 *iface,
2235 DWORD start_idx, DWORD count, D3DVECTOR *vector)
2237 FIXME("iface %p, start_idx %u, count %u, vector %p stub!\n",
2238 iface, start_idx, count, vector);
2240 return E_NOTIMPL;
2243 static HRESULT WINAPI d3drm_mesh_builder3_GetNormals(IDirect3DRMMeshBuilder3 *iface,
2244 DWORD start_idx, DWORD *normal_count, D3DVECTOR *normals)
2246 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
2247 DWORD count = mesh_builder->nb_normals - start_idx;
2249 TRACE("iface %p, start_idx %u, normal_count %p, normals %p.\n",
2250 iface, start_idx, normal_count, normals);
2252 if (normal_count)
2253 *normal_count = count;
2254 if (normals && mesh_builder->nb_normals)
2255 memcpy(normals, &mesh_builder->normals[start_idx], count * sizeof(*normals));
2257 return D3DRM_OK;
2260 static int WINAPI d3drm_mesh_builder3_GetNormalCount(IDirect3DRMMeshBuilder3 *iface)
2262 struct d3drm_mesh_builder *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
2264 TRACE("iface %p.\n", iface);
2266 return mesh_builder->nb_normals;
2269 static const struct IDirect3DRMMeshBuilder3Vtbl d3drm_mesh_builder3_vtbl =
2271 d3drm_mesh_builder3_QueryInterface,
2272 d3drm_mesh_builder3_AddRef,
2273 d3drm_mesh_builder3_Release,
2274 d3drm_mesh_builder3_Clone,
2275 d3drm_mesh_builder3_AddDestroyCallback,
2276 d3drm_mesh_builder3_DeleteDestroyCallback,
2277 d3drm_mesh_builder3_SetAppData,
2278 d3drm_mesh_builder3_GetAppData,
2279 d3drm_mesh_builder3_SetName,
2280 d3drm_mesh_builder3_GetName,
2281 d3drm_mesh_builder3_GetClassName,
2282 d3drm_mesh_builder3_Load,
2283 d3drm_mesh_builder3_Save,
2284 d3drm_mesh_builder3_Scale,
2285 d3drm_mesh_builder3_Translate,
2286 d3drm_mesh_builder3_SetColorSource,
2287 d3drm_mesh_builder3_GetBox,
2288 d3drm_mesh_builder3_GenerateNormals,
2289 d3drm_mesh_builder3_GetColorSource,
2290 d3drm_mesh_builder3_AddMesh,
2291 d3drm_mesh_builder3_AddMeshBuilder,
2292 d3drm_mesh_builder3_AddFrame,
2293 d3drm_mesh_builder3_AddFace,
2294 d3drm_mesh_builder3_AddFaces,
2295 d3drm_mesh_builder3_ReserveSpace,
2296 d3drm_mesh_builder3_SetColorRGB,
2297 d3drm_mesh_builder3_SetColor,
2298 d3drm_mesh_builder3_SetTexture,
2299 d3drm_mesh_builder3_SetMaterial,
2300 d3drm_mesh_builder3_SetTextureTopology,
2301 d3drm_mesh_builder3_SetQuality,
2302 d3drm_mesh_builder3_SetPerspective,
2303 d3drm_mesh_builder3_SetVertex,
2304 d3drm_mesh_builder3_SetNormal,
2305 d3drm_mesh_builder3_SetTextureCoordinates,
2306 d3drm_mesh_builder3_SetVertexColor,
2307 d3drm_mesh_builder3_SetVertexColorRGB,
2308 d3drm_mesh_builder3_GetFaces,
2309 d3drm_mesh_builder3_GetGeometry,
2310 d3drm_mesh_builder3_GetTextureCoordinates,
2311 d3drm_mesh_builder3_AddVertex,
2312 d3drm_mesh_builder3_AddNormal,
2313 d3drm_mesh_builder3_CreateFace,
2314 d3drm_mesh_builder3_GetQuality,
2315 d3drm_mesh_builder3_GetPerspective,
2316 d3drm_mesh_builder3_GetFaceCount,
2317 d3drm_mesh_builder3_GetVertexCount,
2318 d3drm_mesh_builder3_GetVertexColor,
2319 d3drm_mesh_builder3_CreateMesh,
2320 d3drm_mesh_builder3_GetFace,
2321 d3drm_mesh_builder3_GetVertex,
2322 d3drm_mesh_builder3_GetNormal,
2323 d3drm_mesh_builder3_DeleteVertices,
2324 d3drm_mesh_builder3_DeleteNormals,
2325 d3drm_mesh_builder3_DeleteFace,
2326 d3drm_mesh_builder3_Empty,
2327 d3drm_mesh_builder3_Optimize,
2328 d3drm_mesh_builder3_AddFacesIndexed,
2329 d3drm_mesh_builder3_CreateSubMesh,
2330 d3drm_mesh_builder3_GetParentMesh,
2331 d3drm_mesh_builder3_GetSubMeshes,
2332 d3drm_mesh_builder3_DeleteSubMesh,
2333 d3drm_mesh_builder3_Enable,
2334 d3drm_mesh_builder3_GetEnable,
2335 d3drm_mesh_builder3_AddTriangles,
2336 d3drm_mesh_builder3_SetVertices,
2337 d3drm_mesh_builder3_GetVertices,
2338 d3drm_mesh_builder3_SetNormals,
2339 d3drm_mesh_builder3_GetNormals,
2340 d3drm_mesh_builder3_GetNormalCount,
2343 HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm)
2345 static const char classname[] = "Builder";
2346 struct d3drm_mesh_builder *object;
2348 TRACE("mesh_builder %p.\n", mesh_builder);
2350 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2351 return E_OUTOFMEMORY;
2353 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &d3drm_mesh_builder2_vtbl;
2354 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &d3drm_mesh_builder3_vtbl;
2355 object->ref = 1;
2356 object->d3drm = d3drm;
2357 IDirect3DRM_AddRef(object->d3drm);
2359 d3drm_object_init(&object->obj, classname);
2361 *mesh_builder = object;
2363 return S_OK;
2366 static HRESULT WINAPI d3drm_mesh_QueryInterface(IDirect3DRMMesh *iface, REFIID riid, void **out)
2368 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2370 if (IsEqualGUID(riid, &IID_IDirect3DRMMesh)
2371 || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
2372 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
2373 || IsEqualGUID(riid, &IID_IUnknown))
2375 IDirect3DRMMesh_AddRef(iface);
2376 *out = iface;
2377 return S_OK;
2380 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
2382 *out = NULL;
2383 return E_NOINTERFACE;
2386 static ULONG WINAPI d3drm_mesh_AddRef(IDirect3DRMMesh *iface)
2388 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2389 ULONG refcount = InterlockedIncrement(&mesh->ref);
2391 TRACE("%p increasing refcount to %u.\n", iface, refcount);
2393 return refcount;
2396 static ULONG WINAPI d3drm_mesh_Release(IDirect3DRMMesh *iface)
2398 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2399 ULONG refcount = InterlockedDecrement(&mesh->ref);
2401 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
2403 if (!refcount)
2405 DWORD i;
2407 d3drm_object_cleanup((IDirect3DRMObject *)iface, &mesh->obj);
2408 IDirect3DRM_Release(mesh->d3drm);
2409 for (i = 0; i < mesh->nb_groups; ++i)
2411 HeapFree(GetProcessHeap(), 0, mesh->groups[i].vertices);
2412 HeapFree(GetProcessHeap(), 0, mesh->groups[i].face_data);
2413 if (mesh->groups[i].material)
2414 IDirect3DRMMaterial2_Release(mesh->groups[i].material);
2415 if (mesh->groups[i].texture)
2416 IDirect3DRMTexture3_Release(mesh->groups[i].texture);
2418 HeapFree(GetProcessHeap(), 0, mesh->groups);
2419 HeapFree(GetProcessHeap(), 0, mesh);
2422 return refcount;
2425 static HRESULT WINAPI d3drm_mesh_Clone(IDirect3DRMMesh *iface,
2426 IUnknown *outer, REFIID iid, void **out)
2428 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
2430 return E_NOTIMPL;
2433 static HRESULT WINAPI d3drm_mesh_AddDestroyCallback(IDirect3DRMMesh *iface,
2434 D3DRMOBJECTCALLBACK cb, void *ctx)
2436 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2438 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
2440 return d3drm_object_add_destroy_callback(&mesh->obj, cb, ctx);
2443 static HRESULT WINAPI d3drm_mesh_DeleteDestroyCallback(IDirect3DRMMesh *iface,
2444 D3DRMOBJECTCALLBACK cb, void *ctx)
2446 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2448 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
2450 return d3drm_object_delete_destroy_callback(&mesh->obj, cb, ctx);
2453 static HRESULT WINAPI d3drm_mesh_SetAppData(IDirect3DRMMesh *iface, DWORD data)
2455 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2457 TRACE("iface %p, data %#x.\n", iface, data);
2459 mesh->obj.appdata = data;
2461 return D3DRM_OK;
2464 static DWORD WINAPI d3drm_mesh_GetAppData(IDirect3DRMMesh *iface)
2466 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2468 TRACE("iface %p.\n", iface);
2470 return mesh->obj.appdata;
2473 static HRESULT WINAPI d3drm_mesh_SetName(IDirect3DRMMesh *iface, const char *name)
2475 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2477 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2479 return d3drm_object_set_name(&mesh->obj, name);
2482 static HRESULT WINAPI d3drm_mesh_GetName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2484 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2486 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2488 return d3drm_object_get_name(&mesh->obj, size, name);
2491 static HRESULT WINAPI d3drm_mesh_GetClassName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2493 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2495 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2497 return d3drm_object_get_class_name(&mesh->obj, size, name);
2500 static HRESULT WINAPI d3drm_mesh_Scale(IDirect3DRMMesh *iface,
2501 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2503 FIXME("iface %p, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, sx, sy, sz);
2505 return E_NOTIMPL;
2508 static HRESULT WINAPI d3drm_mesh_Translate(IDirect3DRMMesh *iface,
2509 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2511 FIXME("iface %p, tx %.8e, ty %.8e, tz %.8e stub!\n", iface, tx, ty, tz);
2513 return E_NOTIMPL;
2516 static HRESULT WINAPI d3drm_mesh_GetBox(IDirect3DRMMesh *iface, D3DRMBOX *box)
2518 FIXME("iface %p, box %p stub!\n", iface, box);
2520 return E_NOTIMPL;
2523 static HRESULT WINAPI d3drm_mesh_AddGroup(IDirect3DRMMesh *iface, unsigned vertex_count,
2524 unsigned face_count, unsigned vertex_per_face, unsigned *face_data, D3DRMGROUPINDEX *id)
2526 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2527 struct mesh_group *group;
2529 TRACE("iface %p, vertex_count %u, face_count %u, vertex_per_face %u, face_data %p, id %p.\n",
2530 iface, vertex_count, face_count, vertex_per_face, face_data, id);
2532 if (!face_data || !id)
2533 return E_POINTER;
2535 if (!d3drm_array_reserve((void **)&mesh->groups, &mesh->groups_size, mesh->nb_groups + 1, sizeof(*mesh->groups)))
2536 return E_OUTOFMEMORY;
2538 group = mesh->groups + mesh->nb_groups;
2540 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2541 if (!group->vertices)
2542 return E_OUTOFMEMORY;
2543 group->nb_vertices = vertex_count;
2544 group->nb_faces = face_count;
2545 group->vertex_per_face = vertex_per_face;
2547 if (vertex_per_face)
2549 group->face_data_size = face_count * vertex_per_face;
2551 else
2553 unsigned i;
2554 unsigned nb_indices;
2555 unsigned* face_data_ptr = face_data;
2556 group->face_data_size = 0;
2558 for (i = 0; i < face_count; i++)
2560 nb_indices = *face_data_ptr;
2561 group->face_data_size += nb_indices + 1;
2562 face_data_ptr += nb_indices;
2566 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2567 if (!group->face_data)
2569 HeapFree(GetProcessHeap(), 0 , group->vertices);
2570 return E_OUTOFMEMORY;
2573 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2575 group->material = NULL;
2576 group->texture = NULL;
2578 *id = mesh->nb_groups++;
2580 return D3DRM_OK;
2583 static HRESULT WINAPI d3drm_mesh_SetVertices(IDirect3DRMMesh *iface, D3DRMGROUPINDEX group_id,
2584 unsigned int start_idx, unsigned int count, D3DRMVERTEX *values)
2586 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2588 TRACE("iface %p, group_id %#x, start_idx %u, count %u, values %p.\n",
2589 iface, group_id, start_idx, count, values);
2591 if (group_id >= mesh->nb_groups)
2592 return D3DRMERR_BADVALUE;
2594 if ((start_idx + count - 1) >= mesh->groups[group_id].nb_vertices)
2595 return D3DRMERR_BADVALUE;
2597 if (!values)
2598 return E_POINTER;
2600 memcpy(mesh->groups[group_id].vertices + start_idx, values, count * sizeof(*values));
2602 return D3DRM_OK;
2605 static HRESULT WINAPI d3drm_mesh_SetGroupColor(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id, D3DCOLOR color)
2607 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2609 TRACE("iface %p, id %#x, color 0x%08x.\n", iface, id, color);
2611 if (id >= mesh->nb_groups)
2612 return D3DRMERR_BADVALUE;
2614 mesh->groups[id].color = color;
2616 return D3DRM_OK;
2619 static HRESULT WINAPI d3drm_mesh_SetGroupColorRGB(IDirect3DRMMesh *iface,
2620 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2622 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2624 TRACE("iface %p, id %#x, red %.8e, green %.8e, blue %.8e.\n", iface, id, red, green, blue);
2626 if (id >= mesh->nb_groups)
2627 return D3DRMERR_BADVALUE;
2629 d3drm_set_color(&mesh->groups[id].color, red, green, blue, 1.0f);
2631 return D3DRM_OK;
2634 static HRESULT WINAPI d3drm_mesh_SetGroupMapping(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id, D3DRMMAPPING value)
2636 FIXME("iface %p, id %#x, value %#x stub!\n", iface, id, value);
2638 return E_NOTIMPL;
2641 static HRESULT WINAPI d3drm_mesh_SetGroupQuality(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2643 FIXME("iface %p, id %#x, value %#x stub!\n", iface, id, value);
2645 return E_NOTIMPL;
2648 static HRESULT WINAPI d3drm_mesh_SetGroupMaterial(IDirect3DRMMesh *iface,
2649 D3DRMGROUPINDEX id, IDirect3DRMMaterial *material)
2651 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2653 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2655 if (id >= mesh->nb_groups)
2656 return D3DRMERR_BADVALUE;
2658 if (mesh->groups[id].material)
2659 IDirect3DRMMaterial2_Release(mesh->groups[id].material);
2661 mesh->groups[id].material = (IDirect3DRMMaterial2 *)material;
2663 if (material)
2664 IDirect3DRMMaterial2_AddRef(mesh->groups[id].material);
2666 return D3DRM_OK;
2669 static HRESULT WINAPI d3drm_mesh_SetGroupTexture(IDirect3DRMMesh *iface,
2670 D3DRMGROUPINDEX id, IDirect3DRMTexture *texture)
2672 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2674 TRACE("iface %p, id %#x, texture %p.\n", iface, id, texture);
2676 if (id >= mesh->nb_groups)
2677 return D3DRMERR_BADVALUE;
2679 if (mesh->groups[id].texture)
2680 IDirect3DRMTexture3_Release(mesh->groups[id].texture);
2682 if (!texture)
2684 mesh->groups[id].texture = NULL;
2685 return D3DRM_OK;
2688 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (void **)&mesh->groups[id].texture);
2691 static DWORD WINAPI d3drm_mesh_GetGroupCount(IDirect3DRMMesh *iface)
2693 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2695 TRACE("iface %p.\n", iface);
2697 return mesh->nb_groups;
2700 static HRESULT WINAPI d3drm_mesh_GetGroup(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id, unsigned *vertex_count,
2701 unsigned *face_count, unsigned *vertex_per_face, DWORD *face_data_size, unsigned *face_data)
2703 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2705 TRACE("iface %p, id %#x, vertex_count %p, face_count %p, vertex_per_face %p, face_data_size %p, face_data %p.\n",
2706 iface, id, vertex_count, face_count, vertex_per_face, face_data_size,face_data);
2708 if (id >= mesh->nb_groups)
2709 return D3DRMERR_BADVALUE;
2711 if (vertex_count)
2712 *vertex_count = mesh->groups[id].nb_vertices;
2713 if (face_count)
2714 *face_count = mesh->groups[id].nb_faces;
2715 if (vertex_per_face)
2716 *vertex_per_face = mesh->groups[id].vertex_per_face;
2717 if (face_data_size)
2718 *face_data_size = mesh->groups[id].face_data_size;
2719 if (face_data)
2720 memcpy(face_data, mesh->groups[id].face_data, mesh->groups[id].face_data_size * sizeof(*face_data));
2722 return D3DRM_OK;
2725 static HRESULT WINAPI d3drm_mesh_GetVertices(IDirect3DRMMesh *iface,
2726 D3DRMGROUPINDEX group_id, DWORD start_idx, DWORD count, D3DRMVERTEX *vertices)
2728 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2730 TRACE("iface %p, group_id %#x, start_idx %u, count %u, vertices %p.\n",
2731 iface, group_id, start_idx, count, vertices);
2733 if (group_id >= mesh->nb_groups)
2734 return D3DRMERR_BADVALUE;
2736 if ((start_idx + count - 1) >= mesh->groups[group_id].nb_vertices)
2737 return D3DRMERR_BADVALUE;
2739 if (!vertices)
2740 return E_POINTER;
2742 memcpy(vertices, mesh->groups[group_id].vertices + start_idx, count * sizeof(*vertices));
2744 return D3DRM_OK;
2747 static D3DCOLOR WINAPI d3drm_mesh_GetGroupColor(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id)
2749 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2751 TRACE("iface %p, id %#x.\n", iface, id);
2753 return mesh->groups[id].color;
2756 static D3DRMMAPPING WINAPI d3drm_mesh_GetGroupMapping(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id)
2758 FIXME("iface %p, id %#x stub!\n", iface, id);
2760 return 0;
2762 static D3DRMRENDERQUALITY WINAPI d3drm_mesh_GetGroupQuality(IDirect3DRMMesh *iface, D3DRMGROUPINDEX id)
2764 FIXME("iface %p, id %#x stub!\n", iface, id);
2766 return 0;
2769 static HRESULT WINAPI d3drm_mesh_GetGroupMaterial(IDirect3DRMMesh *iface,
2770 D3DRMGROUPINDEX id, IDirect3DRMMaterial **material)
2772 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2774 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2776 if (id >= mesh->nb_groups)
2777 return D3DRMERR_BADVALUE;
2779 if (!material)
2780 return E_POINTER;
2782 if (mesh->groups[id].material)
2783 IDirect3DRMTexture_QueryInterface(mesh->groups[id].material, &IID_IDirect3DRMMaterial, (void **)material);
2784 else
2785 *material = NULL;
2787 return D3DRM_OK;
2790 static HRESULT WINAPI d3drm_mesh_GetGroupTexture(IDirect3DRMMesh *iface,
2791 D3DRMGROUPINDEX id, IDirect3DRMTexture **texture)
2793 struct d3drm_mesh *mesh = impl_from_IDirect3DRMMesh(iface);
2795 TRACE("iface %p, id %#x, texture %p.\n", iface, id, texture);
2797 if (id >= mesh->nb_groups)
2798 return D3DRMERR_BADVALUE;
2800 if (!texture)
2801 return E_POINTER;
2803 if (mesh->groups[id].texture)
2804 IDirect3DRMTexture_QueryInterface(mesh->groups[id].texture, &IID_IDirect3DRMTexture, (void **)texture);
2805 else
2806 *texture = NULL;
2808 return D3DRM_OK;
2811 static const struct IDirect3DRMMeshVtbl d3drm_mesh_vtbl =
2813 d3drm_mesh_QueryInterface,
2814 d3drm_mesh_AddRef,
2815 d3drm_mesh_Release,
2816 d3drm_mesh_Clone,
2817 d3drm_mesh_AddDestroyCallback,
2818 d3drm_mesh_DeleteDestroyCallback,
2819 d3drm_mesh_SetAppData,
2820 d3drm_mesh_GetAppData,
2821 d3drm_mesh_SetName,
2822 d3drm_mesh_GetName,
2823 d3drm_mesh_GetClassName,
2824 d3drm_mesh_Scale,
2825 d3drm_mesh_Translate,
2826 d3drm_mesh_GetBox,
2827 d3drm_mesh_AddGroup,
2828 d3drm_mesh_SetVertices,
2829 d3drm_mesh_SetGroupColor,
2830 d3drm_mesh_SetGroupColorRGB,
2831 d3drm_mesh_SetGroupMapping,
2832 d3drm_mesh_SetGroupQuality,
2833 d3drm_mesh_SetGroupMaterial,
2834 d3drm_mesh_SetGroupTexture,
2835 d3drm_mesh_GetGroupCount,
2836 d3drm_mesh_GetGroup,
2837 d3drm_mesh_GetVertices,
2838 d3drm_mesh_GetGroupColor,
2839 d3drm_mesh_GetGroupMapping,
2840 d3drm_mesh_GetGroupQuality,
2841 d3drm_mesh_GetGroupMaterial,
2842 d3drm_mesh_GetGroupTexture,
2845 HRESULT d3drm_mesh_create(struct d3drm_mesh **mesh, IDirect3DRM *d3drm)
2847 static const char classname[] = "Mesh";
2848 struct d3drm_mesh *object;
2850 TRACE("mesh %p, d3drm %p.\n", mesh, d3drm);
2852 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2853 return E_OUTOFMEMORY;
2855 object->IDirect3DRMMesh_iface.lpVtbl = &d3drm_mesh_vtbl;
2856 object->ref = 1;
2857 object->d3drm = d3drm;
2858 IDirect3DRM_AddRef(object->d3drm);
2860 d3drm_object_init(&object->obj, classname);
2862 *mesh = object;
2864 return S_OK;
2867 static HRESULT WINAPI d3drm_wrap_QueryInterface(IDirect3DRMWrap *iface, REFIID riid, void **out)
2869 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
2871 if (IsEqualGUID(riid, &IID_IDirect3DRMWrap)
2872 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
2873 || IsEqualGUID(riid, &IID_IUnknown))
2875 IDirect3DRMWrap_AddRef(iface);
2876 *out = iface;
2877 return S_OK;
2880 WARN("%s not implemented.\n", debugstr_guid(riid));
2882 *out = NULL;
2883 return CLASS_E_CLASSNOTAVAILABLE;
2886 static ULONG WINAPI d3drm_wrap_AddRef(IDirect3DRMWrap *iface)
2888 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2889 ULONG refcount = InterlockedIncrement(&wrap->ref);
2891 TRACE("%p increasing refcount to %u.\n", iface, refcount);
2893 return refcount;
2896 static ULONG WINAPI d3drm_wrap_Release(IDirect3DRMWrap *iface)
2898 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2899 ULONG refcount = InterlockedDecrement(&wrap->ref);
2901 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
2903 if (!refcount)
2905 d3drm_object_cleanup((IDirect3DRMObject *)iface, &wrap->obj);
2906 HeapFree(GetProcessHeap(), 0, wrap);
2909 return refcount;
2912 static HRESULT WINAPI d3drm_wrap_Clone(IDirect3DRMWrap *iface,
2913 IUnknown *outer, REFIID iid, void **out)
2915 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
2917 return E_NOTIMPL;
2920 static HRESULT WINAPI d3drm_wrap_AddDestroyCallback(IDirect3DRMWrap *iface,
2921 D3DRMOBJECTCALLBACK cb, void *ctx)
2923 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2925 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
2927 return d3drm_object_add_destroy_callback(&wrap->obj, cb, ctx);
2930 static HRESULT WINAPI d3drm_wrap_DeleteDestroyCallback(IDirect3DRMWrap *iface,
2931 D3DRMOBJECTCALLBACK cb, void *ctx)
2933 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2935 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
2937 return d3drm_object_delete_destroy_callback(&wrap->obj, cb, ctx);
2940 static HRESULT WINAPI d3drm_wrap_SetAppData(IDirect3DRMWrap *iface, DWORD data)
2942 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2944 TRACE("iface %p, data %#x.\n", iface, data);
2946 wrap->obj.appdata = data;
2948 return D3DRM_OK;
2951 static DWORD WINAPI d3drm_wrap_GetAppData(IDirect3DRMWrap *iface)
2953 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2955 TRACE("iface %p.\n", iface);
2957 return wrap->obj.appdata;
2960 static HRESULT WINAPI d3drm_wrap_SetName(IDirect3DRMWrap *iface, const char *name)
2962 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2964 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
2966 return d3drm_object_set_name(&wrap->obj, name);
2969 static HRESULT WINAPI d3drm_wrap_GetName(IDirect3DRMWrap *iface, DWORD *size, char *name)
2971 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2973 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2975 return d3drm_object_get_name(&wrap->obj, size, name);
2978 static HRESULT WINAPI d3drm_wrap_GetClassName(IDirect3DRMWrap *iface, DWORD *size, char *name)
2980 struct d3drm_wrap *wrap = impl_from_IDirect3DRMWrap(iface);
2982 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2984 return d3drm_object_get_class_name(&wrap->obj, size, name);
2987 static HRESULT WINAPI d3drm_wrap_Init(IDirect3DRMWrap *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame *reference,
2988 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux,
2989 D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv)
2991 FIXME("iface %p, type %d, reference frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, ux %.8e, "
2992 "uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e.\n", iface, type, reference, ox, oy, oz, dx, dy, dz,
2993 ux, uy, uz, ou, ov, su, sv);
2995 return E_NOTIMPL;
2998 static HRESULT WINAPI d3drm_wrap_Apply(IDirect3DRMWrap *iface, IDirect3DRMObject *object)
3000 FIXME("iface %p, object %p.\n", iface, object);
3002 return E_NOTIMPL;
3005 static HRESULT WINAPI d3drm_wrap_ApplyRelative(IDirect3DRMWrap *iface, IDirect3DRMFrame *frame,
3006 IDirect3DRMObject *object)
3008 FIXME("iface %p, frame %p, object %p.\n", iface, frame, object);
3010 return E_NOTIMPL;
3013 static const struct IDirect3DRMWrapVtbl d3drm_wrap_vtbl =
3015 d3drm_wrap_QueryInterface,
3016 d3drm_wrap_AddRef,
3017 d3drm_wrap_Release,
3018 d3drm_wrap_Clone,
3019 d3drm_wrap_AddDestroyCallback,
3020 d3drm_wrap_DeleteDestroyCallback,
3021 d3drm_wrap_SetAppData,
3022 d3drm_wrap_GetAppData,
3023 d3drm_wrap_SetName,
3024 d3drm_wrap_GetName,
3025 d3drm_wrap_GetClassName,
3026 d3drm_wrap_Init,
3027 d3drm_wrap_Apply,
3028 d3drm_wrap_ApplyRelative,
3031 HRESULT d3drm_wrap_create(struct d3drm_wrap **wrap, IDirect3DRM *d3drm)
3033 static const char classname[] = "";
3034 struct d3drm_wrap *object;
3036 TRACE("wrap %p, d3drm %p.\n", wrap, d3drm);
3038 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
3039 return E_OUTOFMEMORY;
3041 object->IDirect3DRMWrap_iface.lpVtbl = &d3drm_wrap_vtbl;
3042 object->ref = 1;
3044 d3drm_object_init(&object->obj, classname);
3046 *wrap = object;
3048 return S_OK;