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);
371 IDirect3DRMTexture3_Release(This->texture);
372 HeapFree(GetProcessHeap(), 0, This->name);
373 HeapFree(GetProcessHeap(), 0, This->pVertices);
374 HeapFree(GetProcessHeap(), 0, This->pNormals);
375 HeapFree(GetProcessHeap(), 0, This->pFaceData);
376 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
377 HeapFree(GetProcessHeap(), 0, This);
383 /*** IDirect3DRMObject methods ***/
384 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2* iface,
385 LPUNKNOWN pUnkOuter, REFIID riid,
388 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
390 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
395 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2* iface,
396 D3DRMOBJECTCALLBACK cb,
399 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
401 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
406 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2* iface,
407 D3DRMOBJECTCALLBACK cb,
410 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
412 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
417 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
420 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
422 FIXME("(%p)->(%u): stub\n", This, data);
427 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
429 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
431 FIXME("(%p)->(): stub\n", This);
436 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2* iface,
439 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
441 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
443 return IDirect3DRMMeshBuilder3_SetName(&This->IDirect3DRMMeshBuilder3_iface, name);
446 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2* iface,
447 LPDWORD size, LPSTR name)
449 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
451 TRACE("(%p)->(%p,%p)\n", This, size, name);
453 return IDirect3DRMMeshBuilder3_GetName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
456 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2* iface,
457 LPDWORD lpdwSize, LPSTR lpName)
459 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
461 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
466 /*** IDirect3DRMMeshBuilder2 methods ***/
467 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2* iface,
468 LPVOID filename, LPVOID name,
469 D3DRMLOADOPTIONS loadflags,
470 D3DRMLOADTEXTURECALLBACK cb, LPVOID arg)
472 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
474 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
477 FIXME("Texture callback is not yet supported\n");
479 return IDirect3DRMMeshBuilder3_Load(&This->IDirect3DRMMeshBuilder3_iface, filename, name,
480 loadflags, NULL, arg);
483 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
484 const char *filename, D3DRMXOFFORMAT format,
485 D3DRMSAVEOPTIONS save)
487 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
489 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
494 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
495 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
497 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
499 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
501 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
504 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
505 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
507 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
509 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
514 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
515 D3DRMCOLORSOURCE color)
517 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
519 FIXME("(%p)->(%x): stub\n", This, color);
524 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
527 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
529 FIXME("(%p)->(%p): stub\n", This, pBox);
534 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
536 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
538 FIXME("(%p)->(): stub\n", This);
543 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
545 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
547 FIXME("(%p)->(): stub\n", This);
552 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2* iface,
553 LPDIRECT3DRMMESH pMesh)
555 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
557 FIXME("(%p)->(%p): stub\n", This, pMesh);
562 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2* iface,
563 LPDIRECT3DRMMESHBUILDER pMeshBuilder)
565 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
567 FIXME("(%p)->(%p): stub\n", This, pMeshBuilder);
572 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2* iface,
573 LPDIRECT3DRMFRAME pFrame)
575 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
577 FIXME("(%p)->(%p): stub\n", This, pFrame);
582 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2* iface,
583 LPDIRECT3DRMFACE pFace)
585 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
587 FIXME("(%p)->(%p): stub\n", This, pFace);
592 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2* iface,
593 DWORD vcount, D3DVECTOR *vertices,
594 DWORD ncount, D3DVECTOR *normals,
596 LPDIRECT3DRMFACEARRAY* pFaceArray)
598 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
600 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals, data, pFaceArray);
605 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
610 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
612 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
617 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
618 D3DVALUE red, D3DVALUE green,
621 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
623 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
625 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
628 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
631 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
633 TRACE("(%p)->(%x)\n", This, color);
635 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
638 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2* iface,
639 LPDIRECT3DRMTEXTURE texture)
641 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
642 LPDIRECT3DRMTEXTURE3 texture3 = NULL;
643 HRESULT hr = D3DRM_OK;
646 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
648 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
650 IDirect3DRMTexture3_Release(texture3);
655 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2* iface,
656 LPDIRECT3DRMMATERIAL material)
658 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
660 TRACE("(%p)->(%p)\n", This, material);
662 return IDirect3DRMMeshBuilder3_SetMaterial(&This->IDirect3DRMMeshBuilder3_iface, (LPDIRECT3DRMMATERIAL2)material);
665 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
666 BOOL wrap_u, BOOL wrap_v)
668 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
670 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
675 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
676 D3DRMRENDERQUALITY quality)
678 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
680 FIXME("(%p)->(%d): stub\n", This, quality);
685 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
688 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
690 FIXME("(%p)->(%d): stub\n", This, enable);
695 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
697 D3DVALUE x, D3DVALUE y, D3DVALUE z)
699 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
701 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
706 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
708 D3DVALUE x, D3DVALUE y, D3DVALUE z)
710 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
712 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
717 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
719 D3DVALUE u, D3DVALUE v)
721 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
723 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
725 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
729 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
730 DWORD index, D3DCOLOR color)
732 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
734 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
739 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
740 DWORD index, D3DVALUE red,
741 D3DVALUE green, D3DVALUE blue)
743 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
745 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
750 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2* iface,
751 LPDIRECT3DRMFACEARRAY* pFaceArray)
753 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
755 FIXME("(%p)->(%p): stub\n", This, pFaceArray);
760 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
761 DWORD *vcount, D3DVECTOR *vertices,
762 DWORD *ncount, D3DVECTOR *normals,
763 DWORD *face_data_size,
766 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
768 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
771 *vcount = This->nb_vertices;
772 if (vertices && This->nb_vertices)
773 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
775 *ncount = This->nb_normals;
776 if (normals && This->nb_normals)
777 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
779 *face_data_size = This->face_data_size;
780 if (face_data && This->face_data_size)
781 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
786 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
788 D3DVALUE *u, D3DVALUE *v)
790 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
792 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
794 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
798 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
799 D3DVALUE x, D3DVALUE y, D3DVALUE z)
801 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
803 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
808 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
809 D3DVALUE x, D3DVALUE y, D3DVALUE z)
811 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
813 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
818 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2* iface,
819 LPDIRECT3DRMFACE* ppFace)
821 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
823 FIXME("(%p)->(%p): stub\n", This, ppFace);
828 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
830 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
832 FIXME("(%p)->(): stub\n", This);
837 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
839 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
841 FIXME("(%p)->(): stub\n", This);
846 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
848 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
850 TRACE("(%p)->()\n", This);
852 return This->nb_faces;
855 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
857 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
859 TRACE("(%p)->()\n", This);
861 return This->nb_vertices;
864 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
867 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
869 FIXME("(%p)->(%d): stub\n", This, index);
874 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2* iface,
875 LPDIRECT3DRMMESH* mesh)
877 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
879 TRACE("(%p)->(%p)\n", This, mesh);
881 return IDirect3DRMMeshBuilder3_CreateMesh(&This->IDirect3DRMMeshBuilder3_iface, mesh);
884 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
885 D3DVALUE crease, DWORD dwFlags)
887 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
889 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
894 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2* iface,
895 DWORD index, LPDIRECT3DRMFACE* ppFace)
897 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
899 FIXME("(%p)->(%u,%p): stub\n", This, index, ppFace);
904 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
906 /*** IUnknown methods ***/
907 IDirect3DRMMeshBuilder2Impl_QueryInterface,
908 IDirect3DRMMeshBuilder2Impl_AddRef,
909 IDirect3DRMMeshBuilder2Impl_Release,
910 /*** IDirect3DRMObject methods ***/
911 IDirect3DRMMeshBuilder2Impl_Clone,
912 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
913 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
914 IDirect3DRMMeshBuilder2Impl_SetAppData,
915 IDirect3DRMMeshBuilder2Impl_GetAppData,
916 IDirect3DRMMeshBuilder2Impl_SetName,
917 IDirect3DRMMeshBuilder2Impl_GetName,
918 IDirect3DRMMeshBuilder2Impl_GetClassName,
919 /*** IDirect3DRMMeshBuilder methods ***/
920 IDirect3DRMMeshBuilder2Impl_Load,
921 IDirect3DRMMeshBuilder2Impl_Save,
922 IDirect3DRMMeshBuilder2Impl_Scale,
923 IDirect3DRMMeshBuilder2Impl_Translate,
924 IDirect3DRMMeshBuilder2Impl_SetColorSource,
925 IDirect3DRMMeshBuilder2Impl_GetBox,
926 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
927 IDirect3DRMMeshBuilder2Impl_GetColorSource,
928 IDirect3DRMMeshBuilder2Impl_AddMesh,
929 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
930 IDirect3DRMMeshBuilder2Impl_AddFrame,
931 IDirect3DRMMeshBuilder2Impl_AddFace,
932 IDirect3DRMMeshBuilder2Impl_AddFaces,
933 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
934 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
935 IDirect3DRMMeshBuilder2Impl_SetColor,
936 IDirect3DRMMeshBuilder2Impl_SetTexture,
937 IDirect3DRMMeshBuilder2Impl_SetMaterial,
938 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
939 IDirect3DRMMeshBuilder2Impl_SetQuality,
940 IDirect3DRMMeshBuilder2Impl_SetPerspective,
941 IDirect3DRMMeshBuilder2Impl_SetVertex,
942 IDirect3DRMMeshBuilder2Impl_SetNormal,
943 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
944 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
945 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
946 IDirect3DRMMeshBuilder2Impl_GetFaces,
947 IDirect3DRMMeshBuilder2Impl_GetVertices,
948 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
949 IDirect3DRMMeshBuilder2Impl_AddVertex,
950 IDirect3DRMMeshBuilder2Impl_AddNormal,
951 IDirect3DRMMeshBuilder2Impl_CreateFace,
952 IDirect3DRMMeshBuilder2Impl_GetQuality,
953 IDirect3DRMMeshBuilder2Impl_GetPerspective,
954 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
955 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
956 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
957 IDirect3DRMMeshBuilder2Impl_CreateMesh,
958 /*** IDirect3DRMMeshBuilder2 methods ***/
959 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
960 IDirect3DRMMeshBuilder2Impl_GetFace
964 /*** IUnknown methods ***/
965 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
966 REFIID riid, void** ppvObject)
968 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
969 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
972 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
974 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
975 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
978 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
980 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
981 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
984 /*** IDirect3DRMObject methods ***/
985 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3* iface,
986 LPUNKNOWN pUnkOuter, REFIID riid,
989 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
991 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
996 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
997 D3DRMOBJECTCALLBACK cb,
1000 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1002 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1007 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1008 D3DRMOBJECTCALLBACK cb,
1011 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1013 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1018 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1021 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1023 FIXME("(%p)->(%u): stub\n", This, data);
1028 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1030 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1032 FIXME("(%p)->(): stub\n", This);
1037 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1040 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1041 char *string = NULL;
1043 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
1047 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1048 if (!string) return E_OUTOFMEMORY;
1049 strcpy(string, name);
1051 HeapFree(GetProcessHeap(), 0, This->name);
1052 This->name = string;
1057 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3* iface,
1058 LPDWORD size, LPSTR name)
1060 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1062 TRACE("(%p)->(%p,%p)\n", This, size, name);
1073 if (*size < (strlen(This->name) + 1))
1074 return E_INVALIDARG;
1076 strcpy(name, This->name);
1077 *size = strlen(This->name) + 1;
1082 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3* iface,
1083 LPDWORD lpdwSize, LPSTR lpName)
1085 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1087 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
1092 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
1094 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1095 LPDIRECTXFILEOBJECT pObject = NULL;
1096 LPDIRECTXFILEDATA pData2 = NULL;
1101 HRESULT ret = D3DRMERR_BADOBJECT;
1102 DWORD* faces_vertex_idx_data = NULL;
1103 DWORD* faces_vertex_idx_ptr;
1104 DWORD faces_vertex_idx_size;
1105 DWORD* faces_normal_idx_data = NULL;
1106 DWORD* faces_normal_idx_ptr = NULL;
1107 DWORD* faces_data_ptr;
1108 DWORD faces_data_size = 0;
1111 TRACE("(%p)->(%p)\n", This, pData);
1113 /* Remove previous name */
1114 HeapFree(GetProcessHeap(), 0, This->name);
1116 hr = IDirectXFileData_GetName(pData, NULL, &size);
1117 if (hr != DXFILE_OK)
1121 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1123 return E_OUTOFMEMORY;
1125 hr = IDirectXFileData_GetName(pData, This->name, &size);
1126 if (hr != DXFILE_OK)
1128 HeapFree(GetProcessHeap(), 0, This->name);
1134 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1136 This->nb_normals = 0;
1138 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1139 if (hr != DXFILE_OK)
1142 This->nb_vertices = *(DWORD*)ptr;
1143 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1144 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1145 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1147 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1149 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1150 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1152 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1153 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1155 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1156 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size*2);
1157 faces_data_ptr = (DWORD*)This->pFaceData;
1161 hr = IDirectXFileData_GetNextObject(pData, &pObject);
1162 if (hr == DXFILEERR_NOMOREOBJECTS)
1164 TRACE("No more object\n");
1167 if (hr != DXFILE_OK)
1170 hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
1171 IDirectXFileObject_Release(pObject);
1172 if (hr != DXFILE_OK)
1175 hr = IDirectXFileData_GetType(pData2, &pGuid);
1176 if (hr != DXFILE_OK)
1179 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1181 if (IsEqualGUID(pGuid, &TID_D3DRMMeshNormals))
1183 DWORD nb_faces_normals;
1184 DWORD faces_normal_idx_size;
1186 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1187 if (hr != DXFILE_OK)
1190 This->nb_normals = *(DWORD*)ptr;
1191 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1193 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1194 if (nb_faces_normals != This->nb_faces)
1195 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1197 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1198 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1200 faces_normal_idx_size = size - (2*sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1201 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1202 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1204 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshTextureCoords))
1206 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1207 if (hr != DXFILE_OK)
1210 This->nb_coords2d = *(DWORD*)ptr;
1212 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1214 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1215 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1218 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshMaterialList))
1221 DWORD nb_face_indices;
1223 LPDIRECTXFILEOBJECT child;
1227 TRACE("Process MeshMaterialList\n");
1229 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1230 if (hr != DXFILE_OK)
1233 nb_materials = *(DWORD*)ptr;
1234 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1235 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1237 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1239 if (size != data_size)
1240 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1242 if (nb_materials > 2)
1244 FIXME("Only one material per mesh supported, first one applies to all faces\n");
1248 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1250 LPDIRECTXFILEDATA data;
1251 LPDIRECTXFILEDATAREFERENCE reference;
1252 LPDIRECT3DRMMATERIAL2 material;
1253 LPDIRECTXFILEOBJECT material_child;
1255 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1258 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1262 hr = IDirectXFileDataReference_Resolve(reference, &data);
1263 IDirectXFileDataReference_Release(reference);
1268 hr = Direct3DRMMaterial_create(&material);
1271 IDirectXFileData_Release(data);
1275 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1276 if (hr != DXFILE_OK)
1278 IDirectXFileData_Release(data);
1283 WARN("Material size %u does not match expected one %u\n", size, 44);
1285 values = (float*)ptr;
1287 IDirect3DRMMeshBuilder3_SetColorRGB(iface, values[0], values [1], values[2]); /* Alpha ignored */
1289 IDirect3DRMMaterial2_SetAmbient(material, values[0], values [1], values[2]); /* Alpha ignored */
1290 IDirect3DRMMaterial2_SetPower(material, values[4]);
1291 IDirect3DRMMaterial2_SetSpecular(material, values[5], values[6], values[7]);
1292 IDirect3DRMMaterial2_SetEmissive(material, values[8], values[9], values[10]);
1294 This->material = material;
1296 hr = IDirectXFileData_GetNextObject(data, &material_child);
1299 LPDIRECTXFILEDATA data;
1300 LPDIRECT3DRMTEXTURE3 texture;
1303 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1306 LPDIRECTXFILEDATAREFERENCE reference;
1308 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1312 hr = IDirectXFileDataReference_Resolve(reference, &data);
1313 IDirectXFileDataReference_Release(reference);
1318 hr = IDirectXFileData_GetType(data, &pGuid);
1319 if (hr != DXFILE_OK)
1321 if (!IsEqualGUID(pGuid, &TID_D3DRMTextureFilename))
1323 WARN("Not a texture filename\n");
1328 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1333 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1334 if (file != INVALID_HANDLE_VALUE)
1336 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&texture);
1339 IDirectXFileData_Release(data);
1342 This->texture = texture;
1346 else if (hr != DXFILEERR_NOMOREOBJECTS)
1352 IDirectXFileData_Release(data);
1356 WARN("Found more sub-objects than expected\n");
1357 else if (hr != DXFILEERR_NOMOREOBJECTS)
1363 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
1366 IDirectXFileData_Release(pData2);
1370 if (!This->nb_normals)
1372 /* Allocate normals, one per vertex */
1373 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1374 if (!This->pNormals)
1378 for (i = 0; i < This->nb_faces; i++)
1381 DWORD nb_face_indexes;
1382 D3DVECTOR face_normal;
1384 if (faces_vertex_idx_size < sizeof(DWORD))
1385 WARN("Not enough data to read number of indices of face %d\n", i);
1387 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1388 faces_vertex_idx_size--;
1389 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1390 WARN("Faces indices number mismatch\n");
1392 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1393 WARN("Not enough data to read all indices of face %d\n", i);
1395 if (!This->nb_normals)
1397 /* Compute face normal */
1398 if (nb_face_indexes > 2)
1402 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1403 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[1]], &This->pVertices[faces_vertex_idx_ptr[0]]);
1404 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1405 D3DRMVectorNormalize(&face_normal);
1409 face_normal.u1.x = 0.0f;
1410 face_normal.u2.y = 0.0f;
1411 face_normal.u3.z = 0.0f;
1415 for (j = 0; j < nb_face_indexes; j++)
1417 /* Copy vertex index */
1418 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1419 /* Copy normal index */
1420 if (This->nb_normals)
1422 /* Read from x file */
1423 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1427 DWORD vertex_idx = *faces_vertex_idx_ptr;
1428 if (vertex_idx >= This->nb_vertices)
1430 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1433 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1434 /* Add face normal to vertex normal */
1435 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1437 faces_vertex_idx_ptr++;
1439 faces_vertex_idx_size -= nb_face_indexes;
1442 /* Last DWORD must be 0 */
1443 *(faces_data_ptr + faces_data_size++) = 0;
1445 /* Set size (in number of DWORD) of all faces data */
1446 This->face_data_size = faces_data_size;
1448 if (!This->nb_normals)
1450 /* Normalize all normals */
1451 for (i = 0; i < This->nb_vertices; i++)
1453 D3DRMVectorNormalize(&This->pNormals[i]);
1455 This->nb_normals = This->nb_vertices;
1458 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1459 if (!This->pCoords2d)
1461 This->nb_coords2d = This->nb_vertices;
1462 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1463 for (i = 0; i < This->nb_coords2d; i++)
1465 This->pCoords2d[i].u = 0.0f;
1466 This->pCoords2d[i].v = 0.0f;
1470 TRACE("Mesh data loaded successfully\n");
1476 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1477 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1482 /*** IDirect3DRMMeshBuilder3 methods ***/
1483 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1484 LPVOID filename, LPVOID name,
1485 D3DRMLOADOPTIONS loadflags,
1486 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1488 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1489 DXFILELOADOPTIONS load_options;
1490 LPDIRECTXFILE pDXFile = NULL;
1491 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1492 LPDIRECTXFILEDATA pData = NULL;
1493 LPDIRECTXFILEDATA pData2 = NULL;
1498 HRESULT ret = D3DRMERR_BADOBJECT;
1500 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1502 /* First free allocated buffers of previous mesh data */
1503 HeapFree(GetProcessHeap(), 0, This->pVertices);
1504 This->pVertices = NULL;
1505 HeapFree(GetProcessHeap(), 0, This->pNormals);
1506 This->pNormals = NULL;
1507 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1508 This->pFaceData = NULL;
1509 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1510 This->pCoords2d = NULL;
1512 if (loadflags == D3DRMLOAD_FROMMEMORY)
1514 load_options = DXFILELOAD_FROMMEMORY;
1516 else if (loadflags == D3DRMLOAD_FROMFILE)
1518 load_options = DXFILELOAD_FROMFILE;
1519 TRACE("Loading from file %s\n", debugstr_a(filename));
1523 FIXME("Load options %d not supported yet\n", loadflags);
1527 hr = DirectXFileCreate(&pDXFile);
1528 if (hr != DXFILE_OK)
1531 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1532 if (hr != DXFILE_OK)
1535 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1536 if (hr != DXFILE_OK)
1539 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1540 if (hr != DXFILE_OK)
1543 hr = IDirectXFileData_GetType(pData, &pGuid);
1544 if (hr != DXFILE_OK)
1547 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1549 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1551 ret = D3DRMERR_BADFILE;
1555 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1556 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1559 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1561 /* Version must be 1.0.x */
1562 if ((pHeader->major != 1) || (pHeader->minor != 0))
1564 ret = D3DRMERR_BADFILE;
1568 IDirectXFileData_Release(pData);
1571 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1572 if (hr != DXFILE_OK)
1574 ret = D3DRMERR_NOTFOUND;
1578 hr = IDirectXFileData_GetType(pData, &pGuid);
1579 if (hr != DXFILE_OK)
1582 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1584 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1586 ret = D3DRMERR_NOTFOUND;
1590 hr = load_mesh_data(iface, pData);
1597 IDirectXFileData_Release(pData2);
1599 IDirectXFileData_Release(pData);
1601 IDirectXFileEnumObject_Release(pEnumObject);
1603 IDirectXFile_Release(pDXFile);
1605 if (ret != D3DRM_OK)
1607 /* Clean mesh data */
1608 This->nb_vertices = 0;
1609 This->nb_normals = 0;
1611 This->face_data_size = 0;
1612 This->nb_coords2d = 0;
1613 HeapFree(GetProcessHeap(), 0, This->pVertices);
1614 This->pVertices = NULL;
1615 HeapFree(GetProcessHeap(), 0, This->pNormals);
1616 This->pNormals = NULL;
1617 HeapFree(GetProcessHeap(), 0, This->pFaceData);
1618 This->pFaceData = NULL;
1619 HeapFree(GetProcessHeap(), 0, This->pCoords2d);
1620 This->pCoords2d = NULL;
1626 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1627 const char* filename, D3DRMXOFFORMAT format,
1628 D3DRMSAVEOPTIONS save)
1630 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1632 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1637 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1638 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1640 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1643 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1645 for (i = 0; i < This->nb_vertices; i++)
1647 This->pVertices[i].u1.x *= sx;
1648 This->pVertices[i].u2.y *= sy;
1649 This->pVertices[i].u3.z *= sz;
1652 /* Normals are not affected by Scale */
1657 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1658 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1660 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1662 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1667 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1668 D3DRMCOLORSOURCE color)
1670 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1672 FIXME("(%p)->(%x): stub\n", This, color);
1677 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1680 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1682 FIXME("(%p)->(%p): stub\n", This, box);
1687 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1688 D3DVALUE crease, DWORD flags)
1690 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1692 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1697 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1699 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1701 FIXME("(%p)->(): stub\n", This);
1706 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1707 LPDIRECT3DRMMESH Mesh)
1709 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1711 FIXME("(%p)->(%p): stub\n", This, Mesh);
1716 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1717 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1720 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1722 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1727 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1728 LPDIRECT3DRMFRAME3 Frame)
1730 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1732 FIXME("(%p)->(%p): stub\n", This, Frame);
1737 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1738 LPDIRECT3DRMFACE2 Face)
1740 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1742 FIXME("(%p)->(%p): stub\n", This, Face);
1747 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1748 DWORD vcount, D3DVECTOR* vertices,
1749 DWORD ncount, D3DVECTOR* normals,
1751 LPDIRECT3DRMFACEARRAY* FaceArray)
1753 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1755 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1756 normals, data, FaceArray);
1761 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1766 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1768 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1773 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1774 D3DVALUE red, D3DVALUE green,
1777 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1779 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1781 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1782 (BYTE)(green * 255.0f),
1783 (BYTE)(blue * 255.0f));
1788 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1791 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1793 TRACE("(%p)->(%x)\n", This, color);
1795 This->color = color;
1800 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1801 LPDIRECT3DRMTEXTURE3 texture)
1803 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1805 TRACE("(%p)->(%p)\n", This, texture);
1808 IDirect3DRMTexture3_AddRef(texture);
1810 IDirect3DRMTexture3_Release(This->texture);
1811 This->texture = texture;
1816 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1817 LPDIRECT3DRMMATERIAL2 material)
1819 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1821 TRACE("(%p)->(%p)\n", This, material);
1824 IDirect3DRMTexture2_AddRef(material);
1826 IDirect3DRMTexture2_Release(This->material);
1827 This->material = material;
1832 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1833 BOOL wrap_u, BOOL wrap_v)
1835 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1837 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1842 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1843 D3DRMRENDERQUALITY quality)
1845 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1847 FIXME("(%p)->(%d): stub\n", This, quality);
1852 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1855 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1857 FIXME("(%p)->(%d): stub\n", This, enable);
1862 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1864 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1866 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1868 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1873 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1875 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1877 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1879 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1884 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1885 DWORD index, D3DVALUE u,
1888 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1890 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1892 if (index >= This->nb_coords2d)
1893 return D3DRMERR_BADVALUE;
1895 This->pCoords2d[index].u = u;
1896 This->pCoords2d[index].v = v;
1901 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1902 DWORD index, D3DCOLOR color)
1904 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1906 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1911 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1913 D3DVALUE red, D3DVALUE green,
1916 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1918 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1923 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1924 LPDIRECT3DRMFACEARRAY* FaceArray)
1926 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1928 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1933 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1934 DWORD* vcount, D3DVECTOR* vertices,
1935 DWORD* ncount, D3DVECTOR* normals,
1936 DWORD* face_data_size,
1939 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1941 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1942 face_data_size, face_data);
1947 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1948 DWORD index, D3DVALUE* u,
1951 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1953 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1955 if (index >= This->nb_coords2d)
1956 return D3DRMERR_BADVALUE;
1958 *u = This->pCoords2d[index].u;
1959 *v = This->pCoords2d[index].v;
1965 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1966 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1968 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1970 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1975 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1976 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1978 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1980 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1985 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
1986 LPDIRECT3DRMFACE2* Face)
1988 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1990 FIXME("(%p)->(%p): stub\n", This, Face);
1995 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
1997 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1999 FIXME("(%p)->(): stub\n", This);
2004 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2006 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2008 FIXME("(%p)->(): stub\n", This);
2013 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2015 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2017 TRACE("(%p)->()\n", This);
2019 return This->nb_faces;
2022 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2024 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2026 TRACE("(%p)->()\n", This);
2028 return This->nb_vertices;
2031 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2034 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2036 FIXME("(%p)->(%d): stub\n", This, index);
2041 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
2042 LPDIRECT3DRMMESH* mesh)
2044 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2046 D3DRMGROUPINDEX group;
2048 TRACE("(%p)->(%p)\n", This, mesh);
2053 hr = Direct3DRMMesh_create(mesh);
2057 /* If there is mesh data, create a group and put data inside */
2058 if (This->nb_vertices)
2060 unsigned* face_data;
2062 DWORD* in_ptr = This->pFaceData;
2065 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2068 IDirect3DRMMesh_Release(*mesh);
2069 return E_OUTOFMEMORY;
2071 out_ptr = face_data;
2073 /* Put only vertex indices */
2074 for (i = 0; i < This->nb_faces; i++)
2076 DWORD nb_indices = *out_ptr++ = *in_ptr++;
2077 for (j = 0; j < nb_indices; j++)
2079 *out_ptr++ = *in_ptr++;
2080 /* Skip normal index */
2085 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, 0, face_data, &group);
2086 HeapFree(GetProcessHeap(), 0, face_data);
2089 D3DRMVERTEX* vertices;
2091 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2094 for (i = 0; i < This->nb_vertices; i++)
2096 vertices[i].position = This->pVertices[i];
2098 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2099 HeapFree(GetProcessHeap(), 0, vertices);
2107 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2109 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2110 if (SUCCEEDED(hr) && This->texture)
2112 LPDIRECT3DRMTEXTURE texture;
2114 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2115 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2116 IDirect3DRMTexture_Release(texture);
2119 IDirect3DRMMesh_Release(*mesh);
2125 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2126 DWORD index, LPDIRECT3DRMFACE2* Face)
2128 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2130 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2135 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2136 DWORD index, LPD3DVECTOR vector)
2138 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2140 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2145 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2146 DWORD index, LPD3DVECTOR vector)
2148 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2150 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2155 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2156 DWORD IndexFirst, DWORD count)
2158 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2160 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2165 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2166 DWORD IndexFirst, DWORD count)
2168 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2170 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2175 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2176 LPDIRECT3DRMFACE2 Face)
2178 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2180 FIXME("(%p)->(%p): stub\n", This, Face);
2185 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2187 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2189 FIXME("(%p)->(%u): stub\n", This, flags);
2194 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2197 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2199 FIXME("(%p)->(%u): stub\n", This, flags);
2204 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2205 DWORD flags, DWORD* indices,
2206 DWORD* IndexFirst, DWORD* count)
2208 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2210 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2215 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2218 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2220 FIXME("(%p)->(%p): stub\n", This, unkwn);
2225 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2226 DWORD flags, LPUNKNOWN *unkwn)
2228 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2230 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2235 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2236 LPDWORD count, LPUNKNOWN *unkwn)
2238 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2240 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2245 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2248 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2250 FIXME("(%p)->(%p): stub\n", This, unkwn);
2255 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2258 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2260 FIXME("(%p)->(%u): stub\n", This, index);
2265 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2268 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2270 FIXME("(%p)->(%p): stub\n", This, indices);
2275 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2276 DWORD flags, DWORD format,
2277 DWORD VertexCount, LPVOID data)
2279 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2281 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2286 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2287 DWORD IndexFirst, DWORD count,
2290 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2292 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2297 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2298 DWORD IndexFirst, LPDWORD vcount,
2299 LPD3DVECTOR vertices)
2301 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2302 DWORD count = This->nb_vertices - IndexFirst;
2304 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2308 if (vertices && This->nb_vertices)
2309 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2314 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2315 DWORD IndexFirst, DWORD count,
2318 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2320 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2325 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2326 DWORD IndexFirst, LPDWORD count,
2329 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2331 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2336 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2338 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2340 FIXME("(%p)->(): stub\n", This);
2345 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2347 /*** IUnknown methods ***/
2348 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2349 IDirect3DRMMeshBuilder3Impl_AddRef,
2350 IDirect3DRMMeshBuilder3Impl_Release,
2351 /*** IDirect3DRMObject methods ***/
2352 IDirect3DRMMeshBuilder3Impl_Clone,
2353 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2354 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2355 IDirect3DRMMeshBuilder3Impl_SetAppData,
2356 IDirect3DRMMeshBuilder3Impl_GetAppData,
2357 IDirect3DRMMeshBuilder3Impl_SetName,
2358 IDirect3DRMMeshBuilder3Impl_GetName,
2359 IDirect3DRMMeshBuilder3Impl_GetClassName,
2360 /*** IDirect3DRMMeshBuilder3 methods ***/
2361 IDirect3DRMMeshBuilder3Impl_Load,
2362 IDirect3DRMMeshBuilder3Impl_Save,
2363 IDirect3DRMMeshBuilder3Impl_Scale,
2364 IDirect3DRMMeshBuilder3Impl_Translate,
2365 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2366 IDirect3DRMMeshBuilder3Impl_GetBox,
2367 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2368 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2369 IDirect3DRMMeshBuilder3Impl_AddMesh,
2370 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2371 IDirect3DRMMeshBuilder3Impl_AddFrame,
2372 IDirect3DRMMeshBuilder3Impl_AddFace,
2373 IDirect3DRMMeshBuilder3Impl_AddFaces,
2374 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2375 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2376 IDirect3DRMMeshBuilder3Impl_SetColor,
2377 IDirect3DRMMeshBuilder3Impl_SetTexture,
2378 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2379 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2380 IDirect3DRMMeshBuilder3Impl_SetQuality,
2381 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2382 IDirect3DRMMeshBuilder3Impl_SetVertex,
2383 IDirect3DRMMeshBuilder3Impl_SetNormal,
2384 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2385 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2386 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2387 IDirect3DRMMeshBuilder3Impl_GetFaces,
2388 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2389 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2390 IDirect3DRMMeshBuilder3Impl_AddVertex,
2391 IDirect3DRMMeshBuilder3Impl_AddNormal,
2392 IDirect3DRMMeshBuilder3Impl_CreateFace,
2393 IDirect3DRMMeshBuilder3Impl_GetQuality,
2394 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2395 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2396 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2397 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2398 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2399 IDirect3DRMMeshBuilder3Impl_GetFace,
2400 IDirect3DRMMeshBuilder3Impl_GetVertex,
2401 IDirect3DRMMeshBuilder3Impl_GetNormal,
2402 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2403 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2404 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2405 IDirect3DRMMeshBuilder3Impl_Empty,
2406 IDirect3DRMMeshBuilder3Impl_Optimize,
2407 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2408 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2409 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2410 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2411 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2412 IDirect3DRMMeshBuilder3Impl_Enable,
2413 IDirect3DRMMeshBuilder3Impl_GetEnable,
2414 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2415 IDirect3DRMMeshBuilder3Impl_SetVertices,
2416 IDirect3DRMMeshBuilder3Impl_GetVertices,
2417 IDirect3DRMMeshBuilder3Impl_SetNormals,
2418 IDirect3DRMMeshBuilder3Impl_GetNormals,
2419 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2422 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2424 IDirect3DRMMeshBuilderImpl* object;
2426 TRACE("(%p)\n", ppObj);
2428 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2431 ERR("Out of memory\n");
2432 return E_OUTOFMEMORY;
2435 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2436 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2439 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2440 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2442 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2447 /*** IUnknown methods ***/
2448 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2449 REFIID riid, void** ppvObject)
2451 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2453 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2457 if (IsEqualGUID(riid, &IID_IUnknown) ||
2458 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2460 *ppvObject = &This->IDirect3DRMMesh_iface;
2464 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2465 return E_NOINTERFACE;
2468 IDirect3DRMMesh_AddRef(iface);
2472 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2474 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2475 ULONG ref = InterlockedIncrement(&This->ref);
2477 TRACE("(%p)->(): new ref = %d\n", This, ref);
2482 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2484 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2485 ULONG ref = InterlockedDecrement(&This->ref);
2487 TRACE("(%p)->(): new ref = %d\n", This, ref);
2493 for (i = 0; i < This->nb_groups; i++)
2495 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2496 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2497 if (This->groups[i].material)
2498 IDirect3DRMMaterial2_Release(This->groups[i].material);
2499 if (This->groups[i].texture)
2500 IDirect3DRMTexture3_Release(This->groups[i].texture);
2502 HeapFree(GetProcessHeap(), 0, This->groups);
2503 HeapFree(GetProcessHeap(), 0, This);
2509 /*** IDirect3DRMObject methods ***/
2510 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2511 LPUNKNOWN pUnkOuter, REFIID riid,
2514 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2516 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2521 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2522 D3DRMOBJECTCALLBACK cb,
2525 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2527 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2532 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2533 D3DRMOBJECTCALLBACK cb,
2536 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2538 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2543 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2546 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2548 FIXME("(%p)->(%u): stub\n", This, data);
2553 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2555 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2557 FIXME("(%p)->(): stub\n", This);
2562 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2565 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2567 FIXME("(%p)->(%s): stub\n", This, pName);
2572 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2573 LPDWORD lpdwSize, LPSTR lpName)
2575 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2577 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2582 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2583 LPDWORD lpdwSize, LPSTR lpName)
2585 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2587 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2592 /*** IDirect3DRMMesh methods ***/
2593 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2594 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2596 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2598 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2603 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2604 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2606 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2608 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2613 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2616 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2618 FIXME("(%p)->(%p): stub\n", This, box);
2623 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2624 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2625 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2627 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2630 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2632 if (!face_data || !return_id)
2635 if ((This->nb_groups + 1) > This->groups_capacity)
2640 if (!This->groups_capacity)
2643 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2647 new_capacity = This->groups_capacity * 2;
2648 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2652 return E_OUTOFMEMORY;
2654 This->groups_capacity = new_capacity;
2655 This->groups = groups;
2658 group = This->groups + This->nb_groups;
2660 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2661 if (!group->vertices)
2662 return E_OUTOFMEMORY;
2663 group->nb_vertices = vertex_count;
2664 group->nb_faces = face_count;
2665 group->vertex_per_face = vertex_per_face;
2667 if (vertex_per_face)
2669 group->face_data_size = face_count * vertex_per_face;
2674 unsigned nb_indices;
2675 unsigned* face_data_ptr = face_data;
2676 group->face_data_size = 0;
2678 for (i = 0; i < face_count; i++)
2680 nb_indices = *face_data_ptr;
2681 group->face_data_size += nb_indices + 1;
2682 face_data_ptr += nb_indices;
2686 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2687 if (!group->face_data)
2689 HeapFree(GetProcessHeap(), 0 , group->vertices);
2690 return E_OUTOFMEMORY;
2693 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2695 group->material = NULL;
2696 group->texture = NULL;
2698 *return_id = This->nb_groups++;
2703 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2704 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2705 D3DRMVERTEX *values)
2707 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2709 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2711 if (id >= This->nb_groups)
2712 return D3DRMERR_BADVALUE;
2714 if ((index + count - 1) >= This->groups[id].nb_vertices)
2715 return D3DRMERR_BADVALUE;
2720 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2725 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2726 D3DRMGROUPINDEX id, D3DCOLOR color)
2728 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2730 TRACE("(%p)->(%u,%x)\n", This, id, color);
2732 if (id >= This->nb_groups)
2733 return D3DRMERR_BADVALUE;
2735 This->groups[id].color = color;
2740 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2741 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2743 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2745 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2747 if (id >= This->nb_groups)
2748 return D3DRMERR_BADVALUE;
2750 This->groups[id].color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
2751 (BYTE)(green * 255.0f),
2752 (BYTE)(blue * 255.0f));
2757 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2758 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2760 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2762 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2767 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2768 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2770 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2772 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2777 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2778 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2780 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2782 TRACE("(%p)->(%u,%p)\n", This, id, material);
2784 if (id >= This->nb_groups)
2785 return D3DRMERR_BADVALUE;
2787 if (This->groups[id].material)
2788 IDirect3DRMMaterial2_Release(This->groups[id].material);
2790 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2793 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2798 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2799 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2801 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2803 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2805 if (id >= This->nb_groups)
2806 return D3DRMERR_BADVALUE;
2808 if (This->groups[id].texture)
2809 IDirect3DRMTexture3_Release(This->groups[id].texture);
2813 This->groups[id].texture = NULL;
2817 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2820 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2822 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2824 TRACE("(%p)->()\n", This);
2826 return This->nb_groups;
2829 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2830 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2831 DWORD *face_data_size, unsigned *face_data)
2833 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2835 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2837 if (id >= This->nb_groups)
2838 return D3DRMERR_BADVALUE;
2841 *vertex_count = This->groups[id].nb_vertices;
2843 *face_count = This->groups[id].nb_faces;
2844 if (vertex_per_face)
2845 *vertex_per_face = This->groups[id].vertex_per_face;
2847 *face_data_size = This->groups[id].face_data_size;
2849 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2854 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2855 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2857 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2859 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2861 if (id >= This->nb_groups)
2862 return D3DRMERR_BADVALUE;
2864 if ((index + count - 1) >= This->groups[id].nb_vertices)
2865 return D3DRMERR_BADVALUE;
2870 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2875 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2877 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2879 TRACE("(%p)->(%u)\n", This, id);
2881 return This->groups[id].color;
2884 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2886 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2888 FIXME("(%p)->(%u): stub\n", This, id);
2892 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2894 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2896 FIXME("(%p)->(%u): stub\n", This, id);
2901 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2902 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2904 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2906 TRACE("(%p)->(%u,%p)\n", This, id, material);
2908 if (id >= This->nb_groups)
2909 return D3DRMERR_BADVALUE;
2914 if (This->groups[id].material)
2915 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2922 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2923 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2925 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2927 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2929 if (id >= This->nb_groups)
2930 return D3DRMERR_BADVALUE;
2935 if (This->groups[id].texture)
2936 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2943 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2945 /*** IUnknown methods ***/
2946 IDirect3DRMMeshImpl_QueryInterface,
2947 IDirect3DRMMeshImpl_AddRef,
2948 IDirect3DRMMeshImpl_Release,
2949 /*** IDirect3DRMObject methods ***/
2950 IDirect3DRMMeshImpl_Clone,
2951 IDirect3DRMMeshImpl_AddDestroyCallback,
2952 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2953 IDirect3DRMMeshImpl_SetAppData,
2954 IDirect3DRMMeshImpl_GetAppData,
2955 IDirect3DRMMeshImpl_SetName,
2956 IDirect3DRMMeshImpl_GetName,
2957 IDirect3DRMMeshImpl_GetClassName,
2958 /*** IDirect3DRMMesh methods ***/
2959 IDirect3DRMMeshImpl_Scale,
2960 IDirect3DRMMeshImpl_Translate,
2961 IDirect3DRMMeshImpl_GetBox,
2962 IDirect3DRMMeshImpl_AddGroup,
2963 IDirect3DRMMeshImpl_SetVertices,
2964 IDirect3DRMMeshImpl_SetGroupColor,
2965 IDirect3DRMMeshImpl_SetGroupColorRGB,
2966 IDirect3DRMMeshImpl_SetGroupMapping,
2967 IDirect3DRMMeshImpl_SetGroupQuality,
2968 IDirect3DRMMeshImpl_SetGroupMaterial,
2969 IDirect3DRMMeshImpl_SetGroupTexture,
2970 IDirect3DRMMeshImpl_GetGroupCount,
2971 IDirect3DRMMeshImpl_GetGroup,
2972 IDirect3DRMMeshImpl_GetVertices,
2973 IDirect3DRMMeshImpl_GetGroupColor,
2974 IDirect3DRMMeshImpl_GetGroupMapping,
2975 IDirect3DRMMeshImpl_GetGroupQuality,
2976 IDirect3DRMMeshImpl_GetGroupMaterial,
2977 IDirect3DRMMeshImpl_GetGroupTexture
2980 static HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
2982 IDirect3DRMMeshImpl* object;
2984 TRACE("(%p)\n", obj);
2986 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
2989 ERR("Out of memory\n");
2990 return E_OUTOFMEMORY;
2993 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
2996 *obj = &object->IDirect3DRMMesh_iface;