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);
37 static HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj);
41 D3DRMVERTEX* vertices;
43 unsigned vertex_per_face;
47 IDirect3DRMMaterial2* material;
48 IDirect3DRMTexture3* texture;
52 IDirect3DRMMesh IDirect3DRMMesh_iface;
54 DWORD groups_capacity;
57 } IDirect3DRMMeshImpl;
65 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
66 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
79 IDirect3DRMMaterial2* material;
80 IDirect3DRMTexture3* texture;
81 } IDirect3DRMMeshBuilderImpl;
87 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
94 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
101 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
107 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
108 "array FLOAT matrix[16];"
112 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
120 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
125 "template IndexedColor"
127 "<1630B820-7842-11CF-8F52-0040333594A3>"
129 "ColorRGBA indexColor;"
133 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
138 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
142 "template MaterialWrap"
144 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
148 "template TextureFilename"
150 "<A42790E1-7810-11CF-8F52-0040333594A3>"
155 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
156 "ColorRGBA faceColor;"
158 "ColorRGB specularColor;"
159 "ColorRGB emissiveColor;"
164 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
165 "DWORD nFaceVertexIndices;"
166 "array DWORD faceVertexIndices[nFaceVertexIndices];"
168 "template MeshFaceWraps"
170 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
171 "DWORD nFaceWrapValues;"
172 "array Boolean2d faceWrapValues[nFaceWrapValues];"
174 "template MeshTextureCoords"
176 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
177 "DWORD nTextureCoords;"
178 "array Coords2d textureCoords[nTextureCoords];"
180 "template MeshMaterialList"
182 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
184 "DWORD nFaceIndexes;"
185 "array DWORD faceIndexes[nFaceIndexes];"
188 "template MeshNormals"
190 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
192 "array Vector normals[nNormals];"
193 "DWORD nFaceNormals;"
194 "array MeshFace faceNormals[nFaceNormals];"
196 "template MeshVertexColors"
198 "<1630B821-7842-11CF-8F52-0040333594A3>"
199 "DWORD nVertexColors;"
200 "array IndexedColor vertexColors[nVertexColors];"
204 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
206 "array Vector vertices[nVertices];"
208 "array MeshFace faces[nFaces];"
211 "template FrameTransformMatrix"
213 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
214 "Matrix4x4 frameMatrix;"
218 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
223 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
225 "array FLOAT values[nValues];"
227 "template TimedFloatKeys"
229 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
233 "template AnimationKey"
235 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
238 "array TimedFloatKeys keys[nKeys];"
240 "template AnimationOptions"
242 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
244 "DWORD positionquality;"
248 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
251 "template AnimationSet"
253 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
256 "template InlineData"
258 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
263 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
265 "array STRING urls[nUrls];"
267 "template ProgressiveMesh"
269 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
274 "<A42790E0-7810-11CF-8F52-0040333594A3>"
278 "array UCHAR data4[8];"
280 "template StringProperty"
282 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
286 "template PropertyBag"
288 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
291 "template ExternalVisual"
293 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
294 "Guid guidExternalVisual;"
297 "template RightHanded"
299 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
300 "DWORD bRightHanded;"
304 static inline IDirect3DRMMeshImpl *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
306 return CONTAINING_RECORD(iface, IDirect3DRMMeshImpl, IDirect3DRMMesh_iface);
309 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
311 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder2_iface);
314 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
316 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder3_iface);
319 /*** IUnknown methods ***/
320 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2* iface,
321 REFIID riid, void** ppvObject)
323 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
325 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
329 if(IsEqualGUID(riid, &IID_IUnknown) ||
330 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder) ||
331 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2))
333 *ppvObject = &This->IDirect3DRMMeshBuilder2_iface;
335 else if(IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
337 *ppvObject = &This->IDirect3DRMMeshBuilder3_iface;
341 FIXME("interface %s not implemented\n", debugstr_guid(riid));
342 return E_NOINTERFACE;
345 IDirect3DRMMeshBuilder_AddRef(iface);
349 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2* iface)
351 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
352 ULONG ref = InterlockedIncrement(&This->ref);
354 TRACE("(%p)->(): new ref = %d\n", This, ref);
359 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2* iface)
361 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
362 ULONG ref = InterlockedDecrement(&This->ref);
364 TRACE("(%p)->(): new ref = %d\n", This, ref);
369 IDirect3DRMMaterial2_Release(This->material);
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 lpdwSize, LPSTR lpName)
457 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
459 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
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 lpdwSize, LPSTR lpName)
1083 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1085 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
1090 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
1092 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1093 LPDIRECTXFILEOBJECT pObject = NULL;
1094 LPDIRECTXFILEDATA pData2 = NULL;
1099 HRESULT ret = D3DRMERR_BADOBJECT;
1100 DWORD* faces_vertex_idx_data = NULL;
1101 DWORD* faces_vertex_idx_ptr;
1102 DWORD faces_vertex_idx_size;
1103 DWORD* faces_normal_idx_data = NULL;
1104 DWORD* faces_normal_idx_ptr = NULL;
1105 DWORD* faces_data_ptr;
1106 DWORD faces_data_size = 0;
1109 TRACE("(%p)->(%p)\n", This, pData);
1111 /* Remove previous name */
1112 HeapFree(GetProcessHeap(), 0, This->name);
1114 hr = IDirectXFileData_GetName(pData, NULL, &size);
1115 if (hr != DXFILE_OK)
1119 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1121 return E_OUTOFMEMORY;
1123 hr = IDirectXFileData_GetName(pData, This->name, &size);
1124 if (hr != DXFILE_OK)
1126 HeapFree(GetProcessHeap(), 0, This->name);
1132 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1134 This->nb_normals = 0;
1136 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1137 if (hr != DXFILE_OK)
1140 This->nb_vertices = *(DWORD*)ptr;
1141 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1142 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1143 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1145 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1147 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1148 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1150 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1151 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1153 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1154 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size*2);
1155 faces_data_ptr = (DWORD*)This->pFaceData;
1159 hr = IDirectXFileData_GetNextObject(pData, &pObject);
1160 if (hr == DXFILEERR_NOMOREOBJECTS)
1162 TRACE("No more object\n");
1165 if (hr != DXFILE_OK)
1168 hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
1169 IDirectXFileObject_Release(pObject);
1170 if (hr != DXFILE_OK)
1173 hr = IDirectXFileData_GetType(pData2, &pGuid);
1174 if (hr != DXFILE_OK)
1177 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1179 if (IsEqualGUID(pGuid, &TID_D3DRMMeshNormals))
1181 DWORD nb_faces_normals;
1182 DWORD faces_normal_idx_size;
1184 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1185 if (hr != DXFILE_OK)
1188 This->nb_normals = *(DWORD*)ptr;
1189 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1191 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1192 if (nb_faces_normals != This->nb_faces)
1193 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1195 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1196 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1198 faces_normal_idx_size = size - (2*sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1199 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1200 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1202 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshTextureCoords))
1204 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1205 if (hr != DXFILE_OK)
1208 This->nb_coords2d = *(DWORD*)ptr;
1210 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1212 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1213 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1216 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshMaterialList))
1219 DWORD nb_face_indices;
1221 LPDIRECTXFILEOBJECT child;
1225 TRACE("Process MeshMaterialList\n");
1227 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1228 if (hr != DXFILE_OK)
1231 nb_materials = *(DWORD*)ptr;
1232 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1233 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1235 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1237 if (size != data_size)
1238 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1240 if (nb_materials > 2)
1242 FIXME("Only one material per mesh supported, first one applies to all faces\n");
1246 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1248 LPDIRECTXFILEDATA data;
1249 LPDIRECTXFILEDATAREFERENCE reference;
1250 LPDIRECT3DRMMATERIAL2 material;
1252 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1255 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1259 hr = IDirectXFileDataReference_Resolve(reference, &data);
1260 IDirectXFileDataReference_Release(reference);
1265 hr = Direct3DRMMaterial_create(&material);
1268 IDirectXFileData_Release(data);
1272 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1273 if (hr != DXFILE_OK)
1275 IDirectXFileData_Release(data);
1280 WARN("Material size %u does not match expected one %u\n", size, 44);
1282 values = (float*)ptr;
1284 IDirect3DRMMeshBuilder3_SetColorRGB(iface, values[0], values [1], values[2]); /* Alpha ignored */
1286 IDirect3DRMMaterial2_SetAmbient(material, values[0], values [1], values[2]); /* Alpha ignored */
1287 IDirect3DRMMaterial2_SetPower(material, values[4]);
1288 IDirect3DRMMaterial2_SetSpecular(material, values[5], values[6], values[7]);
1289 IDirect3DRMMaterial2_SetEmissive(material, values[8], values[9], values[10]);
1291 This->material = material;
1293 IDirectXFileData_Release(data);
1297 WARN("Found more sub-objects than expected\n");
1298 else if (hr != DXFILEERR_NOMOREOBJECTS)
1304 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
1307 IDirectXFileData_Release(pData2);
1311 if (!This->nb_normals)
1313 /* Allocate normals, one per vertex */
1314 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1315 if (!This->pNormals)
1319 for (i = 0; i < This->nb_faces; i++)
1322 DWORD nb_face_indexes;
1323 D3DVECTOR face_normal;
1325 if (faces_vertex_idx_size < sizeof(DWORD))
1326 WARN("Not enough data to read number of indices of face %d\n", i);
1328 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1329 faces_vertex_idx_size--;
1330 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1331 WARN("Faces indices number mismatch\n");
1333 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1334 WARN("Not enough data to read all indices of face %d\n", i);
1336 if (!This->nb_normals)
1338 /* Compute face normal */
1339 if (nb_face_indexes > 2)
1343 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1344 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[1]], &This->pVertices[faces_vertex_idx_ptr[0]]);
1345 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1346 D3DRMVectorNormalize(&face_normal);
1350 face_normal.u1.x = 0.0f;
1351 face_normal.u2.y = 0.0f;
1352 face_normal.u3.z = 0.0f;
1356 for (j = 0; j < nb_face_indexes; j++)
1358 /* Copy vertex index */
1359 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1360 /* Copy normal index */
1361 if (This->nb_normals)
1363 /* Read from x file */
1364 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1368 DWORD vertex_idx = *faces_vertex_idx_ptr;
1369 if (vertex_idx >= This->nb_vertices)
1371 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1374 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1375 /* Add face normal to vertex normal */
1376 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1378 faces_vertex_idx_ptr++;
1380 faces_vertex_idx_size -= nb_face_indexes;
1383 /* Last DWORD must be 0 */
1384 *(faces_data_ptr + faces_data_size++) = 0;
1386 /* Set size (in number of DWORD) of all faces data */
1387 This->face_data_size = faces_data_size;
1389 if (!This->nb_normals)
1391 /* Normalize all normals */
1392 for (i = 0; i < This->nb_vertices; i++)
1394 D3DRMVectorNormalize(&This->pNormals[i]);
1396 This->nb_normals = This->nb_vertices;
1399 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1400 if (!This->pCoords2d)
1402 This->nb_coords2d = This->nb_vertices;
1403 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1404 for (i = 0; i < This->nb_coords2d; i++)
1406 This->pCoords2d[i].u = 0.0f;
1407 This->pCoords2d[i].v = 0.0f;
1411 TRACE("Mesh data loaded successfully\n");
1417 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1418 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1423 /*** IDirect3DRMMeshBuilder3 methods ***/
1424 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1425 LPVOID filename, LPVOID name,
1426 D3DRMLOADOPTIONS loadflags,
1427 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1429 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1430 DXFILELOADOPTIONS load_options;
1431 LPDIRECTXFILE pDXFile = NULL;
1432 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1433 LPDIRECTXFILEDATA pData = NULL;
1434 LPDIRECTXFILEDATA pData2 = NULL;
1439 HRESULT ret = D3DRMERR_BADOBJECT;
1441 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1443 /* First free allocated buffers of previous mesh data */
1444 HeapFree(GetProcessHeap(), 0, This->pVertices);
1445 This->pVertices = NULL;
1446 HeapFree(GetProcessHeap(), 0, This->pNormals);
1447 This->pNormals = NULL;
1448 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1449 This->pFaceData = NULL;
1450 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1451 This->pCoords2d = NULL;
1453 if (loadflags == D3DRMLOAD_FROMMEMORY)
1455 load_options = DXFILELOAD_FROMMEMORY;
1457 else if (loadflags == D3DRMLOAD_FROMFILE)
1459 load_options = DXFILELOAD_FROMFILE;
1460 TRACE("Loading from file %s\n", debugstr_a(filename));
1464 FIXME("Load options %d not supported yet\n", loadflags);
1468 hr = DirectXFileCreate(&pDXFile);
1469 if (hr != DXFILE_OK)
1472 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1473 if (hr != DXFILE_OK)
1476 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1477 if (hr != DXFILE_OK)
1480 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1481 if (hr != DXFILE_OK)
1484 hr = IDirectXFileData_GetType(pData, &pGuid);
1485 if (hr != DXFILE_OK)
1488 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1490 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1492 ret = D3DRMERR_BADFILE;
1496 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1497 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1500 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1502 /* Version must be 1.0.x */
1503 if ((pHeader->major != 1) || (pHeader->minor != 0))
1505 ret = D3DRMERR_BADFILE;
1509 IDirectXFileData_Release(pData);
1512 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1513 if (hr != DXFILE_OK)
1515 ret = D3DRMERR_NOTFOUND;
1519 hr = IDirectXFileData_GetType(pData, &pGuid);
1520 if (hr != DXFILE_OK)
1523 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1525 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1527 ret = D3DRMERR_NOTFOUND;
1531 hr = load_mesh_data(iface, pData);
1538 IDirectXFileData_Release(pData2);
1540 IDirectXFileData_Release(pData);
1542 IDirectXFileEnumObject_Release(pEnumObject);
1544 IDirectXFile_Release(pDXFile);
1546 if (ret != D3DRM_OK)
1548 /* Clean mesh data */
1549 This->nb_vertices = 0;
1550 This->nb_normals = 0;
1552 This->face_data_size = 0;
1553 This->nb_coords2d = 0;
1554 HeapFree(GetProcessHeap(), 0, This->pVertices);
1555 This->pVertices = NULL;
1556 HeapFree(GetProcessHeap(), 0, This->pNormals);
1557 This->pNormals = NULL;
1558 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1559 This->pFaceData = NULL;
1560 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1561 This->pCoords2d = NULL;
1567 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1568 const char* filename, D3DRMXOFFORMAT format,
1569 D3DRMSAVEOPTIONS save)
1571 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1573 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1578 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1579 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1581 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1584 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1586 for (i = 0; i < This->nb_vertices; i++)
1588 This->pVertices[i].u1.x *= sx;
1589 This->pVertices[i].u2.y *= sy;
1590 This->pVertices[i].u3.z *= sz;
1593 /* Normals are not affected by Scale */
1598 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1599 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1601 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1603 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1608 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1609 D3DRMCOLORSOURCE color)
1611 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1613 FIXME("(%p)->(%x): stub\n", This, color);
1618 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1621 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1623 FIXME("(%p)->(%p): stub\n", This, box);
1628 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1629 D3DVALUE crease, DWORD flags)
1631 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1633 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1638 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1640 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1642 FIXME("(%p)->(): stub\n", This);
1647 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1648 LPDIRECT3DRMMESH Mesh)
1650 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1652 FIXME("(%p)->(%p): stub\n", This, Mesh);
1657 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1658 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1661 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1663 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1668 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1669 LPDIRECT3DRMFRAME3 Frame)
1671 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1673 FIXME("(%p)->(%p): stub\n", This, Frame);
1678 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1679 LPDIRECT3DRMFACE2 Face)
1681 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1683 FIXME("(%p)->(%p): stub\n", This, Face);
1688 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1689 DWORD vcount, D3DVECTOR* vertices,
1690 DWORD ncount, D3DVECTOR* normals,
1692 LPDIRECT3DRMFACEARRAY* FaceArray)
1694 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1696 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1697 normals, data, FaceArray);
1702 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1707 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1709 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1714 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1715 D3DVALUE red, D3DVALUE green,
1718 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1720 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1722 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1723 (BYTE)(green * 255.0f),
1724 (BYTE)(blue * 255.0f));
1729 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1732 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1734 TRACE("(%p)->(%x)\n", This, color);
1736 This->color = color;
1741 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1742 LPDIRECT3DRMTEXTURE3 texture)
1744 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1746 TRACE("(%p)->(%p)\n", This, texture);
1749 IDirect3DRMTexture3_AddRef(texture);
1751 IDirect3DRMTexture3_Release(This->texture);
1752 This->texture = texture;
1757 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1758 LPDIRECT3DRMMATERIAL2 material)
1760 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1762 TRACE("(%p)->(%p)\n", This, material);
1765 IDirect3DRMTexture2_AddRef(material);
1767 IDirect3DRMTexture2_Release(This->material);
1768 This->material = material;
1773 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1774 BOOL wrap_u, BOOL wrap_v)
1776 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1778 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1783 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1784 D3DRMRENDERQUALITY quality)
1786 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1788 FIXME("(%p)->(%d): stub\n", This, quality);
1793 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1796 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1798 FIXME("(%p)->(%d): stub\n", This, enable);
1803 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1805 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1807 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1809 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1814 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1816 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1818 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1820 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1825 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1826 DWORD index, D3DVALUE u,
1829 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1831 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1833 if (index >= This->nb_coords2d)
1834 return D3DRMERR_BADVALUE;
1836 This->pCoords2d[index].u = u;
1837 This->pCoords2d[index].v = v;
1842 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1843 DWORD index, D3DCOLOR color)
1845 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1847 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1852 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1854 D3DVALUE red, D3DVALUE green,
1857 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1859 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1864 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1865 LPDIRECT3DRMFACEARRAY* FaceArray)
1867 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1869 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1874 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1875 DWORD* vcount, D3DVECTOR* vertices,
1876 DWORD* ncount, D3DVECTOR* normals,
1877 DWORD* face_data_size,
1880 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1882 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1883 face_data_size, face_data);
1888 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1889 DWORD index, D3DVALUE* u,
1892 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1894 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1896 if (index >= This->nb_coords2d)
1897 return D3DRMERR_BADVALUE;
1899 *u = This->pCoords2d[index].u;
1900 *v = This->pCoords2d[index].v;
1906 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1907 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1909 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1911 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1916 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1917 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1919 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1921 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1926 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
1927 LPDIRECT3DRMFACE2* Face)
1929 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1931 FIXME("(%p)->(%p): stub\n", This, Face);
1936 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
1938 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1940 FIXME("(%p)->(): stub\n", This);
1945 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
1947 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1949 FIXME("(%p)->(): stub\n", This);
1954 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
1956 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1958 TRACE("(%p)->()\n", This);
1960 return This->nb_faces;
1963 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
1965 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1967 TRACE("(%p)->()\n", This);
1969 return This->nb_vertices;
1972 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
1975 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1977 FIXME("(%p)->(%d): stub\n", This, index);
1982 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
1983 LPDIRECT3DRMMESH* mesh)
1985 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1987 D3DRMGROUPINDEX group;
1989 TRACE("(%p)->(%p)\n", This, mesh);
1994 hr = Direct3DRMMesh_create(mesh);
1998 /* If there is mesh data, create a group and put data inside */
1999 if (This->nb_vertices)
2001 unsigned* face_data;
2003 DWORD* in_ptr = This->pFaceData;
2006 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2009 IDirect3DRMMesh_Release(*mesh);
2010 return E_OUTOFMEMORY;
2012 out_ptr = face_data;
2014 /* Put only vertex indices */
2015 for (i = 0; i < This->nb_faces; i++)
2017 DWORD nb_indices = *out_ptr++ = *in_ptr++;
2018 for (j = 0; j < nb_indices; j++)
2020 *out_ptr++ = *in_ptr++;
2021 /* Skip normal index */
2026 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
2027 HeapFree(GetProcessHeap(), 0, face_data);
2030 D3DRMVERTEX* vertices;
2032 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2035 for (i = 0; i < This->nb_vertices; i++)
2037 vertices[i].position = This->pVertices[i];
2039 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2040 HeapFree(GetProcessHeap(), 0, vertices);
2048 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2050 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2051 if (SUCCEEDED(hr) && This->texture)
2053 LPDIRECT3DRMTEXTURE texture;
2055 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2056 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2057 IDirect3DRMTexture_Release(texture);
2060 IDirect3DRMMesh_Release(*mesh);
2066 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2067 DWORD index, LPDIRECT3DRMFACE2* Face)
2069 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2071 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2076 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2077 DWORD index, LPD3DVECTOR vector)
2079 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2081 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2086 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2087 DWORD index, LPD3DVECTOR vector)
2089 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2091 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2096 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2097 DWORD IndexFirst, DWORD count)
2099 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2101 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2106 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2107 DWORD IndexFirst, DWORD count)
2109 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2111 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2116 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2117 LPDIRECT3DRMFACE2 Face)
2119 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2121 FIXME("(%p)->(%p): stub\n", This, Face);
2126 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2128 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2130 FIXME("(%p)->(%u): stub\n", This, flags);
2135 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2138 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2140 FIXME("(%p)->(%u): stub\n", This, flags);
2145 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2146 DWORD flags, DWORD* indices,
2147 DWORD* IndexFirst, DWORD* count)
2149 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2151 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2156 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2159 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2161 FIXME("(%p)->(%p): stub\n", This, unkwn);
2166 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2167 DWORD flags, LPUNKNOWN *unkwn)
2169 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2171 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2176 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2177 LPDWORD count, LPUNKNOWN *unkwn)
2179 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2181 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2186 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2189 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2191 FIXME("(%p)->(%p): stub\n", This, unkwn);
2196 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2199 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2201 FIXME("(%p)->(%u): stub\n", This, index);
2206 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2209 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2211 FIXME("(%p)->(%p): stub\n", This, indices);
2216 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2217 DWORD flags, DWORD format,
2218 DWORD VertexCount, LPVOID data)
2220 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2222 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2227 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2228 DWORD IndexFirst, DWORD count,
2231 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2233 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2238 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2239 DWORD IndexFirst, LPDWORD vcount,
2240 LPD3DVECTOR vertices)
2242 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2243 DWORD count = This->nb_vertices - IndexFirst;
2245 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2249 if (vertices && This->nb_vertices)
2250 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2255 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2256 DWORD IndexFirst, DWORD count,
2259 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2261 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2266 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2267 DWORD IndexFirst, LPDWORD count,
2270 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2272 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2277 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2279 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2281 FIXME("(%p)->(): stub\n", This);
2286 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2288 /*** IUnknown methods ***/
2289 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2290 IDirect3DRMMeshBuilder3Impl_AddRef,
2291 IDirect3DRMMeshBuilder3Impl_Release,
2292 /*** IDirect3DRMObject methods ***/
2293 IDirect3DRMMeshBuilder3Impl_Clone,
2294 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2295 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2296 IDirect3DRMMeshBuilder3Impl_SetAppData,
2297 IDirect3DRMMeshBuilder3Impl_GetAppData,
2298 IDirect3DRMMeshBuilder3Impl_SetName,
2299 IDirect3DRMMeshBuilder3Impl_GetName,
2300 IDirect3DRMMeshBuilder3Impl_GetClassName,
2301 /*** IDirect3DRMMeshBuilder3 methods ***/
2302 IDirect3DRMMeshBuilder3Impl_Load,
2303 IDirect3DRMMeshBuilder3Impl_Save,
2304 IDirect3DRMMeshBuilder3Impl_Scale,
2305 IDirect3DRMMeshBuilder3Impl_Translate,
2306 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2307 IDirect3DRMMeshBuilder3Impl_GetBox,
2308 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2309 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2310 IDirect3DRMMeshBuilder3Impl_AddMesh,
2311 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2312 IDirect3DRMMeshBuilder3Impl_AddFrame,
2313 IDirect3DRMMeshBuilder3Impl_AddFace,
2314 IDirect3DRMMeshBuilder3Impl_AddFaces,
2315 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2316 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2317 IDirect3DRMMeshBuilder3Impl_SetColor,
2318 IDirect3DRMMeshBuilder3Impl_SetTexture,
2319 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2320 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2321 IDirect3DRMMeshBuilder3Impl_SetQuality,
2322 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2323 IDirect3DRMMeshBuilder3Impl_SetVertex,
2324 IDirect3DRMMeshBuilder3Impl_SetNormal,
2325 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2326 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2327 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2328 IDirect3DRMMeshBuilder3Impl_GetFaces,
2329 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2330 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2331 IDirect3DRMMeshBuilder3Impl_AddVertex,
2332 IDirect3DRMMeshBuilder3Impl_AddNormal,
2333 IDirect3DRMMeshBuilder3Impl_CreateFace,
2334 IDirect3DRMMeshBuilder3Impl_GetQuality,
2335 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2336 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2337 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2338 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2339 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2340 IDirect3DRMMeshBuilder3Impl_GetFace,
2341 IDirect3DRMMeshBuilder3Impl_GetVertex,
2342 IDirect3DRMMeshBuilder3Impl_GetNormal,
2343 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2344 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2345 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2346 IDirect3DRMMeshBuilder3Impl_Empty,
2347 IDirect3DRMMeshBuilder3Impl_Optimize,
2348 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2349 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2350 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2351 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2352 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2353 IDirect3DRMMeshBuilder3Impl_Enable,
2354 IDirect3DRMMeshBuilder3Impl_GetEnable,
2355 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2356 IDirect3DRMMeshBuilder3Impl_SetVertices,
2357 IDirect3DRMMeshBuilder3Impl_GetVertices,
2358 IDirect3DRMMeshBuilder3Impl_SetNormals,
2359 IDirect3DRMMeshBuilder3Impl_GetNormals,
2360 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2363 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2365 IDirect3DRMMeshBuilderImpl* object;
2367 TRACE("(%p)\n", ppObj);
2369 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2372 ERR("Out of memory\n");
2373 return E_OUTOFMEMORY;
2376 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2377 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2380 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2381 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2383 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2388 /*** IUnknown methods ***/
2389 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2390 REFIID riid, void** ppvObject)
2392 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2394 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2398 if (IsEqualGUID(riid, &IID_IUnknown) ||
2399 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2401 *ppvObject = &This->IDirect3DRMMesh_iface;
2405 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2406 return E_NOINTERFACE;
2409 IDirect3DRMMesh_AddRef(iface);
2413 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2415 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2416 ULONG ref = InterlockedIncrement(&This->ref);
2418 TRACE("(%p)->(): new ref = %d\n", This, ref);
2423 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2425 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2426 ULONG ref = InterlockedDecrement(&This->ref);
2428 TRACE("(%p)->(): new ref = %d\n", This, ref);
2434 for (i = 0; i < This->nb_groups; i++)
2435 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2436 HeapFree(GetProcessHeap(), 0, This->groups);
2437 HeapFree(GetProcessHeap(), 0, This);
2443 /*** IDirect3DRMObject methods ***/
2444 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2445 LPUNKNOWN pUnkOuter, REFIID riid,
2448 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2450 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2455 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2456 D3DRMOBJECTCALLBACK cb,
2459 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2461 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2466 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2467 D3DRMOBJECTCALLBACK cb,
2470 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2472 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2477 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2480 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2482 FIXME("(%p)->(%u): stub\n", This, data);
2487 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2489 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2491 FIXME("(%p)->(): stub\n", This);
2496 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2499 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2501 FIXME("(%p)->(%s): stub\n", This, pName);
2506 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2507 LPDWORD lpdwSize, LPSTR lpName)
2509 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2511 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2516 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2517 LPDWORD lpdwSize, LPSTR lpName)
2519 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2521 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2526 /*** IDirect3DRMMesh methods ***/
2527 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2528 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2530 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2532 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2537 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2538 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2540 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2542 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2547 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2550 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2552 FIXME("(%p)->(%p): stub\n", This, box);
2557 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2558 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2559 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2561 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2564 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2566 if (!face_data || !return_id)
2569 if ((This->nb_groups + 1) > This->groups_capacity)
2574 if (!This->groups_capacity)
2577 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2581 new_capacity = This->groups_capacity * 2;
2582 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2586 return E_OUTOFMEMORY;
2588 This->groups_capacity = new_capacity;
2589 This->groups = groups;
2592 group = This->groups + This->nb_groups;
2594 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2595 if (!group->vertices)
2596 return E_OUTOFMEMORY;
2597 group->nb_vertices = vertex_count;
2598 group->nb_faces = face_count;
2599 group->vertex_per_face = vertex_per_face;
2601 if (vertex_per_face)
2603 group->face_data_size = face_count * vertex_per_face;
2608 unsigned nb_indices;
2609 unsigned* face_data_ptr = face_data;
2610 group->face_data_size = 0;
2612 for (i = 0; i < face_count; i++)
2614 nb_indices = *face_data_ptr;
2615 group->face_data_size += nb_indices + 1;
2616 face_data_ptr += nb_indices;
2620 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2621 if (!group->face_data)
2623 HeapFree(GetProcessHeap(), 0 , group->vertices);
2624 return E_OUTOFMEMORY;
2627 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2629 group->material = NULL;
2630 group->texture = NULL;
2632 *return_id = This->nb_groups++;
2637 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2638 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2639 D3DRMVERTEX *values)
2641 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2643 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2645 if (id >= This->nb_groups)
2646 return D3DRMERR_BADVALUE;
2648 if ((index + count - 1) >= This->groups[id].nb_vertices)
2649 return D3DRMERR_BADVALUE;
2654 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2659 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2660 D3DRMGROUPINDEX id, D3DCOLOR color)
2662 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2664 TRACE("(%p)->(%u,%x)\n", This, id, color);
2666 if (id >= This->nb_groups)
2667 return D3DRMERR_BADVALUE;
2669 This->groups[id].color = color;
2674 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2675 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2677 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2679 FIXME("(%p)->(%u,%f,%f,%f): stub\n", This, id, red, green, blue);
2684 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2685 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2687 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2689 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2694 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2695 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2697 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2699 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2704 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2705 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2707 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2709 TRACE("(%p)->(%u,%p)\n", This, id, material);
2711 if (id >= This->nb_groups)
2712 return D3DRMERR_BADVALUE;
2714 if (This->groups[id].material)
2715 IDirect3DRMMaterial2_Release(This->groups[id].material);
2717 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2720 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2725 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2726 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2728 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2730 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2732 if (id >= This->nb_groups)
2733 return D3DRMERR_BADVALUE;
2735 if (This->groups[id].texture)
2736 IDirect3DRMTexture3_Release(This->groups[id].texture);
2740 This->groups[id].texture = NULL;
2744 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2747 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2749 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2751 TRACE("(%p)->()\n", This);
2753 return This->nb_groups;
2756 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2757 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2758 DWORD *face_data_size, unsigned *face_data)
2760 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2762 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2764 if (id >= This->nb_groups)
2765 return D3DRMERR_BADVALUE;
2768 *vertex_count = This->groups[id].nb_vertices;
2770 *face_count = This->groups[id].nb_faces;
2771 if (vertex_per_face)
2772 *vertex_per_face = This->groups[id].vertex_per_face;
2774 *face_data_size = This->groups[id].face_data_size;
2776 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2781 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2782 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2784 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2786 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2788 if (id >= This->nb_groups)
2789 return D3DRMERR_BADVALUE;
2791 if ((index + count - 1) >= This->groups[id].nb_vertices)
2792 return D3DRMERR_BADVALUE;
2797 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2802 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2804 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2806 TRACE("(%p)->(%u)\n", This, id);
2808 return This->groups[id].color;
2811 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2813 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2815 FIXME("(%p)->(%u): stub\n", This, id);
2819 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2821 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2823 FIXME("(%p)->(%u): stub\n", This, id);
2828 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2829 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2831 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2833 TRACE("(%p)->(%u,%p)\n", This, id, material);
2835 if (id >= This->nb_groups)
2836 return D3DRMERR_BADVALUE;
2841 if (This->groups[id].material)
2842 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2849 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2850 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2852 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2854 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2856 if (id >= This->nb_groups)
2857 return D3DRMERR_BADVALUE;
2862 if (This->groups[id].texture)
2863 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2870 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2872 /*** IUnknown methods ***/
2873 IDirect3DRMMeshImpl_QueryInterface,
2874 IDirect3DRMMeshImpl_AddRef,
2875 IDirect3DRMMeshImpl_Release,
2876 /*** IDirect3DRMObject methods ***/
2877 IDirect3DRMMeshImpl_Clone,
2878 IDirect3DRMMeshImpl_AddDestroyCallback,
2879 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2880 IDirect3DRMMeshImpl_SetAppData,
2881 IDirect3DRMMeshImpl_GetAppData,
2882 IDirect3DRMMeshImpl_SetName,
2883 IDirect3DRMMeshImpl_GetName,
2884 IDirect3DRMMeshImpl_GetClassName,
2885 /*** IDirect3DRMMesh methods ***/
2886 IDirect3DRMMeshImpl_Scale,
2887 IDirect3DRMMeshImpl_Translate,
2888 IDirect3DRMMeshImpl_GetBox,
2889 IDirect3DRMMeshImpl_AddGroup,
2890 IDirect3DRMMeshImpl_SetVertices,
2891 IDirect3DRMMeshImpl_SetGroupColor,
2892 IDirect3DRMMeshImpl_SetGroupColorRGB,
2893 IDirect3DRMMeshImpl_SetGroupMapping,
2894 IDirect3DRMMeshImpl_SetGroupQuality,
2895 IDirect3DRMMeshImpl_SetGroupMaterial,
2896 IDirect3DRMMeshImpl_SetGroupTexture,
2897 IDirect3DRMMeshImpl_GetGroupCount,
2898 IDirect3DRMMeshImpl_GetGroup,
2899 IDirect3DRMMeshImpl_GetVertices,
2900 IDirect3DRMMeshImpl_GetGroupColor,
2901 IDirect3DRMMeshImpl_GetGroupMapping,
2902 IDirect3DRMMeshImpl_GetGroupQuality,
2903 IDirect3DRMMeshImpl_GetGroupMaterial,
2904 IDirect3DRMMeshImpl_GetGroupTexture
2907 static HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2909 IDirect3DRMMeshImpl* object;
2911 TRACE("(%p)\n", obj);
2913 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2916 ERR("Out of memory\n");
2917 return E_OUTOFMEMORY;
2920 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
2923 *obj = &object->IDirect3DRMMesh_iface;