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 pMaterial)
656 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
658 FIXME("(%p)->(%p): stub\n", This, pMaterial);
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 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1372 /* Add face normal to vertex normal */
1373 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1375 faces_vertex_idx_ptr++;
1377 faces_vertex_idx_size -= nb_face_indexes;
1380 /* Last DWORD must be 0 */
1381 *(faces_data_ptr + faces_data_size++) = 0;
1383 /* Set size (in number of DWORD) of all faces data */
1384 This->face_data_size = faces_data_size;
1386 if (!This->nb_normals)
1388 /* Normalize all normals */
1389 for (i = 0; i < This->nb_vertices; i++)
1391 D3DRMVectorNormalize(&This->pNormals[i]);
1393 This->nb_normals = This->nb_vertices;
1396 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1397 if (!This->pCoords2d)
1399 This->nb_coords2d = This->nb_vertices;
1400 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1401 for (i = 0; i < This->nb_coords2d; i++)
1403 This->pCoords2d[i].u = 0.0f;
1404 This->pCoords2d[i].v = 0.0f;
1408 TRACE("Mesh data loaded successfully\n");
1414 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1415 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1420 /*** IDirect3DRMMeshBuilder3 methods ***/
1421 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1422 LPVOID filename, LPVOID name,
1423 D3DRMLOADOPTIONS loadflags,
1424 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1426 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1427 DXFILELOADOPTIONS load_options;
1428 LPDIRECTXFILE pDXFile = NULL;
1429 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1430 LPDIRECTXFILEDATA pData = NULL;
1431 LPDIRECTXFILEDATA pData2 = NULL;
1436 HRESULT ret = D3DRMERR_BADOBJECT;
1438 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1440 /* First free allocated buffers of previous mesh data */
1441 HeapFree(GetProcessHeap(), 0, This->pVertices);
1442 This->pVertices = NULL;
1443 HeapFree(GetProcessHeap(), 0, This->pNormals);
1444 This->pNormals = NULL;
1445 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1446 This->pFaceData = NULL;
1447 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1448 This->pCoords2d = NULL;
1450 if (loadflags == D3DRMLOAD_FROMMEMORY)
1452 load_options = DXFILELOAD_FROMMEMORY;
1454 else if (loadflags == D3DRMLOAD_FROMFILE)
1456 load_options = DXFILELOAD_FROMFILE;
1457 TRACE("Loading from file %s\n", debugstr_a(filename));
1461 FIXME("Load options %d not supported yet\n", loadflags);
1465 hr = DirectXFileCreate(&pDXFile);
1466 if (hr != DXFILE_OK)
1469 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1470 if (hr != DXFILE_OK)
1473 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1474 if (hr != DXFILE_OK)
1477 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1478 if (hr != DXFILE_OK)
1481 hr = IDirectXFileData_GetType(pData, &pGuid);
1482 if (hr != DXFILE_OK)
1485 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1487 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1489 ret = D3DRMERR_BADFILE;
1493 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1494 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1497 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1499 /* Version must be 1.0.x */
1500 if ((pHeader->major != 1) || (pHeader->minor != 0))
1502 ret = D3DRMERR_BADFILE;
1506 IDirectXFileData_Release(pData);
1509 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1510 if (hr != DXFILE_OK)
1512 ret = D3DRMERR_NOTFOUND;
1516 hr = IDirectXFileData_GetType(pData, &pGuid);
1517 if (hr != DXFILE_OK)
1520 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1522 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1524 ret = D3DRMERR_NOTFOUND;
1528 hr = load_mesh_data(iface, pData);
1535 IDirectXFileData_Release(pData2);
1537 IDirectXFileData_Release(pData);
1539 IDirectXFileEnumObject_Release(pEnumObject);
1541 IDirectXFile_Release(pDXFile);
1543 if (ret != D3DRM_OK)
1545 /* Clean mesh data */
1546 This->nb_vertices = 0;
1547 This->nb_normals = 0;
1549 This->face_data_size = 0;
1550 This->nb_coords2d = 0;
1551 HeapFree(GetProcessHeap(), 0, This->pVertices);
1552 This->pVertices = NULL;
1553 HeapFree(GetProcessHeap(), 0, This->pNormals);
1554 This->pNormals = NULL;
1555 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1556 This->pFaceData = NULL;
1557 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1558 This->pCoords2d = NULL;
1564 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1565 const char* filename, D3DRMXOFFORMAT format,
1566 D3DRMSAVEOPTIONS save)
1568 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1570 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1575 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1576 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1578 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1581 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1583 for (i = 0; i < This->nb_vertices; i++)
1585 This->pVertices[i].u1.x *= sx;
1586 This->pVertices[i].u2.y *= sy;
1587 This->pVertices[i].u3.z *= sz;
1590 /* Normals are not affected by Scale */
1595 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1596 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1598 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1600 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1605 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1606 D3DRMCOLORSOURCE color)
1608 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1610 FIXME("(%p)->(%x): stub\n", This, color);
1615 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1618 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1620 FIXME("(%p)->(%p): stub\n", This, box);
1625 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1626 D3DVALUE crease, DWORD flags)
1628 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1630 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1635 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1637 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1639 FIXME("(%p)->(): stub\n", This);
1644 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1645 LPDIRECT3DRMMESH Mesh)
1647 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1649 FIXME("(%p)->(%p): stub\n", This, Mesh);
1654 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1655 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1658 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1660 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1665 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1666 LPDIRECT3DRMFRAME3 Frame)
1668 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1670 FIXME("(%p)->(%p): stub\n", This, Frame);
1675 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1676 LPDIRECT3DRMFACE2 Face)
1678 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1680 FIXME("(%p)->(%p): stub\n", This, Face);
1685 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1686 DWORD vcount, D3DVECTOR* vertices,
1687 DWORD ncount, D3DVECTOR* normals,
1689 LPDIRECT3DRMFACEARRAY* FaceArray)
1691 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1693 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1694 normals, data, FaceArray);
1699 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1704 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1706 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1711 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1712 D3DVALUE red, D3DVALUE green,
1715 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1717 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1719 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1720 (BYTE)(green * 255.0f),
1721 (BYTE)(blue * 255.0f));
1726 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1729 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1731 TRACE("(%p)->(%x)\n", This, color);
1733 This->color = color;
1738 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1739 LPDIRECT3DRMTEXTURE3 texture)
1741 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1743 TRACE("(%p)->(%p)\n", This, texture);
1746 IDirect3DRMTexture3_AddRef(texture);
1748 IDirect3DRMTexture3_Release(This->texture);
1749 This->texture = texture;
1754 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1755 LPDIRECT3DRMMATERIAL2 material)
1757 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1759 FIXME("(%p)->(%p): stub\n", This, material);
1764 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1765 BOOL wrap_u, BOOL wrap_v)
1767 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1769 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1774 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1775 D3DRMRENDERQUALITY quality)
1777 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1779 FIXME("(%p)->(%d): stub\n", This, quality);
1784 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1787 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1789 FIXME("(%p)->(%d): stub\n", This, enable);
1794 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1796 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1798 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1800 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1805 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1807 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1809 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1811 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1816 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1817 DWORD index, D3DVALUE u,
1820 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1822 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1824 if (index >= This->nb_coords2d)
1825 return D3DRMERR_BADVALUE;
1827 This->pCoords2d[index].u = u;
1828 This->pCoords2d[index].v = v;
1833 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1834 DWORD index, D3DCOLOR color)
1836 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1838 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1843 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1845 D3DVALUE red, D3DVALUE green,
1848 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1850 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1855 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1856 LPDIRECT3DRMFACEARRAY* FaceArray)
1858 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1860 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1865 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1866 DWORD* vcount, D3DVECTOR* vertices,
1867 DWORD* ncount, D3DVECTOR* normals,
1868 DWORD* face_data_size,
1871 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1873 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1874 face_data_size, face_data);
1879 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1880 DWORD index, D3DVALUE* u,
1883 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1885 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1887 if (index >= This->nb_coords2d)
1888 return D3DRMERR_BADVALUE;
1890 *u = This->pCoords2d[index].u;
1891 *v = This->pCoords2d[index].v;
1897 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1898 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1900 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1902 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1907 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1908 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1910 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1912 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1917 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
1918 LPDIRECT3DRMFACE2* Face)
1920 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1922 FIXME("(%p)->(%p): stub\n", This, Face);
1927 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
1929 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1931 FIXME("(%p)->(): stub\n", This);
1936 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
1938 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1940 FIXME("(%p)->(): stub\n", This);
1945 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
1947 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1949 TRACE("(%p)->()\n", This);
1951 return This->nb_faces;
1954 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
1956 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1958 TRACE("(%p)->()\n", This);
1960 return This->nb_vertices;
1963 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
1966 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1968 FIXME("(%p)->(%d): stub\n", This, index);
1973 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
1974 LPDIRECT3DRMMESH* mesh)
1976 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1978 D3DRMGROUPINDEX group;
1980 TRACE("(%p)->(%p)\n", This, mesh);
1985 hr = Direct3DRMMesh_create(mesh);
1989 /* If there is mesh data, create a group and put data inside */
1990 if (This->nb_vertices)
1992 unsigned* face_data;
1994 DWORD* in_ptr = This->pFaceData;
1997 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2000 IDirect3DRMMesh_Release(*mesh);
2001 return E_OUTOFMEMORY;
2003 out_ptr = face_data;
2005 /* Put only vertex indices */
2006 for (i = 0; i < This->nb_faces; i++)
2008 DWORD nb_indices = *out_ptr++ = *in_ptr++;
2009 for (j = 0; j < nb_indices; j++)
2011 *out_ptr++ = *in_ptr++;
2012 /* Skip normal index */
2017 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
2018 HeapFree(GetProcessHeap(), 0, face_data);
2021 D3DRMVERTEX* vertices;
2023 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2026 for (i = 0; i < This->nb_vertices; i++)
2028 vertices[i].position = This->pVertices[i];
2030 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2031 HeapFree(GetProcessHeap(), 0, vertices);
2039 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2041 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2042 if (SUCCEEDED(hr) && This->texture)
2044 LPDIRECT3DRMTEXTURE texture;
2046 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2047 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2048 IDirect3DRMTexture_Release(texture);
2051 IDirect3DRMMesh_Release(*mesh);
2057 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2058 DWORD index, LPDIRECT3DRMFACE2* Face)
2060 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2062 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2067 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2068 DWORD index, LPD3DVECTOR vector)
2070 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2072 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2077 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2078 DWORD index, LPD3DVECTOR vector)
2080 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2082 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2087 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2088 DWORD IndexFirst, DWORD count)
2090 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2092 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2097 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2098 DWORD IndexFirst, DWORD count)
2100 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2102 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2107 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2108 LPDIRECT3DRMFACE2 Face)
2110 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2112 FIXME("(%p)->(%p): stub\n", This, Face);
2117 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2119 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2121 FIXME("(%p)->(%u): stub\n", This, flags);
2126 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2129 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2131 FIXME("(%p)->(%u): stub\n", This, flags);
2136 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2137 DWORD flags, DWORD* indices,
2138 DWORD* IndexFirst, DWORD* count)
2140 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2142 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2147 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2150 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2152 FIXME("(%p)->(%p): stub\n", This, unkwn);
2157 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2158 DWORD flags, LPUNKNOWN *unkwn)
2160 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2162 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2167 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2168 LPDWORD count, LPUNKNOWN *unkwn)
2170 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2172 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2177 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2180 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2182 FIXME("(%p)->(%p): stub\n", This, unkwn);
2187 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2190 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2192 FIXME("(%p)->(%u): stub\n", This, index);
2197 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2200 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2202 FIXME("(%p)->(%p): stub\n", This, indices);
2207 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2208 DWORD flags, DWORD format,
2209 DWORD VertexCount, LPVOID data)
2211 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2213 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2218 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2219 DWORD IndexFirst, DWORD count,
2222 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2224 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2229 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2230 DWORD IndexFirst, LPDWORD vcount,
2231 LPD3DVECTOR vertices)
2233 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2234 DWORD count = This->nb_vertices - IndexFirst;
2236 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2240 if (vertices && This->nb_vertices)
2241 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2246 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2247 DWORD IndexFirst, DWORD count,
2250 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2252 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2257 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2258 DWORD IndexFirst, LPDWORD count,
2261 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2263 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2268 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2270 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2272 FIXME("(%p)->(): stub\n", This);
2277 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2279 /*** IUnknown methods ***/
2280 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2281 IDirect3DRMMeshBuilder3Impl_AddRef,
2282 IDirect3DRMMeshBuilder3Impl_Release,
2283 /*** IDirect3DRMObject methods ***/
2284 IDirect3DRMMeshBuilder3Impl_Clone,
2285 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2286 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2287 IDirect3DRMMeshBuilder3Impl_SetAppData,
2288 IDirect3DRMMeshBuilder3Impl_GetAppData,
2289 IDirect3DRMMeshBuilder3Impl_SetName,
2290 IDirect3DRMMeshBuilder3Impl_GetName,
2291 IDirect3DRMMeshBuilder3Impl_GetClassName,
2292 /*** IDirect3DRMMeshBuilder3 methods ***/
2293 IDirect3DRMMeshBuilder3Impl_Load,
2294 IDirect3DRMMeshBuilder3Impl_Save,
2295 IDirect3DRMMeshBuilder3Impl_Scale,
2296 IDirect3DRMMeshBuilder3Impl_Translate,
2297 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2298 IDirect3DRMMeshBuilder3Impl_GetBox,
2299 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2300 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2301 IDirect3DRMMeshBuilder3Impl_AddMesh,
2302 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2303 IDirect3DRMMeshBuilder3Impl_AddFrame,
2304 IDirect3DRMMeshBuilder3Impl_AddFace,
2305 IDirect3DRMMeshBuilder3Impl_AddFaces,
2306 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2307 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2308 IDirect3DRMMeshBuilder3Impl_SetColor,
2309 IDirect3DRMMeshBuilder3Impl_SetTexture,
2310 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2311 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2312 IDirect3DRMMeshBuilder3Impl_SetQuality,
2313 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2314 IDirect3DRMMeshBuilder3Impl_SetVertex,
2315 IDirect3DRMMeshBuilder3Impl_SetNormal,
2316 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2317 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2318 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2319 IDirect3DRMMeshBuilder3Impl_GetFaces,
2320 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2321 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2322 IDirect3DRMMeshBuilder3Impl_AddVertex,
2323 IDirect3DRMMeshBuilder3Impl_AddNormal,
2324 IDirect3DRMMeshBuilder3Impl_CreateFace,
2325 IDirect3DRMMeshBuilder3Impl_GetQuality,
2326 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2327 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2328 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2329 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2330 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2331 IDirect3DRMMeshBuilder3Impl_GetFace,
2332 IDirect3DRMMeshBuilder3Impl_GetVertex,
2333 IDirect3DRMMeshBuilder3Impl_GetNormal,
2334 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2335 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2336 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2337 IDirect3DRMMeshBuilder3Impl_Empty,
2338 IDirect3DRMMeshBuilder3Impl_Optimize,
2339 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2340 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2341 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2342 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2343 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2344 IDirect3DRMMeshBuilder3Impl_Enable,
2345 IDirect3DRMMeshBuilder3Impl_GetEnable,
2346 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2347 IDirect3DRMMeshBuilder3Impl_SetVertices,
2348 IDirect3DRMMeshBuilder3Impl_GetVertices,
2349 IDirect3DRMMeshBuilder3Impl_SetNormals,
2350 IDirect3DRMMeshBuilder3Impl_GetNormals,
2351 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2354 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2356 IDirect3DRMMeshBuilderImpl* object;
2358 TRACE("(%p)\n", ppObj);
2360 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2363 ERR("Out of memory\n");
2364 return E_OUTOFMEMORY;
2367 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2368 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2371 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2372 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2374 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2379 /*** IUnknown methods ***/
2380 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2381 REFIID riid, void** ppvObject)
2383 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2385 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2389 if (IsEqualGUID(riid, &IID_IUnknown) ||
2390 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2392 *ppvObject = &This->IDirect3DRMMesh_iface;
2396 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2397 return E_NOINTERFACE;
2400 IDirect3DRMMesh_AddRef(iface);
2404 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2406 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2407 ULONG ref = InterlockedIncrement(&This->ref);
2409 TRACE("(%p)->(): new ref = %d\n", This, ref);
2414 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2416 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2417 ULONG ref = InterlockedDecrement(&This->ref);
2419 TRACE("(%p)->(): new ref = %d\n", This, ref);
2425 for (i = 0; i < This->nb_groups; i++)
2426 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2427 HeapFree(GetProcessHeap(), 0, This->groups);
2428 HeapFree(GetProcessHeap(), 0, This);
2434 /*** IDirect3DRMObject methods ***/
2435 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2436 LPUNKNOWN pUnkOuter, REFIID riid,
2439 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2441 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2446 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2447 D3DRMOBJECTCALLBACK cb,
2450 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2452 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2457 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2458 D3DRMOBJECTCALLBACK cb,
2461 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2463 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2468 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2471 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2473 FIXME("(%p)->(%u): stub\n", This, data);
2478 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2480 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2482 FIXME("(%p)->(): stub\n", This);
2487 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2490 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2492 FIXME("(%p)->(%s): stub\n", This, pName);
2497 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2498 LPDWORD lpdwSize, LPSTR lpName)
2500 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2502 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2507 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2508 LPDWORD lpdwSize, LPSTR lpName)
2510 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2512 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2517 /*** IDirect3DRMMesh methods ***/
2518 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2519 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2521 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2523 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2528 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2529 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2531 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2533 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2538 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2541 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2543 FIXME("(%p)->(%p): stub\n", This, box);
2548 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2549 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2550 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2552 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2555 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2557 if (!face_data || !return_id)
2560 if ((This->nb_groups + 1) > This->groups_capacity)
2565 if (!This->groups_capacity)
2568 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2572 new_capacity = This->groups_capacity * 2;
2573 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2577 return E_OUTOFMEMORY;
2579 This->groups_capacity = new_capacity;
2580 This->groups = groups;
2583 group = This->groups + This->nb_groups;
2585 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2586 if (!group->vertices)
2587 return E_OUTOFMEMORY;
2588 group->nb_vertices = vertex_count;
2589 group->nb_faces = face_count;
2590 group->vertex_per_face = vertex_per_face;
2592 if (vertex_per_face)
2594 group->face_data_size = face_count * vertex_per_face;
2599 unsigned nb_indices;
2600 unsigned* face_data_ptr = face_data;
2601 group->face_data_size = 0;
2603 for (i = 0; i < face_count; i++)
2605 nb_indices = *face_data_ptr;
2606 group->face_data_size += nb_indices + 1;
2607 face_data_ptr += nb_indices;
2611 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2612 if (!group->face_data)
2614 HeapFree(GetProcessHeap(), 0 , group->vertices);
2615 return E_OUTOFMEMORY;
2618 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2620 group->material = NULL;
2621 group->texture = NULL;
2623 *return_id = This->nb_groups++;
2628 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2629 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2630 D3DRMVERTEX *values)
2632 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2634 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2636 if (id >= This->nb_groups)
2637 return D3DRMERR_BADVALUE;
2639 if ((index + count - 1) >= This->groups[id].nb_vertices)
2640 return D3DRMERR_BADVALUE;
2645 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2650 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2651 D3DRMGROUPINDEX id, D3DCOLOR color)
2653 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2655 TRACE("(%p)->(%u,%x)\n", This, id, color);
2657 if (id >= This->nb_groups)
2658 return D3DRMERR_BADVALUE;
2660 This->groups[id].color = color;
2665 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2666 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2668 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2670 FIXME("(%p)->(%u,%f,%f,%f): stub\n", This, id, red, green, blue);
2675 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2676 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2678 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2680 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2685 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2686 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2688 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2690 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2695 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2696 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2698 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2700 TRACE("(%p)->(%u,%p)\n", This, id, material);
2702 if (id >= This->nb_groups)
2703 return D3DRMERR_BADVALUE;
2705 if (This->groups[id].material)
2706 IDirect3DRMMaterial2_Release(This->groups[id].material);
2708 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2711 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2716 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2717 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2719 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2721 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2723 if (id >= This->nb_groups)
2724 return D3DRMERR_BADVALUE;
2726 if (This->groups[id].texture)
2727 IDirect3DRMTexture3_Release(This->groups[id].texture);
2731 This->groups[id].texture = NULL;
2735 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2738 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2740 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2742 TRACE("(%p)->()\n", This);
2744 return This->nb_groups;
2747 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2748 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2749 DWORD *face_data_size, unsigned *face_data)
2751 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2753 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2755 if (id >= This->nb_groups)
2756 return D3DRMERR_BADVALUE;
2759 *vertex_count = This->groups[id].nb_vertices;
2761 *face_count = This->groups[id].nb_faces;
2762 if (vertex_per_face)
2763 *vertex_per_face = This->groups[id].vertex_per_face;
2765 *face_data_size = This->groups[id].face_data_size;
2767 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2772 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2773 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2775 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2777 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2779 if (id >= This->nb_groups)
2780 return D3DRMERR_BADVALUE;
2782 if ((index + count - 1) >= This->groups[id].nb_vertices)
2783 return D3DRMERR_BADVALUE;
2788 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2793 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2795 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2797 TRACE("(%p)->(%u)\n", This, id);
2799 return This->groups[id].color;
2802 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2804 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2806 FIXME("(%p)->(%u): stub\n", This, id);
2810 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2812 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2814 FIXME("(%p)->(%u): stub\n", This, id);
2819 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2820 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2822 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2824 TRACE("(%p)->(%u,%p)\n", This, id, material);
2826 if (id >= This->nb_groups)
2827 return D3DRMERR_BADVALUE;
2832 if (This->groups[id].material)
2833 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2840 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2841 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2843 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2845 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2847 if (id >= This->nb_groups)
2848 return D3DRMERR_BADVALUE;
2853 if (This->groups[id].texture)
2854 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2861 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2863 /*** IUnknown methods ***/
2864 IDirect3DRMMeshImpl_QueryInterface,
2865 IDirect3DRMMeshImpl_AddRef,
2866 IDirect3DRMMeshImpl_Release,
2867 /*** IDirect3DRMObject methods ***/
2868 IDirect3DRMMeshImpl_Clone,
2869 IDirect3DRMMeshImpl_AddDestroyCallback,
2870 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2871 IDirect3DRMMeshImpl_SetAppData,
2872 IDirect3DRMMeshImpl_GetAppData,
2873 IDirect3DRMMeshImpl_SetName,
2874 IDirect3DRMMeshImpl_GetName,
2875 IDirect3DRMMeshImpl_GetClassName,
2876 /*** IDirect3DRMMesh methods ***/
2877 IDirect3DRMMeshImpl_Scale,
2878 IDirect3DRMMeshImpl_Translate,
2879 IDirect3DRMMeshImpl_GetBox,
2880 IDirect3DRMMeshImpl_AddGroup,
2881 IDirect3DRMMeshImpl_SetVertices,
2882 IDirect3DRMMeshImpl_SetGroupColor,
2883 IDirect3DRMMeshImpl_SetGroupColorRGB,
2884 IDirect3DRMMeshImpl_SetGroupMapping,
2885 IDirect3DRMMeshImpl_SetGroupQuality,
2886 IDirect3DRMMeshImpl_SetGroupMaterial,
2887 IDirect3DRMMeshImpl_SetGroupTexture,
2888 IDirect3DRMMeshImpl_GetGroupCount,
2889 IDirect3DRMMeshImpl_GetGroup,
2890 IDirect3DRMMeshImpl_GetVertices,
2891 IDirect3DRMMeshImpl_GetGroupColor,
2892 IDirect3DRMMeshImpl_GetGroupMapping,
2893 IDirect3DRMMeshImpl_GetGroupQuality,
2894 IDirect3DRMMeshImpl_GetGroupMaterial,
2895 IDirect3DRMMeshImpl_GetGroupTexture
2898 static HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2900 IDirect3DRMMeshImpl* object;
2902 TRACE("(%p)\n", obj);
2904 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2907 ERR("Out of memory\n");
2908 return E_OUTOFMEMORY;
2911 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
2914 *obj = &object->IDirect3DRMMesh_iface;