d3drm: Avoid LPDIRECT3DRMMESHBUILDER.
[wine/multimedia.git] / dlls / d3drm / meshbuilder.c
blob46785938c7057ae142824b04f6e2198a12249793
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,
609 LPDIRECT3DRMFACE pFace)
611 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
613 FIXME("(%p)->(%p): stub\n", This, pFace);
615 return E_NOTIMPL;
618 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2* iface,
619 DWORD vcount, D3DVECTOR *vertices,
620 DWORD ncount, D3DVECTOR *normals,
621 DWORD *data,
622 LPDIRECT3DRMFACEARRAY* pFaceArray)
624 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
626 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals, data, pFaceArray);
628 return E_NOTIMPL;
631 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
632 DWORD vertex_Count,
633 DWORD normal_count,
634 DWORD face_count)
636 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
638 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
640 return E_NOTIMPL;
643 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
644 D3DVALUE red, D3DVALUE green,
645 D3DVALUE blue)
647 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
649 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
651 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
654 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
655 D3DCOLOR color)
657 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
659 TRACE("(%p)->(%x)\n", This, color);
661 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
664 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2* iface,
665 LPDIRECT3DRMTEXTURE texture)
667 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
668 LPDIRECT3DRMTEXTURE3 texture3 = NULL;
669 HRESULT hr = D3DRM_OK;
671 if (texture)
672 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
673 if (SUCCEEDED(hr))
674 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
675 if (texture3)
676 IDirect3DRMTexture3_Release(texture3);
678 return hr;
681 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2* iface,
682 LPDIRECT3DRMMATERIAL material)
684 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
686 TRACE("(%p)->(%p)\n", This, material);
688 return IDirect3DRMMeshBuilder3_SetMaterial(&This->IDirect3DRMMeshBuilder3_iface, (LPDIRECT3DRMMATERIAL2)material);
691 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
692 BOOL wrap_u, BOOL wrap_v)
694 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
696 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
698 return E_NOTIMPL;
701 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
702 D3DRMRENDERQUALITY quality)
704 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
706 FIXME("(%p)->(%d): stub\n", This, quality);
708 return E_NOTIMPL;
711 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
712 BOOL enable)
714 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
716 FIXME("(%p)->(%d): stub\n", This, enable);
718 return E_NOTIMPL;
721 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
722 DWORD index,
723 D3DVALUE x, D3DVALUE y, D3DVALUE z)
725 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
727 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
729 return E_NOTIMPL;
732 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
733 DWORD index,
734 D3DVALUE x, D3DVALUE y, D3DVALUE z)
736 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
738 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
740 return E_NOTIMPL;
743 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
744 DWORD index,
745 D3DVALUE u, D3DVALUE v)
747 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
749 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
751 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
752 index, u, v);
755 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
756 DWORD index, D3DCOLOR color)
758 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
760 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
762 return E_NOTIMPL;
765 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
766 DWORD index, D3DVALUE red,
767 D3DVALUE green, D3DVALUE blue)
769 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
771 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
773 return E_NOTIMPL;
776 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2* iface,
777 LPDIRECT3DRMFACEARRAY* pFaceArray)
779 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
781 FIXME("(%p)->(%p): stub\n", This, pFaceArray);
783 return E_NOTIMPL;
786 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
787 DWORD *vcount, D3DVECTOR *vertices,
788 DWORD *ncount, D3DVECTOR *normals,
789 DWORD *face_data_size,
790 DWORD *face_data)
792 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
794 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
796 if (vertices && (!vcount || (*vcount < This->nb_vertices)))
797 return D3DRMERR_BADVALUE;
798 if (vcount)
799 *vcount = This->nb_vertices;
800 if (vertices && This->nb_vertices)
801 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
803 if (normals && (!ncount || (*ncount < This->nb_normals)))
804 return D3DRMERR_BADVALUE;
805 if (ncount)
806 *ncount = This->nb_normals;
807 if (normals && This->nb_normals)
808 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
810 if (face_data && (!face_data_size || (*face_data_size < This->face_data_size)))
811 return D3DRMERR_BADVALUE;
812 if (face_data_size)
813 *face_data_size = This->face_data_size;
814 if (face_data && This->face_data_size)
815 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
817 return D3DRM_OK;
820 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
821 DWORD index,
822 D3DVALUE *u, D3DVALUE *v)
824 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
826 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
828 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
829 index, u, v);
832 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
833 D3DVALUE x, D3DVALUE y, D3DVALUE z)
835 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
837 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
839 return 0;
842 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
843 D3DVALUE x, D3DVALUE y, D3DVALUE z)
845 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
847 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
849 return 0;
852 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2* iface,
853 LPDIRECT3DRMFACE* ppFace)
855 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
857 FIXME("(%p)->(%p): stub\n", This, ppFace);
859 return E_NOTIMPL;
862 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
864 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
866 FIXME("(%p)->(): stub\n", This);
868 return 0;
871 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
873 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
875 FIXME("(%p)->(): stub\n", This);
877 return FALSE;
880 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
882 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
884 TRACE("(%p)->()\n", This);
886 return This->nb_faces;
889 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
891 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
893 TRACE("(%p)->()\n", This);
895 return This->nb_vertices;
898 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
899 DWORD index)
901 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
903 FIXME("(%p)->(%d): stub\n", This, index);
905 return 0;
908 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2 *iface, IDirect3DRMMesh **mesh)
910 IDirect3DRMMeshBuilderImpl *mesh_builder = impl_from_IDirect3DRMMeshBuilder2(iface);
912 TRACE("iface %p, mesh %p.\n", iface, mesh);
914 return IDirect3DRMMeshBuilder3_CreateMesh(&mesh_builder->IDirect3DRMMeshBuilder3_iface, mesh);
917 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
918 D3DVALUE crease, DWORD dwFlags)
920 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
922 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
924 return E_NOTIMPL;
927 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2* iface,
928 DWORD index, LPDIRECT3DRMFACE* ppFace)
930 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
932 FIXME("(%p)->(%u,%p): stub\n", This, index, ppFace);
934 return E_NOTIMPL;
937 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
939 /*** IUnknown methods ***/
940 IDirect3DRMMeshBuilder2Impl_QueryInterface,
941 IDirect3DRMMeshBuilder2Impl_AddRef,
942 IDirect3DRMMeshBuilder2Impl_Release,
943 /*** IDirect3DRMObject methods ***/
944 IDirect3DRMMeshBuilder2Impl_Clone,
945 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
946 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
947 IDirect3DRMMeshBuilder2Impl_SetAppData,
948 IDirect3DRMMeshBuilder2Impl_GetAppData,
949 IDirect3DRMMeshBuilder2Impl_SetName,
950 IDirect3DRMMeshBuilder2Impl_GetName,
951 IDirect3DRMMeshBuilder2Impl_GetClassName,
952 /*** IDirect3DRMMeshBuilder methods ***/
953 IDirect3DRMMeshBuilder2Impl_Load,
954 IDirect3DRMMeshBuilder2Impl_Save,
955 IDirect3DRMMeshBuilder2Impl_Scale,
956 IDirect3DRMMeshBuilder2Impl_Translate,
957 IDirect3DRMMeshBuilder2Impl_SetColorSource,
958 IDirect3DRMMeshBuilder2Impl_GetBox,
959 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
960 IDirect3DRMMeshBuilder2Impl_GetColorSource,
961 IDirect3DRMMeshBuilder2Impl_AddMesh,
962 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
963 IDirect3DRMMeshBuilder2Impl_AddFrame,
964 IDirect3DRMMeshBuilder2Impl_AddFace,
965 IDirect3DRMMeshBuilder2Impl_AddFaces,
966 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
967 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
968 IDirect3DRMMeshBuilder2Impl_SetColor,
969 IDirect3DRMMeshBuilder2Impl_SetTexture,
970 IDirect3DRMMeshBuilder2Impl_SetMaterial,
971 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
972 IDirect3DRMMeshBuilder2Impl_SetQuality,
973 IDirect3DRMMeshBuilder2Impl_SetPerspective,
974 IDirect3DRMMeshBuilder2Impl_SetVertex,
975 IDirect3DRMMeshBuilder2Impl_SetNormal,
976 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
977 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
978 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
979 IDirect3DRMMeshBuilder2Impl_GetFaces,
980 IDirect3DRMMeshBuilder2Impl_GetVertices,
981 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
982 IDirect3DRMMeshBuilder2Impl_AddVertex,
983 IDirect3DRMMeshBuilder2Impl_AddNormal,
984 IDirect3DRMMeshBuilder2Impl_CreateFace,
985 IDirect3DRMMeshBuilder2Impl_GetQuality,
986 IDirect3DRMMeshBuilder2Impl_GetPerspective,
987 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
988 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
989 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
990 IDirect3DRMMeshBuilder2Impl_CreateMesh,
991 /*** IDirect3DRMMeshBuilder2 methods ***/
992 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
993 IDirect3DRMMeshBuilder2Impl_GetFace
997 /*** IUnknown methods ***/
998 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
999 REFIID riid, void** ppvObject)
1001 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1002 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
1005 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
1007 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1008 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
1011 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
1013 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1014 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
1017 /*** IDirect3DRMObject methods ***/
1018 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3* iface,
1019 LPUNKNOWN pUnkOuter, REFIID riid,
1020 LPVOID *ppvObj)
1022 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1024 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1030 D3DRMOBJECTCALLBACK cb,
1031 LPVOID argument)
1033 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1035 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1037 return E_NOTIMPL;
1040 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1041 D3DRMOBJECTCALLBACK cb,
1042 LPVOID argument)
1044 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1046 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1048 return E_NOTIMPL;
1051 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1052 DWORD data)
1054 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1056 FIXME("(%p)->(%u): stub\n", This, data);
1058 return E_NOTIMPL;
1061 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1063 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1065 FIXME("(%p)->(): stub\n", This);
1067 return 0;
1070 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1071 LPCSTR name)
1073 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1074 char *string = NULL;
1076 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
1078 if (name)
1080 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1081 if (!string) return E_OUTOFMEMORY;
1082 strcpy(string, name);
1084 HeapFree(GetProcessHeap(), 0, This->name);
1085 This->name = string;
1087 return D3DRM_OK;
1090 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3* iface,
1091 LPDWORD size, LPSTR name)
1093 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1095 TRACE("(%p)->(%p,%p)\n", This, size, name);
1097 if (!size)
1098 return E_POINTER;
1100 if (!This->name)
1102 *size = 0;
1103 return D3DRM_OK;
1106 if (*size < (strlen(This->name) + 1))
1107 return E_INVALIDARG;
1109 strcpy(name, This->name);
1110 *size = strlen(This->name) + 1;
1112 return D3DRM_OK;
1115 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3* iface,
1116 LPDWORD size, LPSTR name)
1118 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1120 TRACE("(%p)->(%p, %p)\n", This, size, name);
1122 if (!size || *size < strlen("Builder") || !name)
1123 return E_INVALIDARG;
1125 strcpy(name, "Builder");
1126 *size = sizeof("Builder");
1128 return D3DRM_OK;
1131 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *pData, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg)
1133 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1134 IDirectXFileData *pData2 = NULL;
1135 const GUID* guid;
1136 DWORD size;
1137 BYTE *ptr;
1138 HRESULT hr;
1139 HRESULT ret = D3DRMERR_BADOBJECT;
1140 DWORD* faces_vertex_idx_data = NULL;
1141 DWORD* faces_vertex_idx_ptr;
1142 DWORD faces_vertex_idx_size;
1143 DWORD* faces_normal_idx_data = NULL;
1144 DWORD* faces_normal_idx_ptr = NULL;
1145 DWORD* faces_data_ptr;
1146 DWORD faces_data_size = 0;
1147 DWORD i;
1149 TRACE("(%p)->(%p)\n", This, pData);
1151 hr = IDirectXFileData_GetName(pData, NULL, &size);
1152 if (hr != DXFILE_OK)
1153 return hr;
1154 if (size)
1156 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1157 if (!This->name)
1158 return E_OUTOFMEMORY;
1160 hr = IDirectXFileData_GetName(pData, This->name, &size);
1161 if (hr != DXFILE_OK)
1162 return hr;
1165 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1167 This->nb_normals = 0;
1169 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1170 if (hr != DXFILE_OK)
1171 goto end;
1173 This->nb_vertices = *(DWORD*)ptr;
1174 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1175 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1176 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1178 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1180 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1181 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1183 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1184 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1186 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1187 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size * 2);
1188 faces_data_ptr = (DWORD*)This->pFaceData;
1190 while (1)
1192 IDirectXFileObject *object;
1194 hr = IDirectXFileData_GetNextObject(pData, &object);
1195 if (hr == DXFILEERR_NOMOREOBJECTS)
1197 TRACE("No more object\n");
1198 break;
1200 if (hr != DXFILE_OK)
1201 goto end;
1203 hr = IDirectXFileObject_QueryInterface(object, &IID_IDirectXFileData, (void**)&pData2);
1204 IDirectXFileObject_Release(object);
1205 if (hr != DXFILE_OK)
1206 goto end;
1208 hr = IDirectXFileData_GetType(pData2, &guid);
1209 if (hr != DXFILE_OK)
1210 goto end;
1212 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1214 if (IsEqualGUID(guid, &TID_D3DRMMeshNormals))
1216 DWORD nb_faces_normals;
1217 DWORD faces_normal_idx_size;
1219 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1220 if (hr != DXFILE_OK)
1221 goto end;
1223 This->nb_normals = *(DWORD*)ptr;
1224 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1226 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1227 if (nb_faces_normals != This->nb_faces)
1228 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1230 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1231 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1233 faces_normal_idx_size = size - (2 * sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1234 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1235 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1237 else if (IsEqualGUID(guid, &TID_D3DRMMeshTextureCoords))
1239 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1240 if (hr != DXFILE_OK)
1241 goto end;
1243 This->nb_coords2d = *(DWORD*)ptr;
1245 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1247 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1248 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1251 else if (IsEqualGUID(guid, &TID_D3DRMMeshMaterialList))
1253 DWORD nb_materials;
1254 DWORD nb_face_indices;
1255 DWORD data_size;
1256 IDirectXFileObject *child;
1257 DWORD i = 0;
1258 float* values;
1260 TRACE("Process MeshMaterialList\n");
1262 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1263 if (hr != DXFILE_OK)
1264 goto end;
1266 nb_materials = *(DWORD*)ptr;
1267 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1268 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1270 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1272 if (size != data_size)
1273 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1275 This->material_indices = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->material_indices) * nb_face_indices);
1276 if (!This->material_indices)
1277 goto end;
1278 memcpy(This->material_indices, ptr + 2 * sizeof(DWORD), sizeof(*This->material_indices) * nb_face_indices),
1280 This->materials = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->materials) * nb_materials);
1281 if (!This->materials)
1283 HeapFree(GetProcessHeap(), 0, This->material_indices);
1284 goto end;
1286 This->nb_materials = nb_materials;
1288 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1290 IDirectXFileData *data;
1291 IDirectXFileDataReference *reference;
1292 IDirectXFileObject *material_child;
1294 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1295 if (FAILED(hr))
1297 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1298 IDirectXFileObject_Release(child);
1299 if (FAILED(hr))
1300 goto end;
1302 hr = IDirectXFileDataReference_Resolve(reference, &data);
1303 IDirectXFileDataReference_Release(reference);
1304 if (FAILED(hr))
1305 goto end;
1307 else
1309 IDirectXFileObject_Release(child);
1312 hr = Direct3DRMMaterial_create(&This->materials[i].material);
1313 if (FAILED(hr))
1315 IDirectXFileData_Release(data);
1316 goto end;
1319 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1320 if (hr != DXFILE_OK)
1322 IDirectXFileData_Release(data);
1323 goto end;
1326 if (size != 44)
1327 WARN("Material size %u does not match expected one %u\n", size, 44);
1329 values = (float*)ptr;
1331 This->materials[i].color = RGBA_MAKE((BYTE)(values[0] * 255.0f), (BYTE)(values[1] * 255.0f),
1332 (BYTE)(values[2] * 255.0f), (BYTE)(values[3] * 255.0f));
1334 IDirect3DRMMaterial2_SetAmbient(This->materials[i].material, values[0], values [1], values[2]); /* Alpha ignored */
1335 IDirect3DRMMaterial2_SetPower(This->materials[i].material, values[4]);
1336 IDirect3DRMMaterial2_SetSpecular(This->materials[i].material, values[5], values[6], values[7]);
1337 IDirect3DRMMaterial2_SetEmissive(This->materials[i].material, values[8], values[9], values[10]);
1339 This->materials[i].texture = NULL;
1341 hr = IDirectXFileData_GetNextObject(data, &material_child);
1342 if (hr == S_OK)
1344 IDirectXFileData *data;
1345 char **filename;
1347 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1348 if (FAILED(hr))
1350 IDirectXFileDataReference *reference;
1352 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1353 if (FAILED(hr))
1354 goto end;
1356 hr = IDirectXFileDataReference_Resolve(reference, &data);
1357 IDirectXFileDataReference_Release(reference);
1358 if (FAILED(hr))
1359 goto end;
1362 hr = IDirectXFileData_GetType(data, &guid);
1363 if (hr != DXFILE_OK)
1364 goto end;
1365 if (!IsEqualGUID(guid, &TID_D3DRMTextureFilename))
1367 WARN("Not a texture filename\n");
1368 goto end;
1371 size = 4;
1372 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1373 if (SUCCEEDED(hr))
1375 if (load_texture_proc)
1377 IDirect3DRMTexture *texture;
1379 hr = load_texture_proc(*filename, arg, &texture);
1380 if (SUCCEEDED(hr))
1382 hr = IDirect3DTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (void**)&This->materials[i].texture);
1383 IDirect3DTexture_Release(texture);
1386 else
1388 HANDLE file;
1390 /* If the texture file is not found, no texture is associated with the material */
1391 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1392 if (file != INVALID_HANDLE_VALUE)
1394 CloseHandle(file);
1396 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown**)&This->materials[i].texture);
1397 if (FAILED(hr))
1399 IDirectXFileData_Release(data);
1400 goto end;
1406 else if (hr != DXFILEERR_NOMOREOBJECTS)
1408 goto end;
1410 hr = S_OK;
1412 IDirectXFileData_Release(data);
1413 i++;
1415 if (hr == S_OK)
1417 IDirectXFileObject_Release(child);
1418 WARN("Found more sub-objects than expected\n");
1420 else if (hr != DXFILEERR_NOMOREOBJECTS)
1422 goto end;
1424 hr = S_OK;
1426 else
1428 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(guid));
1431 IDirectXFileData_Release(pData2);
1432 pData2 = NULL;
1435 if (!This->nb_normals)
1437 /* Allocate normals, one per vertex */
1438 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1439 if (!This->pNormals)
1440 goto end;
1443 for (i = 0; i < This->nb_faces; i++)
1445 DWORD j;
1446 DWORD nb_face_indexes;
1447 D3DVECTOR face_normal;
1449 if (faces_vertex_idx_size < sizeof(DWORD))
1450 WARN("Not enough data to read number of indices of face %d\n", i);
1452 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1453 faces_vertex_idx_size--;
1454 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1455 WARN("Faces indices number mismatch\n");
1457 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1458 WARN("Not enough data to read all indices of face %d\n", i);
1460 if (!This->nb_normals)
1462 /* Compute face normal */
1463 if (nb_face_indexes > 2)
1465 D3DVECTOR a, b;
1467 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1468 D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1469 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1470 D3DRMVectorNormalize(&face_normal);
1472 else
1474 face_normal.u1.x = 0.0f;
1475 face_normal.u2.y = 0.0f;
1476 face_normal.u3.z = 0.0f;
1480 for (j = 0; j < nb_face_indexes; j++)
1482 /* Copy vertex index */
1483 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1484 /* Copy normal index */
1485 if (This->nb_normals)
1487 /* Read from x file */
1488 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1490 else
1492 DWORD vertex_idx = *faces_vertex_idx_ptr;
1493 if (vertex_idx >= This->nb_vertices)
1495 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1496 vertex_idx = 0;
1498 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1499 /* Add face normal to vertex normal */
1500 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1502 faces_vertex_idx_ptr++;
1504 faces_vertex_idx_size -= nb_face_indexes;
1507 /* Last DWORD must be 0 */
1508 *(faces_data_ptr + faces_data_size++) = 0;
1510 /* Set size (in number of DWORD) of all faces data */
1511 This->face_data_size = faces_data_size;
1513 if (!This->nb_normals)
1515 /* Normalize all normals */
1516 for (i = 0; i < This->nb_vertices; i++)
1518 D3DRMVectorNormalize(&This->pNormals[i]);
1520 This->nb_normals = This->nb_vertices;
1523 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1524 if (!This->pCoords2d)
1526 This->nb_coords2d = This->nb_vertices;
1527 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1528 for (i = 0; i < This->nb_coords2d; i++)
1530 This->pCoords2d[i].u = 0.0f;
1531 This->pCoords2d[i].v = 0.0f;
1535 TRACE("Mesh data loaded successfully\n");
1537 ret = D3DRM_OK;
1539 end:
1541 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1542 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1544 return ret;
1547 /*** IDirect3DRMMeshBuilder3 methods ***/
1548 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1549 void *filename, void *name,
1550 D3DRMLOADOPTIONS loadflags,
1551 D3DRMLOADTEXTURE3CALLBACK cb, void *arg)
1553 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1554 DXFILELOADOPTIONS load_options;
1555 IDirectXFile *dxfile = NULL;
1556 IDirectXFileEnumObject *enum_object = NULL;
1557 IDirectXFileData *data = NULL;
1558 const GUID* guid;
1559 DWORD size;
1560 Header* header;
1561 HRESULT hr;
1562 HRESULT ret = D3DRMERR_BADOBJECT;
1564 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1566 clean_mesh_builder_data(This);
1568 if (loadflags == D3DRMLOAD_FROMMEMORY)
1570 load_options = DXFILELOAD_FROMMEMORY;
1572 else if (loadflags == D3DRMLOAD_FROMFILE)
1574 load_options = DXFILELOAD_FROMFILE;
1575 TRACE("Loading from file %s\n", debugstr_a(filename));
1577 else
1579 FIXME("Load options %d not supported yet\n", loadflags);
1580 return E_NOTIMPL;
1583 hr = DirectXFileCreate(&dxfile);
1584 if (hr != DXFILE_OK)
1585 goto end;
1587 hr = IDirectXFile_RegisterTemplates(dxfile, templates, strlen(templates));
1588 if (hr != DXFILE_OK)
1589 goto end;
1591 hr = IDirectXFile_CreateEnumObject(dxfile, filename, load_options, &enum_object);
1592 if (hr != DXFILE_OK)
1593 goto end;
1595 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1596 if (hr != DXFILE_OK)
1597 goto end;
1599 hr = IDirectXFileData_GetType(data, &guid);
1600 if (hr != DXFILE_OK)
1601 goto end;
1603 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1605 if (!IsEqualGUID(guid, &TID_DXFILEHeader))
1607 ret = D3DRMERR_BADFILE;
1608 goto end;
1611 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&header);
1612 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1613 goto end;
1615 TRACE("Version is %d %d %d\n", header->major, header->minor, header->flags);
1617 /* Version must be 1.0.x */
1618 if ((header->major != 1) || (header->minor != 0))
1620 ret = D3DRMERR_BADFILE;
1621 goto end;
1624 IDirectXFileData_Release(data);
1625 data = NULL;
1627 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1628 if (hr != DXFILE_OK)
1630 ret = D3DRMERR_NOTFOUND;
1631 goto end;
1634 hr = IDirectXFileData_GetType(data, &guid);
1635 if (hr != DXFILE_OK)
1636 goto end;
1638 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1640 if (!IsEqualGUID(guid, &TID_D3DRMMesh))
1642 ret = D3DRMERR_NOTFOUND;
1643 goto end;
1646 /* We don't care about the texture interface version since we rely on QueryInterface */
1647 hr = load_mesh_data(iface, data, (D3DRMLOADTEXTURECALLBACK)cb, arg);
1648 if (hr == S_OK)
1649 ret = D3DRM_OK;
1651 end:
1653 if (data)
1654 IDirectXFileData_Release(data);
1655 if (enum_object)
1656 IDirectXFileEnumObject_Release(enum_object);
1657 if (dxfile)
1658 IDirectXFile_Release(dxfile);
1660 if (ret != D3DRM_OK)
1661 clean_mesh_builder_data(This);
1663 return ret;
1666 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1667 const char* filename, D3DRMXOFFORMAT format,
1668 D3DRMSAVEOPTIONS save)
1670 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1672 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1674 return E_NOTIMPL;
1677 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1678 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1680 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1681 DWORD i;
1683 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1685 for (i = 0; i < This->nb_vertices; i++)
1687 This->pVertices[i].u1.x *= sx;
1688 This->pVertices[i].u2.y *= sy;
1689 This->pVertices[i].u3.z *= sz;
1692 /* Normals are not affected by Scale */
1694 return D3DRM_OK;
1697 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1698 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1700 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1702 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1704 return E_NOTIMPL;
1707 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1708 D3DRMCOLORSOURCE color)
1710 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1712 FIXME("(%p)->(%x): stub\n", This, color);
1714 return E_NOTIMPL;
1717 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1718 D3DRMBOX* box)
1720 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1722 FIXME("(%p)->(%p): stub\n", This, box);
1724 return E_NOTIMPL;
1727 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1728 D3DVALUE crease, DWORD flags)
1730 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1732 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1734 return E_NOTIMPL;
1737 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1739 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1741 FIXME("(%p)->(): stub\n", This);
1743 return E_NOTIMPL;
1746 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh *mesh)
1748 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1750 return E_NOTIMPL;
1753 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1754 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1755 DWORD flags)
1757 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1759 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1761 return E_NOTIMPL;
1764 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMFrame3 *frame)
1766 FIXME("iface %p, frame %p stub!\n", iface, frame);
1768 return E_NOTIMPL;
1771 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1772 LPDIRECT3DRMFACE2 Face)
1774 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1776 FIXME("(%p)->(%p): stub\n", This, Face);
1778 return E_NOTIMPL;
1781 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1782 DWORD vcount, D3DVECTOR* vertices,
1783 DWORD ncount, D3DVECTOR* normals,
1784 DWORD* data,
1785 LPDIRECT3DRMFACEARRAY* FaceArray)
1787 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1789 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1790 normals, data, FaceArray);
1792 return E_NOTIMPL;
1795 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1796 DWORD vertex_Count,
1797 DWORD normal_count,
1798 DWORD face_count)
1800 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1802 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1804 return E_NOTIMPL;
1807 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1808 D3DVALUE red, D3DVALUE green,
1809 D3DVALUE blue)
1811 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1813 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1815 This->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
1817 return D3DRM_OK;
1820 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1821 D3DCOLOR color)
1823 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1825 TRACE("(%p)->(%x)\n", This, color);
1827 This->color = color;
1829 return D3DRM_OK;
1832 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1833 LPDIRECT3DRMTEXTURE3 texture)
1835 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1837 TRACE("(%p)->(%p)\n", This, texture);
1839 if (texture)
1840 IDirect3DRMTexture3_AddRef(texture);
1841 if (This->texture)
1842 IDirect3DRMTexture3_Release(This->texture);
1843 This->texture = texture;
1845 return D3DRM_OK;
1848 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1849 LPDIRECT3DRMMATERIAL2 material)
1851 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1853 TRACE("(%p)->(%p)\n", This, material);
1855 if (material)
1856 IDirect3DRMTexture2_AddRef(material);
1857 if (This->material)
1858 IDirect3DRMTexture2_Release(This->material);
1859 This->material = material;
1861 return D3DRM_OK;
1864 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1865 BOOL wrap_u, BOOL wrap_v)
1867 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1869 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1871 return E_NOTIMPL;
1874 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1875 D3DRMRENDERQUALITY quality)
1877 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1879 FIXME("(%p)->(%d): stub\n", This, quality);
1881 return E_NOTIMPL;
1884 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1885 BOOL enable)
1887 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1889 FIXME("(%p)->(%d): stub\n", This, enable);
1891 return E_NOTIMPL;
1894 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1895 DWORD index,
1896 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1898 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1900 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1902 return E_NOTIMPL;
1905 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1906 DWORD index,
1907 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1909 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1911 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1913 return E_NOTIMPL;
1916 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1917 DWORD index, D3DVALUE u,
1918 D3DVALUE v)
1920 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1922 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1924 if (index >= This->nb_coords2d)
1925 return D3DRMERR_BADVALUE;
1927 This->pCoords2d[index].u = u;
1928 This->pCoords2d[index].v = v;
1930 return D3DRM_OK;
1933 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1934 DWORD index, D3DCOLOR color)
1936 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1938 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1940 return E_NOTIMPL;
1943 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1944 DWORD index,
1945 D3DVALUE red, D3DVALUE green,
1946 D3DVALUE blue)
1948 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1950 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1952 return E_NOTIMPL;
1955 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1956 LPDIRECT3DRMFACEARRAY* FaceArray)
1958 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1960 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1962 return E_NOTIMPL;
1965 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1966 DWORD* vcount, D3DVECTOR* vertices,
1967 DWORD* ncount, D3DVECTOR* normals,
1968 DWORD* face_data_size,
1969 DWORD* face_data)
1971 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1973 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1974 face_data_size, face_data);
1976 return E_NOTIMPL;
1979 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1980 DWORD index, D3DVALUE* u,
1981 D3DVALUE* v)
1983 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1985 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1987 if (index >= This->nb_coords2d)
1988 return D3DRMERR_BADVALUE;
1990 *u = This->pCoords2d[index].u;
1991 *v = This->pCoords2d[index].v;
1993 return D3DRM_OK;
1997 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1998 D3DVALUE x, D3DVALUE y, D3DVALUE z)
2000 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2002 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
2004 return 0;
2007 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
2008 D3DVALUE x, D3DVALUE y, D3DVALUE z)
2010 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2012 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
2014 return 0;
2017 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
2018 LPDIRECT3DRMFACE2* Face)
2020 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2022 FIXME("(%p)->(%p): stub\n", This, Face);
2024 return E_NOTIMPL;
2027 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
2029 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2031 FIXME("(%p)->(): stub\n", This);
2033 return 0;
2036 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2038 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2040 FIXME("(%p)->(): stub\n", This);
2042 return FALSE;
2045 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2047 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2049 TRACE("(%p)->()\n", This);
2051 return This->nb_faces;
2054 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2056 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2058 TRACE("(%p)->()\n", This);
2060 return This->nb_vertices;
2063 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2064 DWORD index)
2066 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2068 FIXME("(%p)->(%d): stub\n", This, index);
2070 return 0;
2073 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3 *iface, IDirect3DRMMesh **mesh)
2075 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2076 HRESULT hr;
2077 D3DRMGROUPINDEX group;
2079 TRACE("(%p)->(%p)\n", This, mesh);
2081 if (!mesh)
2082 return E_POINTER;
2084 hr = Direct3DRMMesh_create(mesh);
2085 if (FAILED(hr))
2086 return hr;
2088 /* If there is mesh data, create a group and put data inside */
2089 if (This->nb_vertices)
2091 DWORD i, j;
2092 int k;
2093 D3DRMVERTEX* vertices;
2095 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2096 if (!vertices)
2098 IDirect3DRMMesh_Release(*mesh);
2099 return E_OUTOFMEMORY;
2101 for (i = 0; i < This->nb_vertices; i++)
2102 vertices[i].position = This->pVertices[i];
2103 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2104 HeapFree(GetProcessHeap(), 0, vertices);
2106 /* Groups are in reverse order compared to materials list in X file */
2107 for (k = This->nb_materials - 1; k >= 0; k--)
2109 unsigned* face_data;
2110 unsigned* out_ptr;
2111 DWORD* in_ptr = This->pFaceData;
2112 ULONG vertex_per_face = 0;
2113 BOOL* used_vertices;
2114 unsigned nb_vertices = 0;
2115 unsigned nb_faces = 0;
2117 used_vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->face_data_size * sizeof(*used_vertices));
2118 if (!used_vertices)
2120 IDirect3DRMMesh_Release(*mesh);
2121 return E_OUTOFMEMORY;
2124 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(*face_data));
2125 if (!face_data)
2127 HeapFree(GetProcessHeap(), 0, used_vertices);
2128 IDirect3DRMMesh_Release(*mesh);
2129 return E_OUTOFMEMORY;
2131 out_ptr = face_data;
2133 /* If all faces have the same number of vertex, set vertex_per_face */
2134 for (i = 0; i < This->nb_faces; i++)
2136 /* Process only faces belonging to the group */
2137 if (This->material_indices[i] == k)
2139 if (vertex_per_face && (vertex_per_face != *in_ptr))
2140 break;
2141 vertex_per_face = *in_ptr;
2143 in_ptr += 1 + *in_ptr * 2;
2145 if (i != This->nb_faces)
2146 vertex_per_face = 0;
2148 /* Put only vertex indices */
2149 in_ptr = This->pFaceData;
2150 for (i = 0; i < This->nb_faces; i++)
2152 DWORD nb_indices = *in_ptr++;
2154 /* Skip faces not belonging to the group */
2155 if (This->material_indices[i] != k)
2157 in_ptr += 2 * nb_indices;
2158 continue;
2161 /* Don't put nb indices when vertex_per_face is set */
2162 if (vertex_per_face)
2163 *out_ptr++ = nb_indices;
2165 for (j = 0; j < nb_indices; j++)
2167 *out_ptr = *in_ptr++;
2168 used_vertices[*out_ptr++] = TRUE;
2169 /* Skip normal index */
2170 in_ptr++;
2173 nb_faces++;
2176 for (i = 0; i < This->nb_vertices; i++)
2177 if (used_vertices[i])
2178 nb_vertices++;
2180 hr = IDirect3DRMMesh_AddGroup(*mesh, nb_vertices, nb_faces, vertex_per_face, face_data, &group);
2181 HeapFree(GetProcessHeap(), 0, used_vertices);
2182 HeapFree(GetProcessHeap(), 0, face_data);
2183 if (SUCCEEDED(hr))
2184 hr = IDirect3DRMMesh_SetGroupColor(*mesh, group, This->materials[k].color);
2185 if (SUCCEEDED(hr))
2186 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, group, (LPDIRECT3DRMMATERIAL)This->materials[k].material);
2187 if (SUCCEEDED(hr) && This->materials[k].texture)
2189 LPDIRECT3DRMTEXTURE texture;
2191 IDirect3DRMTexture3_QueryInterface(This->materials[k].texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2192 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, group, texture);
2193 IDirect3DRMTexture_Release(texture);
2195 if (FAILED(hr))
2197 IDirect3DRMMesh_Release(*mesh);
2198 return hr;
2203 return D3DRM_OK;
2206 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2207 DWORD index, LPDIRECT3DRMFACE2* Face)
2209 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2211 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2213 return E_NOTIMPL;
2216 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3 *iface,
2217 DWORD index, D3DVECTOR *vector)
2219 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2221 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2223 return E_NOTIMPL;
2226 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3 *iface,
2227 DWORD index, D3DVECTOR *vector)
2229 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2231 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2233 return E_NOTIMPL;
2236 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2237 DWORD IndexFirst, DWORD count)
2239 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2241 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2243 return E_NOTIMPL;
2246 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2247 DWORD IndexFirst, DWORD count)
2249 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2251 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2253 return E_NOTIMPL;
2256 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2257 LPDIRECT3DRMFACE2 Face)
2259 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2261 FIXME("(%p)->(%p): stub\n", This, Face);
2263 return E_NOTIMPL;
2266 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2268 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2270 FIXME("(%p)->(%u): stub\n", This, flags);
2272 return E_NOTIMPL;
2275 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2276 DWORD flags)
2278 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2280 FIXME("(%p)->(%u): stub\n", This, flags);
2282 return E_NOTIMPL;
2285 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2286 DWORD flags, DWORD* indices,
2287 DWORD* IndexFirst, DWORD* count)
2289 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2291 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2293 return E_NOTIMPL;
2296 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2297 LPUNKNOWN *unkwn)
2299 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2301 FIXME("(%p)->(%p): stub\n", This, unkwn);
2303 return E_NOTIMPL;
2306 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2307 DWORD flags, LPUNKNOWN *unkwn)
2309 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2311 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2313 return E_NOTIMPL;
2316 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2317 LPDWORD count, LPUNKNOWN *unkwn)
2319 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2321 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2323 return E_NOTIMPL;
2326 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2327 LPUNKNOWN unkwn)
2329 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2331 FIXME("(%p)->(%p): stub\n", This, unkwn);
2333 return E_NOTIMPL;
2336 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2337 DWORD index)
2339 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2341 FIXME("(%p)->(%u): stub\n", This, index);
2343 return E_NOTIMPL;
2346 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2347 DWORD* indices)
2349 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2351 FIXME("(%p)->(%p): stub\n", This, indices);
2353 return E_NOTIMPL;
2356 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2357 DWORD flags, DWORD format,
2358 DWORD VertexCount, LPVOID data)
2360 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2362 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2364 return E_NOTIMPL;
2367 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3 *iface,
2368 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2370 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2372 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2374 return E_NOTIMPL;
2377 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3 *iface,
2378 DWORD IndexFirst, DWORD *vcount, D3DVECTOR *vertices)
2380 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2381 DWORD count = This->nb_vertices - IndexFirst;
2383 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2385 if (vcount)
2386 *vcount = count;
2387 if (vertices && This->nb_vertices)
2388 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2390 return D3DRM_OK;
2393 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3 *iface,
2394 DWORD IndexFirst, DWORD count, D3DVECTOR *vector)
2396 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2398 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2400 return E_NOTIMPL;
2403 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3 *iface,
2404 DWORD IndexFirst, DWORD *count, D3DVECTOR *vector)
2406 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2408 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2410 return E_NOTIMPL;
2413 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2415 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2417 FIXME("(%p)->(): stub\n", This);
2419 return E_NOTIMPL;
2422 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2424 /*** IUnknown methods ***/
2425 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2426 IDirect3DRMMeshBuilder3Impl_AddRef,
2427 IDirect3DRMMeshBuilder3Impl_Release,
2428 /*** IDirect3DRMObject methods ***/
2429 IDirect3DRMMeshBuilder3Impl_Clone,
2430 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2431 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2432 IDirect3DRMMeshBuilder3Impl_SetAppData,
2433 IDirect3DRMMeshBuilder3Impl_GetAppData,
2434 IDirect3DRMMeshBuilder3Impl_SetName,
2435 IDirect3DRMMeshBuilder3Impl_GetName,
2436 IDirect3DRMMeshBuilder3Impl_GetClassName,
2437 /*** IDirect3DRMMeshBuilder3 methods ***/
2438 IDirect3DRMMeshBuilder3Impl_Load,
2439 IDirect3DRMMeshBuilder3Impl_Save,
2440 IDirect3DRMMeshBuilder3Impl_Scale,
2441 IDirect3DRMMeshBuilder3Impl_Translate,
2442 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2443 IDirect3DRMMeshBuilder3Impl_GetBox,
2444 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2445 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2446 IDirect3DRMMeshBuilder3Impl_AddMesh,
2447 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2448 IDirect3DRMMeshBuilder3Impl_AddFrame,
2449 IDirect3DRMMeshBuilder3Impl_AddFace,
2450 IDirect3DRMMeshBuilder3Impl_AddFaces,
2451 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2452 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2453 IDirect3DRMMeshBuilder3Impl_SetColor,
2454 IDirect3DRMMeshBuilder3Impl_SetTexture,
2455 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2456 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2457 IDirect3DRMMeshBuilder3Impl_SetQuality,
2458 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2459 IDirect3DRMMeshBuilder3Impl_SetVertex,
2460 IDirect3DRMMeshBuilder3Impl_SetNormal,
2461 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2462 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2463 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2464 IDirect3DRMMeshBuilder3Impl_GetFaces,
2465 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2466 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2467 IDirect3DRMMeshBuilder3Impl_AddVertex,
2468 IDirect3DRMMeshBuilder3Impl_AddNormal,
2469 IDirect3DRMMeshBuilder3Impl_CreateFace,
2470 IDirect3DRMMeshBuilder3Impl_GetQuality,
2471 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2472 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2473 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2474 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2475 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2476 IDirect3DRMMeshBuilder3Impl_GetFace,
2477 IDirect3DRMMeshBuilder3Impl_GetVertex,
2478 IDirect3DRMMeshBuilder3Impl_GetNormal,
2479 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2480 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2481 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2482 IDirect3DRMMeshBuilder3Impl_Empty,
2483 IDirect3DRMMeshBuilder3Impl_Optimize,
2484 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2485 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2486 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2487 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2488 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2489 IDirect3DRMMeshBuilder3Impl_Enable,
2490 IDirect3DRMMeshBuilder3Impl_GetEnable,
2491 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2492 IDirect3DRMMeshBuilder3Impl_SetVertices,
2493 IDirect3DRMMeshBuilder3Impl_GetVertices,
2494 IDirect3DRMMeshBuilder3Impl_SetNormals,
2495 IDirect3DRMMeshBuilder3Impl_GetNormals,
2496 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2499 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2501 IDirect3DRMMeshBuilderImpl* object;
2503 TRACE("(%p)\n", ppObj);
2505 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2506 if (!object)
2507 return E_OUTOFMEMORY;
2509 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2510 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2511 object->ref = 1;
2513 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2514 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2515 else
2516 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2518 return S_OK;
2521 /*** IUnknown methods ***/
2522 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2523 REFIID riid, void** ppvObject)
2525 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2527 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2529 *ppvObject = NULL;
2531 if (IsEqualGUID(riid, &IID_IUnknown) ||
2532 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2534 *ppvObject = &This->IDirect3DRMMesh_iface;
2536 else
2538 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2539 return E_NOINTERFACE;
2542 IDirect3DRMMesh_AddRef(iface);
2543 return S_OK;
2546 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2548 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2549 ULONG ref = InterlockedIncrement(&This->ref);
2551 TRACE("(%p)->(): new ref = %d\n", This, ref);
2553 return ref;
2556 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2558 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2559 ULONG ref = InterlockedDecrement(&This->ref);
2561 TRACE("(%p)->(): new ref = %d\n", This, ref);
2563 if (!ref)
2565 DWORD i;
2567 for (i = 0; i < This->nb_groups; i++)
2569 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2570 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2571 if (This->groups[i].material)
2572 IDirect3DRMMaterial2_Release(This->groups[i].material);
2573 if (This->groups[i].texture)
2574 IDirect3DRMTexture3_Release(This->groups[i].texture);
2576 HeapFree(GetProcessHeap(), 0, This->groups);
2577 HeapFree(GetProcessHeap(), 0, This);
2580 return ref;
2583 /*** IDirect3DRMObject methods ***/
2584 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2585 LPUNKNOWN pUnkOuter, REFIID riid,
2586 LPVOID *ppvObj)
2588 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2590 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2592 return E_NOTIMPL;
2595 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2596 D3DRMOBJECTCALLBACK cb,
2597 LPVOID argument)
2599 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2601 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2603 return E_NOTIMPL;
2606 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2607 D3DRMOBJECTCALLBACK cb,
2608 LPVOID argument)
2610 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2612 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2614 return E_NOTIMPL;
2617 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2618 DWORD data)
2620 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2622 FIXME("(%p)->(%u): stub\n", This, data);
2624 return E_NOTIMPL;
2627 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2629 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2631 FIXME("(%p)->(): stub\n", This);
2633 return 0;
2636 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2637 LPCSTR pName)
2639 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2641 FIXME("(%p)->(%s): stub\n", This, pName);
2643 return E_NOTIMPL;
2646 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2647 LPDWORD lpdwSize, LPSTR lpName)
2649 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2651 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2653 return E_NOTIMPL;
2656 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2657 LPDWORD size, LPSTR name)
2659 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2661 TRACE("(%p)->(%p, %p)\n", This, size, name);
2663 if (!size || *size < strlen("Mesh") || !name)
2664 return E_INVALIDARG;
2666 strcpy(name, "Mesh");
2667 *size = sizeof("Mesh");
2669 return D3DRM_OK;
2672 /*** IDirect3DRMMesh methods ***/
2673 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2674 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2676 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2678 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2680 return E_NOTIMPL;
2683 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2684 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2686 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2688 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2690 return E_NOTIMPL;
2693 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2694 D3DRMBOX * box)
2696 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2698 FIXME("(%p)->(%p): stub\n", This, box);
2700 return E_NOTIMPL;
2703 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2704 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2705 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2707 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2708 mesh_group* group;
2710 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2712 if (!face_data || !return_id)
2713 return E_POINTER;
2715 if ((This->nb_groups + 1) > This->groups_capacity)
2717 ULONG new_capacity;
2718 mesh_group* groups;
2720 if (!This->groups_capacity)
2722 new_capacity = 16;
2723 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2725 else
2727 new_capacity = This->groups_capacity * 2;
2728 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2731 if (!groups)
2732 return E_OUTOFMEMORY;
2734 This->groups_capacity = new_capacity;
2735 This->groups = groups;
2738 group = This->groups + This->nb_groups;
2740 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2741 if (!group->vertices)
2742 return E_OUTOFMEMORY;
2743 group->nb_vertices = vertex_count;
2744 group->nb_faces = face_count;
2745 group->vertex_per_face = vertex_per_face;
2747 if (vertex_per_face)
2749 group->face_data_size = face_count * vertex_per_face;
2751 else
2753 unsigned i;
2754 unsigned nb_indices;
2755 unsigned* face_data_ptr = face_data;
2756 group->face_data_size = 0;
2758 for (i = 0; i < face_count; i++)
2760 nb_indices = *face_data_ptr;
2761 group->face_data_size += nb_indices + 1;
2762 face_data_ptr += nb_indices;
2766 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2767 if (!group->face_data)
2769 HeapFree(GetProcessHeap(), 0 , group->vertices);
2770 return E_OUTOFMEMORY;
2773 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2775 group->material = NULL;
2776 group->texture = NULL;
2778 *return_id = This->nb_groups++;
2780 return D3DRM_OK;
2783 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2784 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2785 D3DRMVERTEX *values)
2787 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2789 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2791 if (id >= This->nb_groups)
2792 return D3DRMERR_BADVALUE;
2794 if ((index + count - 1) >= This->groups[id].nb_vertices)
2795 return D3DRMERR_BADVALUE;
2797 if (!values)
2798 return E_POINTER;
2800 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2802 return D3DRM_OK;
2805 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2806 D3DRMGROUPINDEX id, D3DCOLOR color)
2808 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2810 TRACE("(%p)->(%u,%x)\n", This, id, color);
2812 if (id >= This->nb_groups)
2813 return D3DRMERR_BADVALUE;
2815 This->groups[id].color = color;
2817 return D3DRM_OK;
2820 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2821 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2823 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2825 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2827 if (id >= This->nb_groups)
2828 return D3DRMERR_BADVALUE;
2830 This->groups[id].color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
2832 return D3DRM_OK;
2835 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2836 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2838 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2840 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2842 return E_NOTIMPL;
2845 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2846 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2848 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2850 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2852 return E_NOTIMPL;
2855 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2856 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2858 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2860 TRACE("(%p)->(%u,%p)\n", This, id, material);
2862 if (id >= This->nb_groups)
2863 return D3DRMERR_BADVALUE;
2865 if (This->groups[id].material)
2866 IDirect3DRMMaterial2_Release(This->groups[id].material);
2868 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2870 if (material)
2871 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2873 return D3DRM_OK;
2876 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2877 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2879 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2881 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2883 if (id >= This->nb_groups)
2884 return D3DRMERR_BADVALUE;
2886 if (This->groups[id].texture)
2887 IDirect3DRMTexture3_Release(This->groups[id].texture);
2889 if (!texture)
2891 This->groups[id].texture = NULL;
2892 return D3DRM_OK;
2895 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2898 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2900 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2902 TRACE("(%p)->()\n", This);
2904 return This->nb_groups;
2907 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2908 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2909 DWORD *face_data_size, unsigned *face_data)
2911 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2913 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2915 if (id >= This->nb_groups)
2916 return D3DRMERR_BADVALUE;
2918 if (vertex_count)
2919 *vertex_count = This->groups[id].nb_vertices;
2920 if (face_count)
2921 *face_count = This->groups[id].nb_faces;
2922 if (vertex_per_face)
2923 *vertex_per_face = This->groups[id].vertex_per_face;
2924 if (face_data_size)
2925 *face_data_size = This->groups[id].face_data_size;
2926 if (face_data)
2927 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size * sizeof(DWORD));
2929 return D3DRM_OK;
2932 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2933 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2935 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2937 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2939 if (id >= This->nb_groups)
2940 return D3DRMERR_BADVALUE;
2942 if ((index + count - 1) >= This->groups[id].nb_vertices)
2943 return D3DRMERR_BADVALUE;
2945 if (!return_ptr)
2946 return E_POINTER;
2948 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2950 return D3DRM_OK;
2953 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2955 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2957 TRACE("(%p)->(%u)\n", This, id);
2959 return This->groups[id].color;
2962 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2964 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2966 FIXME("(%p)->(%u): stub\n", This, id);
2968 return 0;
2970 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2972 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2974 FIXME("(%p)->(%u): stub\n", This, id);
2976 return 0;
2979 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2980 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2982 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2984 TRACE("(%p)->(%u,%p)\n", This, id, material);
2986 if (id >= This->nb_groups)
2987 return D3DRMERR_BADVALUE;
2989 if (!material)
2990 return E_POINTER;
2992 if (This->groups[id].material)
2993 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2994 else
2995 *material = NULL;
2997 return D3DRM_OK;
3000 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
3001 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
3003 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
3005 TRACE("(%p)->(%u,%p)\n", This, id, texture);
3007 if (id >= This->nb_groups)
3008 return D3DRMERR_BADVALUE;
3010 if (!texture)
3011 return E_POINTER;
3013 if (This->groups[id].texture)
3014 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
3015 else
3016 *texture = NULL;
3018 return D3DRM_OK;
3021 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
3023 /*** IUnknown methods ***/
3024 IDirect3DRMMeshImpl_QueryInterface,
3025 IDirect3DRMMeshImpl_AddRef,
3026 IDirect3DRMMeshImpl_Release,
3027 /*** IDirect3DRMObject methods ***/
3028 IDirect3DRMMeshImpl_Clone,
3029 IDirect3DRMMeshImpl_AddDestroyCallback,
3030 IDirect3DRMMeshImpl_DeleteDestroyCallback,
3031 IDirect3DRMMeshImpl_SetAppData,
3032 IDirect3DRMMeshImpl_GetAppData,
3033 IDirect3DRMMeshImpl_SetName,
3034 IDirect3DRMMeshImpl_GetName,
3035 IDirect3DRMMeshImpl_GetClassName,
3036 /*** IDirect3DRMMesh methods ***/
3037 IDirect3DRMMeshImpl_Scale,
3038 IDirect3DRMMeshImpl_Translate,
3039 IDirect3DRMMeshImpl_GetBox,
3040 IDirect3DRMMeshImpl_AddGroup,
3041 IDirect3DRMMeshImpl_SetVertices,
3042 IDirect3DRMMeshImpl_SetGroupColor,
3043 IDirect3DRMMeshImpl_SetGroupColorRGB,
3044 IDirect3DRMMeshImpl_SetGroupMapping,
3045 IDirect3DRMMeshImpl_SetGroupQuality,
3046 IDirect3DRMMeshImpl_SetGroupMaterial,
3047 IDirect3DRMMeshImpl_SetGroupTexture,
3048 IDirect3DRMMeshImpl_GetGroupCount,
3049 IDirect3DRMMeshImpl_GetGroup,
3050 IDirect3DRMMeshImpl_GetVertices,
3051 IDirect3DRMMeshImpl_GetGroupColor,
3052 IDirect3DRMMeshImpl_GetGroupMapping,
3053 IDirect3DRMMeshImpl_GetGroupQuality,
3054 IDirect3DRMMeshImpl_GetGroupMaterial,
3055 IDirect3DRMMeshImpl_GetGroupTexture
3058 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
3060 IDirect3DRMMeshImpl* object;
3062 TRACE("(%p)\n", obj);
3064 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
3065 if (!object)
3066 return E_OUTOFMEMORY;
3068 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
3069 object->ref = 1;
3071 *obj = &object->IDirect3DRMMesh_iface;
3073 return S_OK;