d3drm: Get rid of the mesh_group typedef.
[wine.git] / dlls / d3drm / meshbuilder.c
blobf01d440872c78bed525a0e9a1f10c204b1558e78
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 #define NONAMELESSUNION
24 #define COBJMACROS
26 #include "wine/debug.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "dxfile.h"
31 #include "rmxfguid.h"
33 #include "d3drm_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
37 struct mesh_group
39 unsigned nb_vertices;
40 D3DRMVERTEX* vertices;
41 unsigned nb_faces;
42 unsigned vertex_per_face;
43 DWORD face_data_size;
44 unsigned* face_data;
45 D3DCOLOR color;
46 IDirect3DRMMaterial2* material;
47 IDirect3DRMTexture3* texture;
50 typedef struct {
51 IDirect3DRMMesh IDirect3DRMMesh_iface;
52 LONG ref;
53 DWORD groups_capacity;
54 DWORD nb_groups;
55 struct mesh_group *groups;
56 } IDirect3DRMMeshImpl;
58 typedef struct {
59 D3DVALUE u;
60 D3DVALUE v;
61 } Coords2d;
63 typedef struct {
64 D3DCOLOR color;
65 IDirect3DRMMaterial2 *material;
66 IDirect3DRMTexture3 *texture;
67 } mesh_material;
69 typedef struct {
70 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
71 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
72 LONG ref;
73 char* name;
74 DWORD nb_vertices;
75 D3DVECTOR* pVertices;
76 DWORD nb_normals;
77 D3DVECTOR* pNormals;
78 DWORD nb_faces;
79 DWORD face_data_size;
80 void *pFaceData;
81 DWORD nb_coords2d;
82 Coords2d *pCoords2d;
83 D3DCOLOR color;
84 IDirect3DRMMaterial2 *material;
85 IDirect3DRMTexture3 *texture;
86 DWORD nb_materials;
87 mesh_material *materials;
88 DWORD *material_indices;
89 } IDirect3DRMMeshBuilderImpl;
91 char templates[] = {
92 "xof 0302txt 0064"
93 "template Header"
94 "{"
95 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
96 "WORD major;"
97 "WORD minor;"
98 "DWORD flags;"
99 "}"
100 "template Vector"
102 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
103 "FLOAT x;"
104 "FLOAT y;"
105 "FLOAT z;"
107 "template Coords2d"
109 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
110 "FLOAT u;"
111 "FLOAT v;"
113 "template Matrix4x4"
115 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
116 "array FLOAT matrix[16];"
118 "template ColorRGBA"
120 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
121 "FLOAT red;"
122 "FLOAT green;"
123 "FLOAT blue;"
124 "FLOAT alpha;"
126 "template ColorRGB"
128 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
129 "FLOAT red;"
130 "FLOAT green;"
131 "FLOAT blue;"
133 "template IndexedColor"
135 "<1630B820-7842-11CF-8F52-0040333594A3>"
136 "DWORD index;"
137 "ColorRGBA indexColor;"
139 "template Boolean"
141 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
142 "DWORD truefalse;"
144 "template Boolean2d"
146 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
147 "Boolean u;"
148 "Boolean v;"
150 "template MaterialWrap"
152 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
153 "Boolean u;"
154 "Boolean v;"
156 "template TextureFilename"
158 "<A42790E1-7810-11CF-8F52-0040333594A3>"
159 "STRING filename;"
161 "template Material"
163 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
164 "ColorRGBA faceColor;"
165 "FLOAT power;"
166 "ColorRGB specularColor;"
167 "ColorRGB emissiveColor;"
168 "[...]"
170 "template MeshFace"
172 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
173 "DWORD nFaceVertexIndices;"
174 "array DWORD faceVertexIndices[nFaceVertexIndices];"
176 "template MeshFaceWraps"
178 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
179 "DWORD nFaceWrapValues;"
180 "array Boolean2d faceWrapValues[nFaceWrapValues];"
182 "template MeshTextureCoords"
184 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
185 "DWORD nTextureCoords;"
186 "array Coords2d textureCoords[nTextureCoords];"
188 "template MeshMaterialList"
190 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
191 "DWORD nMaterials;"
192 "DWORD nFaceIndexes;"
193 "array DWORD faceIndexes[nFaceIndexes];"
194 "[Material]"
196 "template MeshNormals"
198 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
199 "DWORD nNormals;"
200 "array Vector normals[nNormals];"
201 "DWORD nFaceNormals;"
202 "array MeshFace faceNormals[nFaceNormals];"
204 "template MeshVertexColors"
206 "<1630B821-7842-11CF-8F52-0040333594A3>"
207 "DWORD nVertexColors;"
208 "array IndexedColor vertexColors[nVertexColors];"
210 "template Mesh"
212 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
213 "DWORD nVertices;"
214 "array Vector vertices[nVertices];"
215 "DWORD nFaces;"
216 "array MeshFace faces[nFaces];"
217 "[...]"
219 "template FrameTransformMatrix"
221 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
222 "Matrix4x4 frameMatrix;"
224 "template Frame"
226 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
227 "[...]"
229 "template FloatKeys"
231 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
232 "DWORD nValues;"
233 "array FLOAT values[nValues];"
235 "template TimedFloatKeys"
237 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
238 "DWORD time;"
239 "FloatKeys tfkeys;"
241 "template AnimationKey"
243 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
244 "DWORD keyType;"
245 "DWORD nKeys;"
246 "array TimedFloatKeys keys[nKeys];"
248 "template AnimationOptions"
250 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
251 "DWORD openclosed;"
252 "DWORD positionquality;"
254 "template Animation"
256 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
257 "[...]"
259 "template AnimationSet"
261 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
262 "[Animation]"
264 "template InlineData"
266 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
267 "[BINARY]"
269 "template Url"
271 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
272 "DWORD nUrls;"
273 "array STRING urls[nUrls];"
275 "template ProgressiveMesh"
277 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
278 "[Url,InlineData]"
280 "template Guid"
282 "<A42790E0-7810-11CF-8F52-0040333594A3>"
283 "DWORD data1;"
284 "WORD data2;"
285 "WORD data3;"
286 "array UCHAR data4[8];"
288 "template StringProperty"
290 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
291 "STRING key;"
292 "STRING value;"
294 "template PropertyBag"
296 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
297 "[StringProperty]"
299 "template ExternalVisual"
301 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
302 "Guid guidExternalVisual;"
303 "[...]"
305 "template RightHanded"
307 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
308 "DWORD bRightHanded;"
312 static inline IDirect3DRMMeshImpl *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
314 return CONTAINING_RECORD(iface, IDirect3DRMMeshImpl, IDirect3DRMMesh_iface);
317 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
319 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder2_iface);
322 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
324 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder3_iface);
327 static void clean_mesh_builder_data(IDirect3DRMMeshBuilderImpl *mesh_builder)
329 DWORD i;
331 HeapFree(GetProcessHeap(), 0, mesh_builder->name);
332 mesh_builder->name = NULL;
333 HeapFree(GetProcessHeap(), 0, mesh_builder->pVertices);
334 mesh_builder->pVertices = NULL;
335 mesh_builder->nb_vertices = 0;
336 HeapFree(GetProcessHeap(), 0, mesh_builder->pNormals);
337 mesh_builder->pNormals = NULL;
338 mesh_builder->nb_normals = 0;
339 HeapFree(GetProcessHeap(), 0, mesh_builder->pFaceData);
340 mesh_builder->pFaceData = NULL;
341 mesh_builder->face_data_size = 0;
342 mesh_builder->nb_faces = 0;
343 HeapFree(GetProcessHeap(), 0, mesh_builder->pCoords2d);
344 mesh_builder->pCoords2d = NULL;
345 mesh_builder->nb_coords2d = 0;
346 for (i = 0; i < mesh_builder->nb_materials; i++)
348 if (mesh_builder->materials[i].material)
349 IDirect3DRMMaterial2_Release(mesh_builder->materials[i].material);
350 if (mesh_builder->materials[i].texture)
351 IDirect3DRMTexture3_Release(mesh_builder->materials[i].texture);
353 mesh_builder->nb_materials = 0;
354 HeapFree(GetProcessHeap(), 0, mesh_builder->materials);
355 HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices);
358 /*** IUnknown methods ***/
359 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2* iface,
360 REFIID riid, void** ppvObject)
362 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
364 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
366 *ppvObject = NULL;
368 if(IsEqualGUID(riid, &IID_IUnknown) ||
369 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder) ||
370 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2))
372 *ppvObject = &This->IDirect3DRMMeshBuilder2_iface;
374 else if(IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
376 *ppvObject = &This->IDirect3DRMMeshBuilder3_iface;
378 else
380 FIXME("interface %s not implemented\n", debugstr_guid(riid));
381 return E_NOINTERFACE;
384 IDirect3DRMMeshBuilder_AddRef(iface);
385 return S_OK;
388 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2* iface)
390 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
391 ULONG ref = InterlockedIncrement(&This->ref);
393 TRACE("(%p)->(): new ref = %d\n", This, ref);
395 return ref;
398 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2* iface)
400 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
401 ULONG ref = InterlockedDecrement(&This->ref);
403 TRACE("(%p)->(): new ref = %d\n", This, ref);
405 if (!ref)
407 clean_mesh_builder_data(This);
408 if (This->material)
409 IDirect3DRMMaterial2_Release(This->material);
410 if (This->texture)
411 IDirect3DRMTexture3_Release(This->texture);
412 HeapFree(GetProcessHeap(), 0, This);
415 return ref;
418 /*** IDirect3DRMObject methods ***/
419 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2 *iface,
420 IUnknown *outer, REFIID iid, void **out)
422 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
424 return E_NOTIMPL;
427 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
428 D3DRMOBJECTCALLBACK cb, void *ctx)
430 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
432 return E_NOTIMPL;
435 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
436 D3DRMOBJECTCALLBACK cb, void *ctx)
438 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
440 return E_NOTIMPL;
443 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
444 DWORD data)
446 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
448 FIXME("(%p)->(%u): stub\n", This, data);
450 return E_NOTIMPL;
453 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
455 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
457 FIXME("(%p)->(): stub\n", This);
459 return 0;
462 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2 *iface, const char *name)
464 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
466 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
468 return IDirect3DRMMeshBuilder3_SetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, name);
471 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2 *iface, DWORD *size, char *name)
473 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
475 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
477 return IDirect3DRMMeshBuilder3_GetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
480 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2 *iface,
481 DWORD *size, char *name)
483 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
485 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
487 return IDirect3DRMMeshBuilder3_GetClassName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
490 /*** IDirect3DRMMeshBuilder2 methods ***/
491 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2 *iface, void *filename,
492 void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURECALLBACK cb, void *ctx)
494 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
496 TRACE("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p.\n",
497 iface, filename, name, flags, cb, ctx);
499 if (cb)
500 FIXME("Texture callback is not yet supported\n");
502 return IDirect3DRMMeshBuilder3_Load(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
503 filename, name, flags, NULL, ctx);
506 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
507 const char *filename, D3DRMXOFFORMAT format,
508 D3DRMSAVEOPTIONS save)
510 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
512 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
514 return E_NOTIMPL;
517 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
518 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
520 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
522 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
524 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
527 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
528 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
530 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
532 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
534 return E_NOTIMPL;
537 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
538 D3DRMCOLORSOURCE color)
540 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
542 FIXME("(%p)->(%x): stub\n", This, color);
544 return E_NOTIMPL;
547 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
548 D3DRMBOX *pBox)
550 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
552 FIXME("(%p)->(%p): stub\n", This, pBox);
554 return E_NOTIMPL;
557 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
559 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
561 FIXME("(%p)->(): stub\n", This);
563 return E_NOTIMPL;
566 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
568 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
570 FIXME("(%p)->(): stub\n", This);
572 return E_NOTIMPL;
575 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh *mesh)
577 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
579 return E_NOTIMPL;
582 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2 *iface,
583 IDirect3DRMMeshBuilder *mesh_builder)
585 FIXME("iface %p, mesh_builder %p stub!\n", iface, mesh_builder);
587 return E_NOTIMPL;
590 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFrame *frame)
592 FIXME("iface %p, frame %p stub!\n", iface, frame);
594 return E_NOTIMPL;
597 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace *face)
599 FIXME("iface %p, face %p stub!\n", iface, face);
601 return E_NOTIMPL;
604 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2 *iface,
605 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
606 DWORD *face_data, IDirect3DRMFaceArray **array)
608 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p, array %p stub!\n",
609 iface, vertex_count, vertices, normal_count, normals, face_data, array);
611 return E_NOTIMPL;
614 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
615 DWORD vertex_Count,
616 DWORD normal_count,
617 DWORD face_count)
619 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
621 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
623 return E_NOTIMPL;
626 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
627 D3DVALUE red, D3DVALUE green,
628 D3DVALUE blue)
630 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
632 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
634 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
637 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
638 D3DCOLOR color)
640 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
642 TRACE("(%p)->(%x)\n", This, color);
644 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
647 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2 *iface,
648 IDirect3DRMTexture *texture)
650 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
651 IDirect3DRMTexture3 *texture3 = NULL;
652 HRESULT hr = D3DRM_OK;
654 if (texture)
655 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void **)&texture3);
656 if (SUCCEEDED(hr))
657 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
658 if (texture3)
659 IDirect3DRMTexture3_Release(texture3);
661 return hr;
664 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2 *iface,
665 IDirect3DRMMaterial *material)
667 IDirect3DRMMeshBuilderImpl *d3drm = impl_from_IDirect3DRMMeshBuilder2(iface);
669 TRACE("iface %p, material %p.\n", iface, material);
671 return IDirect3DRMMeshBuilder3_SetMaterial(&d3drm->IDirect3DRMMeshBuilder3_iface,
672 (IDirect3DRMMaterial2 *)material);
675 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
676 BOOL wrap_u, BOOL wrap_v)
678 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
680 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
682 return E_NOTIMPL;
685 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
686 D3DRMRENDERQUALITY quality)
688 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
690 FIXME("(%p)->(%d): stub\n", This, quality);
692 return E_NOTIMPL;
695 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
696 BOOL enable)
698 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
700 FIXME("(%p)->(%d): stub\n", This, enable);
702 return E_NOTIMPL;
705 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
706 DWORD index,
707 D3DVALUE x, D3DVALUE y, D3DVALUE z)
709 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
711 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
713 return E_NOTIMPL;
716 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
717 DWORD index,
718 D3DVALUE x, D3DVALUE y, D3DVALUE z)
720 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
722 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
724 return E_NOTIMPL;
727 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
728 DWORD index,
729 D3DVALUE u, D3DVALUE v)
731 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
733 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
735 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
736 index, u, v);
739 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
740 DWORD index, D3DCOLOR color)
742 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
744 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
746 return E_NOTIMPL;
749 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
750 DWORD index, D3DVALUE red,
751 D3DVALUE green, D3DVALUE blue)
753 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
755 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
757 return E_NOTIMPL;
760 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2 *iface,
761 IDirect3DRMFaceArray **array)
763 FIXME("iface %p, array %p stub!\n", iface, array);
765 return E_NOTIMPL;
768 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
769 DWORD *vcount, D3DVECTOR *vertices,
770 DWORD *ncount, D3DVECTOR *normals,
771 DWORD *face_data_size,
772 DWORD *face_data)
774 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
776 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
778 if (vertices && (!vcount || (*vcount < This->nb_vertices)))
779 return D3DRMERR_BADVALUE;
780 if (vcount)
781 *vcount = This->nb_vertices;
782 if (vertices && This->nb_vertices)
783 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
785 if (normals && (!ncount || (*ncount < This->nb_normals)))
786 return D3DRMERR_BADVALUE;
787 if (ncount)
788 *ncount = This->nb_normals;
789 if (normals && This->nb_normals)
790 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
792 if (face_data && (!face_data_size || (*face_data_size < This->face_data_size)))
793 return D3DRMERR_BADVALUE;
794 if (face_data_size)
795 *face_data_size = This->face_data_size;
796 if (face_data && This->face_data_size)
797 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
799 return D3DRM_OK;
802 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
803 DWORD index,
804 D3DVALUE *u, D3DVALUE *v)
806 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
808 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
810 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
811 index, u, v);
814 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
815 D3DVALUE x, D3DVALUE y, D3DVALUE z)
817 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
819 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
821 return 0;
824 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
825 D3DVALUE x, D3DVALUE y, D3DVALUE z)
827 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
829 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
831 return 0;
834 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace **face)
836 TRACE("iface %p, face %p.\n", iface, face);
838 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
841 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
843 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
845 FIXME("(%p)->(): stub\n", This);
847 return 0;
850 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
852 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
854 FIXME("(%p)->(): stub\n", This);
856 return FALSE;
859 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
861 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
863 TRACE("(%p)->()\n", This);
865 return This->nb_faces;
868 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
870 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
872 TRACE("(%p)->()\n", This);
874 return This->nb_vertices;
877 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
878 DWORD index)
880 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
882 FIXME("(%p)->(%d): stub\n", This, index);
884 return 0;
887 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh **mesh)
889 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
891 TRACE("iface %p, mesh %p.\n", iface, mesh);
893 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder->IDirect3DRMMeshBuilder3_iface, mesh);
896 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
897 D3DVALUE crease, DWORD dwFlags)
899 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
901 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
903 return E_NOTIMPL;
906 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2 *iface,
907 DWORD index, IDirect3DRMFace **face)
909 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
911 return E_NOTIMPL;
914 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
916 /*** IUnknown methods ***/
917 IDirect3DRMMeshBuilder2Impl_QueryInterface,
918 IDirect3DRMMeshBuilder2Impl_AddRef,
919 IDirect3DRMMeshBuilder2Impl_Release,
920 /*** IDirect3DRMObject methods ***/
921 IDirect3DRMMeshBuilder2Impl_Clone,
922 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
923 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
924 IDirect3DRMMeshBuilder2Impl_SetAppData,
925 IDirect3DRMMeshBuilder2Impl_GetAppData,
926 IDirect3DRMMeshBuilder2Impl_SetName,
927 IDirect3DRMMeshBuilder2Impl_GetName,
928 IDirect3DRMMeshBuilder2Impl_GetClassName,
929 /*** IDirect3DRMMeshBuilder methods ***/
930 IDirect3DRMMeshBuilder2Impl_Load,
931 IDirect3DRMMeshBuilder2Impl_Save,
932 IDirect3DRMMeshBuilder2Impl_Scale,
933 IDirect3DRMMeshBuilder2Impl_Translate,
934 IDirect3DRMMeshBuilder2Impl_SetColorSource,
935 IDirect3DRMMeshBuilder2Impl_GetBox,
936 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
937 IDirect3DRMMeshBuilder2Impl_GetColorSource,
938 IDirect3DRMMeshBuilder2Impl_AddMesh,
939 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
940 IDirect3DRMMeshBuilder2Impl_AddFrame,
941 IDirect3DRMMeshBuilder2Impl_AddFace,
942 IDirect3DRMMeshBuilder2Impl_AddFaces,
943 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
944 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
945 IDirect3DRMMeshBuilder2Impl_SetColor,
946 IDirect3DRMMeshBuilder2Impl_SetTexture,
947 IDirect3DRMMeshBuilder2Impl_SetMaterial,
948 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
949 IDirect3DRMMeshBuilder2Impl_SetQuality,
950 IDirect3DRMMeshBuilder2Impl_SetPerspective,
951 IDirect3DRMMeshBuilder2Impl_SetVertex,
952 IDirect3DRMMeshBuilder2Impl_SetNormal,
953 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
954 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
955 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
956 IDirect3DRMMeshBuilder2Impl_GetFaces,
957 IDirect3DRMMeshBuilder2Impl_GetVertices,
958 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
959 IDirect3DRMMeshBuilder2Impl_AddVertex,
960 IDirect3DRMMeshBuilder2Impl_AddNormal,
961 IDirect3DRMMeshBuilder2Impl_CreateFace,
962 IDirect3DRMMeshBuilder2Impl_GetQuality,
963 IDirect3DRMMeshBuilder2Impl_GetPerspective,
964 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
965 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
966 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
967 IDirect3DRMMeshBuilder2Impl_CreateMesh,
968 /*** IDirect3DRMMeshBuilder2 methods ***/
969 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
970 IDirect3DRMMeshBuilder2Impl_GetFace
974 /*** IUnknown methods ***/
975 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
976 REFIID riid, void** ppvObject)
978 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
979 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
982 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
984 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
985 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
988 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
990 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
991 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
994 /*** IDirect3DRMObject methods ***/
995 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3 *iface,
996 IUnknown *outer, REFIID iid, void **out)
998 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
1000 return E_NOTIMPL;
1003 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
1004 D3DRMOBJECTCALLBACK cb, void *ctx)
1006 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1008 return E_NOTIMPL;
1011 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
1012 D3DRMOBJECTCALLBACK cb, void *ctx)
1014 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1016 return E_NOTIMPL;
1019 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1020 DWORD data)
1022 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1024 FIXME("(%p)->(%u): stub\n", This, data);
1026 return E_NOTIMPL;
1029 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1031 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1033 FIXME("(%p)->(): stub\n", This);
1035 return 0;
1038 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3 *iface, const char *name)
1040 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1041 char *string = NULL;
1043 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1045 if (name)
1047 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1048 if (!string) return E_OUTOFMEMORY;
1049 strcpy(string, name);
1051 HeapFree(GetProcessHeap(), 0, mesh_builder->name);
1052 mesh_builder->name = string;
1054 return D3DRM_OK;
1057 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3 *iface,
1058 DWORD *size, char *name)
1060 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1062 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1064 if (!size)
1065 return E_POINTER;
1067 if (!mesh_builder->name)
1069 *size = 0;
1070 return D3DRM_OK;
1073 if (*size < (strlen(mesh_builder->name) + 1))
1074 return E_INVALIDARG;
1076 strcpy(name, mesh_builder->name);
1077 *size = strlen(mesh_builder->name) + 1;
1079 return D3DRM_OK;
1082 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3 *iface,
1083 DWORD *size, char *name)
1085 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1087 if (!size || *size < strlen("Builder") || !name)
1088 return E_INVALIDARG;
1090 strcpy(name, "Builder");
1091 *size = sizeof("Builder");
1093 return D3DRM_OK;
1096 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
1098 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1099 IDirectXFileData *pData2 = NULL;
1100 const GUID* guid;
1101 DWORD size;
1102 BYTE *ptr;
1103 HRESULT hr;
1104 HRESULT ret = D3DRMERR_BADOBJECT;
1105 DWORD* faces_vertex_idx_data = NULL;
1106 DWORD* faces_vertex_idx_ptr;
1107 DWORD faces_vertex_idx_size;
1108 DWORD* faces_normal_idx_data = NULL;
1109 DWORD* faces_normal_idx_ptr = NULL;
1110 DWORD* faces_data_ptr;
1111 DWORD faces_data_size = 0;
1112 DWORD i;
1114 TRACE("(%p)->(%p)\n", This, pData);
1116 hr = IDirectXFileData_GetName(pData, NULL, &size);
1117 if (hr != DXFILE_OK)
1118 return hr;
1119 if (size)
1121 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1122 if (!This->name)
1123 return E_OUTOFMEMORY;
1125 hr = IDirectXFileData_GetName(pData, This->name, &size);
1126 if (hr != DXFILE_OK)
1127 return hr;
1130 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1132 This->nb_normals = 0;
1134 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1135 if (hr != DXFILE_OK)
1136 goto end;
1138 This->nb_vertices = *(DWORD*)ptr;
1139 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1140 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1141 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1143 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1145 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1146 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1148 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1149 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1151 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1152 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2);
1153 faces_data_ptr = (DWORD*)This->pFaceData;
1155 while (1)
1157 IDirectXFileObject *object;
1159 hr = IDirectXFileData_GetNextObject(pData, &object);
1160 if (hr == DXFILEERR_NOMOREOBJECTS)
1162 TRACE("No more object\n");
1163 break;
1165 if (hr != DXFILE_OK)
1166 goto end;
1168 hr = IDirectXFileObject_QueryInterface(object, &IID_IDirectXFileData, (void**)&pData2);
1169 IDirectXFileObject_Release(object);
1170 if (hr != DXFILE_OK)
1171 goto end;
1173 hr = IDirectXFileData_GetType(pData2, &guid);
1174 if (hr != DXFILE_OK)
1175 goto end;
1177 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1179 if (IsEqualGUID(guid, &TID_D3DRMMeshNormals))
1181 DWORD nb_faces_normals;
1182 DWORD faces_normal_idx_size;
1184 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1185 if (hr != DXFILE_OK)
1186 goto end;
1188 This->nb_normals = *(DWORD*)ptr;
1189 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1191 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1192 if (nb_faces_normals != This->nb_faces)
1193 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1195 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1196 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1198 faces_normal_idx_size = size - (2 * sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1199 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1200 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1202 else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords))
1204 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1205 if (hr != DXFILE_OK)
1206 goto end;
1208 This->nb_coords2d = *(DWORD*)ptr;
1210 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1212 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1213 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1216 else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList))
1218 DWORD nb_materials;
1219 DWORD nb_face_indices;
1220 DWORD data_size;
1221 IDirectXFileObject *child;
1222 DWORD i = 0;
1223 float* values;
1225 TRACE("Process MeshMaterialList\n");
1227 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1228 if (hr != DXFILE_OK)
1229 goto end;
1231 nb_materials = *(DWORD*)ptr;
1232 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1233 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1235 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1237 if (size != data_size)
1238 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1240 This->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->material_indices) * nb_face_indices);
1241 if (!This->material_indices)
1242 goto end;
1243 memcpy(This->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*This->material_indices) * nb_face_indices),
1245 This->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->materials) * nb_materials);
1246 if (!This->materials)
1248 HeapFree(GetProcessHeap(), 0, This->material_indices);
1249 goto end;
1251 This->nb_materials = nb_materials;
1253 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1255 IDirectXFileData *data;
1256 IDirectXFileDataReference *reference;
1257 IDirectXFileObject *material_child;
1259 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1260 if (FAILED(hr))
1262 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1263 IDirectXFileObject_Release(child);
1264 if (FAILED(hr))
1265 goto end;
1267 hr = IDirectXFileDataReference_Resolve(reference, &data);
1268 IDirectXFileDataReference_Release(reference);
1269 if (FAILED(hr))
1270 goto end;
1272 else
1274 IDirectXFileObject_Release(child);
1277 hr = Direct3DRMMaterial_create(&This->materials[i].material);
1278 if (FAILED(hr))
1280 IDirectXFileData_Release(data);
1281 goto end;
1284 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1285 if (hr != DXFILE_OK)
1287 IDirectXFileData_Release(data);
1288 goto end;
1291 if (size != 44)
1292 WARN("Material size %u does not match expected one %u\n", size, 44);
1294 values = (float*)ptr;
1296 This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f), (BYTE)(values[1] * 255.0f),
1297 (BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
1299 IDirect3DRMMaterial2_SetAmbient(This->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
1300 IDirect3DRMMaterial2_SetPower(This->materials[i].material, values[4]);
1301 IDirect3DRMMaterial2_SetSpecular(This->materials[i].material, values[5], values[6], values[7]);
1302 IDirect3DRMMaterial2_SetEmissive(This->materials[i].material, values[8], values[9], values[10]);
1304 This->materials[i].texture = NULL;
1306 hr = IDirectXFileData_GetNextObject(data, &material_child);
1307 if (hr == S_OK)
1309 IDirectXFileData *data;
1310 char **filename;
1312 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1313 if (FAILED(hr))
1315 IDirectXFileDataReference *reference;
1317 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1318 if (FAILED(hr))
1319 goto end;
1321 hr = IDirectXFileDataReference_Resolve(reference, &data);
1322 IDirectXFileDataReference_Release(reference);
1323 if (FAILED(hr))
1324 goto end;
1327 hr = IDirectXFileData_GetType(data, &guid);
1328 if (hr != DXFILE_OK)
1329 goto end;
1330 if (!IsEqualGUID(guid, &TID_D3DRMTextureFilename))
1332 WARN("Not a texture filename\n");
1333 goto end;
1336 size = 4;
1337 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1338 if (SUCCEEDED(hr))
1340 if (load_texture_proc)
1342 IDirect3DRMTexture *texture;
1344 hr = load_texture_proc(*filename, arg, &texture);
1345 if (SUCCEEDED(hr))
1347 hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void**)&This->materials[i].texture);
1348 IDirect3DTexture_Release(texture);
1351 else
1353 HANDLE file;
1355 /* If the texture file is not found, no texture is associated with the material */
1356 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1357 if (file != INVALID_HANDLE_VALUE)
1359 CloseHandle(file);
1361 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
1362 if (FAILED(hr))
1364 IDirectXFileData_Release(data);
1365 goto end;
1371 else if (hr != DXFILEERR_NOMOREOBJECTS)
1373 goto end;
1375 hr = S_OK;
1377 IDirectXFileData_Release(data);
1378 i++;
1380 if (hr == S_OK)
1382 IDirectXFileObject_Release(child);
1383 WARN("Found more sub-objects than expected\n");
1385 else if (hr != DXFILEERR_NOMOREOBJECTS)
1387 goto end;
1389 hr = S_OK;
1391 else
1393 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid));
1396 IDirectXFileData_Release(pData2);
1397 pData2 = NULL;
1400 if (!This->nb_normals)
1402 /* Allocate normals, one per vertex */
1403 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1404 if (!This->pNormals)
1405 goto end;
1408 for (i = 0; i < This->nb_faces; i++)
1410 DWORD j;
1411 DWORD nb_face_indexes;
1412 D3DVECTOR face_normal;
1414 if (faces_vertex_idx_size < sizeof(DWORD))
1415 WARN("Not enough data to read number of indices of face %d\n", i);
1417 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1418 faces_vertex_idx_size--;
1419 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1420 WARN("Faces indices number mismatch\n");
1422 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1423 WARN("Not enough data to read all indices of face %d\n", i);
1425 if (!This->nb_normals)
1427 /* Compute face normal */
1428 if (nb_face_indexes > 2)
1430 D3DVECTOR a, b;
1432 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1433 D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1434 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1435 D3DRMVectorNormalize(&face_normal);
1437 else
1439 face_normal.u1.x = 0.0f;
1440 face_normal.u2.y = 0.0f;
1441 face_normal.u3.z = 0.0f;
1445 for (j = 0; j < nb_face_indexes; j++)
1447 /* Copy vertex index */
1448 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1449 /* Copy normal index */
1450 if (This->nb_normals)
1452 /* Read from x file */
1453 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1455 else
1457 DWORD vertex_idx = *faces_vertex_idx_ptr;
1458 if (vertex_idx >= This->nb_vertices)
1460 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1461 vertex_idx = 0;
1463 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1464 /* Add face normal to vertex normal */
1465 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1467 faces_vertex_idx_ptr++;
1469 faces_vertex_idx_size -= nb_face_indexes;
1472 /* Last DWORD must be 0 */
1473 *(faces_data_ptr + faces_data_size++) = 0;
1475 /* Set size (in number of DWORD) of all faces data */
1476 This->face_data_size = faces_data_size;
1478 if (!This->nb_normals)
1480 /* Normalize all normals */
1481 for (i = 0; i < This->nb_vertices; i++)
1483 D3DRMVectorNormalize(&This->pNormals[i]);
1485 This->nb_normals = This->nb_vertices;
1488 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1489 if (!This->pCoords2d)
1491 This->nb_coords2d = This->nb_vertices;
1492 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1493 for (i = 0; i < This->nb_coords2d; i++)
1495 This->pCoords2d[i].u = 0.0f;
1496 This->pCoords2d[i].v = 0.0f;
1500 TRACE("Mesh data loaded successfully\n");
1502 ret = D3DRM_OK;
1504 end:
1506 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1507 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1509 return ret;
1512 /*** IDirect3DRMMeshBuilder3 methods ***/
1513 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1514 void *filename, void *name,
1515 D3DRMLOADOPTIONS loadflags,
1516 D3DRMLOADTEXTURE3CALLBACK cb, void *arg)
1518 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1519 DXFILELOADOPTIONS load_options;
1520 IDirectXFile *dxfile = NULL;
1521 IDirectXFileEnumObject *enum_object = NULL;
1522 IDirectXFileData *data = NULL;
1523 const GUID* guid;
1524 DWORD size;
1525 struct d3drm_file_header *header;
1526 HRESULT hr;
1527 HRESULT ret = D3DRMERR_BADOBJECT;
1529 TRACE("iface %p, filename %p, name %p, loadflags %#x, cb %p, arg %p.\n",
1530 iface, filename, name, loadflags, cb, arg);
1532 clean_mesh_builder_data(This);
1534 if (loadflags == D3DRMLOAD_FROMMEMORY)
1536 load_options = DXFILELOAD_FROMMEMORY;
1538 else if (loadflags == D3DRMLOAD_FROMFILE)
1540 load_options = DXFILELOAD_FROMFILE;
1541 TRACE("Loading from file %s\n", debugstr_a(filename));
1543 else
1545 FIXME("Load options %d not supported yet\n", loadflags);
1546 return E_NOTIMPL;
1549 hr = DirectXFileCreate(&dxfile);
1550 if (hr != DXFILE_OK)
1551 goto end;
1553 hr = IDirectXFile_RegisterTemplates(dxfile, templates, strlen(templates));
1554 if (hr != DXFILE_OK)
1555 goto end;
1557 hr = IDirectXFile_CreateEnumObject(dxfile, filename, load_options, &enum_object);
1558 if (hr != DXFILE_OK)
1559 goto end;
1561 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1562 if (hr != DXFILE_OK)
1563 goto end;
1565 hr = IDirectXFileData_GetType(data, &guid);
1566 if (hr != DXFILE_OK)
1567 goto end;
1569 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1571 if (!IsEqualGUID(guid, &TID_DXFILEHeader))
1573 ret = D3DRMERR_BADFILE;
1574 goto end;
1577 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&header);
1578 if ((hr != DXFILE_OK) || (size != sizeof(*header)))
1579 goto end;
1581 TRACE("Version is %u.%u, flags %#x.\n", header->major, header->minor, header->flags);
1583 /* Version must be 1.0.x */
1584 if ((header->major != 1) || (header->minor != 0))
1586 ret = D3DRMERR_BADFILE;
1587 goto end;
1590 IDirectXFileData_Release(data);
1591 data = NULL;
1593 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1594 if (hr != DXFILE_OK)
1596 ret = D3DRMERR_NOTFOUND;
1597 goto end;
1600 hr = IDirectXFileData_GetType(data, &guid);
1601 if (hr != DXFILE_OK)
1602 goto end;
1604 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1606 if (!IsEqualGUID(guid, &TID_D3DRMMesh))
1608 ret = D3DRMERR_NOTFOUND;
1609 goto end;
1612 /* We don't care about the texture interface version since we rely on QueryInterface */
1613 hr = load_mesh_data(iface, data, (D3DRMLOADTEXTURECALLBACK)cb, arg);
1614 if (hr == S_OK)
1615 ret = D3DRM_OK;
1617 end:
1619 if (data)
1620 IDirectXFileData_Release(data);
1621 if (enum_object)
1622 IDirectXFileEnumObject_Release(enum_object);
1623 if (dxfile)
1624 IDirectXFile_Release(dxfile);
1626 if (ret != D3DRM_OK)
1627 clean_mesh_builder_data(This);
1629 return ret;
1632 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1633 const char* filename, D3DRMXOFFORMAT format,
1634 D3DRMSAVEOPTIONS save)
1636 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1638 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1640 return E_NOTIMPL;
1643 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1644 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1646 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1647 DWORD i;
1649 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1651 for (i = 0; i < This->nb_vertices; i++)
1653 This->pVertices[i].u1.x *= sx;
1654 This->pVertices[i].u2.y *= sy;
1655 This->pVertices[i].u3.z *= sz;
1658 /* Normals are not affected by Scale */
1660 return D3DRM_OK;
1663 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1664 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1666 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1668 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1670 return E_NOTIMPL;
1673 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1674 D3DRMCOLORSOURCE color)
1676 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1678 FIXME("(%p)->(%x): stub\n", This, color);
1680 return E_NOTIMPL;
1683 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1684 D3DRMBOX* box)
1686 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1688 FIXME("(%p)->(%p): stub\n", This, box);
1690 return E_NOTIMPL;
1693 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1694 D3DVALUE crease, DWORD flags)
1696 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1698 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1700 return E_NOTIMPL;
1703 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1705 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1707 FIXME("(%p)->(): stub\n", This);
1709 return E_NOTIMPL;
1712 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh *mesh)
1714 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1716 return E_NOTIMPL;
1719 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3 *iface,
1720 IDirect3DRMMeshBuilder3 *mesh_builder, DWORD flags)
1722 FIXME("iface %p, mesh_builder %p, flags %#x stub!\n", iface, mesh_builder, flags);
1724 return E_NOTIMPL;
1727 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFrame3 *frame)
1729 FIXME("iface %p, frame %p stub!\n", iface, frame);
1731 return E_NOTIMPL;
1734 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
1736 FIXME("iface %p, face %p stub!\n", iface, face);
1738 return E_NOTIMPL;
1741 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3 *iface,
1742 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
1743 DWORD *face_data, IDirect3DRMFaceArray **array)
1745 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p array %p stub!\n",
1746 iface, vertex_count, vertices, normal_count, normals, face_data, array);
1748 return E_NOTIMPL;
1751 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1752 DWORD vertex_Count,
1753 DWORD normal_count,
1754 DWORD face_count)
1756 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1758 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1760 return E_NOTIMPL;
1763 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1764 D3DVALUE red, D3DVALUE green,
1765 D3DVALUE blue)
1767 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1769 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1771 This->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
1773 return D3DRM_OK;
1776 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1777 D3DCOLOR color)
1779 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1781 TRACE("(%p)->(%x)\n", This, color);
1783 This->color = color;
1785 return D3DRM_OK;
1788 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3 *iface,
1789 IDirect3DRMTexture3 *texture)
1791 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1793 TRACE("(%p)->(%p)\n", This, texture);
1795 if (texture)
1796 IDirect3DRMTexture3_AddRef(texture);
1797 if (This->texture)
1798 IDirect3DRMTexture3_Release(This->texture);
1799 This->texture = texture;
1801 return D3DRM_OK;
1804 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3 *iface,
1805 IDirect3DRMMaterial2 *material)
1807 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1809 TRACE("iface %p, material %p.\n", iface, material);
1811 if (material)
1812 IDirect3DRMTexture2_AddRef(material);
1813 if (mesh_builder->material)
1814 IDirect3DRMTexture2_Release(mesh_builder->material);
1815 mesh_builder->material = material;
1817 return D3DRM_OK;
1820 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1821 BOOL wrap_u, BOOL wrap_v)
1823 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1825 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1827 return E_NOTIMPL;
1830 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1831 D3DRMRENDERQUALITY quality)
1833 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1835 FIXME("(%p)->(%d): stub\n", This, quality);
1837 return E_NOTIMPL;
1840 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1841 BOOL enable)
1843 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1845 FIXME("(%p)->(%d): stub\n", This, enable);
1847 return E_NOTIMPL;
1850 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1851 DWORD index,
1852 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1854 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1856 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1858 return E_NOTIMPL;
1861 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1862 DWORD index,
1863 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1865 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1867 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1873 DWORD index, D3DVALUE u,
1874 D3DVALUE v)
1876 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1878 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1880 if (index >= This->nb_coords2d)
1881 return D3DRMERR_BADVALUE;
1883 This->pCoords2d[index].u = u;
1884 This->pCoords2d[index].v = v;
1886 return D3DRM_OK;
1889 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1890 DWORD index, D3DCOLOR color)
1892 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1894 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1896 return E_NOTIMPL;
1899 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1900 DWORD index,
1901 D3DVALUE red, D3DVALUE green,
1902 D3DVALUE blue)
1904 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1906 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1908 return E_NOTIMPL;
1911 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3 *iface,
1912 IDirect3DRMFaceArray **array)
1914 FIXME("iface %p, array %p stub!\n", iface, array);
1916 return E_NOTIMPL;
1919 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1920 DWORD* vcount, D3DVECTOR* vertices,
1921 DWORD* ncount, D3DVECTOR* normals,
1922 DWORD* face_data_size,
1923 DWORD* face_data)
1925 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1927 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1928 face_data_size, face_data);
1930 return E_NOTIMPL;
1933 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1934 DWORD index, D3DVALUE* u,
1935 D3DVALUE* v)
1937 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1939 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1941 if (index >= This->nb_coords2d)
1942 return D3DRMERR_BADVALUE;
1944 *u = This->pCoords2d[index].u;
1945 *v = This->pCoords2d[index].v;
1947 return D3DRM_OK;
1951 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1952 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1954 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1956 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1958 return 0;
1961 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1962 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1964 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1966 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1968 return 0;
1971 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 **face)
1973 TRACE("iface %p, face %p.\n", iface, face);
1975 return Direct3DRMFace_create(&IID_IDirect3DRMFace2, (IUnknown **)face);
1978 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
1980 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1982 FIXME("(%p)->(): stub\n", This);
1984 return 0;
1987 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
1989 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1991 FIXME("(%p)->(): stub\n", This);
1993 return FALSE;
1996 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
1998 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2000 TRACE("(%p)->()\n", This);
2002 return This->nb_faces;
2005 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2007 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2009 TRACE("(%p)->()\n", This);
2011 return This->nb_vertices;
2014 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2015 DWORD index)
2017 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2019 FIXME("(%p)->(%d): stub\n", This, index);
2021 return 0;
2024 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh **mesh)
2026 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2027 HRESULT hr;
2028 D3DRMGROUPINDEX group;
2030 TRACE("(%p)->(%p)\n", This, mesh);
2032 if (!mesh)
2033 return E_POINTER;
2035 hr = Direct3DRMMesh_create(mesh);
2036 if (FAILED(hr))
2037 return hr;
2039 /* If there is mesh data, create a group and put data inside */
2040 if (This->nb_vertices)
2042 DWORD i, j;
2043 int k;
2044 D3DRMVERTEX* vertices;
2046 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2047 if (!vertices)
2049 IDirect3DRMMesh_Release(*mesh);
2050 return E_OUTOFMEMORY;
2052 for (i = 0; i < This->nb_vertices; i++)
2053 vertices[i].position = This->pVertices[i];
2054 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2055 HeapFree(GetProcessHeap(), 0, vertices);
2057 /* Groups are in reverse order compared to materials list in X file */
2058 for (k = This->nb_materials - 1; k >= 0; k--)
2060 unsigned* face_data;
2061 unsigned* out_ptr;
2062 DWORD* in_ptr = This->pFaceData;
2063 ULONG vertex_per_face = 0;
2064 BOOL* used_vertices;
2065 unsigned nb_vertices = 0;
2066 unsigned nb_faces = 0;
2068 used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->face_data_size * sizeof(*used_vertices));
2069 if (!used_vertices)
2071 IDirect3DRMMesh_Release(*mesh);
2072 return E_OUTOFMEMORY;
2075 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(*face_data));
2076 if (!face_data)
2078 HeapFree(GetProcessHeap(), 0, used_vertices);
2079 IDirect3DRMMesh_Release(*mesh);
2080 return E_OUTOFMEMORY;
2082 out_ptr = face_data;
2084 /* If all faces have the same number of vertex, set vertex_per_face */
2085 for (i = 0; i < This->nb_faces; i++)
2087 /* Process only faces belonging to the group */
2088 if (This->material_indices[i] == k)
2090 if (vertex_per_face && (vertex_per_face != *in_ptr))
2091 break;
2092 vertex_per_face = *in_ptr;
2094 in_ptr += 1 + *in_ptr * 2;
2096 if (i != This->nb_faces)
2097 vertex_per_face = 0;
2099 /* Put only vertex indices */
2100 in_ptr = This->pFaceData;
2101 for (i = 0; i < This->nb_faces; i++)
2103 DWORD nb_indices = *in_ptr++;
2105 /* Skip faces not belonging to the group */
2106 if (This->material_indices[i] != k)
2108 in_ptr += 2 * nb_indices;
2109 continue;
2112 /* Don't put nb indices when vertex_per_face is set */
2113 if (vertex_per_face)
2114 *out_ptr++ = nb_indices;
2116 for (j = 0; j < nb_indices; j++)
2118 *out_ptr = *in_ptr++;
2119 used_vertices[*out_ptr++] = TRUE;
2120 /* Skip normal index */
2121 in_ptr++;
2124 nb_faces++;
2127 for (i = 0; i < This->nb_vertices; i++)
2128 if (used_vertices[i])
2129 nb_vertices++;
2131 hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group);
2132 HeapFree(GetProcessHeap(), 0, used_vertices);
2133 HeapFree(GetProcessHeap(), 0, face_data);
2134 if (SUCCEEDED(hr))
2135 hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, This->materials[k].color);
2136 if (SUCCEEDED(hr))
2137 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, group,
2138 (IDirect3DRMMaterial *)This->materials[k].material);
2139 if (SUCCEEDED(hr) && This->materials[k].texture)
2141 IDirect3DRMTexture *texture;
2143 IDirect3DRMTexture3_QueryInterface(This->materials[k].texture,
2144 &IID_IDirect3DRMTexture, (void **)&texture);
2145 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, group, texture);
2146 IDirect3DRMTexture_Release(texture);
2148 if (FAILED(hr))
2150 IDirect3DRMMesh_Release(*mesh);
2151 return hr;
2156 return D3DRM_OK;
2159 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3 *iface,
2160 DWORD index, IDirect3DRMFace2 **face)
2162 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
2164 return E_NOTIMPL;
2167 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3 *iface,
2168 DWORD index, D3DVECTOR *vector)
2170 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2172 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2174 return E_NOTIMPL;
2177 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3 *iface,
2178 DWORD index, D3DVECTOR *vector)
2180 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2182 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2184 return E_NOTIMPL;
2187 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2188 DWORD IndexFirst, DWORD count)
2190 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2192 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2194 return E_NOTIMPL;
2197 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2198 DWORD IndexFirst, DWORD count)
2200 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2202 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2204 return E_NOTIMPL;
2207 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
2209 FIXME("iface %p, face %p stub!\n", iface, face);
2211 return E_NOTIMPL;
2214 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2216 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2218 FIXME("(%p)->(%u): stub\n", This, flags);
2220 return E_NOTIMPL;
2223 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2224 DWORD flags)
2226 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2228 FIXME("(%p)->(%u): stub\n", This, flags);
2230 return E_NOTIMPL;
2233 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2234 DWORD flags, DWORD* indices,
2235 DWORD* IndexFirst, DWORD* count)
2237 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2239 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2241 return E_NOTIMPL;
2244 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown **mesh)
2246 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2248 return E_NOTIMPL;
2251 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3 *iface,
2252 DWORD flags, IUnknown **parent)
2254 FIXME("iface %p, flags %#x, parent %p stub!\n", iface, flags, parent);
2256 return E_NOTIMPL;
2259 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3 *iface,
2260 DWORD *count, IUnknown **meshes)
2262 FIXME("iface %p, count %p, meshes %p stub!\n", iface, count, meshes);
2264 return E_NOTIMPL;
2267 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown *mesh)
2269 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2271 return E_NOTIMPL;
2274 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2275 DWORD index)
2277 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2279 FIXME("(%p)->(%u): stub\n", This, index);
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2285 DWORD* indices)
2287 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2289 FIXME("(%p)->(%p): stub\n", This, indices);
2291 return E_NOTIMPL;
2294 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3 *iface,
2295 DWORD flags, DWORD format, DWORD vertex_count, void *data)
2297 FIXME("iface %p, flags %#x, format %#x, vertex_count %u, data %p stub!\n",
2298 iface, flags, format, vertex_count, data);
2300 return E_NOTIMPL;
2303 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3 *iface,
2304 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2306 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2308 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2310 return E_NOTIMPL;
2313 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3 *iface,
2314 DWORD IndexFirst, DWORD *vcount, D3DVECTOR *vertices)
2316 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2317 DWORD count = This->nb_vertices - IndexFirst;
2319 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2321 if (vcount)
2322 *vcount = count;
2323 if (vertices && This->nb_vertices)
2324 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2326 return D3DRM_OK;
2329 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3 *iface,
2330 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2332 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2334 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2336 return E_NOTIMPL;
2339 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3 *iface,
2340 DWORD IndexFirst, DWORD *ncount, D3DVECTOR *normals)
2342 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2343 DWORD count = This->nb_normals - IndexFirst;
2345 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, ncount, normals);
2347 if (ncount)
2348 *ncount = count;
2349 if (normals && This->nb_normals)
2350 memcpy(normals, This->pNormals + IndexFirst, count * sizeof(D3DVECTOR));
2352 return D3DRM_OK;
2355 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2357 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2359 TRACE("(%p)->()\n", This);
2361 return This->nb_normals;
2364 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2366 /*** IUnknown methods ***/
2367 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2368 IDirect3DRMMeshBuilder3Impl_AddRef,
2369 IDirect3DRMMeshBuilder3Impl_Release,
2370 /*** IDirect3DRMObject methods ***/
2371 IDirect3DRMMeshBuilder3Impl_Clone,
2372 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2373 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2374 IDirect3DRMMeshBuilder3Impl_SetAppData,
2375 IDirect3DRMMeshBuilder3Impl_GetAppData,
2376 IDirect3DRMMeshBuilder3Impl_SetName,
2377 IDirect3DRMMeshBuilder3Impl_GetName,
2378 IDirect3DRMMeshBuilder3Impl_GetClassName,
2379 /*** IDirect3DRMMeshBuilder3 methods ***/
2380 IDirect3DRMMeshBuilder3Impl_Load,
2381 IDirect3DRMMeshBuilder3Impl_Save,
2382 IDirect3DRMMeshBuilder3Impl_Scale,
2383 IDirect3DRMMeshBuilder3Impl_Translate,
2384 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2385 IDirect3DRMMeshBuilder3Impl_GetBox,
2386 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2387 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2388 IDirect3DRMMeshBuilder3Impl_AddMesh,
2389 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2390 IDirect3DRMMeshBuilder3Impl_AddFrame,
2391 IDirect3DRMMeshBuilder3Impl_AddFace,
2392 IDirect3DRMMeshBuilder3Impl_AddFaces,
2393 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2394 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2395 IDirect3DRMMeshBuilder3Impl_SetColor,
2396 IDirect3DRMMeshBuilder3Impl_SetTexture,
2397 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2398 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2399 IDirect3DRMMeshBuilder3Impl_SetQuality,
2400 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2401 IDirect3DRMMeshBuilder3Impl_SetVertex,
2402 IDirect3DRMMeshBuilder3Impl_SetNormal,
2403 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2404 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2405 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2406 IDirect3DRMMeshBuilder3Impl_GetFaces,
2407 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2408 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2409 IDirect3DRMMeshBuilder3Impl_AddVertex,
2410 IDirect3DRMMeshBuilder3Impl_AddNormal,
2411 IDirect3DRMMeshBuilder3Impl_CreateFace,
2412 IDirect3DRMMeshBuilder3Impl_GetQuality,
2413 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2414 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2415 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2416 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2417 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2418 IDirect3DRMMeshBuilder3Impl_GetFace,
2419 IDirect3DRMMeshBuilder3Impl_GetVertex,
2420 IDirect3DRMMeshBuilder3Impl_GetNormal,
2421 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2422 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2423 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2424 IDirect3DRMMeshBuilder3Impl_Empty,
2425 IDirect3DRMMeshBuilder3Impl_Optimize,
2426 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2427 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2428 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2429 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2430 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2431 IDirect3DRMMeshBuilder3Impl_Enable,
2432 IDirect3DRMMeshBuilder3Impl_GetEnable,
2433 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2434 IDirect3DRMMeshBuilder3Impl_SetVertices,
2435 IDirect3DRMMeshBuilder3Impl_GetVertices,
2436 IDirect3DRMMeshBuilder3Impl_SetNormals,
2437 IDirect3DRMMeshBuilder3Impl_GetNormals,
2438 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2441 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2443 IDirect3DRMMeshBuilderImpl* object;
2445 TRACE("(%p)\n", ppObj);
2447 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2448 if (!object)
2449 return E_OUTOFMEMORY;
2451 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2452 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2453 object->ref = 1;
2455 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2456 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2457 else
2458 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2460 return S_OK;
2463 /*** IUnknown methods ***/
2464 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2465 REFIID riid, void** ppvObject)
2467 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2469 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2471 *ppvObject = NULL;
2473 if (IsEqualGUID(riid, &IID_IUnknown) ||
2474 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2476 *ppvObject = &This->IDirect3DRMMesh_iface;
2478 else
2480 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2481 return E_NOINTERFACE;
2484 IDirect3DRMMesh_AddRef(iface);
2485 return S_OK;
2488 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2490 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2491 ULONG ref = InterlockedIncrement(&This->ref);
2493 TRACE("(%p)->(): new ref = %d\n", This, ref);
2495 return ref;
2498 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2500 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2501 ULONG ref = InterlockedDecrement(&This->ref);
2503 TRACE("(%p)->(): new ref = %d\n", This, ref);
2505 if (!ref)
2507 DWORD i;
2509 for (i = 0; i < This->nb_groups; i++)
2511 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2512 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2513 if (This->groups[i].material)
2514 IDirect3DRMMaterial2_Release(This->groups[i].material);
2515 if (This->groups[i].texture)
2516 IDirect3DRMTexture3_Release(This->groups[i].texture);
2518 HeapFree(GetProcessHeap(), 0, This->groups);
2519 HeapFree(GetProcessHeap(), 0, This);
2522 return ref;
2525 /*** IDirect3DRMObject methods ***/
2526 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh *iface,
2527 IUnknown *outer, REFIID iid, void **out)
2529 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
2531 return E_NOTIMPL;
2534 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh *iface,
2535 D3DRMOBJECTCALLBACK cb, void *ctx)
2537 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2539 return E_NOTIMPL;
2542 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh *iface,
2543 D3DRMOBJECTCALLBACK cb, void *ctx)
2545 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2547 return E_NOTIMPL;
2550 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2551 DWORD data)
2553 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2555 FIXME("(%p)->(%u): stub\n", This, data);
2557 return E_NOTIMPL;
2560 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2562 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2564 FIXME("(%p)->(): stub\n", This);
2566 return 0;
2569 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh *iface, const char *name)
2571 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
2573 return E_NOTIMPL;
2576 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2578 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
2580 return E_NOTIMPL;
2583 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2585 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2587 if (!size || *size < strlen("Mesh") || !name)
2588 return E_INVALIDARG;
2590 strcpy(name, "Mesh");
2591 *size = sizeof("Mesh");
2593 return D3DRM_OK;
2596 /*** IDirect3DRMMesh methods ***/
2597 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2598 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2600 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2602 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2604 return E_NOTIMPL;
2607 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2608 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2610 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2612 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2614 return E_NOTIMPL;
2617 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2618 D3DRMBOX * box)
2620 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2622 FIXME("(%p)->(%p): stub\n", This, box);
2624 return E_NOTIMPL;
2627 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2628 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2629 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2631 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2632 struct mesh_group *group;
2634 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2636 if (!face_data || !return_id)
2637 return E_POINTER;
2639 if ((This->nb_groups + 1) > This->groups_capacity)
2641 struct mesh_group *groups;
2642 ULONG new_capacity;
2644 if (!This->groups_capacity)
2646 new_capacity = 16;
2647 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(*groups));
2649 else
2651 new_capacity = This->groups_capacity * 2;
2652 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(*groups));
2655 if (!groups)
2656 return E_OUTOFMEMORY;
2658 This->groups_capacity = new_capacity;
2659 This->groups = groups;
2662 group = This->groups + This->nb_groups;
2664 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2665 if (!group->vertices)
2666 return E_OUTOFMEMORY;
2667 group->nb_vertices = vertex_count;
2668 group->nb_faces = face_count;
2669 group->vertex_per_face = vertex_per_face;
2671 if (vertex_per_face)
2673 group->face_data_size = face_count * vertex_per_face;
2675 else
2677 unsigned i;
2678 unsigned nb_indices;
2679 unsigned* face_data_ptr = face_data;
2680 group->face_data_size = 0;
2682 for (i = 0; i < face_count; i++)
2684 nb_indices = *face_data_ptr;
2685 group->face_data_size += nb_indices + 1;
2686 face_data_ptr += nb_indices;
2690 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2691 if (!group->face_data)
2693 HeapFree(GetProcessHeap(), 0 , group->vertices);
2694 return E_OUTOFMEMORY;
2697 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2699 group->material = NULL;
2700 group->texture = NULL;
2702 *return_id = This->nb_groups++;
2704 return D3DRM_OK;
2707 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2708 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2709 D3DRMVERTEX *values)
2711 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2713 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2715 if (id >= This->nb_groups)
2716 return D3DRMERR_BADVALUE;
2718 if ((index + count - 1) >= This->groups[id].nb_vertices)
2719 return D3DRMERR_BADVALUE;
2721 if (!values)
2722 return E_POINTER;
2724 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2726 return D3DRM_OK;
2729 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2730 D3DRMGROUPINDEX id, D3DCOLOR color)
2732 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2734 TRACE("(%p)->(%u,%x)\n", This, id, color);
2736 if (id >= This->nb_groups)
2737 return D3DRMERR_BADVALUE;
2739 This->groups[id].color = color;
2741 return D3DRM_OK;
2744 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2745 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2747 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2749 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2751 if (id >= This->nb_groups)
2752 return D3DRMERR_BADVALUE;
2754 This->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
2756 return D3DRM_OK;
2759 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2760 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2762 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2764 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2766 return E_NOTIMPL;
2769 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2770 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2772 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2774 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2776 return E_NOTIMPL;
2779 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh *iface,
2780 D3DRMGROUPINDEX id, IDirect3DRMMaterial *material)
2782 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2784 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2786 if (id >= mesh->nb_groups)
2787 return D3DRMERR_BADVALUE;
2789 if (mesh->groups[id].material)
2790 IDirect3DRMMaterial2_Release(mesh->groups[id].material);
2792 mesh->groups[id].material = (IDirect3DRMMaterial2 *)material;
2794 if (material)
2795 IDirect3DRMMaterial2_AddRef(mesh->groups[id].material);
2797 return D3DRM_OK;
2800 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh *iface,
2801 D3DRMGROUPINDEX id, IDirect3DRMTexture *texture)
2803 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2805 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2807 if (id >= This->nb_groups)
2808 return D3DRMERR_BADVALUE;
2810 if (This->groups[id].texture)
2811 IDirect3DRMTexture3_Release(This->groups[id].texture);
2813 if (!texture)
2815 This->groups[id].texture = NULL;
2816 return D3DRM_OK;
2819 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (void **)&This->groups[id].texture);
2822 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2824 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2826 TRACE("(%p)->()\n", This);
2828 return This->nb_groups;
2831 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2832 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2833 DWORD *face_data_size, unsigned *face_data)
2835 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2837 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2839 if (id >= This->nb_groups)
2840 return D3DRMERR_BADVALUE;
2842 if (vertex_count)
2843 *vertex_count = This->groups[id].nb_vertices;
2844 if (face_count)
2845 *face_count = This->groups[id].nb_faces;
2846 if (vertex_per_face)
2847 *vertex_per_face = This->groups[id].vertex_per_face;
2848 if (face_data_size)
2849 *face_data_size = This->groups[id].face_data_size;
2850 if (face_data)
2851 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size * sizeof(DWORD));
2853 return D3DRM_OK;
2856 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2857 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2859 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2861 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2863 if (id >= This->nb_groups)
2864 return D3DRMERR_BADVALUE;
2866 if ((index + count - 1) >= This->groups[id].nb_vertices)
2867 return D3DRMERR_BADVALUE;
2869 if (!return_ptr)
2870 return E_POINTER;
2872 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2874 return D3DRM_OK;
2877 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2879 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2881 TRACE("(%p)->(%u)\n", This, id);
2883 return This->groups[id].color;
2886 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2888 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2890 FIXME("(%p)->(%u): stub\n", This, id);
2892 return 0;
2894 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2896 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2898 FIXME("(%p)->(%u): stub\n", This, id);
2900 return 0;
2903 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh *iface,
2904 D3DRMGROUPINDEX id, IDirect3DRMMaterial **material)
2906 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2908 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2910 if (id >= mesh->nb_groups)
2911 return D3DRMERR_BADVALUE;
2913 if (!material)
2914 return E_POINTER;
2916 if (mesh->groups[id].material)
2917 IDirect3DRMTexture_QueryInterface(mesh->groups[id].material, &IID_IDirect3DRMMaterial, (void **)material);
2918 else
2919 *material = NULL;
2921 return D3DRM_OK;
2924 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh *iface,
2925 D3DRMGROUPINDEX id, IDirect3DRMTexture **texture)
2927 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2929 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2931 if (id >= This->nb_groups)
2932 return D3DRMERR_BADVALUE;
2934 if (!texture)
2935 return E_POINTER;
2937 if (This->groups[id].texture)
2938 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2939 else
2940 *texture = NULL;
2942 return D3DRM_OK;
2945 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2947 /*** IUnknown methods ***/
2948 IDirect3DRMMeshImpl_QueryInterface,
2949 IDirect3DRMMeshImpl_AddRef,
2950 IDirect3DRMMeshImpl_Release,
2951 /*** IDirect3DRMObject methods ***/
2952 IDirect3DRMMeshImpl_Clone,
2953 IDirect3DRMMeshImpl_AddDestroyCallback,
2954 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2955 IDirect3DRMMeshImpl_SetAppData,
2956 IDirect3DRMMeshImpl_GetAppData,
2957 IDirect3DRMMeshImpl_SetName,
2958 IDirect3DRMMeshImpl_GetName,
2959 IDirect3DRMMeshImpl_GetClassName,
2960 /*** IDirect3DRMMesh methods ***/
2961 IDirect3DRMMeshImpl_Scale,
2962 IDirect3DRMMeshImpl_Translate,
2963 IDirect3DRMMeshImpl_GetBox,
2964 IDirect3DRMMeshImpl_AddGroup,
2965 IDirect3DRMMeshImpl_SetVertices,
2966 IDirect3DRMMeshImpl_SetGroupColor,
2967 IDirect3DRMMeshImpl_SetGroupColorRGB,
2968 IDirect3DRMMeshImpl_SetGroupMapping,
2969 IDirect3DRMMeshImpl_SetGroupQuality,
2970 IDirect3DRMMeshImpl_SetGroupMaterial,
2971 IDirect3DRMMeshImpl_SetGroupTexture,
2972 IDirect3DRMMeshImpl_GetGroupCount,
2973 IDirect3DRMMeshImpl_GetGroup,
2974 IDirect3DRMMeshImpl_GetVertices,
2975 IDirect3DRMMeshImpl_GetGroupColor,
2976 IDirect3DRMMeshImpl_GetGroupMapping,
2977 IDirect3DRMMeshImpl_GetGroupQuality,
2978 IDirect3DRMMeshImpl_GetGroupMaterial,
2979 IDirect3DRMMeshImpl_GetGroupTexture
2982 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2984 IDirect3DRMMeshImpl* object;
2986 TRACE("(%p)\n", obj);
2988 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2989 if (!object)
2990 return E_OUTOFMEMORY;
2992 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
2993 object->ref = 1;
2995 *obj = &object->IDirect3DRMMesh_iface;
2997 return S_OK;