Release 1.6-rc2.
[wine/testsucceed.git] / dlls / d3drm / meshbuilder.c
blob136065c5ae591bf5ce35f1da7418c6fe9ddcd738
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 LPVOID 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 LPUNKNOWN pUnkOuter, REFIID riid,
420 LPVOID *ppvObj)
422 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
424 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
426 return E_NOTIMPL;
429 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2* iface,
430 D3DRMOBJECTCALLBACK cb,
431 LPVOID argument)
433 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
435 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
437 return E_NOTIMPL;
440 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2* iface,
441 D3DRMOBJECTCALLBACK cb,
442 LPVOID argument)
444 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
446 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
448 return E_NOTIMPL;
451 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
452 DWORD data)
454 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
456 FIXME("(%p)->(%u): stub\n", This, data);
458 return E_NOTIMPL;
461 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
463 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
465 FIXME("(%p)->(): stub\n", This);
467 return 0;
470 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2* iface,
471 LPCSTR name)
473 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
475 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
477 return IDirect3DRMMeshBuilder3_SetName(&This->IDirect3DRMMeshBuilder3_iface, name);
480 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2* iface,
481 LPDWORD size, LPSTR name)
483 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
485 TRACE("(%p)->(%p,%p)\n", This, size, name);
487 return IDirect3DRMMeshBuilder3_GetName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
490 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2* iface,
491 LPDWORD size, LPSTR name)
493 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
495 TRACE("(%p)->(%p, %p)\n", This, size, name);
497 return IDirect3DRMMeshBuilder3_GetClassName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
500 /*** IDirect3DRMMeshBuilder2 methods ***/
501 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2* iface,
502 LPVOID filename, LPVOID name,
503 D3DRMLOADOPTIONS loadflags,
504 D3DRMLOADTEXTURECALLBACK cb, LPVOID arg)
506 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
508 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
510 if (cb)
511 FIXME("Texture callback is not yet supported\n");
513 return IDirect3DRMMeshBuilder3_Load(&This->IDirect3DRMMeshBuilder3_iface, filename, name,
514 loadflags, NULL, arg);
517 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
518 const char *filename, D3DRMXOFFORMAT format,
519 D3DRMSAVEOPTIONS save)
521 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
523 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
525 return E_NOTIMPL;
528 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
529 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
531 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
533 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
535 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
538 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
539 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
541 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
543 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
545 return E_NOTIMPL;
548 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
549 D3DRMCOLORSOURCE color)
551 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
553 FIXME("(%p)->(%x): stub\n", This, color);
555 return E_NOTIMPL;
558 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
559 D3DRMBOX *pBox)
561 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
563 FIXME("(%p)->(%p): stub\n", This, pBox);
565 return E_NOTIMPL;
568 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
570 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
572 FIXME("(%p)->(): stub\n", This);
574 return E_NOTIMPL;
577 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
579 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
581 FIXME("(%p)->(): stub\n", This);
583 return E_NOTIMPL;
586 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh *mesh)
588 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
590 return E_NOTIMPL;
593 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2 *iface,
594 IDirect3DRMMeshBuilder *mesh_builder)
596 FIXME("iface %p, mesh_builder %p stub!\n", iface, mesh_builder);
598 return E_NOTIMPL;
601 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFrame *frame)
603 FIXME("iface %p, frame %p stub!\n", iface, frame);
605 return E_NOTIMPL;
608 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace *face)
610 FIXME("iface %p, face %p stub!\n", iface, face);
612 return E_NOTIMPL;
615 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2 *iface,
616 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
617 DWORD *face_data, IDirect3DRMFaceArray **array)
619 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p, array %p stub!\n",
620 iface, vertex_count, vertices, normal_count, normals, face_data, array);
622 return E_NOTIMPL;
625 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
626 DWORD vertex_Count,
627 DWORD normal_count,
628 DWORD face_count)
630 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
632 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
634 return E_NOTIMPL;
637 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
638 D3DVALUE red, D3DVALUE green,
639 D3DVALUE blue)
641 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
643 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
645 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
648 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
649 D3DCOLOR color)
651 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
653 TRACE("(%p)->(%x)\n", This, color);
655 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
658 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2 *iface,
659 IDirect3DRMTexture *texture)
661 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
662 IDirect3DRMTexture3 *texture3 = NULL;
663 HRESULT hr = D3DRM_OK;
665 if (texture)
666 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
667 if (SUCCEEDED(hr))
668 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
669 if (texture3)
670 IDirect3DRMTexture3_Release(texture3);
672 return hr;
675 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2 *iface,
676 IDirect3DRMMaterial *material)
678 IDirect3DRMMeshBuilderImpl *d3drm = impl_from_IDirect3DRMMeshBuilder2(iface);
680 TRACE("iface %p, material %p.\n", iface, material);
682 return IDirect3DRMMeshBuilder3_SetMaterial(&d3drm->IDirect3DRMMeshBuilder3_iface,
683 (IDirect3DRMMaterial2 *)material);
686 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
687 BOOL wrap_u, BOOL wrap_v)
689 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
691 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
693 return E_NOTIMPL;
696 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
697 D3DRMRENDERQUALITY quality)
699 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
701 FIXME("(%p)->(%d): stub\n", This, quality);
703 return E_NOTIMPL;
706 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
707 BOOL enable)
709 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
711 FIXME("(%p)->(%d): stub\n", This, enable);
713 return E_NOTIMPL;
716 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(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_SetNormal(IDirect3DRMMeshBuilder2* iface,
728 DWORD index,
729 D3DVALUE x, D3DVALUE y, D3DVALUE z)
731 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
733 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
735 return E_NOTIMPL;
738 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
739 DWORD index,
740 D3DVALUE u, D3DVALUE v)
742 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
744 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
746 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
747 index, u, v);
750 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
751 DWORD index, D3DCOLOR color)
753 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
755 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
757 return E_NOTIMPL;
760 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
761 DWORD index, D3DVALUE red,
762 D3DVALUE green, D3DVALUE blue)
764 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
766 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
768 return E_NOTIMPL;
771 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2 *iface,
772 IDirect3DRMFaceArray **array)
774 FIXME("iface %p, array %p stub!\n", iface, array);
776 return E_NOTIMPL;
779 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
780 DWORD *vcount, D3DVECTOR *vertices,
781 DWORD *ncount, D3DVECTOR *normals,
782 DWORD *face_data_size,
783 DWORD *face_data)
785 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
787 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
789 if (vertices && (!vcount || (*vcount < This->nb_vertices)))
790 return D3DRMERR_BADVALUE;
791 if (vcount)
792 *vcount = This->nb_vertices;
793 if (vertices && This->nb_vertices)
794 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
796 if (normals && (!ncount || (*ncount < This->nb_normals)))
797 return D3DRMERR_BADVALUE;
798 if (ncount)
799 *ncount = This->nb_normals;
800 if (normals && This->nb_normals)
801 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
803 if (face_data && (!face_data_size || (*face_data_size < This->face_data_size)))
804 return D3DRMERR_BADVALUE;
805 if (face_data_size)
806 *face_data_size = This->face_data_size;
807 if (face_data && This->face_data_size)
808 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
810 return D3DRM_OK;
813 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
814 DWORD index,
815 D3DVALUE *u, D3DVALUE *v)
817 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
819 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
821 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
822 index, u, v);
825 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
826 D3DVALUE x, D3DVALUE y, D3DVALUE z)
828 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
830 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
832 return 0;
835 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
836 D3DVALUE x, D3DVALUE y, D3DVALUE z)
838 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
840 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
842 return 0;
845 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMFace **face)
847 TRACE("iface %p, face %p.\n", iface, face);
849 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
852 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
854 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
856 FIXME("(%p)->(): stub\n", This);
858 return 0;
861 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
863 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
865 FIXME("(%p)->(): stub\n", This);
867 return FALSE;
870 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
872 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
874 TRACE("(%p)->()\n", This);
876 return This->nb_faces;
879 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
881 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
883 TRACE("(%p)->()\n", This);
885 return This->nb_vertices;
888 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
889 DWORD index)
891 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
893 FIXME("(%p)->(%d): stub\n", This, index);
895 return 0;
898 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh **mesh)
900 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
902 TRACE("iface %p, mesh %p.\n", iface, mesh);
904 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder->IDirect3DRMMeshBuilder3_iface, mesh);
907 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
908 D3DVALUE crease, DWORD dwFlags)
910 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
912 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
914 return E_NOTIMPL;
917 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2 *iface,
918 DWORD index, IDirect3DRMFace **face)
920 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
922 return E_NOTIMPL;
925 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
927 /*** IUnknown methods ***/
928 IDirect3DRMMeshBuilder2Impl_QueryInterface,
929 IDirect3DRMMeshBuilder2Impl_AddRef,
930 IDirect3DRMMeshBuilder2Impl_Release,
931 /*** IDirect3DRMObject methods ***/
932 IDirect3DRMMeshBuilder2Impl_Clone,
933 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
934 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
935 IDirect3DRMMeshBuilder2Impl_SetAppData,
936 IDirect3DRMMeshBuilder2Impl_GetAppData,
937 IDirect3DRMMeshBuilder2Impl_SetName,
938 IDirect3DRMMeshBuilder2Impl_GetName,
939 IDirect3DRMMeshBuilder2Impl_GetClassName,
940 /*** IDirect3DRMMeshBuilder methods ***/
941 IDirect3DRMMeshBuilder2Impl_Load,
942 IDirect3DRMMeshBuilder2Impl_Save,
943 IDirect3DRMMeshBuilder2Impl_Scale,
944 IDirect3DRMMeshBuilder2Impl_Translate,
945 IDirect3DRMMeshBuilder2Impl_SetColorSource,
946 IDirect3DRMMeshBuilder2Impl_GetBox,
947 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
948 IDirect3DRMMeshBuilder2Impl_GetColorSource,
949 IDirect3DRMMeshBuilder2Impl_AddMesh,
950 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
951 IDirect3DRMMeshBuilder2Impl_AddFrame,
952 IDirect3DRMMeshBuilder2Impl_AddFace,
953 IDirect3DRMMeshBuilder2Impl_AddFaces,
954 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
955 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
956 IDirect3DRMMeshBuilder2Impl_SetColor,
957 IDirect3DRMMeshBuilder2Impl_SetTexture,
958 IDirect3DRMMeshBuilder2Impl_SetMaterial,
959 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
960 IDirect3DRMMeshBuilder2Impl_SetQuality,
961 IDirect3DRMMeshBuilder2Impl_SetPerspective,
962 IDirect3DRMMeshBuilder2Impl_SetVertex,
963 IDirect3DRMMeshBuilder2Impl_SetNormal,
964 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
965 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
966 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
967 IDirect3DRMMeshBuilder2Impl_GetFaces,
968 IDirect3DRMMeshBuilder2Impl_GetVertices,
969 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
970 IDirect3DRMMeshBuilder2Impl_AddVertex,
971 IDirect3DRMMeshBuilder2Impl_AddNormal,
972 IDirect3DRMMeshBuilder2Impl_CreateFace,
973 IDirect3DRMMeshBuilder2Impl_GetQuality,
974 IDirect3DRMMeshBuilder2Impl_GetPerspective,
975 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
976 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
977 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
978 IDirect3DRMMeshBuilder2Impl_CreateMesh,
979 /*** IDirect3DRMMeshBuilder2 methods ***/
980 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
981 IDirect3DRMMeshBuilder2Impl_GetFace
985 /*** IUnknown methods ***/
986 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
987 REFIID riid, void** ppvObject)
989 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
990 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
993 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
995 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
996 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
999 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
1001 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1002 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
1005 /*** IDirect3DRMObject methods ***/
1006 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3* iface,
1007 LPUNKNOWN pUnkOuter, REFIID riid,
1008 LPVOID *ppvObj)
1010 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1012 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
1014 return E_NOTIMPL;
1017 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1018 D3DRMOBJECTCALLBACK cb,
1019 LPVOID argument)
1021 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1023 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1025 return E_NOTIMPL;
1028 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1029 D3DRMOBJECTCALLBACK cb,
1030 LPVOID argument)
1032 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1034 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1036 return E_NOTIMPL;
1039 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1040 DWORD data)
1042 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1044 FIXME("(%p)->(%u): stub\n", This, data);
1046 return E_NOTIMPL;
1049 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1051 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1053 FIXME("(%p)->(): stub\n", This);
1055 return 0;
1058 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1059 LPCSTR name)
1061 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1062 char *string = NULL;
1064 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
1066 if (name)
1068 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1069 if (!string) return E_OUTOFMEMORY;
1070 strcpy(string, name);
1072 HeapFree(GetProcessHeap(), 0, This->name);
1073 This->name = string;
1075 return D3DRM_OK;
1078 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3* iface,
1079 LPDWORD size, LPSTR name)
1081 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1083 TRACE("(%p)->(%p,%p)\n", This, size, name);
1085 if (!size)
1086 return E_POINTER;
1088 if (!This->name)
1090 *size = 0;
1091 return D3DRM_OK;
1094 if (*size < (strlen(This->name) + 1))
1095 return E_INVALIDARG;
1097 strcpy(name, This->name);
1098 *size = strlen(This->name) + 1;
1100 return D3DRM_OK;
1103 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3* iface,
1104 LPDWORD size, LPSTR name)
1106 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1108 TRACE("(%p)->(%p, %p)\n", This, size, name);
1110 if (!size || *size < strlen("Builder") || !name)
1111 return E_INVALIDARG;
1113 strcpy(name, "Builder");
1114 *size = sizeof("Builder");
1116 return D3DRM_OK;
1119 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
1121 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1122 IDirectXFileData *pData2 = NULL;
1123 const GUID* guid;
1124 DWORD size;
1125 BYTE *ptr;
1126 HRESULT hr;
1127 HRESULT ret = D3DRMERR_BADOBJECT;
1128 DWORD* faces_vertex_idx_data = NULL;
1129 DWORD* faces_vertex_idx_ptr;
1130 DWORD faces_vertex_idx_size;
1131 DWORD* faces_normal_idx_data = NULL;
1132 DWORD* faces_normal_idx_ptr = NULL;
1133 DWORD* faces_data_ptr;
1134 DWORD faces_data_size = 0;
1135 DWORD i;
1137 TRACE("(%p)->(%p)\n", This, pData);
1139 hr = IDirectXFileData_GetName(pData, NULL, &size);
1140 if (hr != DXFILE_OK)
1141 return hr;
1142 if (size)
1144 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1145 if (!This->name)
1146 return E_OUTOFMEMORY;
1148 hr = IDirectXFileData_GetName(pData, This->name, &size);
1149 if (hr != DXFILE_OK)
1150 return hr;
1153 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1155 This->nb_normals = 0;
1157 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1158 if (hr != DXFILE_OK)
1159 goto end;
1161 This->nb_vertices = *(DWORD*)ptr;
1162 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1163 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1164 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1166 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1168 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1169 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1171 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1172 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1174 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1175 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2);
1176 faces_data_ptr = (DWORD*)This->pFaceData;
1178 while (1)
1180 IDirectXFileObject *object;
1182 hr = IDirectXFileData_GetNextObject(pData, &object);
1183 if (hr == DXFILEERR_NOMOREOBJECTS)
1185 TRACE("No more object\n");
1186 break;
1188 if (hr != DXFILE_OK)
1189 goto end;
1191 hr = IDirectXFileObject_QueryInterface(object, &IID_IDirectXFileData, (void**)&pData2);
1192 IDirectXFileObject_Release(object);
1193 if (hr != DXFILE_OK)
1194 goto end;
1196 hr = IDirectXFileData_GetType(pData2, &guid);
1197 if (hr != DXFILE_OK)
1198 goto end;
1200 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1202 if (IsEqualGUID(guid, &TID_D3DRMMeshNormals))
1204 DWORD nb_faces_normals;
1205 DWORD faces_normal_idx_size;
1207 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1208 if (hr != DXFILE_OK)
1209 goto end;
1211 This->nb_normals = *(DWORD*)ptr;
1212 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1214 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1215 if (nb_faces_normals != This->nb_faces)
1216 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1218 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1219 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1221 faces_normal_idx_size = size - (2 * sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1222 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1223 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1225 else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords))
1227 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1228 if (hr != DXFILE_OK)
1229 goto end;
1231 This->nb_coords2d = *(DWORD*)ptr;
1233 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1235 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1236 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1239 else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList))
1241 DWORD nb_materials;
1242 DWORD nb_face_indices;
1243 DWORD data_size;
1244 IDirectXFileObject *child;
1245 DWORD i = 0;
1246 float* values;
1248 TRACE("Process MeshMaterialList\n");
1250 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1251 if (hr != DXFILE_OK)
1252 goto end;
1254 nb_materials = *(DWORD*)ptr;
1255 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1256 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1258 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1260 if (size != data_size)
1261 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1263 This->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->material_indices) * nb_face_indices);
1264 if (!This->material_indices)
1265 goto end;
1266 memcpy(This->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*This->material_indices) * nb_face_indices),
1268 This->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->materials) * nb_materials);
1269 if (!This->materials)
1271 HeapFree(GetProcessHeap(), 0, This->material_indices);
1272 goto end;
1274 This->nb_materials = nb_materials;
1276 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1278 IDirectXFileData *data;
1279 IDirectXFileDataReference *reference;
1280 IDirectXFileObject *material_child;
1282 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1283 if (FAILED(hr))
1285 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1286 IDirectXFileObject_Release(child);
1287 if (FAILED(hr))
1288 goto end;
1290 hr = IDirectXFileDataReference_Resolve(reference, &data);
1291 IDirectXFileDataReference_Release(reference);
1292 if (FAILED(hr))
1293 goto end;
1295 else
1297 IDirectXFileObject_Release(child);
1300 hr = Direct3DRMMaterial_create(&This->materials[i].material);
1301 if (FAILED(hr))
1303 IDirectXFileData_Release(data);
1304 goto end;
1307 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1308 if (hr != DXFILE_OK)
1310 IDirectXFileData_Release(data);
1311 goto end;
1314 if (size != 44)
1315 WARN("Material size %u does not match expected one %u\n", size, 44);
1317 values = (float*)ptr;
1319 This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f), (BYTE)(values[1] * 255.0f),
1320 (BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
1322 IDirect3DRMMaterial2_SetAmbient(This->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
1323 IDirect3DRMMaterial2_SetPower(This->materials[i].material, values[4]);
1324 IDirect3DRMMaterial2_SetSpecular(This->materials[i].material, values[5], values[6], values[7]);
1325 IDirect3DRMMaterial2_SetEmissive(This->materials[i].material, values[8], values[9], values[10]);
1327 This->materials[i].texture = NULL;
1329 hr = IDirectXFileData_GetNextObject(data, &material_child);
1330 if (hr == S_OK)
1332 IDirectXFileData *data;
1333 char **filename;
1335 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1336 if (FAILED(hr))
1338 IDirectXFileDataReference *reference;
1340 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1341 if (FAILED(hr))
1342 goto end;
1344 hr = IDirectXFileDataReference_Resolve(reference, &data);
1345 IDirectXFileDataReference_Release(reference);
1346 if (FAILED(hr))
1347 goto end;
1350 hr = IDirectXFileData_GetType(data, &guid);
1351 if (hr != DXFILE_OK)
1352 goto end;
1353 if (!IsEqualGUID(guid, &TID_D3DRMTextureFilename))
1355 WARN("Not a texture filename\n");
1356 goto end;
1359 size = 4;
1360 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1361 if (SUCCEEDED(hr))
1363 if (load_texture_proc)
1365 IDirect3DRMTexture *texture;
1367 hr = load_texture_proc(*filename, arg, &texture);
1368 if (SUCCEEDED(hr))
1370 hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void**)&This->materials[i].texture);
1371 IDirect3DTexture_Release(texture);
1374 else
1376 HANDLE file;
1378 /* If the texture file is not found, no texture is associated with the material */
1379 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1380 if (file != INVALID_HANDLE_VALUE)
1382 CloseHandle(file);
1384 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
1385 if (FAILED(hr))
1387 IDirectXFileData_Release(data);
1388 goto end;
1394 else if (hr != DXFILEERR_NOMOREOBJECTS)
1396 goto end;
1398 hr = S_OK;
1400 IDirectXFileData_Release(data);
1401 i++;
1403 if (hr == S_OK)
1405 IDirectXFileObject_Release(child);
1406 WARN("Found more sub-objects than expected\n");
1408 else if (hr != DXFILEERR_NOMOREOBJECTS)
1410 goto end;
1412 hr = S_OK;
1414 else
1416 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid));
1419 IDirectXFileData_Release(pData2);
1420 pData2 = NULL;
1423 if (!This->nb_normals)
1425 /* Allocate normals, one per vertex */
1426 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1427 if (!This->pNormals)
1428 goto end;
1431 for (i = 0; i < This->nb_faces; i++)
1433 DWORD j;
1434 DWORD nb_face_indexes;
1435 D3DVECTOR face_normal;
1437 if (faces_vertex_idx_size < sizeof(DWORD))
1438 WARN("Not enough data to read number of indices of face %d\n", i);
1440 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1441 faces_vertex_idx_size--;
1442 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1443 WARN("Faces indices number mismatch\n");
1445 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1446 WARN("Not enough data to read all indices of face %d\n", i);
1448 if (!This->nb_normals)
1450 /* Compute face normal */
1451 if (nb_face_indexes > 2)
1453 D3DVECTOR a, b;
1455 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1456 D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1457 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1458 D3DRMVectorNormalize(&face_normal);
1460 else
1462 face_normal.u1.x = 0.0f;
1463 face_normal.u2.y = 0.0f;
1464 face_normal.u3.z = 0.0f;
1468 for (j = 0; j < nb_face_indexes; j++)
1470 /* Copy vertex index */
1471 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1472 /* Copy normal index */
1473 if (This->nb_normals)
1475 /* Read from x file */
1476 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1478 else
1480 DWORD vertex_idx = *faces_vertex_idx_ptr;
1481 if (vertex_idx >= This->nb_vertices)
1483 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1484 vertex_idx = 0;
1486 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1487 /* Add face normal to vertex normal */
1488 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1490 faces_vertex_idx_ptr++;
1492 faces_vertex_idx_size -= nb_face_indexes;
1495 /* Last DWORD must be 0 */
1496 *(faces_data_ptr + faces_data_size++) = 0;
1498 /* Set size (in number of DWORD) of all faces data */
1499 This->face_data_size = faces_data_size;
1501 if (!This->nb_normals)
1503 /* Normalize all normals */
1504 for (i = 0; i < This->nb_vertices; i++)
1506 D3DRMVectorNormalize(&This->pNormals[i]);
1508 This->nb_normals = This->nb_vertices;
1511 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1512 if (!This->pCoords2d)
1514 This->nb_coords2d = This->nb_vertices;
1515 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1516 for (i = 0; i < This->nb_coords2d; i++)
1518 This->pCoords2d[i].u = 0.0f;
1519 This->pCoords2d[i].v = 0.0f;
1523 TRACE("Mesh data loaded successfully\n");
1525 ret = D3DRM_OK;
1527 end:
1529 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1530 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1532 return ret;
1535 /*** IDirect3DRMMeshBuilder3 methods ***/
1536 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1537 void *filename, void *name,
1538 D3DRMLOADOPTIONS loadflags,
1539 D3DRMLOADTEXTURE3CALLBACK cb, void *arg)
1541 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1542 DXFILELOADOPTIONS load_options;
1543 IDirectXFile *dxfile = NULL;
1544 IDirectXFileEnumObject *enum_object = NULL;
1545 IDirectXFileData *data = NULL;
1546 const GUID* guid;
1547 DWORD size;
1548 Header* header;
1549 HRESULT hr;
1550 HRESULT ret = D3DRMERR_BADOBJECT;
1552 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1554 clean_mesh_builder_data(This);
1556 if (loadflags == D3DRMLOAD_FROMMEMORY)
1558 load_options = DXFILELOAD_FROMMEMORY;
1560 else if (loadflags == D3DRMLOAD_FROMFILE)
1562 load_options = DXFILELOAD_FROMFILE;
1563 TRACE("Loading from file %s\n", debugstr_a(filename));
1565 else
1567 FIXME("Load options %d not supported yet\n", loadflags);
1568 return E_NOTIMPL;
1571 hr = DirectXFileCreate(&dxfile);
1572 if (hr != DXFILE_OK)
1573 goto end;
1575 hr = IDirectXFile_RegisterTemplates(dxfile, templates, strlen(templates));
1576 if (hr != DXFILE_OK)
1577 goto end;
1579 hr = IDirectXFile_CreateEnumObject(dxfile, filename, load_options, &enum_object);
1580 if (hr != DXFILE_OK)
1581 goto end;
1583 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1584 if (hr != DXFILE_OK)
1585 goto end;
1587 hr = IDirectXFileData_GetType(data, &guid);
1588 if (hr != DXFILE_OK)
1589 goto end;
1591 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1593 if (!IsEqualGUID(guid, &TID_DXFILEHeader))
1595 ret = D3DRMERR_BADFILE;
1596 goto end;
1599 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&header);
1600 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1601 goto end;
1603 TRACE("Version is %d %d %d\n", header->major, header->minor, header->flags);
1605 /* Version must be 1.0.x */
1606 if ((header->major != 1) || (header->minor != 0))
1608 ret = D3DRMERR_BADFILE;
1609 goto end;
1612 IDirectXFileData_Release(data);
1613 data = NULL;
1615 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1616 if (hr != DXFILE_OK)
1618 ret = D3DRMERR_NOTFOUND;
1619 goto end;
1622 hr = IDirectXFileData_GetType(data, &guid);
1623 if (hr != DXFILE_OK)
1624 goto end;
1626 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1628 if (!IsEqualGUID(guid, &TID_D3DRMMesh))
1630 ret = D3DRMERR_NOTFOUND;
1631 goto end;
1634 /* We don't care about the texture interface version since we rely on QueryInterface */
1635 hr = load_mesh_data(iface, data, (D3DRMLOADTEXTURECALLBACK)cb, arg);
1636 if (hr == S_OK)
1637 ret = D3DRM_OK;
1639 end:
1641 if (data)
1642 IDirectXFileData_Release(data);
1643 if (enum_object)
1644 IDirectXFileEnumObject_Release(enum_object);
1645 if (dxfile)
1646 IDirectXFile_Release(dxfile);
1648 if (ret != D3DRM_OK)
1649 clean_mesh_builder_data(This);
1651 return ret;
1654 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1655 const char* filename, D3DRMXOFFORMAT format,
1656 D3DRMSAVEOPTIONS save)
1658 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1660 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1662 return E_NOTIMPL;
1665 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1666 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1668 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1669 DWORD i;
1671 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1673 for (i = 0; i < This->nb_vertices; i++)
1675 This->pVertices[i].u1.x *= sx;
1676 This->pVertices[i].u2.y *= sy;
1677 This->pVertices[i].u3.z *= sz;
1680 /* Normals are not affected by Scale */
1682 return D3DRM_OK;
1685 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1686 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1688 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1690 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1692 return E_NOTIMPL;
1695 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1696 D3DRMCOLORSOURCE color)
1698 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1700 FIXME("(%p)->(%x): stub\n", This, color);
1702 return E_NOTIMPL;
1705 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1706 D3DRMBOX* box)
1708 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1710 FIXME("(%p)->(%p): stub\n", This, box);
1712 return E_NOTIMPL;
1715 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1716 D3DVALUE crease, DWORD flags)
1718 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1720 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1722 return E_NOTIMPL;
1725 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1727 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1729 FIXME("(%p)->(): stub\n", This);
1731 return E_NOTIMPL;
1734 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh *mesh)
1736 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1738 return E_NOTIMPL;
1741 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3 *iface,
1742 IDirect3DRMMeshBuilder3 *mesh_builder, DWORD flags)
1744 FIXME("iface %p, mesh_builder %p, flags %#x stub!\n", iface, mesh_builder, flags);
1746 return E_NOTIMPL;
1749 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFrame3 *frame)
1751 FIXME("iface %p, frame %p stub!\n", iface, frame);
1753 return E_NOTIMPL;
1756 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
1758 FIXME("iface %p, face %p stub!\n", iface, face);
1760 return E_NOTIMPL;
1763 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3 *iface,
1764 DWORD vertex_count, D3DVECTOR *vertices, DWORD normal_count, D3DVECTOR *normals,
1765 DWORD *face_data, IDirect3DRMFaceArray **array)
1767 FIXME("iface %p, vertex_count %u, vertices %p, normal_count %u, normals %p, face_data %p array %p stub!\n",
1768 iface, vertex_count, vertices, normal_count, normals, face_data, array);
1770 return E_NOTIMPL;
1773 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1774 DWORD vertex_Count,
1775 DWORD normal_count,
1776 DWORD face_count)
1778 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1780 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1782 return E_NOTIMPL;
1785 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1786 D3DVALUE red, D3DVALUE green,
1787 D3DVALUE blue)
1789 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1791 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1793 This->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
1795 return D3DRM_OK;
1798 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1799 D3DCOLOR color)
1801 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1803 TRACE("(%p)->(%x)\n", This, color);
1805 This->color = color;
1807 return D3DRM_OK;
1810 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3 *iface,
1811 IDirect3DRMTexture3 *texture)
1813 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1815 TRACE("(%p)->(%p)\n", This, texture);
1817 if (texture)
1818 IDirect3DRMTexture3_AddRef(texture);
1819 if (This->texture)
1820 IDirect3DRMTexture3_Release(This->texture);
1821 This->texture = texture;
1823 return D3DRM_OK;
1826 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3 *iface,
1827 IDirect3DRMMaterial2 *material)
1829 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder3(iface);
1831 TRACE("iface %p, material %p.\n", iface, material);
1833 if (material)
1834 IDirect3DRMTexture2_AddRef(material);
1835 if (mesh_builder->material)
1836 IDirect3DRMTexture2_Release(mesh_builder->material);
1837 mesh_builder->material = material;
1839 return D3DRM_OK;
1842 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1843 BOOL wrap_u, BOOL wrap_v)
1845 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1847 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1849 return E_NOTIMPL;
1852 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1853 D3DRMRENDERQUALITY quality)
1855 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1857 FIXME("(%p)->(%d): stub\n", This, quality);
1859 return E_NOTIMPL;
1862 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1863 BOOL enable)
1865 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1867 FIXME("(%p)->(%d): stub\n", This, enable);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1873 DWORD index,
1874 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1876 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1878 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1880 return E_NOTIMPL;
1883 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1884 DWORD index,
1885 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1887 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1889 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1891 return E_NOTIMPL;
1894 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1895 DWORD index, D3DVALUE u,
1896 D3DVALUE v)
1898 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1900 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1902 if (index >= This->nb_coords2d)
1903 return D3DRMERR_BADVALUE;
1905 This->pCoords2d[index].u = u;
1906 This->pCoords2d[index].v = v;
1908 return D3DRM_OK;
1911 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1912 DWORD index, D3DCOLOR color)
1914 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1916 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1918 return E_NOTIMPL;
1921 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1922 DWORD index,
1923 D3DVALUE red, D3DVALUE green,
1924 D3DVALUE blue)
1926 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1928 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1930 return E_NOTIMPL;
1933 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3 *iface,
1934 IDirect3DRMFaceArray **array)
1936 FIXME("iface %p, array %p stub!\n", iface, array);
1938 return E_NOTIMPL;
1941 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1942 DWORD* vcount, D3DVECTOR* vertices,
1943 DWORD* ncount, D3DVECTOR* normals,
1944 DWORD* face_data_size,
1945 DWORD* face_data)
1947 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1949 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1950 face_data_size, face_data);
1952 return E_NOTIMPL;
1955 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1956 DWORD index, D3DVALUE* u,
1957 D3DVALUE* v)
1959 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1961 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1963 if (index >= This->nb_coords2d)
1964 return D3DRMERR_BADVALUE;
1966 *u = This->pCoords2d[index].u;
1967 *v = This->pCoords2d[index].v;
1969 return D3DRM_OK;
1973 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1974 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1976 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1978 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1980 return 0;
1983 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1984 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1986 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1988 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1990 return 0;
1993 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 **face)
1995 TRACE("iface %p, face %p.\n", iface, face);
1997 return Direct3DRMFace_create(&IID_IDirect3DRMFace2, (IUnknown **)face);
2000 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
2002 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2004 FIXME("(%p)->(): stub\n", This);
2006 return 0;
2009 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2011 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2013 FIXME("(%p)->(): stub\n", This);
2015 return FALSE;
2018 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2020 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2022 TRACE("(%p)->()\n", This);
2024 return This->nb_faces;
2027 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2029 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2031 TRACE("(%p)->()\n", This);
2033 return This->nb_vertices;
2036 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2037 DWORD index)
2039 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2041 FIXME("(%p)->(%d): stub\n", This, index);
2043 return 0;
2046 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh **mesh)
2048 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2049 HRESULT hr;
2050 D3DRMGROUPINDEX group;
2052 TRACE("(%p)->(%p)\n", This, mesh);
2054 if (!mesh)
2055 return E_POINTER;
2057 hr = Direct3DRMMesh_create(mesh);
2058 if (FAILED(hr))
2059 return hr;
2061 /* If there is mesh data, create a group and put data inside */
2062 if (This->nb_vertices)
2064 DWORD i, j;
2065 int k;
2066 D3DRMVERTEX* vertices;
2068 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2069 if (!vertices)
2071 IDirect3DRMMesh_Release(*mesh);
2072 return E_OUTOFMEMORY;
2074 for (i = 0; i < This->nb_vertices; i++)
2075 vertices[i].position = This->pVertices[i];
2076 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2077 HeapFree(GetProcessHeap(), 0, vertices);
2079 /* Groups are in reverse order compared to materials list in X file */
2080 for (k = This->nb_materials - 1; k >= 0; k--)
2082 unsigned* face_data;
2083 unsigned* out_ptr;
2084 DWORD* in_ptr = This->pFaceData;
2085 ULONG vertex_per_face = 0;
2086 BOOL* used_vertices;
2087 unsigned nb_vertices = 0;
2088 unsigned nb_faces = 0;
2090 used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->face_data_size * sizeof(*used_vertices));
2091 if (!used_vertices)
2093 IDirect3DRMMesh_Release(*mesh);
2094 return E_OUTOFMEMORY;
2097 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(*face_data));
2098 if (!face_data)
2100 HeapFree(GetProcessHeap(), 0, used_vertices);
2101 IDirect3DRMMesh_Release(*mesh);
2102 return E_OUTOFMEMORY;
2104 out_ptr = face_data;
2106 /* If all faces have the same number of vertex, set vertex_per_face */
2107 for (i = 0; i < This->nb_faces; i++)
2109 /* Process only faces belonging to the group */
2110 if (This->material_indices[i] == k)
2112 if (vertex_per_face && (vertex_per_face != *in_ptr))
2113 break;
2114 vertex_per_face = *in_ptr;
2116 in_ptr += 1 + *in_ptr * 2;
2118 if (i != This->nb_faces)
2119 vertex_per_face = 0;
2121 /* Put only vertex indices */
2122 in_ptr = This->pFaceData;
2123 for (i = 0; i < This->nb_faces; i++)
2125 DWORD nb_indices = *in_ptr++;
2127 /* Skip faces not belonging to the group */
2128 if (This->material_indices[i] != k)
2130 in_ptr += 2 * nb_indices;
2131 continue;
2134 /* Don't put nb indices when vertex_per_face is set */
2135 if (vertex_per_face)
2136 *out_ptr++ = nb_indices;
2138 for (j = 0; j < nb_indices; j++)
2140 *out_ptr = *in_ptr++;
2141 used_vertices[*out_ptr++] = TRUE;
2142 /* Skip normal index */
2143 in_ptr++;
2146 nb_faces++;
2149 for (i = 0; i < This->nb_vertices; i++)
2150 if (used_vertices[i])
2151 nb_vertices++;
2153 hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group);
2154 HeapFree(GetProcessHeap(), 0, used_vertices);
2155 HeapFree(GetProcessHeap(), 0, face_data);
2156 if (SUCCEEDED(hr))
2157 hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, This->materials[k].color);
2158 if (SUCCEEDED(hr))
2159 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, group,
2160 (IDirect3DRMMaterial *)This->materials[k].material);
2161 if (SUCCEEDED(hr) && This->materials[k].texture)
2163 IDirect3DRMTexture *texture;
2165 IDirect3DRMTexture3_QueryInterface(This->materials[k].texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2166 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, group, texture);
2167 IDirect3DRMTexture_Release(texture);
2169 if (FAILED(hr))
2171 IDirect3DRMMesh_Release(*mesh);
2172 return hr;
2177 return D3DRM_OK;
2180 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3 *iface,
2181 DWORD index, IDirect3DRMFace2 **face)
2183 FIXME("iface %p, index %u, face %p stub!\n", iface, index, face);
2185 return E_NOTIMPL;
2188 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3 *iface,
2189 DWORD index, D3DVECTOR *vector)
2191 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2193 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2195 return E_NOTIMPL;
2198 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3 *iface,
2199 DWORD index, D3DVECTOR *vector)
2201 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2203 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2205 return E_NOTIMPL;
2208 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2209 DWORD IndexFirst, DWORD count)
2211 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2213 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2215 return E_NOTIMPL;
2218 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2219 DWORD IndexFirst, DWORD count)
2221 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2223 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2225 return E_NOTIMPL;
2228 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFace2 *face)
2230 FIXME("iface %p, face %p stub!\n", iface, face);
2232 return E_NOTIMPL;
2235 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2237 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2239 FIXME("(%p)->(%u): stub\n", This, flags);
2241 return E_NOTIMPL;
2244 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2245 DWORD flags)
2247 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2249 FIXME("(%p)->(%u): stub\n", This, flags);
2251 return E_NOTIMPL;
2254 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2255 DWORD flags, DWORD* indices,
2256 DWORD* IndexFirst, DWORD* count)
2258 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2260 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2262 return E_NOTIMPL;
2265 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2266 LPUNKNOWN *unkwn)
2268 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2270 FIXME("(%p)->(%p): stub\n", This, unkwn);
2272 return E_NOTIMPL;
2275 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2276 DWORD flags, LPUNKNOWN *unkwn)
2278 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2280 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2282 return E_NOTIMPL;
2285 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2286 LPDWORD count, LPUNKNOWN *unkwn)
2288 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2290 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2292 return E_NOTIMPL;
2295 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2296 LPUNKNOWN unkwn)
2298 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2300 FIXME("(%p)->(%p): stub\n", This, unkwn);
2302 return E_NOTIMPL;
2305 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2306 DWORD index)
2308 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2310 FIXME("(%p)->(%u): stub\n", This, index);
2312 return E_NOTIMPL;
2315 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2316 DWORD* indices)
2318 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2320 FIXME("(%p)->(%p): stub\n", This, indices);
2322 return E_NOTIMPL;
2325 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2326 DWORD flags, DWORD format,
2327 DWORD VertexCount, LPVOID data)
2329 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2331 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2333 return E_NOTIMPL;
2336 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3 *iface,
2337 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2339 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2341 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2343 return E_NOTIMPL;
2346 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3 *iface,
2347 DWORD IndexFirst, DWORD *vcount, D3DVECTOR *vertices)
2349 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2350 DWORD count = This->nb_vertices - IndexFirst;
2352 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2354 if (vcount)
2355 *vcount = count;
2356 if (vertices && This->nb_vertices)
2357 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2359 return D3DRM_OK;
2362 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3 *iface,
2363 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2365 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2367 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2369 return E_NOTIMPL;
2372 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3 *iface,
2373 DWORD IndexFirst, DWORD *ncount, D3DVECTOR *normals)
2375 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2376 DWORD count = This->nb_normals - IndexFirst;
2378 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, ncount, normals);
2380 if (ncount)
2381 *ncount = count;
2382 if (normals && This->nb_normals)
2383 memcpy(normals, This->pNormals + IndexFirst, count * sizeof(D3DVECTOR));
2385 return D3DRM_OK;
2388 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2390 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2392 TRACE("(%p)->()\n", This);
2394 return This->nb_normals;
2397 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2399 /*** IUnknown methods ***/
2400 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2401 IDirect3DRMMeshBuilder3Impl_AddRef,
2402 IDirect3DRMMeshBuilder3Impl_Release,
2403 /*** IDirect3DRMObject methods ***/
2404 IDirect3DRMMeshBuilder3Impl_Clone,
2405 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2406 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2407 IDirect3DRMMeshBuilder3Impl_SetAppData,
2408 IDirect3DRMMeshBuilder3Impl_GetAppData,
2409 IDirect3DRMMeshBuilder3Impl_SetName,
2410 IDirect3DRMMeshBuilder3Impl_GetName,
2411 IDirect3DRMMeshBuilder3Impl_GetClassName,
2412 /*** IDirect3DRMMeshBuilder3 methods ***/
2413 IDirect3DRMMeshBuilder3Impl_Load,
2414 IDirect3DRMMeshBuilder3Impl_Save,
2415 IDirect3DRMMeshBuilder3Impl_Scale,
2416 IDirect3DRMMeshBuilder3Impl_Translate,
2417 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2418 IDirect3DRMMeshBuilder3Impl_GetBox,
2419 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2420 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2421 IDirect3DRMMeshBuilder3Impl_AddMesh,
2422 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2423 IDirect3DRMMeshBuilder3Impl_AddFrame,
2424 IDirect3DRMMeshBuilder3Impl_AddFace,
2425 IDirect3DRMMeshBuilder3Impl_AddFaces,
2426 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2427 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2428 IDirect3DRMMeshBuilder3Impl_SetColor,
2429 IDirect3DRMMeshBuilder3Impl_SetTexture,
2430 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2431 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2432 IDirect3DRMMeshBuilder3Impl_SetQuality,
2433 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2434 IDirect3DRMMeshBuilder3Impl_SetVertex,
2435 IDirect3DRMMeshBuilder3Impl_SetNormal,
2436 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2437 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2438 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2439 IDirect3DRMMeshBuilder3Impl_GetFaces,
2440 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2441 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2442 IDirect3DRMMeshBuilder3Impl_AddVertex,
2443 IDirect3DRMMeshBuilder3Impl_AddNormal,
2444 IDirect3DRMMeshBuilder3Impl_CreateFace,
2445 IDirect3DRMMeshBuilder3Impl_GetQuality,
2446 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2447 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2448 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2449 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2450 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2451 IDirect3DRMMeshBuilder3Impl_GetFace,
2452 IDirect3DRMMeshBuilder3Impl_GetVertex,
2453 IDirect3DRMMeshBuilder3Impl_GetNormal,
2454 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2455 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2456 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2457 IDirect3DRMMeshBuilder3Impl_Empty,
2458 IDirect3DRMMeshBuilder3Impl_Optimize,
2459 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2460 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2461 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2462 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2463 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2464 IDirect3DRMMeshBuilder3Impl_Enable,
2465 IDirect3DRMMeshBuilder3Impl_GetEnable,
2466 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2467 IDirect3DRMMeshBuilder3Impl_SetVertices,
2468 IDirect3DRMMeshBuilder3Impl_GetVertices,
2469 IDirect3DRMMeshBuilder3Impl_SetNormals,
2470 IDirect3DRMMeshBuilder3Impl_GetNormals,
2471 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2474 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2476 IDirect3DRMMeshBuilderImpl* object;
2478 TRACE("(%p)\n", ppObj);
2480 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2481 if (!object)
2482 return E_OUTOFMEMORY;
2484 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2485 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2486 object->ref = 1;
2488 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2489 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2490 else
2491 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2493 return S_OK;
2496 /*** IUnknown methods ***/
2497 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2498 REFIID riid, void** ppvObject)
2500 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2502 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2504 *ppvObject = NULL;
2506 if (IsEqualGUID(riid, &IID_IUnknown) ||
2507 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2509 *ppvObject = &This->IDirect3DRMMesh_iface;
2511 else
2513 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2514 return E_NOINTERFACE;
2517 IDirect3DRMMesh_AddRef(iface);
2518 return S_OK;
2521 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2523 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2524 ULONG ref = InterlockedIncrement(&This->ref);
2526 TRACE("(%p)->(): new ref = %d\n", This, ref);
2528 return ref;
2531 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2533 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2534 ULONG ref = InterlockedDecrement(&This->ref);
2536 TRACE("(%p)->(): new ref = %d\n", This, ref);
2538 if (!ref)
2540 DWORD i;
2542 for (i = 0; i < This->nb_groups; i++)
2544 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2545 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2546 if (This->groups[i].material)
2547 IDirect3DRMMaterial2_Release(This->groups[i].material);
2548 if (This->groups[i].texture)
2549 IDirect3DRMTexture3_Release(This->groups[i].texture);
2551 HeapFree(GetProcessHeap(), 0, This->groups);
2552 HeapFree(GetProcessHeap(), 0, This);
2555 return ref;
2558 /*** IDirect3DRMObject methods ***/
2559 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2560 LPUNKNOWN pUnkOuter, REFIID riid,
2561 LPVOID *ppvObj)
2563 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2565 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2567 return E_NOTIMPL;
2570 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2571 D3DRMOBJECTCALLBACK cb,
2572 LPVOID argument)
2574 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2576 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2578 return E_NOTIMPL;
2581 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2582 D3DRMOBJECTCALLBACK cb,
2583 LPVOID argument)
2585 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2587 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2589 return E_NOTIMPL;
2592 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2593 DWORD data)
2595 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2597 FIXME("(%p)->(%u): stub\n", This, data);
2599 return E_NOTIMPL;
2602 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2604 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2606 FIXME("(%p)->(): stub\n", This);
2608 return 0;
2611 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2612 LPCSTR pName)
2614 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2616 FIXME("(%p)->(%s): stub\n", This, pName);
2618 return E_NOTIMPL;
2621 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2622 LPDWORD lpdwSize, LPSTR lpName)
2624 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2626 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2628 return E_NOTIMPL;
2631 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2632 LPDWORD size, LPSTR name)
2634 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2636 TRACE("(%p)->(%p, %p)\n", This, size, name);
2638 if (!size || *size < strlen("Mesh") || !name)
2639 return E_INVALIDARG;
2641 strcpy(name, "Mesh");
2642 *size = sizeof("Mesh");
2644 return D3DRM_OK;
2647 /*** IDirect3DRMMesh methods ***/
2648 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2649 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2651 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2653 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2655 return E_NOTIMPL;
2658 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2659 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2661 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2663 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2665 return E_NOTIMPL;
2668 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2669 D3DRMBOX * box)
2671 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2673 FIXME("(%p)->(%p): stub\n", This, box);
2675 return E_NOTIMPL;
2678 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2679 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2680 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2682 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2683 mesh_group* group;
2685 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2687 if (!face_data || !return_id)
2688 return E_POINTER;
2690 if ((This->nb_groups + 1) > This->groups_capacity)
2692 ULONG new_capacity;
2693 mesh_group* groups;
2695 if (!This->groups_capacity)
2697 new_capacity = 16;
2698 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2700 else
2702 new_capacity = This->groups_capacity * 2;
2703 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2706 if (!groups)
2707 return E_OUTOFMEMORY;
2709 This->groups_capacity = new_capacity;
2710 This->groups = groups;
2713 group = This->groups + This->nb_groups;
2715 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2716 if (!group->vertices)
2717 return E_OUTOFMEMORY;
2718 group->nb_vertices = vertex_count;
2719 group->nb_faces = face_count;
2720 group->vertex_per_face = vertex_per_face;
2722 if (vertex_per_face)
2724 group->face_data_size = face_count * vertex_per_face;
2726 else
2728 unsigned i;
2729 unsigned nb_indices;
2730 unsigned* face_data_ptr = face_data;
2731 group->face_data_size = 0;
2733 for (i = 0; i < face_count; i++)
2735 nb_indices = *face_data_ptr;
2736 group->face_data_size += nb_indices + 1;
2737 face_data_ptr += nb_indices;
2741 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2742 if (!group->face_data)
2744 HeapFree(GetProcessHeap(), 0 , group->vertices);
2745 return E_OUTOFMEMORY;
2748 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2750 group->material = NULL;
2751 group->texture = NULL;
2753 *return_id = This->nb_groups++;
2755 return D3DRM_OK;
2758 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2759 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2760 D3DRMVERTEX *values)
2762 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2764 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2766 if (id >= This->nb_groups)
2767 return D3DRMERR_BADVALUE;
2769 if ((index + count - 1) >= This->groups[id].nb_vertices)
2770 return D3DRMERR_BADVALUE;
2772 if (!values)
2773 return E_POINTER;
2775 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2777 return D3DRM_OK;
2780 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2781 D3DRMGROUPINDEX id, D3DCOLOR color)
2783 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2785 TRACE("(%p)->(%u,%x)\n", This, id, color);
2787 if (id >= This->nb_groups)
2788 return D3DRMERR_BADVALUE;
2790 This->groups[id].color = color;
2792 return D3DRM_OK;
2795 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2796 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2798 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2800 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2802 if (id >= This->nb_groups)
2803 return D3DRMERR_BADVALUE;
2805 This->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
2807 return D3DRM_OK;
2810 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2811 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2813 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2815 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2817 return E_NOTIMPL;
2820 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2821 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2823 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2825 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2827 return E_NOTIMPL;
2830 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh *iface,
2831 D3DRMGROUPINDEX id, IDirect3DRMMaterial *material)
2833 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2835 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2837 if (id >= mesh->nb_groups)
2838 return D3DRMERR_BADVALUE;
2840 if (mesh->groups[id].material)
2841 IDirect3DRMMaterial2_Release(mesh->groups[id].material);
2843 mesh->groups[id].material = (IDirect3DRMMaterial2 *)material;
2845 if (material)
2846 IDirect3DRMMaterial2_AddRef(mesh->groups[id].material);
2848 return D3DRM_OK;
2851 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh *iface,
2852 D3DRMGROUPINDEX id, IDirect3DRMTexture *texture)
2854 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2856 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2858 if (id >= This->nb_groups)
2859 return D3DRMERR_BADVALUE;
2861 if (This->groups[id].texture)
2862 IDirect3DRMTexture3_Release(This->groups[id].texture);
2864 if (!texture)
2866 This->groups[id].texture = NULL;
2867 return D3DRM_OK;
2870 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2873 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2875 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2877 TRACE("(%p)->()\n", This);
2879 return This->nb_groups;
2882 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2883 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2884 DWORD *face_data_size, unsigned *face_data)
2886 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2888 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2890 if (id >= This->nb_groups)
2891 return D3DRMERR_BADVALUE;
2893 if (vertex_count)
2894 *vertex_count = This->groups[id].nb_vertices;
2895 if (face_count)
2896 *face_count = This->groups[id].nb_faces;
2897 if (vertex_per_face)
2898 *vertex_per_face = This->groups[id].vertex_per_face;
2899 if (face_data_size)
2900 *face_data_size = This->groups[id].face_data_size;
2901 if (face_data)
2902 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size * sizeof(DWORD));
2904 return D3DRM_OK;
2907 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2908 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2910 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2912 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2914 if (id >= This->nb_groups)
2915 return D3DRMERR_BADVALUE;
2917 if ((index + count - 1) >= This->groups[id].nb_vertices)
2918 return D3DRMERR_BADVALUE;
2920 if (!return_ptr)
2921 return E_POINTER;
2923 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2925 return D3DRM_OK;
2928 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2930 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2932 TRACE("(%p)->(%u)\n", This, id);
2934 return This->groups[id].color;
2937 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2939 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2941 FIXME("(%p)->(%u): stub\n", This, id);
2943 return 0;
2945 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2947 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2949 FIXME("(%p)->(%u): stub\n", This, id);
2951 return 0;
2954 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh *iface,
2955 D3DRMGROUPINDEX id, IDirect3DRMMaterial **material)
2957 IDirect3DRMMeshImpl *mesh = impl_from_IDirect3DRMMesh(iface);
2959 TRACE("iface %p, id %#x, material %p.\n", iface, id, material);
2961 if (id >= mesh->nb_groups)
2962 return D3DRMERR_BADVALUE;
2964 if (!material)
2965 return E_POINTER;
2967 if (mesh->groups[id].material)
2968 IDirect3DRMTexture_QueryInterface(mesh->groups[id].material, &IID_IDirect3DRMMaterial, (void **)material);
2969 else
2970 *material = NULL;
2972 return D3DRM_OK;
2975 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh *iface,
2976 D3DRMGROUPINDEX id, IDirect3DRMTexture **texture)
2978 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2980 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2982 if (id >= This->nb_groups)
2983 return D3DRMERR_BADVALUE;
2985 if (!texture)
2986 return E_POINTER;
2988 if (This->groups[id].texture)
2989 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2990 else
2991 *texture = NULL;
2993 return D3DRM_OK;
2996 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2998 /*** IUnknown methods ***/
2999 IDirect3DRMMeshImpl_QueryInterface,
3000 IDirect3DRMMeshImpl_AddRef,
3001 IDirect3DRMMeshImpl_Release,
3002 /*** IDirect3DRMObject methods ***/
3003 IDirect3DRMMeshImpl_Clone,
3004 IDirect3DRMMeshImpl_AddDestroyCallback,
3005 IDirect3DRMMeshImpl_DeleteDestroyCallback,
3006 IDirect3DRMMeshImpl_SetAppData,
3007 IDirect3DRMMeshImpl_GetAppData,
3008 IDirect3DRMMeshImpl_SetName,
3009 IDirect3DRMMeshImpl_GetName,
3010 IDirect3DRMMeshImpl_GetClassName,
3011 /*** IDirect3DRMMesh methods ***/
3012 IDirect3DRMMeshImpl_Scale,
3013 IDirect3DRMMeshImpl_Translate,
3014 IDirect3DRMMeshImpl_GetBox,
3015 IDirect3DRMMeshImpl_AddGroup,
3016 IDirect3DRMMeshImpl_SetVertices,
3017 IDirect3DRMMeshImpl_SetGroupColor,
3018 IDirect3DRMMeshImpl_SetGroupColorRGB,
3019 IDirect3DRMMeshImpl_SetGroupMapping,
3020 IDirect3DRMMeshImpl_SetGroupQuality,
3021 IDirect3DRMMeshImpl_SetGroupMaterial,
3022 IDirect3DRMMeshImpl_SetGroupTexture,
3023 IDirect3DRMMeshImpl_GetGroupCount,
3024 IDirect3DRMMeshImpl_GetGroup,
3025 IDirect3DRMMeshImpl_GetVertices,
3026 IDirect3DRMMeshImpl_GetGroupColor,
3027 IDirect3DRMMeshImpl_GetGroupMapping,
3028 IDirect3DRMMeshImpl_GetGroupQuality,
3029 IDirect3DRMMeshImpl_GetGroupMaterial,
3030 IDirect3DRMMeshImpl_GetGroupTexture
3033 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
3035 IDirect3DRMMeshImpl* object;
3037 TRACE("(%p)\n", obj);
3039 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
3040 if (!object)
3041 return E_OUTOFMEMORY;
3043 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
3044 object->ref = 1;
3046 *obj = &object->IDirect3DRMMesh_iface;
3048 return S_OK;