gdi32: GetCharWidth32A/W return positive widths for all layouts and various DC transf...
[wine/multimedia.git] / dlls / d3drm / meshbuilder.c
blobc198531ace8b5e052ad9c49b8b0554a7f72808c7
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 typedef struct {
38 unsigned nb_vertices;
39 D3DRMVERTEX* vertices;
40 unsigned nb_faces;
41 unsigned vertex_per_face;
42 DWORD face_data_size;
43 unsigned* face_data;
44 D3DCOLOR color;
45 IDirect3DRMMaterial2* material;
46 IDirect3DRMTexture3* texture;
47 } mesh_group;
49 typedef struct {
50 IDirect3DRMMesh IDirect3DRMMesh_iface;
51 LONG ref;
52 DWORD groups_capacity;
53 DWORD nb_groups;
54 mesh_group* groups;
55 } IDirect3DRMMeshImpl;
57 typedef struct {
58 D3DVALUE u;
59 D3DVALUE v;
60 } Coords2d;
62 typedef struct {
63 D3DCOLOR color;
64 IDirect3DRMMaterial2 *material;
65 IDirect3DRMTexture3 *texture;
66 } mesh_material;
68 typedef struct {
69 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
70 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
71 LONG ref;
72 char* name;
73 DWORD nb_vertices;
74 D3DVECTOR* pVertices;
75 DWORD nb_normals;
76 D3DVECTOR* pNormals;
77 DWORD nb_faces;
78 DWORD face_data_size;
79 void *pFaceData;
80 DWORD nb_coords2d;
81 Coords2d *pCoords2d;
82 D3DCOLOR color;
83 IDirect3DRMMaterial2 *material;
84 IDirect3DRMTexture3 *texture;
85 DWORD nb_materials;
86 mesh_material *materials;
87 DWORD *material_indices;
88 } IDirect3DRMMeshBuilderImpl;
90 char templates[] = {
91 "xof 0302txt 0064"
92 "template Header"
93 "{"
94 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
95 "WORD major;"
96 "WORD minor;"
97 "DWORD flags;"
98 "}"
99 "template Vector"
101 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
102 "FLOAT x;"
103 "FLOAT y;"
104 "FLOAT z;"
106 "template Coords2d"
108 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
109 "FLOAT u;"
110 "FLOAT v;"
112 "template Matrix4x4"
114 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
115 "array FLOAT matrix[16];"
117 "template ColorRGBA"
119 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
120 "FLOAT red;"
121 "FLOAT green;"
122 "FLOAT blue;"
123 "FLOAT alpha;"
125 "template ColorRGB"
127 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
128 "FLOAT red;"
129 "FLOAT green;"
130 "FLOAT blue;"
132 "template IndexedColor"
134 "<1630B820-7842-11CF-8F52-0040333594A3>"
135 "DWORD index;"
136 "ColorRGBA indexColor;"
138 "template Boolean"
140 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
141 "DWORD truefalse;"
143 "template Boolean2d"
145 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
146 "Boolean u;"
147 "Boolean v;"
149 "template MaterialWrap"
151 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
152 "Boolean u;"
153 "Boolean v;"
155 "template TextureFilename"
157 "<A42790E1-7810-11CF-8F52-0040333594A3>"
158 "STRING filename;"
160 "template Material"
162 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
163 "ColorRGBA faceColor;"
164 "FLOAT power;"
165 "ColorRGB specularColor;"
166 "ColorRGB emissiveColor;"
167 "[...]"
169 "template MeshFace"
171 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
172 "DWORD nFaceVertexIndices;"
173 "array DWORD faceVertexIndices[nFaceVertexIndices];"
175 "template MeshFaceWraps"
177 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
178 "DWORD nFaceWrapValues;"
179 "array Boolean2d faceWrapValues[nFaceWrapValues];"
181 "template MeshTextureCoords"
183 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
184 "DWORD nTextureCoords;"
185 "array Coords2d textureCoords[nTextureCoords];"
187 "template MeshMaterialList"
189 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
190 "DWORD nMaterials;"
191 "DWORD nFaceIndexes;"
192 "array DWORD faceIndexes[nFaceIndexes];"
193 "[Material]"
195 "template MeshNormals"
197 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
198 "DWORD nNormals;"
199 "array Vector normals[nNormals];"
200 "DWORD nFaceNormals;"
201 "array MeshFace faceNormals[nFaceNormals];"
203 "template MeshVertexColors"
205 "<1630B821-7842-11CF-8F52-0040333594A3>"
206 "DWORD nVertexColors;"
207 "array IndexedColor vertexColors[nVertexColors];"
209 "template Mesh"
211 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
212 "DWORD nVertices;"
213 "array Vector vertices[nVertices];"
214 "DWORD nFaces;"
215 "array MeshFace faces[nFaces];"
216 "[...]"
218 "template FrameTransformMatrix"
220 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
221 "Matrix4x4 frameMatrix;"
223 "template Frame"
225 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
226 "[...]"
228 "template FloatKeys"
230 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
231 "DWORD nValues;"
232 "array FLOAT values[nValues];"
234 "template TimedFloatKeys"
236 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
237 "DWORD time;"
238 "FloatKeys tfkeys;"
240 "template AnimationKey"
242 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
243 "DWORD keyType;"
244 "DWORD nKeys;"
245 "array TimedFloatKeys keys[nKeys];"
247 "template AnimationOptions"
249 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
250 "DWORD openclosed;"
251 "DWORD positionquality;"
253 "template Animation"
255 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
256 "[...]"
258 "template AnimationSet"
260 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
261 "[Animation]"
263 "template InlineData"
265 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
266 "[BINARY]"
268 "template Url"
270 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
271 "DWORD nUrls;"
272 "array STRING urls[nUrls];"
274 "template ProgressiveMesh"
276 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
277 "[Url,InlineData]"
279 "template Guid"
281 "<A42790E0-7810-11CF-8F52-0040333594A3>"
282 "DWORD data1;"
283 "WORD data2;"
284 "WORD data3;"
285 "array UCHAR data4[8];"
287 "template StringProperty"
289 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
290 "STRING key;"
291 "STRING value;"
293 "template PropertyBag"
295 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
296 "[StringProperty]"
298 "template ExternalVisual"
300 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
301 "Guid guidExternalVisual;"
302 "[...]"
304 "template RightHanded"
306 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
307 "DWORD bRightHanded;"
311 static inline IDirect3DRMMeshImpl *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
313 return CONTAINING_RECORD(iface, IDirect3DRMMeshImpl, IDirect3DRMMesh_iface);
316 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
318 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder2_iface);
321 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
323 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder3_iface);
326 static void clean_mesh_builder_data(IDirect3DRMMeshBuilderImpl *mesh_builder)
328 DWORD i;
330 HeapFree(GetProcessHeap(), 0, mesh_builder->name);
331 mesh_builder->name = NULL;
332 HeapFree(GetProcessHeap(), 0, mesh_builder->pVertices);
333 mesh_builder->pVertices = NULL;
334 mesh_builder->nb_vertices = 0;
335 HeapFree(GetProcessHeap(), 0, mesh_builder->pNormals);
336 mesh_builder->pNormals = NULL;
337 mesh_builder->nb_normals = 0;
338 HeapFree(GetProcessHeap(), 0, mesh_builder->pFaceData);
339 mesh_builder->pFaceData = NULL;
340 mesh_builder->face_data_size = 0;
341 mesh_builder->nb_faces = 0;
342 HeapFree(GetProcessHeap(), 0, mesh_builder->pCoords2d);
343 mesh_builder->pCoords2d = NULL;
344 mesh_builder->nb_coords2d = 0;
345 for (i = 0; i < mesh_builder->nb_materials; i++)
347 if (mesh_builder->materials[i].material)
348 IDirect3DRMMaterial2_Release(mesh_builder->materials[i].material);
349 if (mesh_builder->materials[i].texture)
350 IDirect3DRMTexture3_Release(mesh_builder->materials[i].texture);
352 mesh_builder->nb_materials = 0;
353 HeapFree(GetProcessHeap(), 0, mesh_builder->materials);
354 HeapFree(GetProcessHeap(), 0, mesh_builder->material_indices);
357 /*** IUnknown methods ***/
358 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2* iface,
359 REFIID riid, void** ppvObject)
361 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
363 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
365 *ppvObject = NULL;
367 if(IsEqualGUID(riid, &IID_IUnknown) ||
368 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder) ||
369 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2))
371 *ppvObject = &This->IDirect3DRMMeshBuilder2_iface;
373 else if(IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
375 *ppvObject = &This->IDirect3DRMMeshBuilder3_iface;
377 else
379 FIXME("interface %s not implemented\n", debugstr_guid(riid));
380 return E_NOINTERFACE;
383 IDirect3DRMMeshBuilder_AddRef(iface);
384 return S_OK;
387 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2* iface)
389 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
390 ULONG ref = InterlockedIncrement(&This->ref);
392 TRACE("(%p)->(): new ref = %d\n", This, ref);
394 return ref;
397 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2* iface)
399 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
400 ULONG ref = InterlockedDecrement(&This->ref);
402 TRACE("(%p)->(): new ref = %d\n", This, ref);
404 if (!ref)
406 clean_mesh_builder_data(This);
407 if (This->material)
408 IDirect3DRMMaterial2_Release(This->material);
409 if (This->texture)
410 IDirect3DRMTexture3_Release(This->texture);
411 HeapFree(GetProcessHeap(), 0, This);
414 return ref;
417 /*** IDirect3DRMObject methods ***/
418 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2 *iface,
419 IUnknown *outer, REFIID iid, void **out)
421 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
423 return E_NOTIMPL;
426 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
427 D3DRMOBJECTCALLBACK cb, void *ctx)
429 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
431 return E_NOTIMPL;
434 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2 *iface,
435 D3DRMOBJECTCALLBACK cb, void *ctx)
437 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
439 return E_NOTIMPL;
442 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
443 DWORD data)
445 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
447 FIXME("(%p)->(%u): stub\n", This, data);
449 return E_NOTIMPL;
452 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
454 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
456 FIXME("(%p)->(): stub\n", This);
458 return 0;
461 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2 *iface, const char *name)
463 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
465 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
467 return IDirect3DRMMeshBuilder3_SetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, name);
470 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2 *iface, DWORD *size, char *name)
472 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
474 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
476 return IDirect3DRMMeshBuilder3_GetName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
479 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2 *iface,
480 DWORD *size, char *name)
482 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
484 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
486 return IDirect3DRMMeshBuilder3_GetClassName(&mesh_builder->IDirect3DRMMeshBuilder3_iface, size, name);
489 /*** IDirect3DRMMeshBuilder2 methods ***/
490 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2 *iface, void *filename,
491 void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURECALLBACK cb, void *ctx)
493 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
495 TRACE("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p.\n",
496 iface, filename, name, flags, cb, ctx);
498 if (cb)
499 FIXME("Texture callback is not yet supported\n");
501 return IDirect3DRMMeshBuilder3_Load(&mesh_builder->IDirect3DRMMeshBuilder3_iface,
502 filename, name, flags, NULL, ctx);
505 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
506 const char *filename, D3DRMXOFFORMAT format,
507 D3DRMSAVEOPTIONS save)
509 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
511 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
513 return E_NOTIMPL;
516 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
517 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
519 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
521 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
523 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
526 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
527 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
529 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
531 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
533 return E_NOTIMPL;
536 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
537 D3DRMCOLORSOURCE color)
539 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
541 FIXME("(%p)->(%x): stub\n", This, color);
543 return E_NOTIMPL;
546 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
547 D3DRMBOX *pBox)
549 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
551 FIXME("(%p)->(%p): stub\n", This, pBox);
553 return E_NOTIMPL;
556 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
558 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
560 FIXME("(%p)->(): stub\n", This);
562 return E_NOTIMPL;
565 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
567 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
569 FIXME("(%p)->(): stub\n", This);
571 return E_NOTIMPL;
574 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh *mesh)
576 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
578 return E_NOTIMPL;
581 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2 *iface,
582 IDirect3DRMMeshBuilder *mesh_builder)
584 FIXME("iface %p, mesh_builder %p stub!\n", iface, mesh_builder);
586 return E_NOTIMPL;
589 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFrame *frame)
591 FIXME("iface %p, frame %p stub!\n", iface, frame);
593 return E_NOTIMPL;
596 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace *face)
598 FIXME("iface %p, face %p stub!\n", iface, face);
600 return E_NOTIMPL;
603 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2 *iface,
604 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
605 DWORD *face_data, IDirect3DRMFaceArray **array)
607 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p, array %p stub!\n",
608 iface, vertex_count, vertices, normal_count, normals, face_data, array);
610 return E_NOTIMPL;
613 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
614 DWORD vertex_Count,
615 DWORD normal_count,
616 DWORD face_count)
618 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
620 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
622 return E_NOTIMPL;
625 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
626 D3DVALUE red, D3DVALUE green,
627 D3DVALUE blue)
629 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
631 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
633 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
636 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
637 D3DCOLOR color)
639 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
641 TRACE("(%p)->(%x)\n", This, color);
643 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
646 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2 *iface,
647 IDirect3DRMTexture *texture)
649 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
650 IDirect3DRMTexture3 *texture3 = NULL;
651 HRESULT hr = D3DRM_OK;
653 if (texture)
654 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void **)&texture3);
655 if (SUCCEEDED(hr))
656 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
657 if (texture3)
658 IDirect3DRMTexture3_Release(texture3);
660 return hr;
663 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2 *iface,
664 IDirect3DRMMaterial *material)
666 IDirect3DRMMeshBuilderImpl *d3drm = impl_from_IDirect3DRMMeshBuilder2(iface);
668 TRACE("iface %p, material %p.\n", iface, material);
670 return IDirect3DRMMeshBuilder3_SetMaterial(&d3drm->IDirect3DRMMeshBuilder3_iface,
671 (IDirect3DRMMaterial2 *)material);
674 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
675 BOOL wrap_u, BOOL wrap_v)
677 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
679 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
681 return E_NOTIMPL;
684 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
685 D3DRMRENDERQUALITY quality)
687 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
689 FIXME("(%p)->(%d): stub\n", This, quality);
691 return E_NOTIMPL;
694 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
695 BOOL enable)
697 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
699 FIXME("(%p)->(%d): stub\n", This, enable);
701 return E_NOTIMPL;
704 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
705 DWORD index,
706 D3DVALUE x, D3DVALUE y, D3DVALUE z)
708 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
710 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
712 return E_NOTIMPL;
715 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
716 DWORD index,
717 D3DVALUE x, D3DVALUE y, D3DVALUE z)
719 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
721 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
723 return E_NOTIMPL;
726 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
727 DWORD index,
728 D3DVALUE u, D3DVALUE v)
730 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
732 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
734 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
735 index, u, v);
738 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
739 DWORD index, D3DCOLOR color)
741 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
743 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
745 return E_NOTIMPL;
748 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
749 DWORD index, D3DVALUE red,
750 D3DVALUE green, D3DVALUE blue)
752 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
754 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
756 return E_NOTIMPL;
759 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2 *iface,
760 IDirect3DRMFaceArray **array)
762 FIXME("iface %p, array %p stub!\n", iface, array);
764 return E_NOTIMPL;
767 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
768 DWORD *vcount, D3DVECTOR *vertices,
769 DWORD *ncount, D3DVECTOR *normals,
770 DWORD *face_data_size,
771 DWORD *face_data)
773 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
775 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
777 if (vertices && (!vcount || (*vcount < This->nb_vertices)))
778 return D3DRMERR_BADVALUE;
779 if (vcount)
780 *vcount = This->nb_vertices;
781 if (vertices && This->nb_vertices)
782 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
784 if (normals && (!ncount || (*ncount < This->nb_normals)))
785 return D3DRMERR_BADVALUE;
786 if (ncount)
787 *ncount = This->nb_normals;
788 if (normals && This->nb_normals)
789 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
791 if (face_data && (!face_data_size || (*face_data_size < This->face_data_size)))
792 return D3DRMERR_BADVALUE;
793 if (face_data_size)
794 *face_data_size = This->face_data_size;
795 if (face_data && This->face_data_size)
796 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
798 return D3DRM_OK;
801 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
802 DWORD index,
803 D3DVALUE *u, D3DVALUE *v)
805 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
807 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
809 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
810 index, u, v);
813 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
814 D3DVALUE x, D3DVALUE y, D3DVALUE z)
816 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
818 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
820 return 0;
823 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
824 D3DVALUE x, D3DVALUE y, D3DVALUE z)
826 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
828 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
830 return 0;
833 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace **face)
835 TRACE("iface %p, face %p.\n", iface, face);
837 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
840 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
842 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
844 FIXME("(%p)->(): stub\n", This);
846 return 0;
849 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
851 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
853 FIXME("(%p)->(): stub\n", This);
855 return FALSE;
858 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
860 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
862 TRACE("(%p)->()\n", This);
864 return This->nb_faces;
867 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
869 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
871 TRACE("(%p)->()\n", This);
873 return This->nb_vertices;
876 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
877 DWORD index)
879 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
881 FIXME("(%p)->(%d): stub\n", This, index);
883 return 0;
886 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh **mesh)
888 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
890 TRACE("iface %p, mesh %p.\n", iface, mesh);
892 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder->IDirect3DRMMeshBuilder3_iface, mesh);
895 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
896 D3DVALUE crease, DWORD dwFlags)
898 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
900 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
902 return E_NOTIMPL;
905 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2 *iface,
906 DWORD index, IDirect3DRMFace **face)
908 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
910 return E_NOTIMPL;
913 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
915 /*** IUnknown methods ***/
916 IDirect3DRMMeshBuilder2Impl_QueryInterface,
917 IDirect3DRMMeshBuilder2Impl_AddRef,
918 IDirect3DRMMeshBuilder2Impl_Release,
919 /*** IDirect3DRMObject methods ***/
920 IDirect3DRMMeshBuilder2Impl_Clone,
921 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
922 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
923 IDirect3DRMMeshBuilder2Impl_SetAppData,
924 IDirect3DRMMeshBuilder2Impl_GetAppData,
925 IDirect3DRMMeshBuilder2Impl_SetName,
926 IDirect3DRMMeshBuilder2Impl_GetName,
927 IDirect3DRMMeshBuilder2Impl_GetClassName,
928 /*** IDirect3DRMMeshBuilder methods ***/
929 IDirect3DRMMeshBuilder2Impl_Load,
930 IDirect3DRMMeshBuilder2Impl_Save,
931 IDirect3DRMMeshBuilder2Impl_Scale,
932 IDirect3DRMMeshBuilder2Impl_Translate,
933 IDirect3DRMMeshBuilder2Impl_SetColorSource,
934 IDirect3DRMMeshBuilder2Impl_GetBox,
935 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
936 IDirect3DRMMeshBuilder2Impl_GetColorSource,
937 IDirect3DRMMeshBuilder2Impl_AddMesh,
938 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
939 IDirect3DRMMeshBuilder2Impl_AddFrame,
940 IDirect3DRMMeshBuilder2Impl_AddFace,
941 IDirect3DRMMeshBuilder2Impl_AddFaces,
942 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
943 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
944 IDirect3DRMMeshBuilder2Impl_SetColor,
945 IDirect3DRMMeshBuilder2Impl_SetTexture,
946 IDirect3DRMMeshBuilder2Impl_SetMaterial,
947 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
948 IDirect3DRMMeshBuilder2Impl_SetQuality,
949 IDirect3DRMMeshBuilder2Impl_SetPerspective,
950 IDirect3DRMMeshBuilder2Impl_SetVertex,
951 IDirect3DRMMeshBuilder2Impl_SetNormal,
952 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
953 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
954 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
955 IDirect3DRMMeshBuilder2Impl_GetFaces,
956 IDirect3DRMMeshBuilder2Impl_GetVertices,
957 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
958 IDirect3DRMMeshBuilder2Impl_AddVertex,
959 IDirect3DRMMeshBuilder2Impl_AddNormal,
960 IDirect3DRMMeshBuilder2Impl_CreateFace,
961 IDirect3DRMMeshBuilder2Impl_GetQuality,
962 IDirect3DRMMeshBuilder2Impl_GetPerspective,
963 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
964 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
965 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
966 IDirect3DRMMeshBuilder2Impl_CreateMesh,
967 /*** IDirect3DRMMeshBuilder2 methods ***/
968 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
969 IDirect3DRMMeshBuilder2Impl_GetFace
973 /*** IUnknown methods ***/
974 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
975 REFIID riid, void** ppvObject)
977 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
978 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
981 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
983 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
984 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
987 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
989 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
990 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
993 /*** IDirect3DRMObject methods ***/
994 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3 *iface,
995 IUnknown *outer, REFIID iid, void **out)
997 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
999 return E_NOTIMPL;
1002 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
1003 D3DRMOBJECTCALLBACK cb, void *ctx)
1005 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1007 return E_NOTIMPL;
1010 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3 *iface,
1011 D3DRMOBJECTCALLBACK cb, void *ctx)
1013 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1015 return E_NOTIMPL;
1018 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1019 DWORD data)
1021 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1023 FIXME("(%p)->(%u): stub\n", This, data);
1025 return E_NOTIMPL;
1028 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1030 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1032 FIXME("(%p)->(): stub\n", This);
1034 return 0;
1037 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3 *iface, const char *name)
1039 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1040 char *string = NULL;
1042 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1044 if (name)
1046 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1047 if (!string) return E_OUTOFMEMORY;
1048 strcpy(string, name);
1050 HeapFree(GetProcessHeap(), 0, mesh_builder->name);
1051 mesh_builder->name = string;
1053 return D3DRM_OK;
1056 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3 *iface,
1057 DWORD *size, char *name)
1059 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1061 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1063 if (!size)
1064 return E_POINTER;
1066 if (!mesh_builder->name)
1068 *size = 0;
1069 return D3DRM_OK;
1072 if (*size < (strlen(mesh_builder->name) + 1))
1073 return E_INVALIDARG;
1075 strcpy(name, mesh_builder->name);
1076 *size = strlen(mesh_builder->name) + 1;
1078 return D3DRM_OK;
1081 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3 *iface,
1082 DWORD *size, char *name)
1084 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1086 if (!size || *size < strlen("Builder") || !name)
1087 return E_INVALIDARG;
1089 strcpy(name, "Builder");
1090 *size = sizeof("Builder");
1092 return D3DRM_OK;
1095 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
1097 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1098 IDirectXFileData *pData2 = NULL;
1099 const GUID* guid;
1100 DWORD size;
1101 BYTE *ptr;
1102 HRESULT hr;
1103 HRESULT ret = D3DRMERR_BADOBJECT;
1104 DWORD* faces_vertex_idx_data = NULL;
1105 DWORD* faces_vertex_idx_ptr;
1106 DWORD faces_vertex_idx_size;
1107 DWORD* faces_normal_idx_data = NULL;
1108 DWORD* faces_normal_idx_ptr = NULL;
1109 DWORD* faces_data_ptr;
1110 DWORD faces_data_size = 0;
1111 DWORD i;
1113 TRACE("(%p)->(%p)\n", This, pData);
1115 hr = IDirectXFileData_GetName(pData, NULL, &size);
1116 if (hr != DXFILE_OK)
1117 return hr;
1118 if (size)
1120 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1121 if (!This->name)
1122 return E_OUTOFMEMORY;
1124 hr = IDirectXFileData_GetName(pData, This->name, &size);
1125 if (hr != DXFILE_OK)
1126 return hr;
1129 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1131 This->nb_normals = 0;
1133 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1134 if (hr != DXFILE_OK)
1135 goto end;
1137 This->nb_vertices = *(DWORD*)ptr;
1138 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1139 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1140 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1142 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1144 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1145 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1147 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1148 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1150 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1151 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2);
1152 faces_data_ptr = (DWORD*)This->pFaceData;
1154 while (1)
1156 IDirectXFileObject *object;
1158 hr = IDirectXFileData_GetNextObject(pData, &object);
1159 if (hr == DXFILEERR_NOMOREOBJECTS)
1161 TRACE("No more object\n");
1162 break;
1164 if (hr != DXFILE_OK)
1165 goto end;
1167 hr = IDirectXFileObject_QueryInterface(object, &IID_IDirectXFileData, (void**)&pData2);
1168 IDirectXFileObject_Release(object);
1169 if (hr != DXFILE_OK)
1170 goto end;
1172 hr = IDirectXFileData_GetType(pData2, &guid);
1173 if (hr != DXFILE_OK)
1174 goto end;
1176 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1178 if (IsEqualGUID(guid, &TID_D3DRMMeshNormals))
1180 DWORD nb_faces_normals;
1181 DWORD faces_normal_idx_size;
1183 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1184 if (hr != DXFILE_OK)
1185 goto end;
1187 This->nb_normals = *(DWORD*)ptr;
1188 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1190 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1191 if (nb_faces_normals != This->nb_faces)
1192 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1194 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1195 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1197 faces_normal_idx_size = size - (2 * sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1198 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1199 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1201 else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords))
1203 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1204 if (hr != DXFILE_OK)
1205 goto end;
1207 This->nb_coords2d = *(DWORD*)ptr;
1209 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1211 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1212 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1215 else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList))
1217 DWORD nb_materials;
1218 DWORD nb_face_indices;
1219 DWORD data_size;
1220 IDirectXFileObject *child;
1221 DWORD i = 0;
1222 float* values;
1224 TRACE("Process MeshMaterialList\n");
1226 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1227 if (hr != DXFILE_OK)
1228 goto end;
1230 nb_materials = *(DWORD*)ptr;
1231 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1232 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1234 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1236 if (size != data_size)
1237 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1239 This->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->material_indices) * nb_face_indices);
1240 if (!This->material_indices)
1241 goto end;
1242 memcpy(This->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*This->material_indices) * nb_face_indices),
1244 This->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->materials) * nb_materials);
1245 if (!This->materials)
1247 HeapFree(GetProcessHeap(), 0, This->material_indices);
1248 goto end;
1250 This->nb_materials = nb_materials;
1252 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1254 IDirectXFileData *data;
1255 IDirectXFileDataReference *reference;
1256 IDirectXFileObject *material_child;
1258 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1259 if (FAILED(hr))
1261 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1262 IDirectXFileObject_Release(child);
1263 if (FAILED(hr))
1264 goto end;
1266 hr = IDirectXFileDataReference_Resolve(reference, &data);
1267 IDirectXFileDataReference_Release(reference);
1268 if (FAILED(hr))
1269 goto end;
1271 else
1273 IDirectXFileObject_Release(child);
1276 hr = Direct3DRMMaterial_create(&This->materials[i].material);
1277 if (FAILED(hr))
1279 IDirectXFileData_Release(data);
1280 goto end;
1283 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1284 if (hr != DXFILE_OK)
1286 IDirectXFileData_Release(data);
1287 goto end;
1290 if (size != 44)
1291 WARN("Material size %u does not match expected one %u\n", size, 44);
1293 values = (float*)ptr;
1295 This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f), (BYTE)(values[1] * 255.0f),
1296 (BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
1298 IDirect3DRMMaterial2_SetAmbient(This->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
1299 IDirect3DRMMaterial2_SetPower(This->materials[i].material, values[4]);
1300 IDirect3DRMMaterial2_SetSpecular(This->materials[i].material, values[5], values[6], values[7]);
1301 IDirect3DRMMaterial2_SetEmissive(This->materials[i].material, values[8], values[9], values[10]);
1303 This->materials[i].texture = NULL;
1305 hr = IDirectXFileData_GetNextObject(data, &material_child);
1306 if (hr == S_OK)
1308 IDirectXFileData *data;
1309 char **filename;
1311 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1312 if (FAILED(hr))
1314 IDirectXFileDataReference *reference;
1316 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1317 if (FAILED(hr))
1318 goto end;
1320 hr = IDirectXFileDataReference_Resolve(reference, &data);
1321 IDirectXFileDataReference_Release(reference);
1322 if (FAILED(hr))
1323 goto end;
1326 hr = IDirectXFileData_GetType(data, &guid);
1327 if (hr != DXFILE_OK)
1328 goto end;
1329 if (!IsEqualGUID(guid, &TID_D3DRMTextureFilename))
1331 WARN("Not a texture filename\n");
1332 goto end;
1335 size = 4;
1336 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1337 if (SUCCEEDED(hr))
1339 if (load_texture_proc)
1341 IDirect3DRMTexture *texture;
1343 hr = load_texture_proc(*filename, arg, &texture);
1344 if (SUCCEEDED(hr))
1346 hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void**)&This->materials[i].texture);
1347 IDirect3DTexture_Release(texture);
1350 else
1352 HANDLE file;
1354 /* If the texture file is not found, no texture is associated with the material */
1355 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1356 if (file != INVALID_HANDLE_VALUE)
1358 CloseHandle(file);
1360 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
1361 if (FAILED(hr))
1363 IDirectXFileData_Release(data);
1364 goto end;
1370 else if (hr != DXFILEERR_NOMOREOBJECTS)
1372 goto end;
1374 hr = S_OK;
1376 IDirectXFileData_Release(data);
1377 i++;
1379 if (hr == S_OK)
1381 IDirectXFileObject_Release(child);
1382 WARN("Found more sub-objects than expected\n");
1384 else if (hr != DXFILEERR_NOMOREOBJECTS)
1386 goto end;
1388 hr = S_OK;
1390 else
1392 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid));
1395 IDirectXFileData_Release(pData2);
1396 pData2 = NULL;
1399 if (!This->nb_normals)
1401 /* Allocate normals, one per vertex */
1402 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1403 if (!This->pNormals)
1404 goto end;
1407 for (i = 0; i < This->nb_faces; i++)
1409 DWORD j;
1410 DWORD nb_face_indexes;
1411 D3DVECTOR face_normal;
1413 if (faces_vertex_idx_size < sizeof(DWORD))
1414 WARN("Not enough data to read number of indices of face %d\n", i);
1416 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1417 faces_vertex_idx_size--;
1418 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1419 WARN("Faces indices number mismatch\n");
1421 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1422 WARN("Not enough data to read all indices of face %d\n", i);
1424 if (!This->nb_normals)
1426 /* Compute face normal */
1427 if (nb_face_indexes > 2)
1429 D3DVECTOR a, b;
1431 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1432 D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1433 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1434 D3DRMVectorNormalize(&face_normal);
1436 else
1438 face_normal.u1.x = 0.0f;
1439 face_normal.u2.y = 0.0f;
1440 face_normal.u3.z = 0.0f;
1444 for (j = 0; j < nb_face_indexes; j++)
1446 /* Copy vertex index */
1447 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1448 /* Copy normal index */
1449 if (This->nb_normals)
1451 /* Read from x file */
1452 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1454 else
1456 DWORD vertex_idx = *faces_vertex_idx_ptr;
1457 if (vertex_idx >= This->nb_vertices)
1459 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1460 vertex_idx = 0;
1462 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1463 /* Add face normal to vertex normal */
1464 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1466 faces_vertex_idx_ptr++;
1468 faces_vertex_idx_size -= nb_face_indexes;
1471 /* Last DWORD must be 0 */
1472 *(faces_data_ptr + faces_data_size++) = 0;
1474 /* Set size (in number of DWORD) of all faces data */
1475 This->face_data_size = faces_data_size;
1477 if (!This->nb_normals)
1479 /* Normalize all normals */
1480 for (i = 0; i < This->nb_vertices; i++)
1482 D3DRMVectorNormalize(&This->pNormals[i]);
1484 This->nb_normals = This->nb_vertices;
1487 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1488 if (!This->pCoords2d)
1490 This->nb_coords2d = This->nb_vertices;
1491 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1492 for (i = 0; i < This->nb_coords2d; i++)
1494 This->pCoords2d[i].u = 0.0f;
1495 This->pCoords2d[i].v = 0.0f;
1499 TRACE("Mesh data loaded successfully\n");
1501 ret = D3DRM_OK;
1503 end:
1505 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1506 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1508 return ret;
1511 /*** IDirect3DRMMeshBuilder3 methods ***/
1512 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1513 void *filename, void *name,
1514 D3DRMLOADOPTIONS loadflags,
1515 D3DRMLOADTEXTURE3CALLBACK cb, void *arg)
1517 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1518 DXFILELOADOPTIONS load_options;
1519 IDirectXFile *dxfile = NULL;
1520 IDirectXFileEnumObject *enum_object = NULL;
1521 IDirectXFileData *data = NULL;
1522 const GUID* guid;
1523 DWORD size;
1524 Header* header;
1525 HRESULT hr;
1526 HRESULT ret = D3DRMERR_BADOBJECT;
1528 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1530 clean_mesh_builder_data(This);
1532 if (loadflags == D3DRMLOAD_FROMMEMORY)
1534 load_options = DXFILELOAD_FROMMEMORY;
1536 else if (loadflags == D3DRMLOAD_FROMFILE)
1538 load_options = DXFILELOAD_FROMFILE;
1539 TRACE("Loading from file %s\n", debugstr_a(filename));
1541 else
1543 FIXME("Load options %d not supported yet\n", loadflags);
1544 return E_NOTIMPL;
1547 hr = DirectXFileCreate(&dxfile);
1548 if (hr != DXFILE_OK)
1549 goto end;
1551 hr = IDirectXFile_RegisterTemplates(dxfile, templates, strlen(templates));
1552 if (hr != DXFILE_OK)
1553 goto end;
1555 hr = IDirectXFile_CreateEnumObject(dxfile, filename, load_options, &enum_object);
1556 if (hr != DXFILE_OK)
1557 goto end;
1559 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1560 if (hr != DXFILE_OK)
1561 goto end;
1563 hr = IDirectXFileData_GetType(data, &guid);
1564 if (hr != DXFILE_OK)
1565 goto end;
1567 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1569 if (!IsEqualGUID(guid, &TID_DXFILEHeader))
1571 ret = D3DRMERR_BADFILE;
1572 goto end;
1575 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&header);
1576 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1577 goto end;
1579 TRACE("Version is %d %d %d\n", header->major, header->minor, header->flags);
1581 /* Version must be 1.0.x */
1582 if ((header->major != 1) || (header->minor != 0))
1584 ret = D3DRMERR_BADFILE;
1585 goto end;
1588 IDirectXFileData_Release(data);
1589 data = NULL;
1591 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1592 if (hr != DXFILE_OK)
1594 ret = D3DRMERR_NOTFOUND;
1595 goto end;
1598 hr = IDirectXFileData_GetType(data, &guid);
1599 if (hr != DXFILE_OK)
1600 goto end;
1602 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1604 if (!IsEqualGUID(guid, &TID_D3DRMMesh))
1606 ret = D3DRMERR_NOTFOUND;
1607 goto end;
1610 /* We don't care about the texture interface version since we rely on QueryInterface */
1611 hr = load_mesh_data(iface, data, (D3DRMLOADTEXTURECALLBACK)cb, arg);
1612 if (hr == S_OK)
1613 ret = D3DRM_OK;
1615 end:
1617 if (data)
1618 IDirectXFileData_Release(data);
1619 if (enum_object)
1620 IDirectXFileEnumObject_Release(enum_object);
1621 if (dxfile)
1622 IDirectXFile_Release(dxfile);
1624 if (ret != D3DRM_OK)
1625 clean_mesh_builder_data(This);
1627 return ret;
1630 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1631 const char* filename, D3DRMXOFFORMAT format,
1632 D3DRMSAVEOPTIONS save)
1634 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1636 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1638 return E_NOTIMPL;
1641 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1642 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1644 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1645 DWORD i;
1647 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1649 for (i = 0; i < This->nb_vertices; i++)
1651 This->pVertices[i].u1.x *= sx;
1652 This->pVertices[i].u2.y *= sy;
1653 This->pVertices[i].u3.z *= sz;
1656 /* Normals are not affected by Scale */
1658 return D3DRM_OK;
1661 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1662 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1664 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1666 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1672 D3DRMCOLORSOURCE color)
1674 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1676 FIXME("(%p)->(%x): stub\n", This, color);
1678 return E_NOTIMPL;
1681 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1682 D3DRMBOX* box)
1684 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1686 FIXME("(%p)->(%p): stub\n", This, box);
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1692 D3DVALUE crease, DWORD flags)
1694 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1696 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1698 return E_NOTIMPL;
1701 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1703 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1705 FIXME("(%p)->(): stub\n", This);
1707 return E_NOTIMPL;
1710 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh *mesh)
1712 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1714 return E_NOTIMPL;
1717 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3 *iface,
1718 IDirect3DRMMeshBuilder3 *mesh_builder, DWORD flags)
1720 FIXME("iface %p, mesh_builder %p, flags %#x stub!\n", iface, mesh_builder, flags);
1722 return E_NOTIMPL;
1725 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFrame3 *frame)
1727 FIXME("iface %p, frame %p stub!\n", iface, frame);
1729 return E_NOTIMPL;
1732 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
1734 FIXME("iface %p, face %p stub!\n", iface, face);
1736 return E_NOTIMPL;
1739 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3 *iface,
1740 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
1741 DWORD *face_data, IDirect3DRMFaceArray **array)
1743 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p array %p stub!\n",
1744 iface, vertex_count, vertices, normal_count, normals, face_data, array);
1746 return E_NOTIMPL;
1749 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1750 DWORD vertex_Count,
1751 DWORD normal_count,
1752 DWORD face_count)
1754 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1756 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1758 return E_NOTIMPL;
1761 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1762 D3DVALUE red, D3DVALUE green,
1763 D3DVALUE blue)
1765 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1767 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1769 This->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
1771 return D3DRM_OK;
1774 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1775 D3DCOLOR color)
1777 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1779 TRACE("(%p)->(%x)\n", This, color);
1781 This->color = color;
1783 return D3DRM_OK;
1786 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3 *iface,
1787 IDirect3DRMTexture3 *texture)
1789 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1791 TRACE("(%p)->(%p)\n", This, texture);
1793 if (texture)
1794 IDirect3DRMTexture3_AddRef(texture);
1795 if (This->texture)
1796 IDirect3DRMTexture3_Release(This->texture);
1797 This->texture = texture;
1799 return D3DRM_OK;
1802 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3 *iface,
1803 IDirect3DRMMaterial2 *material)
1805 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1807 TRACE("iface %p, material %p.\n", iface, material);
1809 if (material)
1810 IDirect3DRMTexture2_AddRef(material);
1811 if (mesh_builder->material)
1812 IDirect3DRMTexture2_Release(mesh_builder->material);
1813 mesh_builder->material = material;
1815 return D3DRM_OK;
1818 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1819 BOOL wrap_u, BOOL wrap_v)
1821 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1823 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1825 return E_NOTIMPL;
1828 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1829 D3DRMRENDERQUALITY quality)
1831 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1833 FIXME("(%p)->(%d): stub\n", This, quality);
1835 return E_NOTIMPL;
1838 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1839 BOOL enable)
1841 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1843 FIXME("(%p)->(%d): stub\n", This, enable);
1845 return E_NOTIMPL;
1848 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1849 DWORD index,
1850 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1852 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1854 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1856 return E_NOTIMPL;
1859 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1860 DWORD index,
1861 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1863 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1865 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1867 return E_NOTIMPL;
1870 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1871 DWORD index, D3DVALUE u,
1872 D3DVALUE v)
1874 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1876 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1878 if (index >= This->nb_coords2d)
1879 return D3DRMERR_BADVALUE;
1881 This->pCoords2d[index].u = u;
1882 This->pCoords2d[index].v = v;
1884 return D3DRM_OK;
1887 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1888 DWORD index, D3DCOLOR color)
1890 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1892 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1894 return E_NOTIMPL;
1897 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1898 DWORD index,
1899 D3DVALUE red, D3DVALUE green,
1900 D3DVALUE blue)
1902 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1904 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1906 return E_NOTIMPL;
1909 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3 *iface,
1910 IDirect3DRMFaceArray **array)
1912 FIXME("iface %p, array %p stub!\n", iface, array);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1918 DWORD* vcount, D3DVECTOR* vertices,
1919 DWORD* ncount, D3DVECTOR* normals,
1920 DWORD* face_data_size,
1921 DWORD* face_data)
1923 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1925 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1926 face_data_size, face_data);
1928 return E_NOTIMPL;
1931 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1932 DWORD index, D3DVALUE* u,
1933 D3DVALUE* v)
1935 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1937 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1939 if (index >= This->nb_coords2d)
1940 return D3DRMERR_BADVALUE;
1942 *u = This->pCoords2d[index].u;
1943 *v = This->pCoords2d[index].v;
1945 return D3DRM_OK;
1949 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1950 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1952 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1954 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1956 return 0;
1959 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1960 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1962 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1964 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1966 return 0;
1969 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 **face)
1971 TRACE("iface %p, face %p.\n", iface, face);
1973 return Direct3DRMFace_create(&IID_IDirect3DRMFace2, (IUnknown **)face);
1976 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
1978 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1980 FIXME("(%p)->(): stub\n", This);
1982 return 0;
1985 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
1987 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1989 FIXME("(%p)->(): stub\n", This);
1991 return FALSE;
1994 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
1996 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1998 TRACE("(%p)->()\n", This);
2000 return This->nb_faces;
2003 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2005 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2007 TRACE("(%p)->()\n", This);
2009 return This->nb_vertices;
2012 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2013 DWORD index)
2015 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2017 FIXME("(%p)->(%d): stub\n", This, index);
2019 return 0;
2022 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh **mesh)
2024 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2025 HRESULT hr;
2026 D3DRMGROUPINDEX group;
2028 TRACE("(%p)->(%p)\n", This, mesh);
2030 if (!mesh)
2031 return E_POINTER;
2033 hr = Direct3DRMMesh_create(mesh);
2034 if (FAILED(hr))
2035 return hr;
2037 /* If there is mesh data, create a group and put data inside */
2038 if (This->nb_vertices)
2040 DWORD i, j;
2041 int k;
2042 D3DRMVERTEX* vertices;
2044 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2045 if (!vertices)
2047 IDirect3DRMMesh_Release(*mesh);
2048 return E_OUTOFMEMORY;
2050 for (i = 0; i < This->nb_vertices; i++)
2051 vertices[i].position = This->pVertices[i];
2052 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2053 HeapFree(GetProcessHeap(), 0, vertices);
2055 /* Groups are in reverse order compared to materials list in X file */
2056 for (k = This->nb_materials - 1; k >= 0; k--)
2058 unsigned* face_data;
2059 unsigned* out_ptr;
2060 DWORD* in_ptr = This->pFaceData;
2061 ULONG vertex_per_face = 0;
2062 BOOL* used_vertices;
2063 unsigned nb_vertices = 0;
2064 unsigned nb_faces = 0;
2066 used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->face_data_size * sizeof(*used_vertices));
2067 if (!used_vertices)
2069 IDirect3DRMMesh_Release(*mesh);
2070 return E_OUTOFMEMORY;
2073 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(*face_data));
2074 if (!face_data)
2076 HeapFree(GetProcessHeap(), 0, used_vertices);
2077 IDirect3DRMMesh_Release(*mesh);
2078 return E_OUTOFMEMORY;
2080 out_ptr = face_data;
2082 /* If all faces have the same number of vertex, set vertex_per_face */
2083 for (i = 0; i < This->nb_faces; i++)
2085 /* Process only faces belonging to the group */
2086 if (This->material_indices[i] == k)
2088 if (vertex_per_face && (vertex_per_face != *in_ptr))
2089 break;
2090 vertex_per_face = *in_ptr;
2092 in_ptr += 1 + *in_ptr * 2;
2094 if (i != This->nb_faces)
2095 vertex_per_face = 0;
2097 /* Put only vertex indices */
2098 in_ptr = This->pFaceData;
2099 for (i = 0; i < This->nb_faces; i++)
2101 DWORD nb_indices = *in_ptr++;
2103 /* Skip faces not belonging to the group */
2104 if (This->material_indices[i] != k)
2106 in_ptr += 2 * nb_indices;
2107 continue;
2110 /* Don't put nb indices when vertex_per_face is set */
2111 if (vertex_per_face)
2112 *out_ptr++ = nb_indices;
2114 for (j = 0; j < nb_indices; j++)
2116 *out_ptr = *in_ptr++;
2117 used_vertices[*out_ptr++] = TRUE;
2118 /* Skip normal index */
2119 in_ptr++;
2122 nb_faces++;
2125 for (i = 0; i < This->nb_vertices; i++)
2126 if (used_vertices[i])
2127 nb_vertices++;
2129 hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group);
2130 HeapFree(GetProcessHeap(), 0, used_vertices);
2131 HeapFree(GetProcessHeap(), 0, face_data);
2132 if (SUCCEEDED(hr))
2133 hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, This->materials[k].color);
2134 if (SUCCEEDED(hr))
2135 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, group,
2136 (IDirect3DRMMaterial *)This->materials[k].material);
2137 if (SUCCEEDED(hr) && This->materials[k].texture)
2139 IDirect3DRMTexture *texture;
2141 IDirect3DRMTexture3_QueryInterface(This->materials[k].texture,
2142 &IID_IDirect3DRMTexture, (void **)&texture);
2143 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, group, texture);
2144 IDirect3DRMTexture_Release(texture);
2146 if (FAILED(hr))
2148 IDirect3DRMMesh_Release(*mesh);
2149 return hr;
2154 return D3DRM_OK;
2157 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3 *iface,
2158 DWORD index, IDirect3DRMFace2 **face)
2160 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
2162 return E_NOTIMPL;
2165 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3 *iface,
2166 DWORD index, D3DVECTOR *vector)
2168 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2170 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2172 return E_NOTIMPL;
2175 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3 *iface,
2176 DWORD index, D3DVECTOR *vector)
2178 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2180 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2182 return E_NOTIMPL;
2185 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2186 DWORD IndexFirst, DWORD count)
2188 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2190 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2192 return E_NOTIMPL;
2195 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2196 DWORD IndexFirst, DWORD count)
2198 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2200 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2202 return E_NOTIMPL;
2205 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
2207 FIXME("iface %p, face %p stub!\n", iface, face);
2209 return E_NOTIMPL;
2212 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2214 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2216 FIXME("(%p)->(%u): stub\n", This, flags);
2218 return E_NOTIMPL;
2221 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2222 DWORD flags)
2224 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2226 FIXME("(%p)->(%u): stub\n", This, flags);
2228 return E_NOTIMPL;
2231 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2232 DWORD flags, DWORD* indices,
2233 DWORD* IndexFirst, DWORD* count)
2235 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2237 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2239 return E_NOTIMPL;
2242 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown **mesh)
2244 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2246 return E_NOTIMPL;
2249 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3 *iface,
2250 DWORD flags, IUnknown **parent)
2252 FIXME("iface %p, flags %#x, parent %p stub!\n", iface, flags, parent);
2254 return E_NOTIMPL;
2257 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3 *iface,
2258 DWORD *count, IUnknown **meshes)
2260 FIXME("iface %p, count %p, meshes %p stub!\n", iface, count, meshes);
2262 return E_NOTIMPL;
2265 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3 *iface, IUnknown *mesh)
2267 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
2269 return E_NOTIMPL;
2272 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2273 DWORD index)
2275 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2277 FIXME("(%p)->(%u): stub\n", This, index);
2279 return E_NOTIMPL;
2282 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2283 DWORD* indices)
2285 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2287 FIXME("(%p)->(%p): stub\n", This, indices);
2289 return E_NOTIMPL;
2292 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3 *iface,
2293 DWORD flags, DWORD format, DWORD vertex_count, void *data)
2295 FIXME("iface %p, flags %#x, format %#x, vertex_count %u, data %p stub!\n",
2296 iface, flags, format, vertex_count, data);
2298 return E_NOTIMPL;
2301 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3 *iface,
2302 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2304 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2306 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2308 return E_NOTIMPL;
2311 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3 *iface,
2312 DWORD IndexFirst, DWORD *vcount, D3DVECTOR *vertices)
2314 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2315 DWORD count = This->nb_vertices - IndexFirst;
2317 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2319 if (vcount)
2320 *vcount = count;
2321 if (vertices && This->nb_vertices)
2322 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2324 return D3DRM_OK;
2327 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3 *iface,
2328 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2330 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2332 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2334 return E_NOTIMPL;
2337 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3 *iface,
2338 DWORD IndexFirst, DWORD *ncount, D3DVECTOR *normals)
2340 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2341 DWORD count = This->nb_normals - IndexFirst;
2343 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, ncount, normals);
2345 if (ncount)
2346 *ncount = count;
2347 if (normals && This->nb_normals)
2348 memcpy(normals, This->pNormals + IndexFirst, count * sizeof(D3DVECTOR));
2350 return D3DRM_OK;
2353 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2355 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2357 TRACE("(%p)->()\n", This);
2359 return This->nb_normals;
2362 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2364 /*** IUnknown methods ***/
2365 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2366 IDirect3DRMMeshBuilder3Impl_AddRef,
2367 IDirect3DRMMeshBuilder3Impl_Release,
2368 /*** IDirect3DRMObject methods ***/
2369 IDirect3DRMMeshBuilder3Impl_Clone,
2370 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2371 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2372 IDirect3DRMMeshBuilder3Impl_SetAppData,
2373 IDirect3DRMMeshBuilder3Impl_GetAppData,
2374 IDirect3DRMMeshBuilder3Impl_SetName,
2375 IDirect3DRMMeshBuilder3Impl_GetName,
2376 IDirect3DRMMeshBuilder3Impl_GetClassName,
2377 /*** IDirect3DRMMeshBuilder3 methods ***/
2378 IDirect3DRMMeshBuilder3Impl_Load,
2379 IDirect3DRMMeshBuilder3Impl_Save,
2380 IDirect3DRMMeshBuilder3Impl_Scale,
2381 IDirect3DRMMeshBuilder3Impl_Translate,
2382 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2383 IDirect3DRMMeshBuilder3Impl_GetBox,
2384 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2385 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2386 IDirect3DRMMeshBuilder3Impl_AddMesh,
2387 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2388 IDirect3DRMMeshBuilder3Impl_AddFrame,
2389 IDirect3DRMMeshBuilder3Impl_AddFace,
2390 IDirect3DRMMeshBuilder3Impl_AddFaces,
2391 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2392 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2393 IDirect3DRMMeshBuilder3Impl_SetColor,
2394 IDirect3DRMMeshBuilder3Impl_SetTexture,
2395 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2396 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2397 IDirect3DRMMeshBuilder3Impl_SetQuality,
2398 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2399 IDirect3DRMMeshBuilder3Impl_SetVertex,
2400 IDirect3DRMMeshBuilder3Impl_SetNormal,
2401 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2402 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2403 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2404 IDirect3DRMMeshBuilder3Impl_GetFaces,
2405 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2406 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2407 IDirect3DRMMeshBuilder3Impl_AddVertex,
2408 IDirect3DRMMeshBuilder3Impl_AddNormal,
2409 IDirect3DRMMeshBuilder3Impl_CreateFace,
2410 IDirect3DRMMeshBuilder3Impl_GetQuality,
2411 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2412 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2413 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2414 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2415 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2416 IDirect3DRMMeshBuilder3Impl_GetFace,
2417 IDirect3DRMMeshBuilder3Impl_GetVertex,
2418 IDirect3DRMMeshBuilder3Impl_GetNormal,
2419 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2420 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2421 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2422 IDirect3DRMMeshBuilder3Impl_Empty,
2423 IDirect3DRMMeshBuilder3Impl_Optimize,
2424 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2425 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2426 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2427 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2428 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2429 IDirect3DRMMeshBuilder3Impl_Enable,
2430 IDirect3DRMMeshBuilder3Impl_GetEnable,
2431 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2432 IDirect3DRMMeshBuilder3Impl_SetVertices,
2433 IDirect3DRMMeshBuilder3Impl_GetVertices,
2434 IDirect3DRMMeshBuilder3Impl_SetNormals,
2435 IDirect3DRMMeshBuilder3Impl_GetNormals,
2436 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2439 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2441 IDirect3DRMMeshBuilderImpl* object;
2443 TRACE("(%p)\n", ppObj);
2445 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2446 if (!object)
2447 return E_OUTOFMEMORY;
2449 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2450 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2451 object->ref = 1;
2453 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2454 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2455 else
2456 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2458 return S_OK;
2461 /*** IUnknown methods ***/
2462 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2463 REFIID riid, void** ppvObject)
2465 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2467 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2469 *ppvObject = NULL;
2471 if (IsEqualGUID(riid, &IID_IUnknown) ||
2472 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2474 *ppvObject = &This->IDirect3DRMMesh_iface;
2476 else
2478 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2479 return E_NOINTERFACE;
2482 IDirect3DRMMesh_AddRef(iface);
2483 return S_OK;
2486 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2488 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2489 ULONG ref = InterlockedIncrement(&This->ref);
2491 TRACE("(%p)->(): new ref = %d\n", This, ref);
2493 return ref;
2496 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2498 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2499 ULONG ref = InterlockedDecrement(&This->ref);
2501 TRACE("(%p)->(): new ref = %d\n", This, ref);
2503 if (!ref)
2505 DWORD i;
2507 for (i = 0; i < This->nb_groups; i++)
2509 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2510 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2511 if (This->groups[i].material)
2512 IDirect3DRMMaterial2_Release(This->groups[i].material);
2513 if (This->groups[i].texture)
2514 IDirect3DRMTexture3_Release(This->groups[i].texture);
2516 HeapFree(GetProcessHeap(), 0, This->groups);
2517 HeapFree(GetProcessHeap(), 0, This);
2520 return ref;
2523 /*** IDirect3DRMObject methods ***/
2524 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh *iface,
2525 IUnknown *outer, REFIID iid, void **out)
2527 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
2529 return E_NOTIMPL;
2532 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh *iface,
2533 D3DRMOBJECTCALLBACK cb, void *ctx)
2535 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2537 return E_NOTIMPL;
2540 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh *iface,
2541 D3DRMOBJECTCALLBACK cb, void *ctx)
2543 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
2545 return E_NOTIMPL;
2548 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2549 DWORD data)
2551 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2553 FIXME("(%p)->(%u): stub\n", This, data);
2555 return E_NOTIMPL;
2558 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2560 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2562 FIXME("(%p)->(): stub\n", This);
2564 return 0;
2567 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh *iface, const char *name)
2569 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
2571 return E_NOTIMPL;
2574 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2576 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
2578 return E_NOTIMPL;
2581 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh *iface, DWORD *size, char *name)
2583 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
2585 if (!size || *size < strlen("Mesh") || !name)
2586 return E_INVALIDARG;
2588 strcpy(name, "Mesh");
2589 *size = sizeof("Mesh");
2591 return D3DRM_OK;
2594 /*** IDirect3DRMMesh methods ***/
2595 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2596 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2598 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2600 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2602 return E_NOTIMPL;
2605 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2606 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2608 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2610 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2612 return E_NOTIMPL;
2615 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2616 D3DRMBOX * box)
2618 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2620 FIXME("(%p)->(%p): stub\n", This, box);
2622 return E_NOTIMPL;
2625 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2626 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2627 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2629 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2630 mesh_group* group;
2632 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2634 if (!face_data || !return_id)
2635 return E_POINTER;
2637 if ((This->nb_groups + 1) > This->groups_capacity)
2639 ULONG new_capacity;
2640 mesh_group* groups;
2642 if (!This->groups_capacity)
2644 new_capacity = 16;
2645 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2647 else
2649 new_capacity = This->groups_capacity * 2;
2650 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2653 if (!groups)
2654 return E_OUTOFMEMORY;
2656 This->groups_capacity = new_capacity;
2657 This->groups = groups;
2660 group = This->groups + This->nb_groups;
2662 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2663 if (!group->vertices)
2664 return E_OUTOFMEMORY;
2665 group->nb_vertices = vertex_count;
2666 group->nb_faces = face_count;
2667 group->vertex_per_face = vertex_per_face;
2669 if (vertex_per_face)
2671 group->face_data_size = face_count * vertex_per_face;
2673 else
2675 unsigned i;
2676 unsigned nb_indices;
2677 unsigned* face_data_ptr = face_data;
2678 group->face_data_size = 0;
2680 for (i = 0; i < face_count; i++)
2682 nb_indices = *face_data_ptr;
2683 group->face_data_size += nb_indices + 1;
2684 face_data_ptr += nb_indices;
2688 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2689 if (!group->face_data)
2691 HeapFree(GetProcessHeap(), 0 , group->vertices);
2692 return E_OUTOFMEMORY;
2695 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2697 group->material = NULL;
2698 group->texture = NULL;
2700 *return_id = This->nb_groups++;
2702 return D3DRM_OK;
2705 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2706 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2707 D3DRMVERTEX *values)
2709 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2711 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2713 if (id >= This->nb_groups)
2714 return D3DRMERR_BADVALUE;
2716 if ((index + count - 1) >= This->groups[id].nb_vertices)
2717 return D3DRMERR_BADVALUE;
2719 if (!values)
2720 return E_POINTER;
2722 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2724 return D3DRM_OK;
2727 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2728 D3DRMGROUPINDEX id, D3DCOLOR color)
2730 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2732 TRACE("(%p)->(%u,%x)\n", This, id, color);
2734 if (id >= This->nb_groups)
2735 return D3DRMERR_BADVALUE;
2737 This->groups[id].color = color;
2739 return D3DRM_OK;
2742 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2743 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2745 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2747 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2749 if (id >= This->nb_groups)
2750 return D3DRMERR_BADVALUE;
2752 This->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
2754 return D3DRM_OK;
2757 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2758 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2760 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2762 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2764 return E_NOTIMPL;
2767 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2768 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2770 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2772 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2774 return E_NOTIMPL;
2777 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh *iface,
2778 D3DRMGROUPINDEX id, IDirect3DRMMaterial *material)
2780 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2782 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2784 if (id >= mesh->nb_groups)
2785 return D3DRMERR_BADVALUE;
2787 if (mesh->groups[id].material)
2788 IDirect3DRMMaterial2_Release(mesh->groups[id].material);
2790 mesh->groups[id].material = (IDirect3DRMMaterial2 *)material;
2792 if (material)
2793 IDirect3DRMMaterial2_AddRef(mesh->groups[id].material);
2795 return D3DRM_OK;
2798 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh *iface,
2799 D3DRMGROUPINDEX id, IDirect3DRMTexture *texture)
2801 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2803 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2805 if (id >= This->nb_groups)
2806 return D3DRMERR_BADVALUE;
2808 if (This->groups[id].texture)
2809 IDirect3DRMTexture3_Release(This->groups[id].texture);
2811 if (!texture)
2813 This->groups[id].texture = NULL;
2814 return D3DRM_OK;
2817 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (void **)&This->groups[id].texture);
2820 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2822 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2824 TRACE("(%p)->()\n", This);
2826 return This->nb_groups;
2829 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2830 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2831 DWORD *face_data_size, unsigned *face_data)
2833 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2835 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2837 if (id >= This->nb_groups)
2838 return D3DRMERR_BADVALUE;
2840 if (vertex_count)
2841 *vertex_count = This->groups[id].nb_vertices;
2842 if (face_count)
2843 *face_count = This->groups[id].nb_faces;
2844 if (vertex_per_face)
2845 *vertex_per_face = This->groups[id].vertex_per_face;
2846 if (face_data_size)
2847 *face_data_size = This->groups[id].face_data_size;
2848 if (face_data)
2849 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size * sizeof(DWORD));
2851 return D3DRM_OK;
2854 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2855 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2857 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2859 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2861 if (id >= This->nb_groups)
2862 return D3DRMERR_BADVALUE;
2864 if ((index + count - 1) >= This->groups[id].nb_vertices)
2865 return D3DRMERR_BADVALUE;
2867 if (!return_ptr)
2868 return E_POINTER;
2870 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2872 return D3DRM_OK;
2875 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2877 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2879 TRACE("(%p)->(%u)\n", This, id);
2881 return This->groups[id].color;
2884 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2886 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2888 FIXME("(%p)->(%u): stub\n", This, id);
2890 return 0;
2892 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2894 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2896 FIXME("(%p)->(%u): stub\n", This, id);
2898 return 0;
2901 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh *iface,
2902 D3DRMGROUPINDEX id, IDirect3DRMMaterial **material)
2904 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2906 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2908 if (id >= mesh->nb_groups)
2909 return D3DRMERR_BADVALUE;
2911 if (!material)
2912 return E_POINTER;
2914 if (mesh->groups[id].material)
2915 IDirect3DRMTexture_QueryInterface(mesh->groups[id].material, &IID_IDirect3DRMMaterial, (void **)material);
2916 else
2917 *material = NULL;
2919 return D3DRM_OK;
2922 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh *iface,
2923 D3DRMGROUPINDEX id, IDirect3DRMTexture **texture)
2925 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2927 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2929 if (id >= This->nb_groups)
2930 return D3DRMERR_BADVALUE;
2932 if (!texture)
2933 return E_POINTER;
2935 if (This->groups[id].texture)
2936 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2937 else
2938 *texture = NULL;
2940 return D3DRM_OK;
2943 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2945 /*** IUnknown methods ***/
2946 IDirect3DRMMeshImpl_QueryInterface,
2947 IDirect3DRMMeshImpl_AddRef,
2948 IDirect3DRMMeshImpl_Release,
2949 /*** IDirect3DRMObject methods ***/
2950 IDirect3DRMMeshImpl_Clone,
2951 IDirect3DRMMeshImpl_AddDestroyCallback,
2952 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2953 IDirect3DRMMeshImpl_SetAppData,
2954 IDirect3DRMMeshImpl_GetAppData,
2955 IDirect3DRMMeshImpl_SetName,
2956 IDirect3DRMMeshImpl_GetName,
2957 IDirect3DRMMeshImpl_GetClassName,
2958 /*** IDirect3DRMMesh methods ***/
2959 IDirect3DRMMeshImpl_Scale,
2960 IDirect3DRMMeshImpl_Translate,
2961 IDirect3DRMMeshImpl_GetBox,
2962 IDirect3DRMMeshImpl_AddGroup,
2963 IDirect3DRMMeshImpl_SetVertices,
2964 IDirect3DRMMeshImpl_SetGroupColor,
2965 IDirect3DRMMeshImpl_SetGroupColorRGB,
2966 IDirect3DRMMeshImpl_SetGroupMapping,
2967 IDirect3DRMMeshImpl_SetGroupQuality,
2968 IDirect3DRMMeshImpl_SetGroupMaterial,
2969 IDirect3DRMMeshImpl_SetGroupTexture,
2970 IDirect3DRMMeshImpl_GetGroupCount,
2971 IDirect3DRMMeshImpl_GetGroup,
2972 IDirect3DRMMeshImpl_GetVertices,
2973 IDirect3DRMMeshImpl_GetGroupColor,
2974 IDirect3DRMMeshImpl_GetGroupMapping,
2975 IDirect3DRMMeshImpl_GetGroupQuality,
2976 IDirect3DRMMeshImpl_GetGroupMaterial,
2977 IDirect3DRMMeshImpl_GetGroupTexture
2980 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2982 IDirect3DRMMeshImpl* object;
2984 TRACE("(%p)\n", obj);
2986 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2987 if (!object)
2988 return E_OUTOFMEMORY;
2990 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
2991 object->ref = 1;
2993 *obj = &object->IDirect3DRMMesh_iface;
2995 return S_OK;