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
26 #include "wine/debug.h"
33 #include "d3drm_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
39 D3DRMVERTEX* vertices;
41 unsigned vertex_per_face;
45 IDirect3DRMMaterial2* material;
46 IDirect3DRMTexture3* texture;
50 IDirect3DRMMesh IDirect3DRMMesh_iface;
52 DWORD groups_capacity;
55 } IDirect3DRMMeshImpl;
63 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
64 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
77 IDirect3DRMMaterial2* material;
78 IDirect3DRMTexture3* texture;
79 } IDirect3DRMMeshBuilderImpl;
85 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
92 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
99 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
105 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
106 "array FLOAT matrix[16];"
110 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
118 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
123 "template IndexedColor"
125 "<1630B820-7842-11CF-8F52-0040333594A3>"
127 "ColorRGBA indexColor;"
131 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
136 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
140 "template MaterialWrap"
142 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
146 "template TextureFilename"
148 "<A42790E1-7810-11CF-8F52-0040333594A3>"
153 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
154 "ColorRGBA faceColor;"
156 "ColorRGB specularColor;"
157 "ColorRGB emissiveColor;"
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>"
182 "DWORD nFaceIndexes;"
183 "array DWORD faceIndexes[nFaceIndexes];"
186 "template MeshNormals"
188 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
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];"
202 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
204 "array Vector vertices[nVertices];"
206 "array MeshFace faces[nFaces];"
209 "template FrameTransformMatrix"
211 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
212 "Matrix4x4 frameMatrix;"
216 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
221 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
223 "array FLOAT values[nValues];"
225 "template TimedFloatKeys"
227 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
231 "template AnimationKey"
233 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
236 "array TimedFloatKeys keys[nKeys];"
238 "template AnimationOptions"
240 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
242 "DWORD positionquality;"
246 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
249 "template AnimationSet"
251 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
254 "template InlineData"
256 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
261 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
263 "array STRING urls[nUrls];"
265 "template ProgressiveMesh"
267 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
272 "<A42790E0-7810-11CF-8F52-0040333594A3>"
276 "array UCHAR data4[8];"
278 "template StringProperty"
280 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
284 "template PropertyBag"
286 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
289 "template ExternalVisual"
291 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
292 "Guid guidExternalVisual;"
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);
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;
339 FIXME("interface %s not implemented\n", debugstr_guid(riid));
340 return E_NOINTERFACE;
343 IDirect3DRMMeshBuilder_AddRef(iface);
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);
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);
367 IDirect3DRMMaterial2_Release(This->material);
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);
381 /*** IDirect3DRMObject methods ***/
382 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2* iface,
383 LPUNKNOWN pUnkOuter, REFIID riid,
386 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
388 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
393 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2* iface,
394 D3DRMOBJECTCALLBACK cb,
397 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
399 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
404 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2* iface,
405 D3DRMOBJECTCALLBACK cb,
408 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
410 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
415 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
418 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
420 FIXME("(%p)->(%u): stub\n", This, data);
425 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
427 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
429 FIXME("(%p)->(): stub\n", This);
434 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2* iface,
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);
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);
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);
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);
522 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
525 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
527 FIXME("(%p)->(%p): stub\n", This, pBox);
532 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
534 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
536 FIXME("(%p)->(): stub\n", This);
541 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
543 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
545 FIXME("(%p)->(): stub\n", This);
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);
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);
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);
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);
590 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2* iface,
591 DWORD vcount, D3DVECTOR *vertices,
592 DWORD ncount, D3DVECTOR *normals,
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);
603 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
608 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
610 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
615 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
616 D3DVALUE red, D3DVALUE green,
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,
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;
644 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
646 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
648 IDirect3DRMTexture3_Release(texture3);
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);
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);
683 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
686 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
688 FIXME("(%p)->(%d): stub\n", This, enable);
693 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
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);
704 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
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);
715 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
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,
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);
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);
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);
758 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
759 DWORD *vcount, D3DVECTOR *vertices,
760 DWORD *ncount, D3DVECTOR *normals,
761 DWORD *face_data_size,
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);
769 *vcount = This->nb_vertices;
770 if (vertices && This->nb_vertices)
771 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
773 *ncount = This->nb_normals;
774 if (normals && This->nb_normals)
775 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
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));
784 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
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,
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);
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);
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);
826 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
828 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
830 FIXME("(%p)->(): stub\n", This);
835 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
837 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
839 FIXME("(%p)->(): stub\n", This);
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,
865 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
867 FIXME("(%p)->(%d): stub\n", This, index);
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);
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);
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,
987 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
989 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
994 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
995 D3DRMOBJECTCALLBACK cb,
998 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1000 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1005 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1006 D3DRMOBJECTCALLBACK cb,
1009 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1011 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1016 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1019 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1021 FIXME("(%p)->(%u): stub\n", This, data);
1026 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1028 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1030 FIXME("(%p)->(): stub\n", This);
1035 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1038 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1039 char *string = NULL;
1041 TRACE("(%p)->(%s)\n", This, debugstr_a(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;
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);
1071 if (*size < (strlen(This->name) + 1))
1072 return E_INVALIDARG;
1074 strcpy(name, This->name);
1075 *size = strlen(This->name) + 1;
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");
1096 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
1098 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1099 LPDIRECTXFILEOBJECT pObject = NULL;
1100 LPDIRECTXFILEDATA pData2 = NULL;
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;
1115 TRACE("(%p)->(%p)\n", This, pData);
1117 /* Remove previous name */
1118 HeapFree(GetProcessHeap(), 0, This->name);
1120 hr = IDirectXFileData_GetName(pData, NULL, &size);
1121 if (hr != DXFILE_OK)
1125 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1127 return E_OUTOFMEMORY;
1129 hr = IDirectXFileData_GetName(pData, This->name, &size);
1130 if (hr != DXFILE_OK)
1132 HeapFree(GetProcessHeap(), 0, This->name);
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)
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;
1165 hr = IDirectXFileData_GetNextObject(pData, &pObject);
1166 if (hr == DXFILEERR_NOMOREOBJECTS)
1168 TRACE("No more object\n");
1171 if (hr != DXFILE_OK)
1174 hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
1175 IDirectXFileObject_Release(pObject);
1176 if (hr != DXFILE_OK)
1179 hr = IDirectXFileData_GetType(pData2, &pGuid);
1180 if (hr != DXFILE_OK)
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)
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)
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))
1225 DWORD nb_face_indices;
1227 LPDIRECTXFILEOBJECT child;
1231 TRACE("Process MeshMaterialList\n");
1233 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1234 if (hr != DXFILE_OK)
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 > 1)
1247 FIXME("Only one material per mesh supported, first one applies to all faces\n");
1249 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1251 LPDIRECTXFILEDATA data;
1252 LPDIRECTXFILEDATAREFERENCE reference;
1253 LPDIRECT3DRMMATERIAL2 material;
1254 LPDIRECTXFILEOBJECT material_child;
1258 /* FIXME: Only handle first material but enum all of them */
1259 IDirectXFileObject_Release(child);
1264 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1267 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1268 IDirectXFileObject_Release(child);
1272 hr = IDirectXFileDataReference_Resolve(reference, &data);
1273 IDirectXFileDataReference_Release(reference);
1279 IDirectXFileObject_Release(child);
1282 hr = Direct3DRMMaterial_create(&material);
1285 IDirectXFileData_Release(data);
1289 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1290 if (hr != DXFILE_OK)
1292 IDirectXFileData_Release(data);
1297 WARN("Material size %u does not match expected one %u\n", size, 44);
1299 values = (float*)ptr;
1301 IDirect3DRMMeshBuilder3_SetColorRGB(iface, values[0], values [1], values[2]); /* Alpha ignored */
1303 IDirect3DRMMaterial2_SetAmbient(material, values[0], values [1], values[2]); /* Alpha ignored */
1304 IDirect3DRMMaterial2_SetPower(material, values[4]);
1305 IDirect3DRMMaterial2_SetSpecular(material, values[5], values[6], values[7]);
1306 IDirect3DRMMaterial2_SetEmissive(material, values[8], values[9], values[10]);
1308 This->material = material;
1310 hr = IDirectXFileData_GetNextObject(data, &material_child);
1313 LPDIRECTXFILEDATA data;
1314 LPDIRECT3DRMTEXTURE3 texture;
1317 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1320 LPDIRECTXFILEDATAREFERENCE reference;
1322 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1326 hr = IDirectXFileDataReference_Resolve(reference, &data);
1327 IDirectXFileDataReference_Release(reference);
1332 hr = IDirectXFileData_GetType(data, &pGuid);
1333 if (hr != DXFILE_OK)
1335 if (!IsEqualGUID(pGuid, &TID_D3DRMTextureFilename))
1337 WARN("Not a texture filename\n");
1342 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1347 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1348 if (file != INVALID_HANDLE_VALUE)
1350 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&texture);
1353 IDirectXFileData_Release(data);
1356 This->texture = texture;
1360 else if (hr != DXFILEERR_NOMOREOBJECTS)
1366 IDirectXFileData_Release(data);
1371 IDirectXFileObject_Release(child);
1372 WARN("Found more sub-objects than expected\n");
1374 else if (hr != DXFILEERR_NOMOREOBJECTS)
1382 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
1385 IDirectXFileData_Release(pData2);
1389 if (!This->nb_normals)
1391 /* Allocate normals, one per vertex */
1392 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1393 if (!This->pNormals)
1397 for (i = 0; i < This->nb_faces; i++)
1400 DWORD nb_face_indexes;
1401 D3DVECTOR face_normal;
1403 if (faces_vertex_idx_size < sizeof(DWORD))
1404 WARN("Not enough data to read number of indices of face %d\n", i);
1406 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1407 faces_vertex_idx_size--;
1408 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1409 WARN("Faces indices number mismatch\n");
1411 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1412 WARN("Not enough data to read all indices of face %d\n", i);
1414 if (!This->nb_normals)
1416 /* Compute face normal */
1417 if (nb_face_indexes > 2)
1421 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1422 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[1]], &This->pVertices[faces_vertex_idx_ptr[0]]);
1423 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1424 D3DRMVectorNormalize(&face_normal);
1428 face_normal.u1.x = 0.0f;
1429 face_normal.u2.y = 0.0f;
1430 face_normal.u3.z = 0.0f;
1434 for (j = 0; j < nb_face_indexes; j++)
1436 /* Copy vertex index */
1437 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1438 /* Copy normal index */
1439 if (This->nb_normals)
1441 /* Read from x file */
1442 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1446 DWORD vertex_idx = *faces_vertex_idx_ptr;
1447 if (vertex_idx >= This->nb_vertices)
1449 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1452 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1453 /* Add face normal to vertex normal */
1454 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1456 faces_vertex_idx_ptr++;
1458 faces_vertex_idx_size -= nb_face_indexes;
1461 /* Last DWORD must be 0 */
1462 *(faces_data_ptr + faces_data_size++) = 0;
1464 /* Set size (in number of DWORD) of all faces data */
1465 This->face_data_size = faces_data_size;
1467 if (!This->nb_normals)
1469 /* Normalize all normals */
1470 for (i = 0; i < This->nb_vertices; i++)
1472 D3DRMVectorNormalize(&This->pNormals[i]);
1474 This->nb_normals = This->nb_vertices;
1477 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1478 if (!This->pCoords2d)
1480 This->nb_coords2d = This->nb_vertices;
1481 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1482 for (i = 0; i < This->nb_coords2d; i++)
1484 This->pCoords2d[i].u = 0.0f;
1485 This->pCoords2d[i].v = 0.0f;
1489 TRACE("Mesh data loaded successfully\n");
1495 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1496 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1501 /*** IDirect3DRMMeshBuilder3 methods ***/
1502 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1503 LPVOID filename, LPVOID name,
1504 D3DRMLOADOPTIONS loadflags,
1505 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1507 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1508 DXFILELOADOPTIONS load_options;
1509 LPDIRECTXFILE pDXFile = NULL;
1510 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1511 LPDIRECTXFILEDATA pData = NULL;
1512 LPDIRECTXFILEDATA pData2 = NULL;
1517 HRESULT ret = D3DRMERR_BADOBJECT;
1519 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1521 /* First free allocated buffers of previous mesh data */
1522 HeapFree(GetProcessHeap(), 0, This->pVertices);
1523 This->pVertices = NULL;
1524 HeapFree(GetProcessHeap(), 0, This->pNormals);
1525 This->pNormals = NULL;
1526 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1527 This->pFaceData = NULL;
1528 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1529 This->pCoords2d = NULL;
1531 if (loadflags == D3DRMLOAD_FROMMEMORY)
1533 load_options = DXFILELOAD_FROMMEMORY;
1535 else if (loadflags == D3DRMLOAD_FROMFILE)
1537 load_options = DXFILELOAD_FROMFILE;
1538 TRACE("Loading from file %s\n", debugstr_a(filename));
1542 FIXME("Load options %d not supported yet\n", loadflags);
1546 hr = DirectXFileCreate(&pDXFile);
1547 if (hr != DXFILE_OK)
1550 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1551 if (hr != DXFILE_OK)
1554 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1555 if (hr != DXFILE_OK)
1558 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1559 if (hr != DXFILE_OK)
1562 hr = IDirectXFileData_GetType(pData, &pGuid);
1563 if (hr != DXFILE_OK)
1566 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1568 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1570 ret = D3DRMERR_BADFILE;
1574 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1575 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1578 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1580 /* Version must be 1.0.x */
1581 if ((pHeader->major != 1) || (pHeader->minor != 0))
1583 ret = D3DRMERR_BADFILE;
1587 IDirectXFileData_Release(pData);
1590 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1591 if (hr != DXFILE_OK)
1593 ret = D3DRMERR_NOTFOUND;
1597 hr = IDirectXFileData_GetType(pData, &pGuid);
1598 if (hr != DXFILE_OK)
1601 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1603 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1605 ret = D3DRMERR_NOTFOUND;
1609 hr = load_mesh_data(iface, pData);
1616 IDirectXFileData_Release(pData2);
1618 IDirectXFileData_Release(pData);
1620 IDirectXFileEnumObject_Release(pEnumObject);
1622 IDirectXFile_Release(pDXFile);
1624 if (ret != D3DRM_OK)
1626 /* Clean mesh data */
1627 This->nb_vertices = 0;
1628 This->nb_normals = 0;
1630 This->face_data_size = 0;
1631 This->nb_coords2d = 0;
1632 HeapFree(GetProcessHeap(), 0, This->pVertices);
1633 This->pVertices = NULL;
1634 HeapFree(GetProcessHeap(), 0, This->pNormals);
1635 This->pNormals = NULL;
1636 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1637 This->pFaceData = NULL;
1638 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1639 This->pCoords2d = NULL;
1645 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1646 const char* filename, D3DRMXOFFORMAT format,
1647 D3DRMSAVEOPTIONS save)
1649 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1651 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1656 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1657 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1659 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1662 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1664 for (i = 0; i < This->nb_vertices; i++)
1666 This->pVertices[i].u1.x *= sx;
1667 This->pVertices[i].u2.y *= sy;
1668 This->pVertices[i].u3.z *= sz;
1671 /* Normals are not affected by Scale */
1676 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1677 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1679 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1681 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1686 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1687 D3DRMCOLORSOURCE color)
1689 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1691 FIXME("(%p)->(%x): stub\n", This, color);
1696 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1699 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1701 FIXME("(%p)->(%p): stub\n", This, box);
1706 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1707 D3DVALUE crease, DWORD flags)
1709 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1711 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1716 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1718 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1720 FIXME("(%p)->(): stub\n", This);
1725 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1726 LPDIRECT3DRMMESH Mesh)
1728 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1730 FIXME("(%p)->(%p): stub\n", This, Mesh);
1735 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1736 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1739 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1741 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1746 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1747 LPDIRECT3DRMFRAME3 Frame)
1749 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1751 FIXME("(%p)->(%p): stub\n", This, Frame);
1756 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1757 LPDIRECT3DRMFACE2 Face)
1759 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1761 FIXME("(%p)->(%p): stub\n", This, Face);
1766 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1767 DWORD vcount, D3DVECTOR* vertices,
1768 DWORD ncount, D3DVECTOR* normals,
1770 LPDIRECT3DRMFACEARRAY* FaceArray)
1772 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1774 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1775 normals, data, FaceArray);
1780 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1785 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1787 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1792 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1793 D3DVALUE red, D3DVALUE green,
1796 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1798 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1800 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1801 (BYTE)(green * 255.0f),
1802 (BYTE)(blue * 255.0f));
1807 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1810 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1812 TRACE("(%p)->(%x)\n", This, color);
1814 This->color = color;
1819 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1820 LPDIRECT3DRMTEXTURE3 texture)
1822 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1824 TRACE("(%p)->(%p)\n", This, texture);
1827 IDirect3DRMTexture3_AddRef(texture);
1829 IDirect3DRMTexture3_Release(This->texture);
1830 This->texture = texture;
1835 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1836 LPDIRECT3DRMMATERIAL2 material)
1838 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1840 TRACE("(%p)->(%p)\n", This, material);
1843 IDirect3DRMTexture2_AddRef(material);
1845 IDirect3DRMTexture2_Release(This->material);
1846 This->material = material;
1851 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1852 BOOL wrap_u, BOOL wrap_v)
1854 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1856 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1861 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1862 D3DRMRENDERQUALITY quality)
1864 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1866 FIXME("(%p)->(%d): stub\n", This, quality);
1871 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1874 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1876 FIXME("(%p)->(%d): stub\n", This, enable);
1881 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1883 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1885 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1887 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1892 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1894 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1896 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1898 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1903 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1904 DWORD index, D3DVALUE u,
1907 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1909 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1911 if (index >= This->nb_coords2d)
1912 return D3DRMERR_BADVALUE;
1914 This->pCoords2d[index].u = u;
1915 This->pCoords2d[index].v = v;
1920 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1921 DWORD index, D3DCOLOR color)
1923 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1925 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1930 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1932 D3DVALUE red, D3DVALUE green,
1935 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1937 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1942 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1943 LPDIRECT3DRMFACEARRAY* FaceArray)
1945 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1947 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1952 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1953 DWORD* vcount, D3DVECTOR* vertices,
1954 DWORD* ncount, D3DVECTOR* normals,
1955 DWORD* face_data_size,
1958 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1960 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1961 face_data_size, face_data);
1966 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1967 DWORD index, D3DVALUE* u,
1970 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1972 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1974 if (index >= This->nb_coords2d)
1975 return D3DRMERR_BADVALUE;
1977 *u = This->pCoords2d[index].u;
1978 *v = This->pCoords2d[index].v;
1984 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1985 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1987 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1989 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1994 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1995 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1997 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1999 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
2004 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
2005 LPDIRECT3DRMFACE2* Face)
2007 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2009 FIXME("(%p)->(%p): stub\n", This, Face);
2014 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
2016 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2018 FIXME("(%p)->(): stub\n", This);
2023 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2025 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2027 FIXME("(%p)->(): stub\n", This);
2032 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2034 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2036 TRACE("(%p)->()\n", This);
2038 return This->nb_faces;
2041 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2043 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2045 TRACE("(%p)->()\n", This);
2047 return This->nb_vertices;
2050 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2053 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2055 FIXME("(%p)->(%d): stub\n", This, index);
2060 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
2061 LPDIRECT3DRMMESH* mesh)
2063 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2065 D3DRMGROUPINDEX group;
2067 TRACE("(%p)->(%p)\n", This, mesh);
2072 hr = Direct3DRMMesh_create(mesh);
2076 /* If there is mesh data, create a group and put data inside */
2077 if (This->nb_vertices)
2079 unsigned* face_data;
2081 DWORD* in_ptr = This->pFaceData;
2084 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2087 IDirect3DRMMesh_Release(*mesh);
2088 return E_OUTOFMEMORY;
2090 out_ptr = face_data;
2092 /* Put only vertex indices */
2093 for (i = 0; i < This->nb_faces; i++)
2095 DWORD nb_indices = *out_ptr++ = *in_ptr++;
2096 for (j = 0; j < nb_indices; j++)
2098 *out_ptr++ = *in_ptr++;
2099 /* Skip normal index */
2104 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
2105 HeapFree(GetProcessHeap(), 0, face_data);
2108 D3DRMVERTEX* vertices;
2110 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2113 for (i = 0; i < This->nb_vertices; i++)
2115 vertices[i].position = This->pVertices[i];
2117 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2118 HeapFree(GetProcessHeap(), 0, vertices);
2126 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2128 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2129 if (SUCCEEDED(hr) && This->texture)
2131 LPDIRECT3DRMTEXTURE texture;
2133 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2134 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2135 IDirect3DRMTexture_Release(texture);
2138 IDirect3DRMMesh_Release(*mesh);
2144 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2145 DWORD index, LPDIRECT3DRMFACE2* Face)
2147 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2149 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2154 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2155 DWORD index, LPD3DVECTOR vector)
2157 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2159 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2164 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2165 DWORD index, LPD3DVECTOR vector)
2167 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2169 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2174 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2175 DWORD IndexFirst, DWORD count)
2177 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2179 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2184 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2185 DWORD IndexFirst, DWORD count)
2187 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2189 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2194 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2195 LPDIRECT3DRMFACE2 Face)
2197 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2199 FIXME("(%p)->(%p): stub\n", This, Face);
2204 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2206 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2208 FIXME("(%p)->(%u): stub\n", This, flags);
2213 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2216 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2218 FIXME("(%p)->(%u): stub\n", This, flags);
2223 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2224 DWORD flags, DWORD* indices,
2225 DWORD* IndexFirst, DWORD* count)
2227 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2229 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2234 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2237 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2239 FIXME("(%p)->(%p): stub\n", This, unkwn);
2244 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2245 DWORD flags, LPUNKNOWN *unkwn)
2247 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2249 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2254 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2255 LPDWORD count, LPUNKNOWN *unkwn)
2257 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2259 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2264 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2267 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2269 FIXME("(%p)->(%p): stub\n", This, unkwn);
2274 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2277 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2279 FIXME("(%p)->(%u): stub\n", This, index);
2284 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2287 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2289 FIXME("(%p)->(%p): stub\n", This, indices);
2294 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2295 DWORD flags, DWORD format,
2296 DWORD VertexCount, LPVOID data)
2298 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2300 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2305 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2306 DWORD IndexFirst, DWORD count,
2309 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2311 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2316 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2317 DWORD IndexFirst, LPDWORD vcount,
2318 LPD3DVECTOR vertices)
2320 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2321 DWORD count = This->nb_vertices - IndexFirst;
2323 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2327 if (vertices && This->nb_vertices)
2328 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2333 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2334 DWORD IndexFirst, DWORD count,
2337 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2339 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2344 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2345 DWORD IndexFirst, LPDWORD count,
2348 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2350 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2355 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2357 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2359 FIXME("(%p)->(): stub\n", This);
2364 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2366 /*** IUnknown methods ***/
2367 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2368 IDirect3DRMMeshBuilder3Impl_AddRef,
2369 IDirect3DRMMeshBuilder3Impl_Release,
2370 /*** IDirect3DRMObject methods ***/
2371 IDirect3DRMMeshBuilder3Impl_Clone,
2372 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2373 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2374 IDirect3DRMMeshBuilder3Impl_SetAppData,
2375 IDirect3DRMMeshBuilder3Impl_GetAppData,
2376 IDirect3DRMMeshBuilder3Impl_SetName,
2377 IDirect3DRMMeshBuilder3Impl_GetName,
2378 IDirect3DRMMeshBuilder3Impl_GetClassName,
2379 /*** IDirect3DRMMeshBuilder3 methods ***/
2380 IDirect3DRMMeshBuilder3Impl_Load,
2381 IDirect3DRMMeshBuilder3Impl_Save,
2382 IDirect3DRMMeshBuilder3Impl_Scale,
2383 IDirect3DRMMeshBuilder3Impl_Translate,
2384 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2385 IDirect3DRMMeshBuilder3Impl_GetBox,
2386 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2387 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2388 IDirect3DRMMeshBuilder3Impl_AddMesh,
2389 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2390 IDirect3DRMMeshBuilder3Impl_AddFrame,
2391 IDirect3DRMMeshBuilder3Impl_AddFace,
2392 IDirect3DRMMeshBuilder3Impl_AddFaces,
2393 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2394 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2395 IDirect3DRMMeshBuilder3Impl_SetColor,
2396 IDirect3DRMMeshBuilder3Impl_SetTexture,
2397 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2398 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2399 IDirect3DRMMeshBuilder3Impl_SetQuality,
2400 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2401 IDirect3DRMMeshBuilder3Impl_SetVertex,
2402 IDirect3DRMMeshBuilder3Impl_SetNormal,
2403 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2404 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2405 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2406 IDirect3DRMMeshBuilder3Impl_GetFaces,
2407 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2408 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2409 IDirect3DRMMeshBuilder3Impl_AddVertex,
2410 IDirect3DRMMeshBuilder3Impl_AddNormal,
2411 IDirect3DRMMeshBuilder3Impl_CreateFace,
2412 IDirect3DRMMeshBuilder3Impl_GetQuality,
2413 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2414 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2415 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2416 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2417 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2418 IDirect3DRMMeshBuilder3Impl_GetFace,
2419 IDirect3DRMMeshBuilder3Impl_GetVertex,
2420 IDirect3DRMMeshBuilder3Impl_GetNormal,
2421 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2422 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2423 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2424 IDirect3DRMMeshBuilder3Impl_Empty,
2425 IDirect3DRMMeshBuilder3Impl_Optimize,
2426 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2427 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2428 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2429 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2430 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2431 IDirect3DRMMeshBuilder3Impl_Enable,
2432 IDirect3DRMMeshBuilder3Impl_GetEnable,
2433 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2434 IDirect3DRMMeshBuilder3Impl_SetVertices,
2435 IDirect3DRMMeshBuilder3Impl_GetVertices,
2436 IDirect3DRMMeshBuilder3Impl_SetNormals,
2437 IDirect3DRMMeshBuilder3Impl_GetNormals,
2438 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2441 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2443 IDirect3DRMMeshBuilderImpl* object;
2445 TRACE("(%p)\n", ppObj);
2447 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2450 ERR("Out of memory\n");
2451 return E_OUTOFMEMORY;
2454 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2455 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2458 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2459 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2461 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2466 /*** IUnknown methods ***/
2467 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2468 REFIID riid, void** ppvObject)
2470 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2472 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2476 if (IsEqualGUID(riid, &IID_IUnknown) ||
2477 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2479 *ppvObject = &This->IDirect3DRMMesh_iface;
2483 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2484 return E_NOINTERFACE;
2487 IDirect3DRMMesh_AddRef(iface);
2491 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2493 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2494 ULONG ref = InterlockedIncrement(&This->ref);
2496 TRACE("(%p)->(): new ref = %d\n", This, ref);
2501 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2503 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2504 ULONG ref = InterlockedDecrement(&This->ref);
2506 TRACE("(%p)->(): new ref = %d\n", This, ref);
2512 for (i = 0; i < This->nb_groups; i++)
2514 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2515 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2516 if (This->groups[i].material)
2517 IDirect3DRMMaterial2_Release(This->groups[i].material);
2518 if (This->groups[i].texture)
2519 IDirect3DRMTexture3_Release(This->groups[i].texture);
2521 HeapFree(GetProcessHeap(), 0, This->groups);
2522 HeapFree(GetProcessHeap(), 0, This);
2528 /*** IDirect3DRMObject methods ***/
2529 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2530 LPUNKNOWN pUnkOuter, REFIID riid,
2533 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2535 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2540 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2541 D3DRMOBJECTCALLBACK cb,
2544 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2546 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2551 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2552 D3DRMOBJECTCALLBACK cb,
2555 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2557 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2562 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2565 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2567 FIXME("(%p)->(%u): stub\n", This, data);
2572 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2574 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2576 FIXME("(%p)->(): stub\n", This);
2581 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2584 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2586 FIXME("(%p)->(%s): stub\n", This, pName);
2591 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2592 LPDWORD lpdwSize, LPSTR lpName)
2594 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2596 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2601 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2602 LPDWORD size, LPSTR name)
2604 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2606 TRACE("(%p)->(%p, %p)\n", This, size, name);
2608 if (!size || *size < strlen("Mesh") || !name)
2609 return E_INVALIDARG;
2611 strcpy(name, "Mesh");
2612 *size = sizeof("Mesh");
2617 /*** IDirect3DRMMesh methods ***/
2618 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2619 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2621 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2623 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2628 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2629 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2631 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2633 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2638 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2641 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2643 FIXME("(%p)->(%p): stub\n", This, box);
2648 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2649 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2650 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2652 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2655 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2657 if (!face_data || !return_id)
2660 if ((This->nb_groups + 1) > This->groups_capacity)
2665 if (!This->groups_capacity)
2668 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2672 new_capacity = This->groups_capacity * 2;
2673 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2677 return E_OUTOFMEMORY;
2679 This->groups_capacity = new_capacity;
2680 This->groups = groups;
2683 group = This->groups + This->nb_groups;
2685 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2686 if (!group->vertices)
2687 return E_OUTOFMEMORY;
2688 group->nb_vertices = vertex_count;
2689 group->nb_faces = face_count;
2690 group->vertex_per_face = vertex_per_face;
2692 if (vertex_per_face)
2694 group->face_data_size = face_count * vertex_per_face;
2699 unsigned nb_indices;
2700 unsigned* face_data_ptr = face_data;
2701 group->face_data_size = 0;
2703 for (i = 0; i < face_count; i++)
2705 nb_indices = *face_data_ptr;
2706 group->face_data_size += nb_indices + 1;
2707 face_data_ptr += nb_indices;
2711 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2712 if (!group->face_data)
2714 HeapFree(GetProcessHeap(), 0 , group->vertices);
2715 return E_OUTOFMEMORY;
2718 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2720 group->material = NULL;
2721 group->texture = NULL;
2723 *return_id = This->nb_groups++;
2728 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2729 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2730 D3DRMVERTEX *values)
2732 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2734 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2736 if (id >= This->nb_groups)
2737 return D3DRMERR_BADVALUE;
2739 if ((index + count - 1) >= This->groups[id].nb_vertices)
2740 return D3DRMERR_BADVALUE;
2745 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2750 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2751 D3DRMGROUPINDEX id, D3DCOLOR color)
2753 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2755 TRACE("(%p)->(%u,%x)\n", This, id, color);
2757 if (id >= This->nb_groups)
2758 return D3DRMERR_BADVALUE;
2760 This->groups[id].color = color;
2765 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2766 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2768 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2770 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2772 if (id >= This->nb_groups)
2773 return D3DRMERR_BADVALUE;
2775 This->groups[id].color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
2776 (BYTE)(green * 255.0f),
2777 (BYTE)(blue * 255.0f));
2782 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2783 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2785 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2787 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2792 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2793 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2795 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2797 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2802 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2803 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2805 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2807 TRACE("(%p)->(%u,%p)\n", This, id, material);
2809 if (id >= This->nb_groups)
2810 return D3DRMERR_BADVALUE;
2812 if (This->groups[id].material)
2813 IDirect3DRMMaterial2_Release(This->groups[id].material);
2815 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2818 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2823 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2824 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2826 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2828 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2830 if (id >= This->nb_groups)
2831 return D3DRMERR_BADVALUE;
2833 if (This->groups[id].texture)
2834 IDirect3DRMTexture3_Release(This->groups[id].texture);
2838 This->groups[id].texture = NULL;
2842 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2845 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2847 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2849 TRACE("(%p)->()\n", This);
2851 return This->nb_groups;
2854 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2855 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2856 DWORD *face_data_size, unsigned *face_data)
2858 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2860 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2862 if (id >= This->nb_groups)
2863 return D3DRMERR_BADVALUE;
2866 *vertex_count = This->groups[id].nb_vertices;
2868 *face_count = This->groups[id].nb_faces;
2869 if (vertex_per_face)
2870 *vertex_per_face = This->groups[id].vertex_per_face;
2872 *face_data_size = This->groups[id].face_data_size;
2874 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2879 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2880 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2882 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2884 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2886 if (id >= This->nb_groups)
2887 return D3DRMERR_BADVALUE;
2889 if ((index + count - 1) >= This->groups[id].nb_vertices)
2890 return D3DRMERR_BADVALUE;
2895 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2900 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2902 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2904 TRACE("(%p)->(%u)\n", This, id);
2906 return This->groups[id].color;
2909 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2911 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2913 FIXME("(%p)->(%u): stub\n", This, id);
2917 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2919 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2921 FIXME("(%p)->(%u): stub\n", This, id);
2926 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2927 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2929 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2931 TRACE("(%p)->(%u,%p)\n", This, id, material);
2933 if (id >= This->nb_groups)
2934 return D3DRMERR_BADVALUE;
2939 if (This->groups[id].material)
2940 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2947 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2948 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2950 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2952 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2954 if (id >= This->nb_groups)
2955 return D3DRMERR_BADVALUE;
2960 if (This->groups[id].texture)
2961 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2968 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2970 /*** IUnknown methods ***/
2971 IDirect3DRMMeshImpl_QueryInterface,
2972 IDirect3DRMMeshImpl_AddRef,
2973 IDirect3DRMMeshImpl_Release,
2974 /*** IDirect3DRMObject methods ***/
2975 IDirect3DRMMeshImpl_Clone,
2976 IDirect3DRMMeshImpl_AddDestroyCallback,
2977 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2978 IDirect3DRMMeshImpl_SetAppData,
2979 IDirect3DRMMeshImpl_GetAppData,
2980 IDirect3DRMMeshImpl_SetName,
2981 IDirect3DRMMeshImpl_GetName,
2982 IDirect3DRMMeshImpl_GetClassName,
2983 /*** IDirect3DRMMesh methods ***/
2984 IDirect3DRMMeshImpl_Scale,
2985 IDirect3DRMMeshImpl_Translate,
2986 IDirect3DRMMeshImpl_GetBox,
2987 IDirect3DRMMeshImpl_AddGroup,
2988 IDirect3DRMMeshImpl_SetVertices,
2989 IDirect3DRMMeshImpl_SetGroupColor,
2990 IDirect3DRMMeshImpl_SetGroupColorRGB,
2991 IDirect3DRMMeshImpl_SetGroupMapping,
2992 IDirect3DRMMeshImpl_SetGroupQuality,
2993 IDirect3DRMMeshImpl_SetGroupMaterial,
2994 IDirect3DRMMeshImpl_SetGroupTexture,
2995 IDirect3DRMMeshImpl_GetGroupCount,
2996 IDirect3DRMMeshImpl_GetGroup,
2997 IDirect3DRMMeshImpl_GetVertices,
2998 IDirect3DRMMeshImpl_GetGroupColor,
2999 IDirect3DRMMeshImpl_GetGroupMapping,
3000 IDirect3DRMMeshImpl_GetGroupQuality,
3001 IDirect3DRMMeshImpl_GetGroupMaterial,
3002 IDirect3DRMMeshImpl_GetGroupTexture
3005 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
3007 IDirect3DRMMeshImpl* object;
3009 TRACE("(%p)\n", obj);
3011 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
3014 ERR("Out of memory\n");
3015 return E_OUTOFMEMORY;
3018 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
3021 *obj = &object->IDirect3DRMMesh_iface;