wbemprox: Add support for enumerating class methods.
[wine/multimedia.git] / dlls / d3drm / meshbuilder.c
blob455bb324089e2aeeda642c9879995ce595c72fec
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 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
64 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
65 LONG ref;
66 char* name;
67 DWORD nb_vertices;
68 D3DVECTOR* pVertices;
69 DWORD nb_normals;
70 D3DVECTOR* pNormals;
71 DWORD nb_faces;
72 DWORD face_data_size;
73 LPVOID pFaceData;
74 DWORD nb_coords2d;
75 Coords2d* pCoords2d;
76 D3DCOLOR color;
77 IDirect3DRMMaterial2* material;
78 IDirect3DRMTexture3* texture;
79 } IDirect3DRMMeshBuilderImpl;
81 char templates[] = {
82 "xof 0302txt 0064"
83 "template Header"
84 "{"
85 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
86 "WORD major;"
87 "WORD minor;"
88 "DWORD flags;"
89 "}"
90 "template Vector"
91 "{"
92 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
93 "FLOAT x;"
94 "FLOAT y;"
95 "FLOAT z;"
96 "}"
97 "template Coords2d"
98 "{"
99 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
100 "FLOAT u;"
101 "FLOAT v;"
103 "template Matrix4x4"
105 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
106 "array FLOAT matrix[16];"
108 "template ColorRGBA"
110 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
111 "FLOAT red;"
112 "FLOAT green;"
113 "FLOAT blue;"
114 "FLOAT alpha;"
116 "template ColorRGB"
118 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
119 "FLOAT red;"
120 "FLOAT green;"
121 "FLOAT blue;"
123 "template IndexedColor"
125 "<1630B820-7842-11CF-8F52-0040333594A3>"
126 "DWORD index;"
127 "ColorRGBA indexColor;"
129 "template Boolean"
131 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
132 "DWORD truefalse;"
134 "template Boolean2d"
136 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
137 "Boolean u;"
138 "Boolean v;"
140 "template MaterialWrap"
142 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
143 "Boolean u;"
144 "Boolean v;"
146 "template TextureFilename"
148 "<A42790E1-7810-11CF-8F52-0040333594A3>"
149 "STRING filename;"
151 "template Material"
153 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
154 "ColorRGBA faceColor;"
155 "FLOAT power;"
156 "ColorRGB specularColor;"
157 "ColorRGB emissiveColor;"
158 "[...]"
160 "template MeshFace"
162 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
163 "DWORD nFaceVertexIndices;"
164 "array DWORD faceVertexIndices[nFaceVertexIndices];"
166 "template MeshFaceWraps"
168 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
169 "DWORD nFaceWrapValues;"
170 "array Boolean2d faceWrapValues[nFaceWrapValues];"
172 "template MeshTextureCoords"
174 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
175 "DWORD nTextureCoords;"
176 "array Coords2d textureCoords[nTextureCoords];"
178 "template MeshMaterialList"
180 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
181 "DWORD nMaterials;"
182 "DWORD nFaceIndexes;"
183 "array DWORD faceIndexes[nFaceIndexes];"
184 "[Material]"
186 "template MeshNormals"
188 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
189 "DWORD nNormals;"
190 "array Vector normals[nNormals];"
191 "DWORD nFaceNormals;"
192 "array MeshFace faceNormals[nFaceNormals];"
194 "template MeshVertexColors"
196 "<1630B821-7842-11CF-8F52-0040333594A3>"
197 "DWORD nVertexColors;"
198 "array IndexedColor vertexColors[nVertexColors];"
200 "template Mesh"
202 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
203 "DWORD nVertices;"
204 "array Vector vertices[nVertices];"
205 "DWORD nFaces;"
206 "array MeshFace faces[nFaces];"
207 "[...]"
209 "template FrameTransformMatrix"
211 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
212 "Matrix4x4 frameMatrix;"
214 "template Frame"
216 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
217 "[...]"
219 "template FloatKeys"
221 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
222 "DWORD nValues;"
223 "array FLOAT values[nValues];"
225 "template TimedFloatKeys"
227 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
228 "DWORD time;"
229 "FloatKeys tfkeys;"
231 "template AnimationKey"
233 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
234 "DWORD keyType;"
235 "DWORD nKeys;"
236 "array TimedFloatKeys keys[nKeys];"
238 "template AnimationOptions"
240 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
241 "DWORD openclosed;"
242 "DWORD positionquality;"
244 "template Animation"
246 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
247 "[...]"
249 "template AnimationSet"
251 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
252 "[Animation]"
254 "template InlineData"
256 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
257 "[BINARY]"
259 "template Url"
261 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
262 "DWORD nUrls;"
263 "array STRING urls[nUrls];"
265 "template ProgressiveMesh"
267 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
268 "[Url,InlineData]"
270 "template Guid"
272 "<A42790E0-7810-11CF-8F52-0040333594A3>"
273 "DWORD data1;"
274 "WORD data2;"
275 "WORD data3;"
276 "array UCHAR data4[8];"
278 "template StringProperty"
280 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
281 "STRING key;"
282 "STRING value;"
284 "template PropertyBag"
286 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
287 "[StringProperty]"
289 "template ExternalVisual"
291 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
292 "Guid guidExternalVisual;"
293 "[...]"
295 "template RightHanded"
297 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
298 "DWORD bRightHanded;"
302 static inline IDirect3DRMMeshImpl *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
304 return CONTAINING_RECORD(iface, IDirect3DRMMeshImpl, IDirect3DRMMesh_iface);
307 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
309 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder2_iface);
312 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
314 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder3_iface);
317 /*** IUnknown methods ***/
318 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2* iface,
319 REFIID riid, void** ppvObject)
321 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
323 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
325 *ppvObject = NULL;
327 if(IsEqualGUID(riid, &IID_IUnknown) ||
328 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder) ||
329 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2))
331 *ppvObject = &This->IDirect3DRMMeshBuilder2_iface;
333 else if(IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
335 *ppvObject = &This->IDirect3DRMMeshBuilder3_iface;
337 else
339 FIXME("interface %s not implemented\n", debugstr_guid(riid));
340 return E_NOINTERFACE;
343 IDirect3DRMMeshBuilder_AddRef(iface);
344 return S_OK;
347 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2* iface)
349 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
350 ULONG ref = InterlockedIncrement(&This->ref);
352 TRACE("(%p)->(): new ref = %d\n", This, ref);
354 return ref;
357 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2* iface)
359 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
360 ULONG ref = InterlockedDecrement(&This->ref);
362 TRACE("(%p)->(): new ref = %d\n", This, ref);
364 if (!ref)
366 if (This->material)
367 IDirect3DRMMaterial2_Release(This->material);
368 if (This->texture)
369 IDirect3DRMTexture3_Release(This->texture);
370 HeapFree(GetProcessHeap(), 0, This->name);
371 HeapFree(GetProcessHeap(), 0, This->pVertices);
372 HeapFree(GetProcessHeap(), 0, This->pNormals);
373 HeapFree(GetProcessHeap(), 0, This->pFaceData);
374 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
375 HeapFree(GetProcessHeap(), 0, This);
378 return ref;
381 /*** IDirect3DRMObject methods ***/
382 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2* iface,
383 LPUNKNOWN pUnkOuter, REFIID riid,
384 LPVOID *ppvObj)
386 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
388 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
390 return E_NOTIMPL;
393 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2* iface,
394 D3DRMOBJECTCALLBACK cb,
395 LPVOID argument)
397 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
399 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
401 return E_NOTIMPL;
404 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2* iface,
405 D3DRMOBJECTCALLBACK cb,
406 LPVOID argument)
408 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
410 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
412 return E_NOTIMPL;
415 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
416 DWORD data)
418 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
420 FIXME("(%p)->(%u): stub\n", This, data);
422 return E_NOTIMPL;
425 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
427 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
429 FIXME("(%p)->(): stub\n", This);
431 return 0;
434 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2* iface,
435 LPCSTR name)
437 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
439 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
441 return IDirect3DRMMeshBuilder3_SetName(&This->IDirect3DRMMeshBuilder3_iface, name);
444 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2* iface,
445 LPDWORD size, LPSTR name)
447 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
449 TRACE("(%p)->(%p,%p)\n", This, size, name);
451 return IDirect3DRMMeshBuilder3_GetName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
454 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2* iface,
455 LPDWORD size, LPSTR name)
457 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
459 TRACE("(%p)->(%p, %p)\n", This, size, name);
461 return IDirect3DRMMeshBuilder3_GetClassName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
464 /*** IDirect3DRMMeshBuilder2 methods ***/
465 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2* iface,
466 LPVOID filename, LPVOID name,
467 D3DRMLOADOPTIONS loadflags,
468 D3DRMLOADTEXTURECALLBACK cb, LPVOID arg)
470 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
472 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
474 if (cb)
475 FIXME("Texture callback is not yet supported\n");
477 return IDirect3DRMMeshBuilder3_Load(&This->IDirect3DRMMeshBuilder3_iface, filename, name,
478 loadflags, NULL, arg);
481 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
482 const char *filename, D3DRMXOFFORMAT format,
483 D3DRMSAVEOPTIONS save)
485 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
487 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
489 return E_NOTIMPL;
492 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
493 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
495 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
497 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
499 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
502 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
503 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
505 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
507 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
509 return E_NOTIMPL;
512 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
513 D3DRMCOLORSOURCE color)
515 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
517 FIXME("(%p)->(%x): stub\n", This, color);
519 return E_NOTIMPL;
522 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
523 D3DRMBOX *pBox)
525 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
527 FIXME("(%p)->(%p): stub\n", This, pBox);
529 return E_NOTIMPL;
532 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
534 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
536 FIXME("(%p)->(): stub\n", This);
538 return E_NOTIMPL;
541 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
543 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
545 FIXME("(%p)->(): stub\n", This);
547 return E_NOTIMPL;
550 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2* iface,
551 LPDIRECT3DRMMESH pMesh)
553 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
555 FIXME("(%p)->(%p): stub\n", This, pMesh);
557 return E_NOTIMPL;
560 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2* iface,
561 LPDIRECT3DRMMESHBUILDER pMeshBuilder)
563 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
565 FIXME("(%p)->(%p): stub\n", This, pMeshBuilder);
567 return E_NOTIMPL;
570 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2* iface,
571 LPDIRECT3DRMFRAME pFrame)
573 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
575 FIXME("(%p)->(%p): stub\n", This, pFrame);
577 return E_NOTIMPL;
580 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2* iface,
581 LPDIRECT3DRMFACE pFace)
583 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
585 FIXME("(%p)->(%p): stub\n", This, pFace);
587 return E_NOTIMPL;
590 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2* iface,
591 DWORD vcount, D3DVECTOR *vertices,
592 DWORD ncount, D3DVECTOR *normals,
593 DWORD *data,
594 LPDIRECT3DRMFACEARRAY* pFaceArray)
596 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
598 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals, data, pFaceArray);
600 return E_NOTIMPL;
603 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
604 DWORD vertex_Count,
605 DWORD normal_count,
606 DWORD face_count)
608 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
610 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
612 return E_NOTIMPL;
615 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
616 D3DVALUE red, D3DVALUE green,
617 D3DVALUE blue)
619 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
621 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
623 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
626 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
627 D3DCOLOR color)
629 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
631 TRACE("(%p)->(%x)\n", This, color);
633 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
636 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2* iface,
637 LPDIRECT3DRMTEXTURE texture)
639 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
640 LPDIRECT3DRMTEXTURE3 texture3 = NULL;
641 HRESULT hr = D3DRM_OK;
643 if (texture)
644 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
645 if (SUCCEEDED(hr))
646 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
647 if (texture3)
648 IDirect3DRMTexture3_Release(texture3);
650 return hr;
653 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2* iface,
654 LPDIRECT3DRMMATERIAL material)
656 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
658 TRACE("(%p)->(%p)\n", This, material);
660 return IDirect3DRMMeshBuilder3_SetMaterial(&This->IDirect3DRMMeshBuilder3_iface, (LPDIRECT3DRMMATERIAL2)material);
663 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
664 BOOL wrap_u, BOOL wrap_v)
666 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
668 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
670 return E_NOTIMPL;
673 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
674 D3DRMRENDERQUALITY quality)
676 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
678 FIXME("(%p)->(%d): stub\n", This, quality);
680 return E_NOTIMPL;
683 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
684 BOOL enable)
686 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
688 FIXME("(%p)->(%d): stub\n", This, enable);
690 return E_NOTIMPL;
693 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
694 DWORD index,
695 D3DVALUE x, D3DVALUE y, D3DVALUE z)
697 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
699 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
701 return E_NOTIMPL;
704 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
705 DWORD index,
706 D3DVALUE x, D3DVALUE y, D3DVALUE z)
708 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
710 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
712 return E_NOTIMPL;
715 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
716 DWORD index,
717 D3DVALUE u, D3DVALUE v)
719 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
721 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
723 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
724 index, u, v);
727 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
728 DWORD index, D3DCOLOR color)
730 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
732 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
734 return E_NOTIMPL;
737 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
738 DWORD index, D3DVALUE red,
739 D3DVALUE green, D3DVALUE blue)
741 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
743 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
745 return E_NOTIMPL;
748 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2* iface,
749 LPDIRECT3DRMFACEARRAY* pFaceArray)
751 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
753 FIXME("(%p)->(%p): stub\n", This, pFaceArray);
755 return E_NOTIMPL;
758 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
759 DWORD *vcount, D3DVECTOR *vertices,
760 DWORD *ncount, D3DVECTOR *normals,
761 DWORD *face_data_size,
762 DWORD *face_data)
764 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
766 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
768 if (vcount)
769 *vcount = This->nb_vertices;
770 if (vertices && This->nb_vertices)
771 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
772 if (ncount)
773 *ncount = This->nb_normals;
774 if (normals && This->nb_normals)
775 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
776 if (face_data_size)
777 *face_data_size = This->face_data_size;
778 if (face_data && This->face_data_size)
779 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
781 return D3DRM_OK;
784 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
785 DWORD index,
786 D3DVALUE *u, D3DVALUE *v)
788 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
790 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
792 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
793 index, u, v);
796 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
797 D3DVALUE x, D3DVALUE y, D3DVALUE z)
799 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
801 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
803 return 0;
806 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
807 D3DVALUE x, D3DVALUE y, D3DVALUE z)
809 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
811 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
813 return 0;
816 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2* iface,
817 LPDIRECT3DRMFACE* ppFace)
819 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
821 FIXME("(%p)->(%p): stub\n", This, ppFace);
823 return E_NOTIMPL;
826 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
828 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
830 FIXME("(%p)->(): stub\n", This);
832 return 0;
835 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
837 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
839 FIXME("(%p)->(): stub\n", This);
841 return FALSE;
844 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
846 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
848 TRACE("(%p)->()\n", This);
850 return This->nb_faces;
853 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
855 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
857 TRACE("(%p)->()\n", This);
859 return This->nb_vertices;
862 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
863 DWORD index)
865 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
867 FIXME("(%p)->(%d): stub\n", This, index);
869 return 0;
872 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2* iface,
873 LPDIRECT3DRMMESH* mesh)
875 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
877 TRACE("(%p)->(%p)\n", This, mesh);
879 return IDirect3DRMMeshBuilder3_CreateMesh(&This->IDirect3DRMMeshBuilder3_iface, mesh);
882 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
883 D3DVALUE crease, DWORD dwFlags)
885 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
887 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
889 return E_NOTIMPL;
892 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2* iface,
893 DWORD index, LPDIRECT3DRMFACE* ppFace)
895 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
897 FIXME("(%p)->(%u,%p): stub\n", This, index, ppFace);
899 return E_NOTIMPL;
902 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
904 /*** IUnknown methods ***/
905 IDirect3DRMMeshBuilder2Impl_QueryInterface,
906 IDirect3DRMMeshBuilder2Impl_AddRef,
907 IDirect3DRMMeshBuilder2Impl_Release,
908 /*** IDirect3DRMObject methods ***/
909 IDirect3DRMMeshBuilder2Impl_Clone,
910 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
911 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
912 IDirect3DRMMeshBuilder2Impl_SetAppData,
913 IDirect3DRMMeshBuilder2Impl_GetAppData,
914 IDirect3DRMMeshBuilder2Impl_SetName,
915 IDirect3DRMMeshBuilder2Impl_GetName,
916 IDirect3DRMMeshBuilder2Impl_GetClassName,
917 /*** IDirect3DRMMeshBuilder methods ***/
918 IDirect3DRMMeshBuilder2Impl_Load,
919 IDirect3DRMMeshBuilder2Impl_Save,
920 IDirect3DRMMeshBuilder2Impl_Scale,
921 IDirect3DRMMeshBuilder2Impl_Translate,
922 IDirect3DRMMeshBuilder2Impl_SetColorSource,
923 IDirect3DRMMeshBuilder2Impl_GetBox,
924 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
925 IDirect3DRMMeshBuilder2Impl_GetColorSource,
926 IDirect3DRMMeshBuilder2Impl_AddMesh,
927 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
928 IDirect3DRMMeshBuilder2Impl_AddFrame,
929 IDirect3DRMMeshBuilder2Impl_AddFace,
930 IDirect3DRMMeshBuilder2Impl_AddFaces,
931 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
932 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
933 IDirect3DRMMeshBuilder2Impl_SetColor,
934 IDirect3DRMMeshBuilder2Impl_SetTexture,
935 IDirect3DRMMeshBuilder2Impl_SetMaterial,
936 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
937 IDirect3DRMMeshBuilder2Impl_SetQuality,
938 IDirect3DRMMeshBuilder2Impl_SetPerspective,
939 IDirect3DRMMeshBuilder2Impl_SetVertex,
940 IDirect3DRMMeshBuilder2Impl_SetNormal,
941 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
942 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
943 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
944 IDirect3DRMMeshBuilder2Impl_GetFaces,
945 IDirect3DRMMeshBuilder2Impl_GetVertices,
946 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
947 IDirect3DRMMeshBuilder2Impl_AddVertex,
948 IDirect3DRMMeshBuilder2Impl_AddNormal,
949 IDirect3DRMMeshBuilder2Impl_CreateFace,
950 IDirect3DRMMeshBuilder2Impl_GetQuality,
951 IDirect3DRMMeshBuilder2Impl_GetPerspective,
952 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
953 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
954 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
955 IDirect3DRMMeshBuilder2Impl_CreateMesh,
956 /*** IDirect3DRMMeshBuilder2 methods ***/
957 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
958 IDirect3DRMMeshBuilder2Impl_GetFace
962 /*** IUnknown methods ***/
963 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
964 REFIID riid, void** ppvObject)
966 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
967 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
970 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
972 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
973 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
976 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
978 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
979 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
982 /*** IDirect3DRMObject methods ***/
983 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3* iface,
984 LPUNKNOWN pUnkOuter, REFIID riid,
985 LPVOID *ppvObj)
987 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
989 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
991 return E_NOTIMPL;
994 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
995 D3DRMOBJECTCALLBACK cb,
996 LPVOID argument)
998 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1000 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1002 return E_NOTIMPL;
1005 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1006 D3DRMOBJECTCALLBACK cb,
1007 LPVOID argument)
1009 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1011 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1013 return E_NOTIMPL;
1016 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1017 DWORD data)
1019 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1021 FIXME("(%p)->(%u): stub\n", This, data);
1023 return E_NOTIMPL;
1026 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1028 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1030 FIXME("(%p)->(): stub\n", This);
1032 return 0;
1035 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1036 LPCSTR name)
1038 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1039 char *string = NULL;
1041 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
1043 if (name)
1045 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1046 if (!string) return E_OUTOFMEMORY;
1047 strcpy(string, name);
1049 HeapFree(GetProcessHeap(), 0, This->name);
1050 This->name = string;
1052 return D3DRM_OK;
1055 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3* iface,
1056 LPDWORD size, LPSTR name)
1058 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1060 TRACE("(%p)->(%p,%p)\n", This, size, name);
1062 if (!size)
1063 return E_POINTER;
1065 if (!This->name)
1067 *size = 0;
1068 return D3DRM_OK;
1071 if (*size < (strlen(This->name) + 1))
1072 return E_INVALIDARG;
1074 strcpy(name, This->name);
1075 *size = strlen(This->name) + 1;
1077 return D3DRM_OK;
1080 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3* iface,
1081 LPDWORD size, LPSTR name)
1083 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1085 TRACE("(%p)->(%p, %p)\n", This, size, name);
1087 if (!size || *size < strlen("Builder") || !name)
1088 return E_INVALIDARG;
1090 strcpy(name, "Builder");
1091 *size = sizeof("Builder");
1093 return D3DRM_OK;
1096 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
1098 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1099 LPDIRECTXFILEOBJECT pObject = NULL;
1100 LPDIRECTXFILEDATA pData2 = NULL;
1101 const GUID* pGuid;
1102 DWORD size;
1103 LPBYTE ptr;
1104 HRESULT hr;
1105 HRESULT ret = D3DRMERR_BADOBJECT;
1106 DWORD* faces_vertex_idx_data = NULL;
1107 DWORD* faces_vertex_idx_ptr;
1108 DWORD faces_vertex_idx_size;
1109 DWORD* faces_normal_idx_data = NULL;
1110 DWORD* faces_normal_idx_ptr = NULL;
1111 DWORD* faces_data_ptr;
1112 DWORD faces_data_size = 0;
1113 DWORD i;
1115 TRACE("(%p)->(%p)\n", This, pData);
1117 /* Remove previous name */
1118 HeapFree(GetProcessHeap(), 0, This->name);
1119 This->name = NULL;
1120 hr = IDirectXFileData_GetName(pData, NULL, &size);
1121 if (hr != DXFILE_OK)
1122 return hr;
1123 if (size)
1125 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1126 if (!This->name)
1127 return E_OUTOFMEMORY;
1129 hr = IDirectXFileData_GetName(pData, This->name, &size);
1130 if (hr != DXFILE_OK)
1132 HeapFree(GetProcessHeap(), 0, This->name);
1133 This->name = NULL;
1134 return hr;
1138 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1140 This->nb_normals = 0;
1142 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1143 if (hr != DXFILE_OK)
1144 goto end;
1146 This->nb_vertices = *(DWORD*)ptr;
1147 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1148 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1149 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1151 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1153 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1154 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1156 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1157 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1159 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1160 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size*2);
1161 faces_data_ptr = (DWORD*)This->pFaceData;
1163 while (1)
1165 hr = IDirectXFileData_GetNextObject(pData, &pObject);
1166 if (hr == DXFILEERR_NOMOREOBJECTS)
1168 TRACE("No more object\n");
1169 break;
1171 if (hr != DXFILE_OK)
1172 goto end;
1174 hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
1175 IDirectXFileObject_Release(pObject);
1176 if (hr != DXFILE_OK)
1177 goto end;
1179 hr = IDirectXFileData_GetType(pData2, &pGuid);
1180 if (hr != DXFILE_OK)
1181 goto end;
1183 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1185 if (IsEqualGUID(pGuid, &TID_D3DRMMeshNormals))
1187 DWORD nb_faces_normals;
1188 DWORD faces_normal_idx_size;
1190 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1191 if (hr != DXFILE_OK)
1192 goto end;
1194 This->nb_normals = *(DWORD*)ptr;
1195 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1197 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1198 if (nb_faces_normals != This->nb_faces)
1199 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1201 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1202 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1204 faces_normal_idx_size = size - (2*sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1205 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1206 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1208 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshTextureCoords))
1210 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1211 if (hr != DXFILE_OK)
1212 goto end;
1214 This->nb_coords2d = *(DWORD*)ptr;
1216 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1218 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1219 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1222 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshMaterialList))
1224 DWORD nb_materials;
1225 DWORD nb_face_indices;
1226 DWORD data_size;
1227 LPDIRECTXFILEOBJECT child;
1228 DWORD i = 0;
1229 float* values;
1231 TRACE("Process MeshMaterialList\n");
1233 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1234 if (hr != DXFILE_OK)
1235 goto end;
1237 nb_materials = *(DWORD*)ptr;
1238 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1239 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1241 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1243 if (size != data_size)
1244 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1246 if (nb_materials > 2)
1248 FIXME("Only one material per mesh supported, first one applies to all faces\n");
1249 nb_materials = 1;
1252 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1254 LPDIRECTXFILEDATA data;
1255 LPDIRECTXFILEDATAREFERENCE reference;
1256 LPDIRECT3DRMMATERIAL2 material;
1257 LPDIRECTXFILEOBJECT material_child;
1259 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1260 if (FAILED(hr))
1262 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1263 if (FAILED(hr))
1264 goto end;
1266 hr = IDirectXFileDataReference_Resolve(reference, &data);
1267 IDirectXFileDataReference_Release(reference);
1268 if (FAILED(hr))
1269 goto end;
1272 hr = Direct3DRMMaterial_create(&material);
1273 if (FAILED(hr))
1275 IDirectXFileData_Release(data);
1276 goto end;
1279 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1280 if (hr != DXFILE_OK)
1282 IDirectXFileData_Release(data);
1283 goto end;
1286 if (size != 44)
1287 WARN("Material size %u does not match expected one %u\n", size, 44);
1289 values = (float*)ptr;
1291 IDirect3DRMMeshBuilder3_SetColorRGB(iface, values[0], values [1], values[2]); /* Alpha ignored */
1293 IDirect3DRMMaterial2_SetAmbient(material, values[0], values [1], values[2]); /* Alpha ignored */
1294 IDirect3DRMMaterial2_SetPower(material, values[4]);
1295 IDirect3DRMMaterial2_SetSpecular(material, values[5], values[6], values[7]);
1296 IDirect3DRMMaterial2_SetEmissive(material, values[8], values[9], values[10]);
1298 This->material = material;
1300 hr = IDirectXFileData_GetNextObject(data, &material_child);
1301 if (hr == S_OK)
1303 LPDIRECTXFILEDATA data;
1304 LPDIRECT3DRMTEXTURE3 texture;
1305 char** filename;
1307 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1308 if (FAILED(hr))
1310 LPDIRECTXFILEDATAREFERENCE reference;
1312 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1313 if (FAILED(hr))
1314 goto end;
1316 hr = IDirectXFileDataReference_Resolve(reference, &data);
1317 IDirectXFileDataReference_Release(reference);
1318 if (FAILED(hr))
1319 goto end;
1322 hr = IDirectXFileData_GetType(data, &pGuid);
1323 if (hr != DXFILE_OK)
1324 goto end;
1325 if (!IsEqualGUID(pGuid, &TID_D3DRMTextureFilename))
1327 WARN("Not a texture filename\n");
1328 goto end;
1331 size = 4;
1332 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1333 if (SUCCEEDED(hr))
1335 HANDLE file;
1337 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1338 if (file != INVALID_HANDLE_VALUE)
1340 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&texture);
1341 if (FAILED(hr))
1343 IDirectXFileData_Release(data);
1344 goto end;
1346 This->texture = texture;
1350 else if (hr != DXFILEERR_NOMOREOBJECTS)
1352 goto end;
1354 hr = S_OK;
1356 IDirectXFileData_Release(data);
1357 i++;
1359 if (hr == S_OK)
1360 WARN("Found more sub-objects than expected\n");
1361 else if (hr != DXFILEERR_NOMOREOBJECTS)
1362 goto end;
1363 hr = S_OK;
1365 else
1367 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
1370 IDirectXFileData_Release(pData2);
1371 pData2 = NULL;
1374 if (!This->nb_normals)
1376 /* Allocate normals, one per vertex */
1377 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1378 if (!This->pNormals)
1379 goto end;
1382 for (i = 0; i < This->nb_faces; i++)
1384 DWORD j;
1385 DWORD nb_face_indexes;
1386 D3DVECTOR face_normal;
1388 if (faces_vertex_idx_size < sizeof(DWORD))
1389 WARN("Not enough data to read number of indices of face %d\n", i);
1391 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1392 faces_vertex_idx_size--;
1393 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1394 WARN("Faces indices number mismatch\n");
1396 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1397 WARN("Not enough data to read all indices of face %d\n", i);
1399 if (!This->nb_normals)
1401 /* Compute face normal */
1402 if (nb_face_indexes > 2)
1404 D3DVECTOR a, b;
1406 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1407 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[1]], &This->pVertices[faces_vertex_idx_ptr[0]]);
1408 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1409 D3DRMVectorNormalize(&face_normal);
1411 else
1413 face_normal.u1.x = 0.0f;
1414 face_normal.u2.y = 0.0f;
1415 face_normal.u3.z = 0.0f;
1419 for (j = 0; j < nb_face_indexes; j++)
1421 /* Copy vertex index */
1422 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1423 /* Copy normal index */
1424 if (This->nb_normals)
1426 /* Read from x file */
1427 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1429 else
1431 DWORD vertex_idx = *faces_vertex_idx_ptr;
1432 if (vertex_idx >= This->nb_vertices)
1434 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1435 vertex_idx = 0;
1437 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1438 /* Add face normal to vertex normal */
1439 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1441 faces_vertex_idx_ptr++;
1443 faces_vertex_idx_size -= nb_face_indexes;
1446 /* Last DWORD must be 0 */
1447 *(faces_data_ptr + faces_data_size++) = 0;
1449 /* Set size (in number of DWORD) of all faces data */
1450 This->face_data_size = faces_data_size;
1452 if (!This->nb_normals)
1454 /* Normalize all normals */
1455 for (i = 0; i < This->nb_vertices; i++)
1457 D3DRMVectorNormalize(&This->pNormals[i]);
1459 This->nb_normals = This->nb_vertices;
1462 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1463 if (!This->pCoords2d)
1465 This->nb_coords2d = This->nb_vertices;
1466 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1467 for (i = 0; i < This->nb_coords2d; i++)
1469 This->pCoords2d[i].u = 0.0f;
1470 This->pCoords2d[i].v = 0.0f;
1474 TRACE("Mesh data loaded successfully\n");
1476 ret = D3DRM_OK;
1478 end:
1480 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1481 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1483 return ret;
1486 /*** IDirect3DRMMeshBuilder3 methods ***/
1487 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1488 LPVOID filename, LPVOID name,
1489 D3DRMLOADOPTIONS loadflags,
1490 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1492 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1493 DXFILELOADOPTIONS load_options;
1494 LPDIRECTXFILE pDXFile = NULL;
1495 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1496 LPDIRECTXFILEDATA pData = NULL;
1497 LPDIRECTXFILEDATA pData2 = NULL;
1498 const GUID* pGuid;
1499 DWORD size;
1500 Header* pHeader;
1501 HRESULT hr;
1502 HRESULT ret = D3DRMERR_BADOBJECT;
1504 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1506 /* First free allocated buffers of previous mesh data */
1507 HeapFree(GetProcessHeap(), 0, This->pVertices);
1508 This->pVertices = NULL;
1509 HeapFree(GetProcessHeap(), 0, This->pNormals);
1510 This->pNormals = NULL;
1511 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1512 This->pFaceData = NULL;
1513 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1514 This->pCoords2d = NULL;
1516 if (loadflags == D3DRMLOAD_FROMMEMORY)
1518 load_options = DXFILELOAD_FROMMEMORY;
1520 else if (loadflags == D3DRMLOAD_FROMFILE)
1522 load_options = DXFILELOAD_FROMFILE;
1523 TRACE("Loading from file %s\n", debugstr_a(filename));
1525 else
1527 FIXME("Load options %d not supported yet\n", loadflags);
1528 return E_NOTIMPL;
1531 hr = DirectXFileCreate(&pDXFile);
1532 if (hr != DXFILE_OK)
1533 goto end;
1535 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1536 if (hr != DXFILE_OK)
1537 goto end;
1539 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1540 if (hr != DXFILE_OK)
1541 goto end;
1543 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1544 if (hr != DXFILE_OK)
1545 goto end;
1547 hr = IDirectXFileData_GetType(pData, &pGuid);
1548 if (hr != DXFILE_OK)
1549 goto end;
1551 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1553 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1555 ret = D3DRMERR_BADFILE;
1556 goto end;
1559 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1560 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1561 goto end;
1563 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1565 /* Version must be 1.0.x */
1566 if ((pHeader->major != 1) || (pHeader->minor != 0))
1568 ret = D3DRMERR_BADFILE;
1569 goto end;
1572 IDirectXFileData_Release(pData);
1573 pData = NULL;
1575 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1576 if (hr != DXFILE_OK)
1578 ret = D3DRMERR_NOTFOUND;
1579 goto end;
1582 hr = IDirectXFileData_GetType(pData, &pGuid);
1583 if (hr != DXFILE_OK)
1584 goto end;
1586 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1588 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1590 ret = D3DRMERR_NOTFOUND;
1591 goto end;
1594 hr = load_mesh_data(iface, pData);
1595 if (hr == S_OK)
1596 ret = D3DRM_OK;
1598 end:
1600 if (pData2)
1601 IDirectXFileData_Release(pData2);
1602 if (pData)
1603 IDirectXFileData_Release(pData);
1604 if (pEnumObject)
1605 IDirectXFileEnumObject_Release(pEnumObject);
1606 if (pDXFile)
1607 IDirectXFile_Release(pDXFile);
1609 if (ret != D3DRM_OK)
1611 /* Clean mesh data */
1612 This->nb_vertices = 0;
1613 This->nb_normals = 0;
1614 This->nb_faces = 0;
1615 This->face_data_size = 0;
1616 This->nb_coords2d = 0;
1617 HeapFree(GetProcessHeap(), 0, This->pVertices);
1618 This->pVertices = NULL;
1619 HeapFree(GetProcessHeap(), 0, This->pNormals);
1620 This->pNormals = NULL;
1621 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1622 This->pFaceData = NULL;
1623 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1624 This->pCoords2d = NULL;
1627 return ret;
1630 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1631 const char* filename, D3DRMXOFFORMAT format,
1632 D3DRMSAVEOPTIONS save)
1634 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1636 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1638 return E_NOTIMPL;
1641 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1642 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1644 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1645 int i;
1647 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1649 for (i = 0; i < This->nb_vertices; i++)
1651 This->pVertices[i].u1.x *= sx;
1652 This->pVertices[i].u2.y *= sy;
1653 This->pVertices[i].u3.z *= sz;
1656 /* Normals are not affected by Scale */
1658 return D3DRM_OK;
1661 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1662 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1664 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1666 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1668 return E_NOTIMPL;
1671 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1672 D3DRMCOLORSOURCE color)
1674 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1676 FIXME("(%p)->(%x): stub\n", This, color);
1678 return E_NOTIMPL;
1681 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1682 D3DRMBOX* box)
1684 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1686 FIXME("(%p)->(%p): stub\n", This, box);
1688 return E_NOTIMPL;
1691 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1692 D3DVALUE crease, DWORD flags)
1694 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1696 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1698 return E_NOTIMPL;
1701 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1703 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1705 FIXME("(%p)->(): stub\n", This);
1707 return E_NOTIMPL;
1710 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1711 LPDIRECT3DRMMESH Mesh)
1713 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1715 FIXME("(%p)->(%p): stub\n", This, Mesh);
1717 return E_NOTIMPL;
1720 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1721 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1722 DWORD flags)
1724 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1726 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1728 return E_NOTIMPL;
1731 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1732 LPDIRECT3DRMFRAME3 Frame)
1734 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1736 FIXME("(%p)->(%p): stub\n", This, Frame);
1738 return E_NOTIMPL;
1741 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1742 LPDIRECT3DRMFACE2 Face)
1744 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1746 FIXME("(%p)->(%p): stub\n", This, Face);
1748 return E_NOTIMPL;
1751 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1752 DWORD vcount, D3DVECTOR* vertices,
1753 DWORD ncount, D3DVECTOR* normals,
1754 DWORD* data,
1755 LPDIRECT3DRMFACEARRAY* FaceArray)
1757 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1759 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1760 normals, data, FaceArray);
1762 return E_NOTIMPL;
1765 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1766 DWORD vertex_Count,
1767 DWORD normal_count,
1768 DWORD face_count)
1770 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1772 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1774 return E_NOTIMPL;
1777 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1778 D3DVALUE red, D3DVALUE green,
1779 D3DVALUE blue)
1781 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1783 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1785 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1786 (BYTE)(green * 255.0f),
1787 (BYTE)(blue * 255.0f));
1789 return D3DRM_OK;
1792 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1793 D3DCOLOR color)
1795 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1797 TRACE("(%p)->(%x)\n", This, color);
1799 This->color = color;
1801 return D3DRM_OK;
1804 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1805 LPDIRECT3DRMTEXTURE3 texture)
1807 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1809 TRACE("(%p)->(%p)\n", This, texture);
1811 if (texture)
1812 IDirect3DRMTexture3_AddRef(texture);
1813 if (This->texture)
1814 IDirect3DRMTexture3_Release(This->texture);
1815 This->texture = texture;
1817 return D3DRM_OK;
1820 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1821 LPDIRECT3DRMMATERIAL2 material)
1823 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1825 TRACE("(%p)->(%p)\n", This, material);
1827 if (material)
1828 IDirect3DRMTexture2_AddRef(material);
1829 if (This->material)
1830 IDirect3DRMTexture2_Release(This->material);
1831 This->material = material;
1833 return D3DRM_OK;
1836 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1837 BOOL wrap_u, BOOL wrap_v)
1839 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1841 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1843 return E_NOTIMPL;
1846 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1847 D3DRMRENDERQUALITY quality)
1849 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1851 FIXME("(%p)->(%d): stub\n", This, quality);
1853 return E_NOTIMPL;
1856 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1857 BOOL enable)
1859 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1861 FIXME("(%p)->(%d): stub\n", This, enable);
1863 return E_NOTIMPL;
1866 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1867 DWORD index,
1868 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1870 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1872 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1874 return E_NOTIMPL;
1877 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1878 DWORD index,
1879 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1881 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1883 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1885 return E_NOTIMPL;
1888 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1889 DWORD index, D3DVALUE u,
1890 D3DVALUE v)
1892 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1894 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1896 if (index >= This->nb_coords2d)
1897 return D3DRMERR_BADVALUE;
1899 This->pCoords2d[index].u = u;
1900 This->pCoords2d[index].v = v;
1902 return D3DRM_OK;
1905 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1906 DWORD index, D3DCOLOR color)
1908 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1910 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1912 return E_NOTIMPL;
1915 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1916 DWORD index,
1917 D3DVALUE red, D3DVALUE green,
1918 D3DVALUE blue)
1920 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1922 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1924 return E_NOTIMPL;
1927 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1928 LPDIRECT3DRMFACEARRAY* FaceArray)
1930 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1932 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1934 return E_NOTIMPL;
1937 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1938 DWORD* vcount, D3DVECTOR* vertices,
1939 DWORD* ncount, D3DVECTOR* normals,
1940 DWORD* face_data_size,
1941 DWORD* face_data)
1943 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1945 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1946 face_data_size, face_data);
1948 return E_NOTIMPL;
1951 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1952 DWORD index, D3DVALUE* u,
1953 D3DVALUE* v)
1955 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1957 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1959 if (index >= This->nb_coords2d)
1960 return D3DRMERR_BADVALUE;
1962 *u = This->pCoords2d[index].u;
1963 *v = This->pCoords2d[index].v;
1965 return D3DRM_OK;
1969 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1970 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1972 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1974 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1976 return 0;
1979 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1980 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1982 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1984 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1986 return 0;
1989 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
1990 LPDIRECT3DRMFACE2* Face)
1992 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1994 FIXME("(%p)->(%p): stub\n", This, Face);
1996 return E_NOTIMPL;
1999 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
2001 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2003 FIXME("(%p)->(): stub\n", This);
2005 return 0;
2008 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2010 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2012 FIXME("(%p)->(): stub\n", This);
2014 return FALSE;
2017 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2019 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2021 TRACE("(%p)->()\n", This);
2023 return This->nb_faces;
2026 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2028 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2030 TRACE("(%p)->()\n", This);
2032 return This->nb_vertices;
2035 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2036 DWORD index)
2038 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2040 FIXME("(%p)->(%d): stub\n", This, index);
2042 return 0;
2045 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
2046 LPDIRECT3DRMMESH* 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 unsigned* face_data;
2065 unsigned* out_ptr;
2066 DWORD* in_ptr = This->pFaceData;
2067 int i, j;
2069 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2070 if (!face_data)
2072 IDirect3DRMMesh_Release(*mesh);
2073 return E_OUTOFMEMORY;
2075 out_ptr = face_data;
2077 /* Put only vertex indices */
2078 for (i = 0; i < This->nb_faces; i++)
2080 DWORD nb_indices = *out_ptr++ = *in_ptr++;
2081 for (j = 0; j < nb_indices; j++)
2083 *out_ptr++ = *in_ptr++;
2084 /* Skip normal index */
2085 in_ptr++;
2089 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
2090 HeapFree(GetProcessHeap(), 0, face_data);
2091 if (SUCCEEDED(hr))
2093 D3DRMVERTEX* vertices;
2095 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2096 if (vertices)
2098 for (i = 0; i < This->nb_vertices; i++)
2100 vertices[i].position = This->pVertices[i];
2102 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2103 HeapFree(GetProcessHeap(), 0, vertices);
2105 else
2107 hr = E_OUTOFMEMORY;
2110 if (SUCCEEDED(hr))
2111 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2112 if (SUCCEEDED(hr))
2113 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2114 if (SUCCEEDED(hr) && This->texture)
2116 LPDIRECT3DRMTEXTURE texture;
2118 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2119 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2120 IDirect3DRMTexture_Release(texture);
2122 if (FAILED(hr))
2123 IDirect3DRMMesh_Release(*mesh);
2126 return hr;
2129 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2130 DWORD index, LPDIRECT3DRMFACE2* Face)
2132 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2134 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2136 return E_NOTIMPL;
2139 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2140 DWORD index, LPD3DVECTOR vector)
2142 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2144 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2146 return E_NOTIMPL;
2149 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2150 DWORD index, LPD3DVECTOR vector)
2152 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2154 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2156 return E_NOTIMPL;
2159 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2160 DWORD IndexFirst, DWORD count)
2162 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2164 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2166 return E_NOTIMPL;
2169 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2170 DWORD IndexFirst, DWORD count)
2172 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2174 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2176 return E_NOTIMPL;
2179 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2180 LPDIRECT3DRMFACE2 Face)
2182 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2184 FIXME("(%p)->(%p): stub\n", This, Face);
2186 return E_NOTIMPL;
2189 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2191 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2193 FIXME("(%p)->(%u): stub\n", This, flags);
2195 return E_NOTIMPL;
2198 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2199 DWORD flags)
2201 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2203 FIXME("(%p)->(%u): stub\n", This, flags);
2205 return E_NOTIMPL;
2208 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2209 DWORD flags, DWORD* indices,
2210 DWORD* IndexFirst, DWORD* count)
2212 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2214 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2216 return E_NOTIMPL;
2219 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2220 LPUNKNOWN *unkwn)
2222 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2224 FIXME("(%p)->(%p): stub\n", This, unkwn);
2226 return E_NOTIMPL;
2229 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2230 DWORD flags, LPUNKNOWN *unkwn)
2232 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2234 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2236 return E_NOTIMPL;
2239 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2240 LPDWORD count, LPUNKNOWN *unkwn)
2242 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2244 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2246 return E_NOTIMPL;
2249 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2250 LPUNKNOWN unkwn)
2252 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2254 FIXME("(%p)->(%p): stub\n", This, unkwn);
2256 return E_NOTIMPL;
2259 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2260 DWORD index)
2262 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2264 FIXME("(%p)->(%u): stub\n", This, index);
2266 return E_NOTIMPL;
2269 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2270 DWORD* indices)
2272 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2274 FIXME("(%p)->(%p): stub\n", This, indices);
2276 return E_NOTIMPL;
2279 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2280 DWORD flags, DWORD format,
2281 DWORD VertexCount, LPVOID data)
2283 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2285 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2287 return E_NOTIMPL;
2290 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2291 DWORD IndexFirst, DWORD count,
2292 LPD3DVECTOR vector)
2294 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2296 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2298 return E_NOTIMPL;
2301 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2302 DWORD IndexFirst, LPDWORD vcount,
2303 LPD3DVECTOR vertices)
2305 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2306 DWORD count = This->nb_vertices - IndexFirst;
2308 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2310 if (vcount)
2311 *vcount = count;
2312 if (vertices && This->nb_vertices)
2313 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2315 return D3DRM_OK;
2318 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2319 DWORD IndexFirst, DWORD count,
2320 LPD3DVECTOR vector)
2322 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2324 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2326 return E_NOTIMPL;
2329 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2330 DWORD IndexFirst, LPDWORD count,
2331 LPD3DVECTOR vector)
2333 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2335 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2337 return E_NOTIMPL;
2340 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2342 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2344 FIXME("(%p)->(): stub\n", This);
2346 return E_NOTIMPL;
2349 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2351 /*** IUnknown methods ***/
2352 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2353 IDirect3DRMMeshBuilder3Impl_AddRef,
2354 IDirect3DRMMeshBuilder3Impl_Release,
2355 /*** IDirect3DRMObject methods ***/
2356 IDirect3DRMMeshBuilder3Impl_Clone,
2357 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2358 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2359 IDirect3DRMMeshBuilder3Impl_SetAppData,
2360 IDirect3DRMMeshBuilder3Impl_GetAppData,
2361 IDirect3DRMMeshBuilder3Impl_SetName,
2362 IDirect3DRMMeshBuilder3Impl_GetName,
2363 IDirect3DRMMeshBuilder3Impl_GetClassName,
2364 /*** IDirect3DRMMeshBuilder3 methods ***/
2365 IDirect3DRMMeshBuilder3Impl_Load,
2366 IDirect3DRMMeshBuilder3Impl_Save,
2367 IDirect3DRMMeshBuilder3Impl_Scale,
2368 IDirect3DRMMeshBuilder3Impl_Translate,
2369 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2370 IDirect3DRMMeshBuilder3Impl_GetBox,
2371 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2372 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2373 IDirect3DRMMeshBuilder3Impl_AddMesh,
2374 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2375 IDirect3DRMMeshBuilder3Impl_AddFrame,
2376 IDirect3DRMMeshBuilder3Impl_AddFace,
2377 IDirect3DRMMeshBuilder3Impl_AddFaces,
2378 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2379 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2380 IDirect3DRMMeshBuilder3Impl_SetColor,
2381 IDirect3DRMMeshBuilder3Impl_SetTexture,
2382 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2383 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2384 IDirect3DRMMeshBuilder3Impl_SetQuality,
2385 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2386 IDirect3DRMMeshBuilder3Impl_SetVertex,
2387 IDirect3DRMMeshBuilder3Impl_SetNormal,
2388 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2389 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2390 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2391 IDirect3DRMMeshBuilder3Impl_GetFaces,
2392 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2393 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2394 IDirect3DRMMeshBuilder3Impl_AddVertex,
2395 IDirect3DRMMeshBuilder3Impl_AddNormal,
2396 IDirect3DRMMeshBuilder3Impl_CreateFace,
2397 IDirect3DRMMeshBuilder3Impl_GetQuality,
2398 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2399 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2400 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2401 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2402 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2403 IDirect3DRMMeshBuilder3Impl_GetFace,
2404 IDirect3DRMMeshBuilder3Impl_GetVertex,
2405 IDirect3DRMMeshBuilder3Impl_GetNormal,
2406 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2407 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2408 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2409 IDirect3DRMMeshBuilder3Impl_Empty,
2410 IDirect3DRMMeshBuilder3Impl_Optimize,
2411 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2412 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2413 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2414 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2415 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2416 IDirect3DRMMeshBuilder3Impl_Enable,
2417 IDirect3DRMMeshBuilder3Impl_GetEnable,
2418 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2419 IDirect3DRMMeshBuilder3Impl_SetVertices,
2420 IDirect3DRMMeshBuilder3Impl_GetVertices,
2421 IDirect3DRMMeshBuilder3Impl_SetNormals,
2422 IDirect3DRMMeshBuilder3Impl_GetNormals,
2423 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2426 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2428 IDirect3DRMMeshBuilderImpl* object;
2430 TRACE("(%p)\n", ppObj);
2432 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2433 if (!object)
2435 ERR("Out of memory\n");
2436 return E_OUTOFMEMORY;
2439 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2440 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2441 object->ref = 1;
2443 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2444 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2445 else
2446 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2448 return S_OK;
2451 /*** IUnknown methods ***/
2452 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2453 REFIID riid, void** ppvObject)
2455 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2457 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2459 *ppvObject = NULL;
2461 if (IsEqualGUID(riid, &IID_IUnknown) ||
2462 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2464 *ppvObject = &This->IDirect3DRMMesh_iface;
2466 else
2468 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2469 return E_NOINTERFACE;
2472 IDirect3DRMMesh_AddRef(iface);
2473 return S_OK;
2476 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2478 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2479 ULONG ref = InterlockedIncrement(&This->ref);
2481 TRACE("(%p)->(): new ref = %d\n", This, ref);
2483 return ref;
2486 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2488 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2489 ULONG ref = InterlockedDecrement(&This->ref);
2491 TRACE("(%p)->(): new ref = %d\n", This, ref);
2493 if (!ref)
2495 int i;
2497 for (i = 0; i < This->nb_groups; i++)
2499 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2500 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2501 if (This->groups[i].material)
2502 IDirect3DRMMaterial2_Release(This->groups[i].material);
2503 if (This->groups[i].texture)
2504 IDirect3DRMTexture3_Release(This->groups[i].texture);
2506 HeapFree(GetProcessHeap(), 0, This->groups);
2507 HeapFree(GetProcessHeap(), 0, This);
2510 return ref;
2513 /*** IDirect3DRMObject methods ***/
2514 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2515 LPUNKNOWN pUnkOuter, REFIID riid,
2516 LPVOID *ppvObj)
2518 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2520 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2522 return E_NOTIMPL;
2525 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2526 D3DRMOBJECTCALLBACK cb,
2527 LPVOID argument)
2529 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2531 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2533 return E_NOTIMPL;
2536 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2537 D3DRMOBJECTCALLBACK cb,
2538 LPVOID argument)
2540 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2542 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2544 return E_NOTIMPL;
2547 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2548 DWORD data)
2550 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2552 FIXME("(%p)->(%u): stub\n", This, data);
2554 return E_NOTIMPL;
2557 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2559 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2561 FIXME("(%p)->(): stub\n", This);
2563 return 0;
2566 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2567 LPCSTR pName)
2569 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2571 FIXME("(%p)->(%s): stub\n", This, pName);
2573 return E_NOTIMPL;
2576 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2577 LPDWORD lpdwSize, LPSTR lpName)
2579 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2581 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2583 return E_NOTIMPL;
2586 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2587 LPDWORD size, LPSTR name)
2589 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2591 TRACE("(%p)->(%p, %p)\n", This, size, name);
2593 if (!size || *size < strlen("Mesh") || !name)
2594 return E_INVALIDARG;
2596 strcpy(name, "Mesh");
2597 *size = sizeof("Mesh");
2599 return D3DRM_OK;
2602 /*** IDirect3DRMMesh methods ***/
2603 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2604 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2606 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2608 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2610 return E_NOTIMPL;
2613 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2614 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2616 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2618 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2620 return E_NOTIMPL;
2623 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2624 D3DRMBOX * box)
2626 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2628 FIXME("(%p)->(%p): stub\n", This, box);
2630 return E_NOTIMPL;
2633 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2634 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2635 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2637 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2638 mesh_group* group;
2640 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2642 if (!face_data || !return_id)
2643 return E_POINTER;
2645 if ((This->nb_groups + 1) > This->groups_capacity)
2647 ULONG new_capacity;
2648 mesh_group* groups;
2650 if (!This->groups_capacity)
2652 new_capacity = 16;
2653 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2655 else
2657 new_capacity = This->groups_capacity * 2;
2658 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2661 if (!groups)
2662 return E_OUTOFMEMORY;
2664 This->groups_capacity = new_capacity;
2665 This->groups = groups;
2668 group = This->groups + This->nb_groups;
2670 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2671 if (!group->vertices)
2672 return E_OUTOFMEMORY;
2673 group->nb_vertices = vertex_count;
2674 group->nb_faces = face_count;
2675 group->vertex_per_face = vertex_per_face;
2677 if (vertex_per_face)
2679 group->face_data_size = face_count * vertex_per_face;
2681 else
2683 int i;
2684 unsigned nb_indices;
2685 unsigned* face_data_ptr = face_data;
2686 group->face_data_size = 0;
2688 for (i = 0; i < face_count; i++)
2690 nb_indices = *face_data_ptr;
2691 group->face_data_size += nb_indices + 1;
2692 face_data_ptr += nb_indices;
2696 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2697 if (!group->face_data)
2699 HeapFree(GetProcessHeap(), 0 , group->vertices);
2700 return E_OUTOFMEMORY;
2703 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2705 group->material = NULL;
2706 group->texture = NULL;
2708 *return_id = This->nb_groups++;
2710 return D3DRM_OK;
2713 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2714 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2715 D3DRMVERTEX *values)
2717 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2719 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2721 if (id >= This->nb_groups)
2722 return D3DRMERR_BADVALUE;
2724 if ((index + count - 1) >= This->groups[id].nb_vertices)
2725 return D3DRMERR_BADVALUE;
2727 if (!values)
2728 return E_POINTER;
2730 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2732 return D3DRM_OK;
2735 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2736 D3DRMGROUPINDEX id, D3DCOLOR color)
2738 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2740 TRACE("(%p)->(%u,%x)\n", This, id, color);
2742 if (id >= This->nb_groups)
2743 return D3DRMERR_BADVALUE;
2745 This->groups[id].color = color;
2747 return D3DRM_OK;
2750 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2751 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2753 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2755 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2757 if (id >= This->nb_groups)
2758 return D3DRMERR_BADVALUE;
2760 This->groups[id].color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
2761 (BYTE)(green * 255.0f),
2762 (BYTE)(blue * 255.0f));
2764 return D3DRM_OK;
2767 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2768 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2770 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2772 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2774 return E_NOTIMPL;
2777 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2778 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2780 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2782 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2784 return E_NOTIMPL;
2787 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2788 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2790 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2792 TRACE("(%p)->(%u,%p)\n", This, id, material);
2794 if (id >= This->nb_groups)
2795 return D3DRMERR_BADVALUE;
2797 if (This->groups[id].material)
2798 IDirect3DRMMaterial2_Release(This->groups[id].material);
2800 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2802 if (material)
2803 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2805 return D3DRM_OK;
2808 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2809 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2811 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2813 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2815 if (id >= This->nb_groups)
2816 return D3DRMERR_BADVALUE;
2818 if (This->groups[id].texture)
2819 IDirect3DRMTexture3_Release(This->groups[id].texture);
2821 if (!texture)
2823 This->groups[id].texture = NULL;
2824 return D3DRM_OK;
2827 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2830 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2832 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2834 TRACE("(%p)->()\n", This);
2836 return This->nb_groups;
2839 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2840 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2841 DWORD *face_data_size, unsigned *face_data)
2843 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2845 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2847 if (id >= This->nb_groups)
2848 return D3DRMERR_BADVALUE;
2850 if (vertex_count)
2851 *vertex_count = This->groups[id].nb_vertices;
2852 if (face_count)
2853 *face_count = This->groups[id].nb_faces;
2854 if (vertex_per_face)
2855 *vertex_per_face = This->groups[id].vertex_per_face;
2856 if (face_data_size)
2857 *face_data_size = This->groups[id].face_data_size;
2858 if (face_data)
2859 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2861 return D3DRM_OK;
2864 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2865 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2867 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2869 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2871 if (id >= This->nb_groups)
2872 return D3DRMERR_BADVALUE;
2874 if ((index + count - 1) >= This->groups[id].nb_vertices)
2875 return D3DRMERR_BADVALUE;
2877 if (!return_ptr)
2878 return E_POINTER;
2880 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2882 return D3DRM_OK;
2885 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2887 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2889 TRACE("(%p)->(%u)\n", This, id);
2891 return This->groups[id].color;
2894 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2896 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2898 FIXME("(%p)->(%u): stub\n", This, id);
2900 return 0;
2902 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2904 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2906 FIXME("(%p)->(%u): stub\n", This, id);
2908 return 0;
2911 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2912 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2914 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2916 TRACE("(%p)->(%u,%p)\n", This, id, material);
2918 if (id >= This->nb_groups)
2919 return D3DRMERR_BADVALUE;
2921 if (!material)
2922 return E_POINTER;
2924 if (This->groups[id].material)
2925 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2926 else
2927 *material = NULL;
2929 return D3DRM_OK;
2932 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2933 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2935 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2937 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2939 if (id >= This->nb_groups)
2940 return D3DRMERR_BADVALUE;
2942 if (!texture)
2943 return E_POINTER;
2945 if (This->groups[id].texture)
2946 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2947 else
2948 *texture = NULL;
2950 return D3DRM_OK;
2953 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2955 /*** IUnknown methods ***/
2956 IDirect3DRMMeshImpl_QueryInterface,
2957 IDirect3DRMMeshImpl_AddRef,
2958 IDirect3DRMMeshImpl_Release,
2959 /*** IDirect3DRMObject methods ***/
2960 IDirect3DRMMeshImpl_Clone,
2961 IDirect3DRMMeshImpl_AddDestroyCallback,
2962 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2963 IDirect3DRMMeshImpl_SetAppData,
2964 IDirect3DRMMeshImpl_GetAppData,
2965 IDirect3DRMMeshImpl_SetName,
2966 IDirect3DRMMeshImpl_GetName,
2967 IDirect3DRMMeshImpl_GetClassName,
2968 /*** IDirect3DRMMesh methods ***/
2969 IDirect3DRMMeshImpl_Scale,
2970 IDirect3DRMMeshImpl_Translate,
2971 IDirect3DRMMeshImpl_GetBox,
2972 IDirect3DRMMeshImpl_AddGroup,
2973 IDirect3DRMMeshImpl_SetVertices,
2974 IDirect3DRMMeshImpl_SetGroupColor,
2975 IDirect3DRMMeshImpl_SetGroupColorRGB,
2976 IDirect3DRMMeshImpl_SetGroupMapping,
2977 IDirect3DRMMeshImpl_SetGroupQuality,
2978 IDirect3DRMMeshImpl_SetGroupMaterial,
2979 IDirect3DRMMeshImpl_SetGroupTexture,
2980 IDirect3DRMMeshImpl_GetGroupCount,
2981 IDirect3DRMMeshImpl_GetGroup,
2982 IDirect3DRMMeshImpl_GetVertices,
2983 IDirect3DRMMeshImpl_GetGroupColor,
2984 IDirect3DRMMeshImpl_GetGroupMapping,
2985 IDirect3DRMMeshImpl_GetGroupQuality,
2986 IDirect3DRMMeshImpl_GetGroupMaterial,
2987 IDirect3DRMMeshImpl_GetGroupTexture
2990 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2992 IDirect3DRMMeshImpl* object;
2994 TRACE("(%p)\n", obj);
2996 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2997 if (!object)
2999 ERR("Out of memory\n");
3000 return E_OUTOFMEMORY;
3003 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
3004 object->ref = 1;
3006 *obj = &object->IDirect3DRMMesh_iface;
3008 return S_OK;