2 * Implementation of IDirect3DRMMeshBuilderX and IDirect3DRMMesh interfaces
4 * Copyright 2010, 2012 Christian Costa
5 * Copyright 2011 André Hentschel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
26 #include "wine/debug.h"
33 #include "d3drm_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
39 D3DRMVERTEX* vertices;
41 unsigned vertex_per_face;
45 IDirect3DRMMaterial2* material;
46 IDirect3DRMTexture3* texture;
50 IDirect3DRMMesh IDirect3DRMMesh_iface;
52 DWORD groups_capacity;
55 } IDirect3DRMMeshImpl;
63 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
64 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
77 IDirect3DRMMaterial2* material;
78 IDirect3DRMTexture3* texture;
79 } IDirect3DRMMeshBuilderImpl;
85 "<3D82AB43-62DA-11CF-AB39-0020AF71E433>"
92 "<3D82AB5E-62DA-11CF-AB39-0020AF71E433>"
99 "<F6F23F44-7686-11CF-8F52-0040333594A3>"
105 "<F6F23F45-7686-11CF-8F52-0040333594A3>"
106 "array FLOAT matrix[16];"
110 "<35FF44E0-6C7C-11CF-8F52-0040333594A3>"
118 "<D3E16E81-7835-11CF-8F52-0040333594A3>"
123 "template IndexedColor"
125 "<1630B820-7842-11CF-8F52-0040333594A3>"
127 "ColorRGBA indexColor;"
131 "<537DA6A0-CA37-11D0-941C-0080C80CFA7B>"
136 "<4885AE63-78E8-11CF-8F52-0040333594A3>"
140 "template MaterialWrap"
142 "<4885AE60-78E8-11CF-8F52-0040333594A3>"
146 "template TextureFilename"
148 "<A42790E1-7810-11CF-8F52-0040333594A3>"
153 "<3D82AB4D-62DA-11CF-AB39-0020AF71E433>"
154 "ColorRGBA faceColor;"
156 "ColorRGB specularColor;"
157 "ColorRGB emissiveColor;"
162 "<3D82AB5F-62DA-11CF-AB39-0020AF71E433>"
163 "DWORD nFaceVertexIndices;"
164 "array DWORD faceVertexIndices[nFaceVertexIndices];"
166 "template MeshFaceWraps"
168 "<ED1EC5C0-C0A8-11D0-941C-0080C80CFA7B>"
169 "DWORD nFaceWrapValues;"
170 "array Boolean2d faceWrapValues[nFaceWrapValues];"
172 "template MeshTextureCoords"
174 "<F6F23F40-7686-11CF-8F52-0040333594A3>"
175 "DWORD nTextureCoords;"
176 "array Coords2d textureCoords[nTextureCoords];"
178 "template MeshMaterialList"
180 "<F6F23F42-7686-11CF-8F52-0040333594A3>"
182 "DWORD nFaceIndexes;"
183 "array DWORD faceIndexes[nFaceIndexes];"
186 "template MeshNormals"
188 "<F6F23F43-7686-11CF-8F52-0040333594A3>"
190 "array Vector normals[nNormals];"
191 "DWORD nFaceNormals;"
192 "array MeshFace faceNormals[nFaceNormals];"
194 "template MeshVertexColors"
196 "<1630B821-7842-11CF-8F52-0040333594A3>"
197 "DWORD nVertexColors;"
198 "array IndexedColor vertexColors[nVertexColors];"
202 "<3D82AB44-62DA-11CF-AB39-0020AF71E433>"
204 "array Vector vertices[nVertices];"
206 "array MeshFace faces[nFaces];"
209 "template FrameTransformMatrix"
211 "<F6F23F41-7686-11CF-8F52-0040333594A3>"
212 "Matrix4x4 frameMatrix;"
216 "<3D82AB46-62DA-11CF-AB39-0020AF71E433>"
221 "<10DD46A9-775B-11CF-8F52-0040333594A3>"
223 "array FLOAT values[nValues];"
225 "template TimedFloatKeys"
227 "<F406B180-7B3B-11CF-8F52-0040333594A3>"
231 "template AnimationKey"
233 "<10DD46A8-775B-11CF-8F52-0040333594A3>"
236 "array TimedFloatKeys keys[nKeys];"
238 "template AnimationOptions"
240 "<E2BF56C0-840F-11CF-8F52-0040333594A3>"
242 "DWORD positionquality;"
246 "<3D82AB4F-62DA-11CF-AB39-0020AF71E433>"
249 "template AnimationSet"
251 "<3D82AB50-62DA-11CF-AB39-0020AF71E433>"
254 "template InlineData"
256 "<3A23EEA0-94B1-11D0-AB39-0020AF71E433>"
261 "<3A23EEA1-94B1-11D0-AB39-0020AF71E433>"
263 "array STRING urls[nUrls];"
265 "template ProgressiveMesh"
267 "<8A63C360-997D-11D0-941C-0080C80CFA7B>"
272 "<A42790E0-7810-11CF-8F52-0040333594A3>"
276 "array UCHAR data4[8];"
278 "template StringProperty"
280 "<7F0F21E0-BFE1-11D1-82C0-00A0C9697271>"
284 "template PropertyBag"
286 "<7F0F21E1-BFE1-11D1-82C0-00A0C9697271>"
289 "template ExternalVisual"
291 "<98116AA0-BDBA-11D1-82C0-00A0C9697271>"
292 "Guid guidExternalVisual;"
295 "template RightHanded"
297 "<7F5D5EA0-D53A-11D1-82C0-00A0C9697271>"
298 "DWORD bRightHanded;"
302 static inline IDirect3DRMMeshImpl *impl_from_IDirect3DRMMesh(IDirect3DRMMesh *iface)
304 return CONTAINING_RECORD(iface, IDirect3DRMMeshImpl, IDirect3DRMMesh_iface);
307 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder2(IDirect3DRMMeshBuilder2 *iface)
309 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder2_iface);
312 static inline IDirect3DRMMeshBuilderImpl *impl_from_IDirect3DRMMeshBuilder3(IDirect3DRMMeshBuilder3 *iface)
314 return CONTAINING_RECORD(iface, IDirect3DRMMeshBuilderImpl, IDirect3DRMMeshBuilder3_iface);
317 static void clean_mesh_builder_data(IDirect3DRMMeshBuilderImpl *mesh_builder)
319 HeapFree(GetProcessHeap(), 0, mesh_builder->name);
320 mesh_builder->name = NULL;
321 HeapFree(GetProcessHeap(), 0, mesh_builder->pVertices);
322 mesh_builder->pVertices = NULL;
323 mesh_builder->nb_vertices = 0;
324 HeapFree(GetProcessHeap(), 0, mesh_builder->pNormals);
325 mesh_builder->pNormals = NULL;
326 mesh_builder->nb_normals = 0;
327 HeapFree(GetProcessHeap(), 0, mesh_builder->pFaceData);
328 mesh_builder->pFaceData = NULL;
329 mesh_builder->face_data_size = 0;
330 mesh_builder->nb_faces = 0;
331 HeapFree(GetProcessHeap(), 0, mesh_builder->pCoords2d);
332 mesh_builder->pCoords2d = NULL;
333 mesh_builder->nb_coords2d = 0;
336 /*** IUnknown methods ***/
337 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_QueryInterface(IDirect3DRMMeshBuilder2* iface,
338 REFIID riid, void** ppvObject)
340 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
342 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
346 if(IsEqualGUID(riid, &IID_IUnknown) ||
347 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder) ||
348 IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder2))
350 *ppvObject = &This->IDirect3DRMMeshBuilder2_iface;
352 else if(IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
354 *ppvObject = &This->IDirect3DRMMeshBuilder3_iface;
358 FIXME("interface %s not implemented\n", debugstr_guid(riid));
359 return E_NOINTERFACE;
362 IDirect3DRMMeshBuilder_AddRef(iface);
366 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_AddRef(IDirect3DRMMeshBuilder2* iface)
368 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
369 ULONG ref = InterlockedIncrement(&This->ref);
371 TRACE("(%p)->(): new ref = %d\n", This, ref);
376 static ULONG WINAPI IDirect3DRMMeshBuilder2Impl_Release(IDirect3DRMMeshBuilder2* iface)
378 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
379 ULONG ref = InterlockedDecrement(&This->ref);
381 TRACE("(%p)->(): new ref = %d\n", This, ref);
385 clean_mesh_builder_data(This);
387 IDirect3DRMMaterial2_Release(This->material);
389 IDirect3DRMTexture3_Release(This->texture);
390 HeapFree(GetProcessHeap(), 0, This);
396 /*** IDirect3DRMObject methods ***/
397 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Clone(IDirect3DRMMeshBuilder2* iface,
398 LPUNKNOWN pUnkOuter, REFIID riid,
401 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
403 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
408 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddDestroyCallback(IDirect3DRMMeshBuilder2* iface,
409 D3DRMOBJECTCALLBACK cb,
412 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
414 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
419 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder2* iface,
420 D3DRMOBJECTCALLBACK cb,
423 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
425 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
430 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetAppData(IDirect3DRMMeshBuilder2* iface,
433 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
435 FIXME("(%p)->(%u): stub\n", This, data);
440 static DWORD WINAPI IDirect3DRMMeshBuilder2Impl_GetAppData(IDirect3DRMMeshBuilder2* iface)
442 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
444 FIXME("(%p)->(): stub\n", This);
449 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetName(IDirect3DRMMeshBuilder2* iface,
452 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
454 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
456 return IDirect3DRMMeshBuilder3_SetName(&This->IDirect3DRMMeshBuilder3_iface, name);
459 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetName(IDirect3DRMMeshBuilder2* iface,
460 LPDWORD size, LPSTR name)
462 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
464 TRACE("(%p)->(%p,%p)\n", This, size, name);
466 return IDirect3DRMMeshBuilder3_GetName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
469 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetClassName(IDirect3DRMMeshBuilder2* iface,
470 LPDWORD size, LPSTR name)
472 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
474 TRACE("(%p)->(%p, %p)\n", This, size, name);
476 return IDirect3DRMMeshBuilder3_GetClassName(&This->IDirect3DRMMeshBuilder3_iface, size, name);
479 /*** IDirect3DRMMeshBuilder2 methods ***/
480 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Load(IDirect3DRMMeshBuilder2* iface,
481 LPVOID filename, LPVOID name,
482 D3DRMLOADOPTIONS loadflags,
483 D3DRMLOADTEXTURECALLBACK cb, LPVOID arg)
485 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
487 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
490 FIXME("Texture callback is not yet supported\n");
492 return IDirect3DRMMeshBuilder3_Load(&This->IDirect3DRMMeshBuilder3_iface, filename, name,
493 loadflags, NULL, arg);
496 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Save(IDirect3DRMMeshBuilder2* iface,
497 const char *filename, D3DRMXOFFORMAT format,
498 D3DRMSAVEOPTIONS save)
500 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
502 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
507 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Scale(IDirect3DRMMeshBuilder2* iface,
508 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
510 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
512 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
514 return IDirect3DRMMeshBuilder3_Scale(&This->IDirect3DRMMeshBuilder3_iface, sx, sy, sz);
517 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_Translate(IDirect3DRMMeshBuilder2* iface,
518 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
520 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
522 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
527 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorSource(IDirect3DRMMeshBuilder2* iface,
528 D3DRMCOLORSOURCE color)
530 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
532 FIXME("(%p)->(%x): stub\n", This, color);
537 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetBox(IDirect3DRMMeshBuilder2* iface,
540 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
542 FIXME("(%p)->(%p): stub\n", This, pBox);
547 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals(IDirect3DRMMeshBuilder2* iface)
549 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
551 FIXME("(%p)->(): stub\n", This);
556 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder2Impl_GetColorSource(IDirect3DRMMeshBuilder2* iface)
558 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
560 FIXME("(%p)->(): stub\n", This);
565 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMesh(IDirect3DRMMeshBuilder2* iface,
566 LPDIRECT3DRMMESH pMesh)
568 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
570 FIXME("(%p)->(%p): stub\n", This, pMesh);
575 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddMeshBuilder(IDirect3DRMMeshBuilder2* iface,
576 LPDIRECT3DRMMESHBUILDER pMeshBuilder)
578 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
580 FIXME("(%p)->(%p): stub\n", This, pMeshBuilder);
585 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFrame(IDirect3DRMMeshBuilder2* iface,
586 LPDIRECT3DRMFRAME pFrame)
588 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
590 FIXME("(%p)->(%p): stub\n", This, pFrame);
595 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFace(IDirect3DRMMeshBuilder2* iface,
596 LPDIRECT3DRMFACE pFace)
598 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
600 FIXME("(%p)->(%p): stub\n", This, pFace);
605 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_AddFaces(IDirect3DRMMeshBuilder2* iface,
606 DWORD vcount, D3DVECTOR *vertices,
607 DWORD ncount, D3DVECTOR *normals,
609 LPDIRECT3DRMFACEARRAY* pFaceArray)
611 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
613 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals, data, pFaceArray);
618 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_ReserveSpace(IDirect3DRMMeshBuilder2* iface,
623 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
625 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
630 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColorRGB(IDirect3DRMMeshBuilder2* iface,
631 D3DVALUE red, D3DVALUE green,
634 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
636 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
638 return IDirect3DRMMeshBuilder3_SetColorRGB(&This->IDirect3DRMMeshBuilder3_iface, red, green, blue);
641 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetColor(IDirect3DRMMeshBuilder2* iface,
644 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
646 TRACE("(%p)->(%x)\n", This, color);
648 return IDirect3DRMMeshBuilder3_SetColor(&This->IDirect3DRMMeshBuilder3_iface, color);
651 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTexture(IDirect3DRMMeshBuilder2* iface,
652 LPDIRECT3DRMTEXTURE texture)
654 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
655 LPDIRECT3DRMTEXTURE3 texture3 = NULL;
656 HRESULT hr = D3DRM_OK;
659 hr = IDirect3DRMTexture_QueryInterface(texture, &IID_IDirect3DRMTexture3, (LPVOID*)&texture3);
661 hr = IDirect3DRMMeshBuilder3_SetTexture(&This->IDirect3DRMMeshBuilder3_iface, texture3);
663 IDirect3DRMTexture3_Release(texture3);
668 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetMaterial(IDirect3DRMMeshBuilder2* iface,
669 LPDIRECT3DRMMATERIAL material)
671 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
673 TRACE("(%p)->(%p)\n", This, material);
675 return IDirect3DRMMeshBuilder3_SetMaterial(&This->IDirect3DRMMeshBuilder3_iface, (LPDIRECT3DRMMATERIAL2)material);
678 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureTopology(IDirect3DRMMeshBuilder2* iface,
679 BOOL wrap_u, BOOL wrap_v)
681 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
683 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
688 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetQuality(IDirect3DRMMeshBuilder2* iface,
689 D3DRMRENDERQUALITY quality)
691 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
693 FIXME("(%p)->(%d): stub\n", This, quality);
698 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetPerspective(IDirect3DRMMeshBuilder2* iface,
701 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
703 FIXME("(%p)->(%d): stub\n", This, enable);
708 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertex(IDirect3DRMMeshBuilder2* iface,
710 D3DVALUE x, D3DVALUE y, D3DVALUE z)
712 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
714 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
719 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetNormal(IDirect3DRMMeshBuilder2* iface,
721 D3DVALUE x, D3DVALUE y, D3DVALUE z)
723 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
725 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
730 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
732 D3DVALUE u, D3DVALUE v)
734 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
736 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
738 return IDirect3DRMMeshBuilder3_SetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
742 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColor(IDirect3DRMMeshBuilder2* iface,
743 DWORD index, D3DCOLOR color)
745 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
747 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
752 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder2* iface,
753 DWORD index, D3DVALUE red,
754 D3DVALUE green, D3DVALUE blue)
756 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
758 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
763 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFaces(IDirect3DRMMeshBuilder2* iface,
764 LPDIRECT3DRMFACEARRAY* pFaceArray)
766 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
768 FIXME("(%p)->(%p): stub\n", This, pFaceArray);
773 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetVertices(IDirect3DRMMeshBuilder2* iface,
774 DWORD *vcount, D3DVECTOR *vertices,
775 DWORD *ncount, D3DVECTOR *normals,
776 DWORD *face_data_size,
779 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
781 TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
784 *vcount = This->nb_vertices;
785 if (vertices && This->nb_vertices)
786 memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
788 *ncount = This->nb_normals;
789 if (normals && This->nb_normals)
790 memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
792 *face_data_size = This->face_data_size;
793 if (face_data && This->face_data_size)
794 memcpy(face_data, This->pFaceData, This->face_data_size * sizeof(DWORD));
799 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder2* iface,
801 D3DVALUE *u, D3DVALUE *v)
803 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
805 TRACE("(%p)->(%u,%p,%p)\n", This, index, u, v);
807 return IDirect3DRMMeshBuilder3_GetTextureCoordinates(&This->IDirect3DRMMeshBuilder3_iface,
811 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddVertex(IDirect3DRMMeshBuilder2* iface,
812 D3DVALUE x, D3DVALUE y, D3DVALUE z)
814 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
816 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
821 static int WINAPI IDirect3DRMMeshBuilder2Impl_AddNormal(IDirect3DRMMeshBuilder2* iface,
822 D3DVALUE x, D3DVALUE y, D3DVALUE z)
824 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
826 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
831 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateFace(IDirect3DRMMeshBuilder2* iface,
832 LPDIRECT3DRMFACE* ppFace)
834 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
836 FIXME("(%p)->(%p): stub\n", This, ppFace);
841 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder2Impl_GetQuality(IDirect3DRMMeshBuilder2* iface)
843 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
845 FIXME("(%p)->(): stub\n", This);
850 static BOOL WINAPI IDirect3DRMMeshBuilder2Impl_GetPerspective(IDirect3DRMMeshBuilder2* iface)
852 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
854 FIXME("(%p)->(): stub\n", This);
859 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetFaceCount(IDirect3DRMMeshBuilder2* iface)
861 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
863 TRACE("(%p)->()\n", This);
865 return This->nb_faces;
868 static int WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexCount(IDirect3DRMMeshBuilder2* iface)
870 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
872 TRACE("(%p)->()\n", This);
874 return This->nb_vertices;
877 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder2Impl_GetVertexColor(IDirect3DRMMeshBuilder2* iface,
880 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
882 FIXME("(%p)->(%d): stub\n", This, index);
887 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_CreateMesh(IDirect3DRMMeshBuilder2* iface,
888 LPDIRECT3DRMMESH* mesh)
890 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
892 TRACE("(%p)->(%p)\n", This, mesh);
894 return IDirect3DRMMeshBuilder3_CreateMesh(&This->IDirect3DRMMeshBuilder3_iface, mesh);
897 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GenerateNormals2(IDirect3DRMMeshBuilder2* iface,
898 D3DVALUE crease, DWORD dwFlags)
900 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
902 FIXME("(%p)->(%f,%u): stub\n", This, crease, dwFlags);
907 static HRESULT WINAPI IDirect3DRMMeshBuilder2Impl_GetFace(IDirect3DRMMeshBuilder2* iface,
908 DWORD index, LPDIRECT3DRMFACE* ppFace)
910 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder2(iface);
912 FIXME("(%p)->(%u,%p): stub\n", This, index, ppFace);
917 static const struct IDirect3DRMMeshBuilder2Vtbl Direct3DRMMeshBuilder2_Vtbl =
919 /*** IUnknown methods ***/
920 IDirect3DRMMeshBuilder2Impl_QueryInterface,
921 IDirect3DRMMeshBuilder2Impl_AddRef,
922 IDirect3DRMMeshBuilder2Impl_Release,
923 /*** IDirect3DRMObject methods ***/
924 IDirect3DRMMeshBuilder2Impl_Clone,
925 IDirect3DRMMeshBuilder2Impl_AddDestroyCallback,
926 IDirect3DRMMeshBuilder2Impl_DeleteDestroyCallback,
927 IDirect3DRMMeshBuilder2Impl_SetAppData,
928 IDirect3DRMMeshBuilder2Impl_GetAppData,
929 IDirect3DRMMeshBuilder2Impl_SetName,
930 IDirect3DRMMeshBuilder2Impl_GetName,
931 IDirect3DRMMeshBuilder2Impl_GetClassName,
932 /*** IDirect3DRMMeshBuilder methods ***/
933 IDirect3DRMMeshBuilder2Impl_Load,
934 IDirect3DRMMeshBuilder2Impl_Save,
935 IDirect3DRMMeshBuilder2Impl_Scale,
936 IDirect3DRMMeshBuilder2Impl_Translate,
937 IDirect3DRMMeshBuilder2Impl_SetColorSource,
938 IDirect3DRMMeshBuilder2Impl_GetBox,
939 IDirect3DRMMeshBuilder2Impl_GenerateNormals,
940 IDirect3DRMMeshBuilder2Impl_GetColorSource,
941 IDirect3DRMMeshBuilder2Impl_AddMesh,
942 IDirect3DRMMeshBuilder2Impl_AddMeshBuilder,
943 IDirect3DRMMeshBuilder2Impl_AddFrame,
944 IDirect3DRMMeshBuilder2Impl_AddFace,
945 IDirect3DRMMeshBuilder2Impl_AddFaces,
946 IDirect3DRMMeshBuilder2Impl_ReserveSpace,
947 IDirect3DRMMeshBuilder2Impl_SetColorRGB,
948 IDirect3DRMMeshBuilder2Impl_SetColor,
949 IDirect3DRMMeshBuilder2Impl_SetTexture,
950 IDirect3DRMMeshBuilder2Impl_SetMaterial,
951 IDirect3DRMMeshBuilder2Impl_SetTextureTopology,
952 IDirect3DRMMeshBuilder2Impl_SetQuality,
953 IDirect3DRMMeshBuilder2Impl_SetPerspective,
954 IDirect3DRMMeshBuilder2Impl_SetVertex,
955 IDirect3DRMMeshBuilder2Impl_SetNormal,
956 IDirect3DRMMeshBuilder2Impl_SetTextureCoordinates,
957 IDirect3DRMMeshBuilder2Impl_SetVertexColor,
958 IDirect3DRMMeshBuilder2Impl_SetVertexColorRGB,
959 IDirect3DRMMeshBuilder2Impl_GetFaces,
960 IDirect3DRMMeshBuilder2Impl_GetVertices,
961 IDirect3DRMMeshBuilder2Impl_GetTextureCoordinates,
962 IDirect3DRMMeshBuilder2Impl_AddVertex,
963 IDirect3DRMMeshBuilder2Impl_AddNormal,
964 IDirect3DRMMeshBuilder2Impl_CreateFace,
965 IDirect3DRMMeshBuilder2Impl_GetQuality,
966 IDirect3DRMMeshBuilder2Impl_GetPerspective,
967 IDirect3DRMMeshBuilder2Impl_GetFaceCount,
968 IDirect3DRMMeshBuilder2Impl_GetVertexCount,
969 IDirect3DRMMeshBuilder2Impl_GetVertexColor,
970 IDirect3DRMMeshBuilder2Impl_CreateMesh,
971 /*** IDirect3DRMMeshBuilder2 methods ***/
972 IDirect3DRMMeshBuilder2Impl_GenerateNormals2,
973 IDirect3DRMMeshBuilder2Impl_GetFace
977 /*** IUnknown methods ***/
978 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_QueryInterface(IDirect3DRMMeshBuilder3* iface,
979 REFIID riid, void** ppvObject)
981 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
982 return IDirect3DRMMeshBuilder2_QueryInterface(&This->IDirect3DRMMeshBuilder2_iface, riid, ppvObject);
985 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_AddRef(IDirect3DRMMeshBuilder3* iface)
987 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
988 return IDirect3DRMMeshBuilder2_AddRef(&This->IDirect3DRMMeshBuilder2_iface);
991 static ULONG WINAPI IDirect3DRMMeshBuilder3Impl_Release(IDirect3DRMMeshBuilder3* iface)
993 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
994 return IDirect3DRMMeshBuilder2_Release(&This->IDirect3DRMMeshBuilder2_iface);
997 /*** IDirect3DRMObject methods ***/
998 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Clone(IDirect3DRMMeshBuilder3* iface,
999 LPUNKNOWN pUnkOuter, REFIID riid,
1002 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1004 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
1009 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1010 D3DRMOBJECTCALLBACK cb,
1013 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1015 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1020 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback(IDirect3DRMMeshBuilder3* iface,
1021 D3DRMOBJECTCALLBACK cb,
1024 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1026 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
1031 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetAppData(IDirect3DRMMeshBuilder3* iface,
1034 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1036 FIXME("(%p)->(%u): stub\n", This, data);
1041 static DWORD WINAPI IDirect3DRMMeshBuilder3Impl_GetAppData(IDirect3DRMMeshBuilder3* iface)
1043 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1045 FIXME("(%p)->(): stub\n", This);
1050 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetName(IDirect3DRMMeshBuilder3* iface,
1053 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1054 char *string = NULL;
1056 TRACE("(%p)->(%s)\n", This, debugstr_a(name));
1060 string = HeapAlloc(GetProcessHeap(), 0, strlen(name) + 1);
1061 if (!string) return E_OUTOFMEMORY;
1062 strcpy(string, name);
1064 HeapFree(GetProcessHeap(), 0, This->name);
1065 This->name = string;
1070 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetName(IDirect3DRMMeshBuilder3* iface,
1071 LPDWORD size, LPSTR name)
1073 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1075 TRACE("(%p)->(%p,%p)\n", This, size, name);
1086 if (*size < (strlen(This->name) + 1))
1087 return E_INVALIDARG;
1089 strcpy(name, This->name);
1090 *size = strlen(This->name) + 1;
1095 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetClassName(IDirect3DRMMeshBuilder3* iface,
1096 LPDWORD size, LPSTR name)
1098 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1100 TRACE("(%p)->(%p, %p)\n", This, size, name);
1102 if (!size || *size < strlen("Builder") || !name)
1103 return E_INVALIDARG;
1105 strcpy(name, "Builder");
1106 *size = sizeof("Builder");
1111 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3* iface, LPDIRECTXFILEDATA pData)
1113 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1114 LPDIRECTXFILEOBJECT pObject = NULL;
1115 LPDIRECTXFILEDATA pData2 = NULL;
1120 HRESULT ret = D3DRMERR_BADOBJECT;
1121 DWORD* faces_vertex_idx_data = NULL;
1122 DWORD* faces_vertex_idx_ptr;
1123 DWORD faces_vertex_idx_size;
1124 DWORD* faces_normal_idx_data = NULL;
1125 DWORD* faces_normal_idx_ptr = NULL;
1126 DWORD* faces_data_ptr;
1127 DWORD faces_data_size = 0;
1130 TRACE("(%p)->(%p)\n", This, pData);
1132 hr = IDirectXFileData_GetName(pData, NULL, &size);
1133 if (hr != DXFILE_OK)
1137 This->name = HeapAlloc(GetProcessHeap(), 0, size);
1139 return E_OUTOFMEMORY;
1141 hr = IDirectXFileData_GetName(pData, This->name, &size);
1142 if (hr != DXFILE_OK)
1146 TRACE("Mesh name is '%s'\n", This->name ? This->name : "");
1148 This->nb_normals = 0;
1150 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
1151 if (hr != DXFILE_OK)
1154 This->nb_vertices = *(DWORD*)ptr;
1155 This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
1156 faces_vertex_idx_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
1157 faces_vertex_idx_ptr = (DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD));
1159 TRACE("Mesh: nb_vertices = %d, nb_faces = %d, faces_vertex_idx_size = %d\n", This->nb_vertices, This->nb_faces, faces_vertex_idx_size);
1161 This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
1162 memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
1164 faces_vertex_idx_ptr = faces_vertex_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size);
1165 memcpy(faces_vertex_idx_data, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), faces_vertex_idx_size);
1167 /* Each vertex index will have its normal index counterpart so just allocate twice the size */
1168 This->pFaceData = HeapAlloc(GetProcessHeap(), 0, faces_vertex_idx_size*2);
1169 faces_data_ptr = (DWORD*)This->pFaceData;
1173 hr = IDirectXFileData_GetNextObject(pData, &pObject);
1174 if (hr == DXFILEERR_NOMOREOBJECTS)
1176 TRACE("No more object\n");
1179 if (hr != DXFILE_OK)
1182 hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
1183 IDirectXFileObject_Release(pObject);
1184 if (hr != DXFILE_OK)
1187 hr = IDirectXFileData_GetType(pData2, &pGuid);
1188 if (hr != DXFILE_OK)
1191 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1193 if (IsEqualGUID(pGuid, &TID_D3DRMMeshNormals))
1195 DWORD nb_faces_normals;
1196 DWORD faces_normal_idx_size;
1198 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1199 if (hr != DXFILE_OK)
1202 This->nb_normals = *(DWORD*)ptr;
1203 nb_faces_normals = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1205 TRACE("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, nb_faces_normals);
1206 if (nb_faces_normals != This->nb_faces)
1207 WARN("nb_face_normals (%d) != nb_faces (%d)\n", nb_faces_normals, This->nb_normals);
1209 This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
1210 memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
1212 faces_normal_idx_size = size - (2*sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
1213 faces_normal_idx_ptr = faces_normal_idx_data = HeapAlloc(GetProcessHeap(), 0, faces_normal_idx_size);
1214 memcpy(faces_normal_idx_data, ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR) + sizeof(DWORD), faces_normal_idx_size);
1216 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshTextureCoords))
1218 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1219 if (hr != DXFILE_OK)
1222 This->nb_coords2d = *(DWORD*)ptr;
1224 TRACE("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
1226 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1227 memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
1230 else if (IsEqualGUID(pGuid, &TID_D3DRMMeshMaterialList))
1233 DWORD nb_face_indices;
1235 LPDIRECTXFILEOBJECT child;
1239 TRACE("Process MeshMaterialList\n");
1241 hr = IDirectXFileData_GetData(pData2, NULL, &size, (void**)&ptr);
1242 if (hr != DXFILE_OK)
1245 nb_materials = *(DWORD*)ptr;
1246 nb_face_indices = *(DWORD*)(ptr + sizeof(DWORD));
1247 data_size = 2 * sizeof(DWORD) + nb_face_indices * sizeof(DWORD);
1249 TRACE("nMaterials = %u, nFaceIndexes = %u\n", nb_materials, nb_face_indices);
1251 if (size != data_size)
1252 WARN("Returned size %u does not match expected one %u\n", size, data_size);
1254 if (nb_materials > 1)
1255 FIXME("Only one material per mesh supported, first one applies to all faces\n");
1257 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(pData2, &child)) && (i < nb_materials))
1259 LPDIRECTXFILEDATA data;
1260 LPDIRECTXFILEDATAREFERENCE reference;
1261 LPDIRECT3DRMMATERIAL2 material;
1262 LPDIRECTXFILEOBJECT material_child;
1266 /* FIXME: Only handle first material but enum all of them */
1267 IDirectXFileObject_Release(child);
1272 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1275 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1276 IDirectXFileObject_Release(child);
1280 hr = IDirectXFileDataReference_Resolve(reference, &data);
1281 IDirectXFileDataReference_Release(reference);
1287 IDirectXFileObject_Release(child);
1290 hr = Direct3DRMMaterial_create(&material);
1293 IDirectXFileData_Release(data);
1297 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&ptr);
1298 if (hr != DXFILE_OK)
1300 IDirectXFileData_Release(data);
1305 WARN("Material size %u does not match expected one %u\n", size, 44);
1307 values = (float*)ptr;
1309 IDirect3DRMMeshBuilder3_SetColorRGB(iface, values[0], values [1], values[2]); /* Alpha ignored */
1311 IDirect3DRMMaterial2_SetAmbient(material, values[0], values [1], values[2]); /* Alpha ignored */
1312 IDirect3DRMMaterial2_SetPower(material, values[4]);
1313 IDirect3DRMMaterial2_SetSpecular(material, values[5], values[6], values[7]);
1314 IDirect3DRMMaterial2_SetEmissive(material, values[8], values[9], values[10]);
1316 This->material = material;
1318 hr = IDirectXFileData_GetNextObject(data, &material_child);
1321 LPDIRECTXFILEDATA data;
1322 LPDIRECT3DRMTEXTURE3 texture;
1325 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileData, (void **)&data);
1328 LPDIRECTXFILEDATAREFERENCE reference;
1330 hr = IDirectXFileObject_QueryInterface(material_child, &IID_IDirectXFileDataReference, (void **)&reference);
1334 hr = IDirectXFileDataReference_Resolve(reference, &data);
1335 IDirectXFileDataReference_Release(reference);
1340 hr = IDirectXFileData_GetType(data, &pGuid);
1341 if (hr != DXFILE_OK)
1343 if (!IsEqualGUID(pGuid, &TID_D3DRMTextureFilename))
1345 WARN("Not a texture filename\n");
1350 hr = IDirectXFileData_GetData(data, NULL, &size, (void**)&filename);
1355 file = CreateFileA(*filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
1356 if (file != INVALID_HANDLE_VALUE)
1358 hr = Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (LPUNKNOWN*)&texture);
1361 IDirectXFileData_Release(data);
1364 This->texture = texture;
1368 else if (hr != DXFILEERR_NOMOREOBJECTS)
1374 IDirectXFileData_Release(data);
1379 IDirectXFileObject_Release(child);
1380 WARN("Found more sub-objects than expected\n");
1382 else if (hr != DXFILEERR_NOMOREOBJECTS)
1390 FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
1393 IDirectXFileData_Release(pData2);
1397 if (!This->nb_normals)
1399 /* Allocate normals, one per vertex */
1400 This->pNormals = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nb_vertices * sizeof(D3DVECTOR));
1401 if (!This->pNormals)
1405 for (i = 0; i < This->nb_faces; i++)
1408 DWORD nb_face_indexes;
1409 D3DVECTOR face_normal;
1411 if (faces_vertex_idx_size < sizeof(DWORD))
1412 WARN("Not enough data to read number of indices of face %d\n", i);
1414 nb_face_indexes = *(faces_data_ptr + faces_data_size++) = *(faces_vertex_idx_ptr++);
1415 faces_vertex_idx_size--;
1416 if (faces_normal_idx_data && (*(faces_normal_idx_ptr++) != nb_face_indexes))
1417 WARN("Faces indices number mismatch\n");
1419 if (faces_vertex_idx_size < (nb_face_indexes * sizeof(DWORD)))
1420 WARN("Not enough data to read all indices of face %d\n", i);
1422 if (!This->nb_normals)
1424 /* Compute face normal */
1425 if (nb_face_indexes > 2)
1429 D3DRMVectorSubtract(&a, &This->pVertices[faces_vertex_idx_ptr[2]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1430 D3DRMVectorSubtract(&b, &This->pVertices[faces_vertex_idx_ptr[0]], &This->pVertices[faces_vertex_idx_ptr[1]]);
1431 D3DRMVectorCrossProduct(&face_normal, &a, &b);
1432 D3DRMVectorNormalize(&face_normal);
1436 face_normal.u1.x = 0.0f;
1437 face_normal.u2.y = 0.0f;
1438 face_normal.u3.z = 0.0f;
1442 for (j = 0; j < nb_face_indexes; j++)
1444 /* Copy vertex index */
1445 *(faces_data_ptr + faces_data_size++) = *faces_vertex_idx_ptr;
1446 /* Copy normal index */
1447 if (This->nb_normals)
1449 /* Read from x file */
1450 *(faces_data_ptr + faces_data_size++) = *(faces_normal_idx_ptr++);
1454 DWORD vertex_idx = *faces_vertex_idx_ptr;
1455 if (vertex_idx >= This->nb_vertices)
1457 WARN("Found vertex index %u but only %u vertices available => use index 0\n", vertex_idx, This->nb_vertices);
1460 *(faces_data_ptr + faces_data_size++) = vertex_idx;
1461 /* Add face normal to vertex normal */
1462 D3DRMVectorAdd(&This->pNormals[vertex_idx], &This->pNormals[vertex_idx], &face_normal);
1464 faces_vertex_idx_ptr++;
1466 faces_vertex_idx_size -= nb_face_indexes;
1469 /* Last DWORD must be 0 */
1470 *(faces_data_ptr + faces_data_size++) = 0;
1472 /* Set size (in number of DWORD) of all faces data */
1473 This->face_data_size = faces_data_size;
1475 if (!This->nb_normals)
1477 /* Normalize all normals */
1478 for (i = 0; i < This->nb_vertices; i++)
1480 D3DRMVectorNormalize(&This->pNormals[i]);
1482 This->nb_normals = This->nb_vertices;
1485 /* If there is no texture coordinates, generate default texture coordinates (0.0f, 0.0f) for each vertex */
1486 if (!This->pCoords2d)
1488 This->nb_coords2d = This->nb_vertices;
1489 This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
1490 for (i = 0; i < This->nb_coords2d; i++)
1492 This->pCoords2d[i].u = 0.0f;
1493 This->pCoords2d[i].v = 0.0f;
1497 TRACE("Mesh data loaded successfully\n");
1503 HeapFree(GetProcessHeap(), 0, faces_normal_idx_data);
1504 HeapFree(GetProcessHeap(), 0, faces_vertex_idx_data);
1509 /*** IDirect3DRMMeshBuilder3 methods ***/
1510 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Load(IDirect3DRMMeshBuilder3* iface,
1511 LPVOID filename, LPVOID name,
1512 D3DRMLOADOPTIONS loadflags,
1513 D3DRMLOADTEXTURE3CALLBACK cb, LPVOID arg)
1515 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1516 DXFILELOADOPTIONS load_options;
1517 LPDIRECTXFILE pDXFile = NULL;
1518 LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1519 LPDIRECTXFILEDATA pData = NULL;
1520 LPDIRECTXFILEDATA pData2 = NULL;
1525 HRESULT ret = D3DRMERR_BADOBJECT;
1527 TRACE("(%p)->(%p,%p,%x,%p,%p)\n", This, filename, name, loadflags, cb, arg);
1529 clean_mesh_builder_data(This);
1531 if (loadflags == D3DRMLOAD_FROMMEMORY)
1533 load_options = DXFILELOAD_FROMMEMORY;
1535 else if (loadflags == D3DRMLOAD_FROMFILE)
1537 load_options = DXFILELOAD_FROMFILE;
1538 TRACE("Loading from file %s\n", debugstr_a(filename));
1542 FIXME("Load options %d not supported yet\n", loadflags);
1546 hr = DirectXFileCreate(&pDXFile);
1547 if (hr != DXFILE_OK)
1550 hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1551 if (hr != DXFILE_OK)
1554 hr = IDirectXFile_CreateEnumObject(pDXFile, filename, load_options, &pEnumObject);
1555 if (hr != DXFILE_OK)
1558 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1559 if (hr != DXFILE_OK)
1562 hr = IDirectXFileData_GetType(pData, &pGuid);
1563 if (hr != DXFILE_OK)
1566 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1568 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1570 ret = D3DRMERR_BADFILE;
1574 hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1575 if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1578 TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1580 /* Version must be 1.0.x */
1581 if ((pHeader->major != 1) || (pHeader->minor != 0))
1583 ret = D3DRMERR_BADFILE;
1587 IDirectXFileData_Release(pData);
1590 hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1591 if (hr != DXFILE_OK)
1593 ret = D3DRMERR_NOTFOUND;
1597 hr = IDirectXFileData_GetType(pData, &pGuid);
1598 if (hr != DXFILE_OK)
1601 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1603 if (!IsEqualGUID(pGuid, &TID_D3DRMMesh))
1605 ret = D3DRMERR_NOTFOUND;
1609 hr = load_mesh_data(iface, pData);
1616 IDirectXFileData_Release(pData2);
1618 IDirectXFileData_Release(pData);
1620 IDirectXFileEnumObject_Release(pEnumObject);
1622 IDirectXFile_Release(pDXFile);
1624 if (ret != D3DRM_OK)
1625 clean_mesh_builder_data(This);
1630 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Save(IDirect3DRMMeshBuilder3* iface,
1631 const char* filename, D3DRMXOFFORMAT format,
1632 D3DRMSAVEOPTIONS save)
1634 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1636 FIXME("(%p)->(%s,%d,%d): stub\n", This, filename, format, save);
1641 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Scale(IDirect3DRMMeshBuilder3* iface,
1642 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1644 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1647 TRACE("(%p)->(%f,%f,%f)\n", This, sx, sy, sz);
1649 for (i = 0; i < This->nb_vertices; i++)
1651 This->pVertices[i].u1.x *= sx;
1652 This->pVertices[i].u2.y *= sy;
1653 This->pVertices[i].u3.z *= sz;
1656 /* Normals are not affected by Scale */
1661 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Translate(IDirect3DRMMeshBuilder3* iface,
1662 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
1664 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1666 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty, tz);
1671 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorSource(IDirect3DRMMeshBuilder3* iface,
1672 D3DRMCOLORSOURCE color)
1674 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1676 FIXME("(%p)->(%x): stub\n", This, color);
1681 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetBox(IDirect3DRMMeshBuilder3* iface,
1684 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1686 FIXME("(%p)->(%p): stub\n", This, box);
1691 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GenerateNormals(IDirect3DRMMeshBuilder3* iface,
1692 D3DVALUE crease, DWORD flags)
1694 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1696 FIXME("(%p)->(%f,%u): stub\n", This, crease, flags);
1701 static D3DRMCOLORSOURCE WINAPI IDirect3DRMMeshBuilder3Impl_GetColorSource(IDirect3DRMMeshBuilder3* iface)
1703 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1705 FIXME("(%p)->(): stub\n", This);
1710 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMesh(IDirect3DRMMeshBuilder3* iface,
1711 LPDIRECT3DRMMESH Mesh)
1713 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1715 FIXME("(%p)->(%p): stub\n", This, Mesh);
1720 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddMeshBuilder(IDirect3DRMMeshBuilder3* iface,
1721 LPDIRECT3DRMMESHBUILDER3 MeshBuilder,
1724 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1726 FIXME("(%p)->(%p,%u): stub\n", This, MeshBuilder, flags);
1731 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFrame(IDirect3DRMMeshBuilder3* iface,
1732 LPDIRECT3DRMFRAME3 Frame)
1734 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1736 FIXME("(%p)->(%p): stub\n", This, Frame);
1741 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFace(IDirect3DRMMeshBuilder3* iface,
1742 LPDIRECT3DRMFACE2 Face)
1744 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1746 FIXME("(%p)->(%p): stub\n", This, Face);
1751 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFaces(IDirect3DRMMeshBuilder3* iface,
1752 DWORD vcount, D3DVECTOR* vertices,
1753 DWORD ncount, D3DVECTOR* normals,
1755 LPDIRECT3DRMFACEARRAY* FaceArray)
1757 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1759 FIXME("(%p)->(%d,%p,%d,%p,%p,%p): stub\n", This, vcount, vertices, ncount,
1760 normals, data, FaceArray);
1765 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_ReserveSpace(IDirect3DRMMeshBuilder3* iface,
1770 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1772 FIXME("(%p)->(%d,%d,%d): stub\n", This, vertex_Count, normal_count, face_count);
1777 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColorRGB(IDirect3DRMMeshBuilder3* iface,
1778 D3DVALUE red, D3DVALUE green,
1781 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1783 TRACE("(%p)->(%f,%f,%f)\n", This, red, green, blue);
1785 This->color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
1786 (BYTE)(green * 255.0f),
1787 (BYTE)(blue * 255.0f));
1792 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetColor(IDirect3DRMMeshBuilder3* iface,
1795 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1797 TRACE("(%p)->(%x)\n", This, color);
1799 This->color = color;
1804 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTexture(IDirect3DRMMeshBuilder3* iface,
1805 LPDIRECT3DRMTEXTURE3 texture)
1807 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1809 TRACE("(%p)->(%p)\n", This, texture);
1812 IDirect3DRMTexture3_AddRef(texture);
1814 IDirect3DRMTexture3_Release(This->texture);
1815 This->texture = texture;
1820 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetMaterial(IDirect3DRMMeshBuilder3* iface,
1821 LPDIRECT3DRMMATERIAL2 material)
1823 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1825 TRACE("(%p)->(%p)\n", This, material);
1828 IDirect3DRMTexture2_AddRef(material);
1830 IDirect3DRMTexture2_Release(This->material);
1831 This->material = material;
1836 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureTopology(IDirect3DRMMeshBuilder3* iface,
1837 BOOL wrap_u, BOOL wrap_v)
1839 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1841 FIXME("(%p)->(%d,%d): stub\n", This, wrap_u, wrap_v);
1846 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetQuality(IDirect3DRMMeshBuilder3* iface,
1847 D3DRMRENDERQUALITY quality)
1849 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1851 FIXME("(%p)->(%d): stub\n", This, quality);
1856 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetPerspective(IDirect3DRMMeshBuilder3* iface,
1859 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1861 FIXME("(%p)->(%d): stub\n", This, enable);
1866 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertex(IDirect3DRMMeshBuilder3* iface,
1868 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1870 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1872 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1877 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormal(IDirect3DRMMeshBuilder3* iface,
1879 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1881 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1883 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1888 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1889 DWORD index, D3DVALUE u,
1892 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1894 TRACE("(%p)->(%u,%f,%f)\n", This, index, u, v);
1896 if (index >= This->nb_coords2d)
1897 return D3DRMERR_BADVALUE;
1899 This->pCoords2d[index].u = u;
1900 This->pCoords2d[index].v = v;
1905 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColor(IDirect3DRMMeshBuilder3* iface,
1906 DWORD index, D3DCOLOR color)
1908 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1910 FIXME("(%p)->(%d,%x): stub\n", This, index, color);
1915 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB(IDirect3DRMMeshBuilder3* iface,
1917 D3DVALUE red, D3DVALUE green,
1920 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1922 FIXME("(%p)->(%d,%f,%f,%f): stub\n", This, index, red, green, blue);
1927 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFaces(IDirect3DRMMeshBuilder3* iface,
1928 LPDIRECT3DRMFACEARRAY* FaceArray)
1930 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1932 FIXME("(%p)->(%p): stub\n", This, FaceArray);
1937 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetGeometry(IDirect3DRMMeshBuilder3* iface,
1938 DWORD* vcount, D3DVECTOR* vertices,
1939 DWORD* ncount, D3DVECTOR* normals,
1940 DWORD* face_data_size,
1943 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1945 FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals,
1946 face_data_size, face_data);
1951 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates(IDirect3DRMMeshBuilder3* iface,
1952 DWORD index, D3DVALUE* u,
1955 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1957 TRACE("(%p)->(%d,%p,%p)\n", This, index, u, v);
1959 if (index >= This->nb_coords2d)
1960 return D3DRMERR_BADVALUE;
1962 *u = This->pCoords2d[index].u;
1963 *v = This->pCoords2d[index].v;
1969 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddVertex(IDirect3DRMMeshBuilder3* iface,
1970 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1972 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1974 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1979 static int WINAPI IDirect3DRMMeshBuilder3Impl_AddNormal(IDirect3DRMMeshBuilder3* iface,
1980 D3DVALUE x, D3DVALUE y, D3DVALUE z)
1982 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1984 FIXME("(%p)->(%f,%f,%f): stub\n", This, x, y, z);
1989 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateFace(IDirect3DRMMeshBuilder3* iface,
1990 LPDIRECT3DRMFACE2* Face)
1992 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
1994 FIXME("(%p)->(%p): stub\n", This, Face);
1999 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshBuilder3Impl_GetQuality(IDirect3DRMMeshBuilder3* iface)
2001 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2003 FIXME("(%p)->(): stub\n", This);
2008 static BOOL WINAPI IDirect3DRMMeshBuilder3Impl_GetPerspective(IDirect3DRMMeshBuilder3* iface)
2010 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2012 FIXME("(%p)->(): stub\n", This);
2017 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetFaceCount(IDirect3DRMMeshBuilder3* iface)
2019 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2021 TRACE("(%p)->()\n", This);
2023 return This->nb_faces;
2026 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexCount(IDirect3DRMMeshBuilder3* iface)
2028 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2030 TRACE("(%p)->()\n", This);
2032 return This->nb_vertices;
2035 static D3DCOLOR WINAPI IDirect3DRMMeshBuilder3Impl_GetVertexColor(IDirect3DRMMeshBuilder3* iface,
2038 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2040 FIXME("(%p)->(%d): stub\n", This, index);
2045 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateMesh(IDirect3DRMMeshBuilder3* iface,
2046 LPDIRECT3DRMMESH* mesh)
2048 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2050 D3DRMGROUPINDEX group;
2051 ULONG vertex_per_face = 0;
2053 TRACE("(%p)->(%p)\n", This, mesh);
2058 hr = Direct3DRMMesh_create(mesh);
2062 /* If there is mesh data, create a group and put data inside */
2063 if (This->nb_vertices)
2065 unsigned* face_data;
2067 DWORD* in_ptr = This->pFaceData;
2069 D3DRMVERTEX* vertices;
2071 vertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DRMVERTEX));
2074 IDirect3DRMMesh_Release(*mesh);
2075 return E_OUTOFMEMORY;
2077 for (i = 0; i < This->nb_vertices; i++)
2078 vertices[i].position = This->pVertices[i];
2079 hr = IDirect3DRMMesh_SetVertices(*mesh, 0, 0, This->nb_vertices, vertices);
2080 HeapFree(GetProcessHeap(), 0, vertices);
2082 face_data = HeapAlloc(GetProcessHeap(), 0, This->face_data_size * sizeof(DWORD));
2085 IDirect3DRMMesh_Release(*mesh);
2086 return E_OUTOFMEMORY;
2088 out_ptr = face_data;
2090 /* If all faces have the same number of vertex, set vertex_per_face */
2091 for (i = 0; i < This->nb_faces; i++)
2093 if (vertex_per_face && (vertex_per_face != *in_ptr))
2095 vertex_per_face = *in_ptr;
2096 in_ptr += 1 + *in_ptr * 2;
2098 if (i != This->nb_faces)
2099 vertex_per_face = 0;
2101 /* Put only vertex indices */
2102 in_ptr = This->pFaceData;
2103 for (i = 0; i < This->nb_faces; i++)
2105 DWORD nb_indices = *in_ptr++;
2107 /* Don't put nb indices when vertex_per_face is set */
2108 if (vertex_per_face)
2109 *out_ptr++ = nb_indices;
2111 for (j = 0; j < nb_indices; j++)
2113 *out_ptr++ = *in_ptr++;
2114 /* Skip normal index */
2119 hr = IDirect3DRMMesh_AddGroup(*mesh, This->nb_vertices, This->nb_faces, vertex_per_face, face_data, &group);
2120 HeapFree(GetProcessHeap(), 0, face_data);
2123 hr = IDirect3DRMMesh_SetGroupColor(*mesh, 0, This->color);
2125 hr = IDirect3DRMMesh_SetGroupMaterial(*mesh, 0, (LPDIRECT3DRMMATERIAL)This->material);
2126 if (SUCCEEDED(hr) && This->texture)
2128 LPDIRECT3DRMTEXTURE texture;
2130 IDirect3DRMTexture3_QueryInterface(This->texture, &IID_IDirect3DRMTexture, (LPVOID*)&texture);
2131 hr = IDirect3DRMMesh_SetGroupTexture(*mesh, 0, texture);
2132 IDirect3DRMTexture_Release(texture);
2135 IDirect3DRMMesh_Release(*mesh);
2141 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetFace(IDirect3DRMMeshBuilder3* iface,
2142 DWORD index, LPDIRECT3DRMFACE2* Face)
2144 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2146 FIXME("(%p)->(%u,%p): stub\n", This, index, Face);
2151 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertex(IDirect3DRMMeshBuilder3* iface,
2152 DWORD index, LPD3DVECTOR vector)
2154 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2156 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2161 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormal(IDirect3DRMMeshBuilder3* iface,
2162 DWORD index, LPD3DVECTOR vector)
2164 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2166 FIXME("(%p)->(%u,%p): stub\n", This, index, vector);
2171 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteVertices(IDirect3DRMMeshBuilder3* iface,
2172 DWORD IndexFirst, DWORD count)
2174 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2176 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2181 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteNormals(IDirect3DRMMeshBuilder3* iface,
2182 DWORD IndexFirst, DWORD count)
2184 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2186 FIXME("(%p)->(%u,%u): stub\n", This, IndexFirst, count);
2191 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteFace(IDirect3DRMMeshBuilder3* iface,
2192 LPDIRECT3DRMFACE2 Face)
2194 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2196 FIXME("(%p)->(%p): stub\n", This, Face);
2201 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Empty(IDirect3DRMMeshBuilder3* iface, DWORD flags)
2203 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2205 FIXME("(%p)->(%u): stub\n", This, flags);
2210 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Optimize(IDirect3DRMMeshBuilder3* iface,
2213 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2215 FIXME("(%p)->(%u): stub\n", This, flags);
2220 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddFacesIndexed(IDirect3DRMMeshBuilder3* iface,
2221 DWORD flags, DWORD* indices,
2222 DWORD* IndexFirst, DWORD* count)
2224 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2226 FIXME("(%p)->(%u,%p,%p,%p): stub\n", This, flags, indices, IndexFirst, count);
2231 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_CreateSubMesh(IDirect3DRMMeshBuilder3* iface,
2234 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2236 FIXME("(%p)->(%p): stub\n", This, unkwn);
2241 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetParentMesh(IDirect3DRMMeshBuilder3* iface,
2242 DWORD flags, LPUNKNOWN *unkwn)
2244 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2246 FIXME("(%p)->(%u,%p): stub\n", This, flags, unkwn);
2251 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetSubMeshes(IDirect3DRMMeshBuilder3* iface,
2252 LPDWORD count, LPUNKNOWN *unkwn)
2254 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2256 FIXME("(%p)->(%p,%p): stub\n", This, count, unkwn);
2261 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_DeleteSubMesh(IDirect3DRMMeshBuilder3* iface,
2264 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2266 FIXME("(%p)->(%p): stub\n", This, unkwn);
2271 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_Enable(IDirect3DRMMeshBuilder3* iface,
2274 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2276 FIXME("(%p)->(%u): stub\n", This, index);
2281 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetEnable(IDirect3DRMMeshBuilder3* iface,
2284 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2286 FIXME("(%p)->(%p): stub\n", This, indices);
2291 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_AddTriangles(IDirect3DRMMeshBuilder3* iface,
2292 DWORD flags, DWORD format,
2293 DWORD VertexCount, LPVOID data)
2295 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2297 FIXME("(%p)->(%u,%u,%u,%p): stub\n", This, flags, format, VertexCount, data);
2302 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetVertices(IDirect3DRMMeshBuilder3* iface,
2303 DWORD IndexFirst, DWORD count,
2306 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2308 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2313 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetVertices(IDirect3DRMMeshBuilder3* iface,
2314 DWORD IndexFirst, LPDWORD vcount,
2315 LPD3DVECTOR vertices)
2317 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2318 DWORD count = This->nb_vertices - IndexFirst;
2320 TRACE("(%p)->(%u,%p,%p)\n", This, IndexFirst, vcount, vertices);
2324 if (vertices && This->nb_vertices)
2325 memcpy(vertices, This->pVertices + IndexFirst, count * sizeof(D3DVECTOR));
2330 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_SetNormals(IDirect3DRMMeshBuilder3* iface,
2331 DWORD IndexFirst, DWORD count,
2334 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2336 FIXME("(%p)->(%u,%u,%p): stub\n", This, IndexFirst, count, vector);
2341 static HRESULT WINAPI IDirect3DRMMeshBuilder3Impl_GetNormals(IDirect3DRMMeshBuilder3* iface,
2342 DWORD IndexFirst, LPDWORD count,
2345 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2347 FIXME("(%p)->(%u,%p,%p): stub\n", This, IndexFirst, count, vector);
2352 static int WINAPI IDirect3DRMMeshBuilder3Impl_GetNormalCount(IDirect3DRMMeshBuilder3* iface)
2354 IDirect3DRMMeshBuilderImpl *This = impl_from_IDirect3DRMMeshBuilder3(iface);
2356 FIXME("(%p)->(): stub\n", This);
2361 static const struct IDirect3DRMMeshBuilder3Vtbl Direct3DRMMeshBuilder3_Vtbl =
2363 /*** IUnknown methods ***/
2364 IDirect3DRMMeshBuilder3Impl_QueryInterface,
2365 IDirect3DRMMeshBuilder3Impl_AddRef,
2366 IDirect3DRMMeshBuilder3Impl_Release,
2367 /*** IDirect3DRMObject methods ***/
2368 IDirect3DRMMeshBuilder3Impl_Clone,
2369 IDirect3DRMMeshBuilder3Impl_AddDestroyCallback,
2370 IDirect3DRMMeshBuilder3Impl_DeleteDestroyCallback,
2371 IDirect3DRMMeshBuilder3Impl_SetAppData,
2372 IDirect3DRMMeshBuilder3Impl_GetAppData,
2373 IDirect3DRMMeshBuilder3Impl_SetName,
2374 IDirect3DRMMeshBuilder3Impl_GetName,
2375 IDirect3DRMMeshBuilder3Impl_GetClassName,
2376 /*** IDirect3DRMMeshBuilder3 methods ***/
2377 IDirect3DRMMeshBuilder3Impl_Load,
2378 IDirect3DRMMeshBuilder3Impl_Save,
2379 IDirect3DRMMeshBuilder3Impl_Scale,
2380 IDirect3DRMMeshBuilder3Impl_Translate,
2381 IDirect3DRMMeshBuilder3Impl_SetColorSource,
2382 IDirect3DRMMeshBuilder3Impl_GetBox,
2383 IDirect3DRMMeshBuilder3Impl_GenerateNormals,
2384 IDirect3DRMMeshBuilder3Impl_GetColorSource,
2385 IDirect3DRMMeshBuilder3Impl_AddMesh,
2386 IDirect3DRMMeshBuilder3Impl_AddMeshBuilder,
2387 IDirect3DRMMeshBuilder3Impl_AddFrame,
2388 IDirect3DRMMeshBuilder3Impl_AddFace,
2389 IDirect3DRMMeshBuilder3Impl_AddFaces,
2390 IDirect3DRMMeshBuilder3Impl_ReserveSpace,
2391 IDirect3DRMMeshBuilder3Impl_SetColorRGB,
2392 IDirect3DRMMeshBuilder3Impl_SetColor,
2393 IDirect3DRMMeshBuilder3Impl_SetTexture,
2394 IDirect3DRMMeshBuilder3Impl_SetMaterial,
2395 IDirect3DRMMeshBuilder3Impl_SetTextureTopology,
2396 IDirect3DRMMeshBuilder3Impl_SetQuality,
2397 IDirect3DRMMeshBuilder3Impl_SetPerspective,
2398 IDirect3DRMMeshBuilder3Impl_SetVertex,
2399 IDirect3DRMMeshBuilder3Impl_SetNormal,
2400 IDirect3DRMMeshBuilder3Impl_SetTextureCoordinates,
2401 IDirect3DRMMeshBuilder3Impl_SetVertexColor,
2402 IDirect3DRMMeshBuilder3Impl_SetVertexColorRGB,
2403 IDirect3DRMMeshBuilder3Impl_GetFaces,
2404 IDirect3DRMMeshBuilder3Impl_GetGeometry,
2405 IDirect3DRMMeshBuilder3Impl_GetTextureCoordinates,
2406 IDirect3DRMMeshBuilder3Impl_AddVertex,
2407 IDirect3DRMMeshBuilder3Impl_AddNormal,
2408 IDirect3DRMMeshBuilder3Impl_CreateFace,
2409 IDirect3DRMMeshBuilder3Impl_GetQuality,
2410 IDirect3DRMMeshBuilder3Impl_GetPerspective,
2411 IDirect3DRMMeshBuilder3Impl_GetFaceCount,
2412 IDirect3DRMMeshBuilder3Impl_GetVertexCount,
2413 IDirect3DRMMeshBuilder3Impl_GetVertexColor,
2414 IDirect3DRMMeshBuilder3Impl_CreateMesh,
2415 IDirect3DRMMeshBuilder3Impl_GetFace,
2416 IDirect3DRMMeshBuilder3Impl_GetVertex,
2417 IDirect3DRMMeshBuilder3Impl_GetNormal,
2418 IDirect3DRMMeshBuilder3Impl_DeleteVertices,
2419 IDirect3DRMMeshBuilder3Impl_DeleteNormals,
2420 IDirect3DRMMeshBuilder3Impl_DeleteFace,
2421 IDirect3DRMMeshBuilder3Impl_Empty,
2422 IDirect3DRMMeshBuilder3Impl_Optimize,
2423 IDirect3DRMMeshBuilder3Impl_AddFacesIndexed,
2424 IDirect3DRMMeshBuilder3Impl_CreateSubMesh,
2425 IDirect3DRMMeshBuilder3Impl_GetParentMesh,
2426 IDirect3DRMMeshBuilder3Impl_GetSubMeshes,
2427 IDirect3DRMMeshBuilder3Impl_DeleteSubMesh,
2428 IDirect3DRMMeshBuilder3Impl_Enable,
2429 IDirect3DRMMeshBuilder3Impl_GetEnable,
2430 IDirect3DRMMeshBuilder3Impl_AddTriangles,
2431 IDirect3DRMMeshBuilder3Impl_SetVertices,
2432 IDirect3DRMMeshBuilder3Impl_GetVertices,
2433 IDirect3DRMMeshBuilder3Impl_SetNormals,
2434 IDirect3DRMMeshBuilder3Impl_GetNormals,
2435 IDirect3DRMMeshBuilder3Impl_GetNormalCount
2438 HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj)
2440 IDirect3DRMMeshBuilderImpl* object;
2442 TRACE("(%p)\n", ppObj);
2444 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshBuilderImpl));
2447 ERR("Out of memory\n");
2448 return E_OUTOFMEMORY;
2451 object->IDirect3DRMMeshBuilder2_iface.lpVtbl = &Direct3DRMMeshBuilder2_Vtbl;
2452 object->IDirect3DRMMeshBuilder3_iface.lpVtbl = &Direct3DRMMeshBuilder3_Vtbl;
2455 if (IsEqualGUID(riid, &IID_IDirect3DRMMeshBuilder3))
2456 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder3_iface;
2458 *ppObj = (IUnknown*)&object->IDirect3DRMMeshBuilder2_iface;
2463 /*** IUnknown methods ***/
2464 static HRESULT WINAPI IDirect3DRMMeshImpl_QueryInterface(IDirect3DRMMesh* iface,
2465 REFIID riid, void** ppvObject)
2467 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2469 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
2473 if (IsEqualGUID(riid, &IID_IUnknown) ||
2474 IsEqualGUID(riid, &IID_IDirect3DRMMesh))
2476 *ppvObject = &This->IDirect3DRMMesh_iface;
2480 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2481 return E_NOINTERFACE;
2484 IDirect3DRMMesh_AddRef(iface);
2488 static ULONG WINAPI IDirect3DRMMeshImpl_AddRef(IDirect3DRMMesh* iface)
2490 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2491 ULONG ref = InterlockedIncrement(&This->ref);
2493 TRACE("(%p)->(): new ref = %d\n", This, ref);
2498 static ULONG WINAPI IDirect3DRMMeshImpl_Release(IDirect3DRMMesh* iface)
2500 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2501 ULONG ref = InterlockedDecrement(&This->ref);
2503 TRACE("(%p)->(): new ref = %d\n", This, ref);
2509 for (i = 0; i < This->nb_groups; i++)
2511 HeapFree(GetProcessHeap(), 0, This->groups[i].vertices);
2512 HeapFree(GetProcessHeap(), 0, This->groups[i].face_data);
2513 if (This->groups[i].material)
2514 IDirect3DRMMaterial2_Release(This->groups[i].material);
2515 if (This->groups[i].texture)
2516 IDirect3DRMTexture3_Release(This->groups[i].texture);
2518 HeapFree(GetProcessHeap(), 0, This->groups);
2519 HeapFree(GetProcessHeap(), 0, This);
2525 /*** IDirect3DRMObject methods ***/
2526 static HRESULT WINAPI IDirect3DRMMeshImpl_Clone(IDirect3DRMMesh* iface,
2527 LPUNKNOWN pUnkOuter, REFIID riid,
2530 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2532 FIXME("(%p)->(%p,%s,%p): stub\n", This, pUnkOuter, debugstr_guid(riid), ppvObj);
2537 static HRESULT WINAPI IDirect3DRMMeshImpl_AddDestroyCallback(IDirect3DRMMesh* iface,
2538 D3DRMOBJECTCALLBACK cb,
2541 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2543 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2548 static HRESULT WINAPI IDirect3DRMMeshImpl_DeleteDestroyCallback(IDirect3DRMMesh* iface,
2549 D3DRMOBJECTCALLBACK cb,
2552 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2554 FIXME("(%p)->(%p,%p): stub\n", This, cb, argument);
2559 static HRESULT WINAPI IDirect3DRMMeshImpl_SetAppData(IDirect3DRMMesh* iface,
2562 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2564 FIXME("(%p)->(%u): stub\n", This, data);
2569 static DWORD WINAPI IDirect3DRMMeshImpl_GetAppData(IDirect3DRMMesh* iface)
2571 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2573 FIXME("(%p)->(): stub\n", This);
2578 static HRESULT WINAPI IDirect3DRMMeshImpl_SetName(IDirect3DRMMesh* iface,
2581 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2583 FIXME("(%p)->(%s): stub\n", This, pName);
2588 static HRESULT WINAPI IDirect3DRMMeshImpl_GetName(IDirect3DRMMesh* iface,
2589 LPDWORD lpdwSize, LPSTR lpName)
2591 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2593 FIXME("(%p)->(%p,%p): stub\n", This, lpdwSize, lpName);
2598 static HRESULT WINAPI IDirect3DRMMeshImpl_GetClassName(IDirect3DRMMesh* iface,
2599 LPDWORD size, LPSTR name)
2601 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2603 TRACE("(%p)->(%p, %p)\n", This, size, name);
2605 if (!size || *size < strlen("Mesh") || !name)
2606 return E_INVALIDARG;
2608 strcpy(name, "Mesh");
2609 *size = sizeof("Mesh");
2614 /*** IDirect3DRMMesh methods ***/
2615 static HRESULT WINAPI IDirect3DRMMeshImpl_Scale(IDirect3DRMMesh* iface,
2616 D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
2618 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2620 FIXME("(%p)->(%f,%f,%f): stub\n", This, sx, sy,sz);
2625 static HRESULT WINAPI IDirect3DRMMeshImpl_Translate(IDirect3DRMMesh* iface,
2626 D3DVALUE tx, D3DVALUE ty, D3DVALUE tz)
2628 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2630 FIXME("(%p)->(%f,%f,%f): stub\n", This, tx, ty,tz);
2635 static HRESULT WINAPI IDirect3DRMMeshImpl_GetBox(IDirect3DRMMesh* iface,
2638 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2640 FIXME("(%p)->(%p): stub\n", This, box);
2645 static HRESULT WINAPI IDirect3DRMMeshImpl_AddGroup(IDirect3DRMMesh* iface,
2646 unsigned vertex_count, unsigned face_count, unsigned vertex_per_face,
2647 unsigned *face_data, D3DRMGROUPINDEX *return_id)
2649 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2652 TRACE("(%p)->(%u,%u,%u,%p,%p)\n", This, vertex_count, face_count, vertex_per_face, face_data, return_id);
2654 if (!face_data || !return_id)
2657 if ((This->nb_groups + 1) > This->groups_capacity)
2662 if (!This->groups_capacity)
2665 groups = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(mesh_group));
2669 new_capacity = This->groups_capacity * 2;
2670 groups = HeapReAlloc(GetProcessHeap(), 0, This->groups, new_capacity * sizeof(mesh_group));
2674 return E_OUTOFMEMORY;
2676 This->groups_capacity = new_capacity;
2677 This->groups = groups;
2680 group = This->groups + This->nb_groups;
2682 group->vertices = HeapAlloc(GetProcessHeap(), 0, vertex_count * sizeof(D3DRMVERTEX));
2683 if (!group->vertices)
2684 return E_OUTOFMEMORY;
2685 group->nb_vertices = vertex_count;
2686 group->nb_faces = face_count;
2687 group->vertex_per_face = vertex_per_face;
2689 if (vertex_per_face)
2691 group->face_data_size = face_count * vertex_per_face;
2696 unsigned nb_indices;
2697 unsigned* face_data_ptr = face_data;
2698 group->face_data_size = 0;
2700 for (i = 0; i < face_count; i++)
2702 nb_indices = *face_data_ptr;
2703 group->face_data_size += nb_indices + 1;
2704 face_data_ptr += nb_indices;
2708 group->face_data = HeapAlloc(GetProcessHeap(), 0, group->face_data_size * sizeof(unsigned));
2709 if (!group->face_data)
2711 HeapFree(GetProcessHeap(), 0 , group->vertices);
2712 return E_OUTOFMEMORY;
2715 memcpy(group->face_data, face_data, group->face_data_size * sizeof(unsigned));
2717 group->material = NULL;
2718 group->texture = NULL;
2720 *return_id = This->nb_groups++;
2725 static HRESULT WINAPI IDirect3DRMMeshImpl_SetVertices(IDirect3DRMMesh* iface,
2726 D3DRMGROUPINDEX id, unsigned index, unsigned count,
2727 D3DRMVERTEX *values)
2729 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2731 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, values);
2733 if (id >= This->nb_groups)
2734 return D3DRMERR_BADVALUE;
2736 if ((index + count - 1) >= This->groups[id].nb_vertices)
2737 return D3DRMERR_BADVALUE;
2742 memcpy(This->groups[id].vertices + index, values, count * sizeof(D3DRMVERTEX));
2747 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColor(IDirect3DRMMesh* iface,
2748 D3DRMGROUPINDEX id, D3DCOLOR color)
2750 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2752 TRACE("(%p)->(%u,%x)\n", This, id, color);
2754 if (id >= This->nb_groups)
2755 return D3DRMERR_BADVALUE;
2757 This->groups[id].color = color;
2762 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupColorRGB(IDirect3DRMMesh* iface,
2763 D3DRMGROUPINDEX id, D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2765 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2767 TRACE("(%p)->(%u,%f,%f,%f)\n", This, id, red, green, blue);
2769 if (id >= This->nb_groups)
2770 return D3DRMERR_BADVALUE;
2772 This->groups[id].color = D3DCOLOR_ARGB(0xff, (BYTE)(red * 255.0f),
2773 (BYTE)(green * 255.0f),
2774 (BYTE)(blue * 255.0f));
2779 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMapping(IDirect3DRMMesh* iface,
2780 D3DRMGROUPINDEX id, D3DRMMAPPING value)
2782 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2784 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2789 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupQuality(IDirect3DRMMesh* iface,
2790 D3DRMGROUPINDEX id, D3DRMRENDERQUALITY value)
2792 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2794 FIXME("(%p)->(%u,%u): stub\n", This, id, value);
2799 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupMaterial(IDirect3DRMMesh* iface,
2800 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL material)
2802 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2804 TRACE("(%p)->(%u,%p)\n", This, id, material);
2806 if (id >= This->nb_groups)
2807 return D3DRMERR_BADVALUE;
2809 if (This->groups[id].material)
2810 IDirect3DRMMaterial2_Release(This->groups[id].material);
2812 This->groups[id].material = (LPDIRECT3DRMMATERIAL2)material;
2815 IDirect3DRMMaterial2_AddRef(This->groups[id].material);
2820 static HRESULT WINAPI IDirect3DRMMeshImpl_SetGroupTexture(IDirect3DRMMesh* iface,
2821 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE texture)
2823 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2825 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2827 if (id >= This->nb_groups)
2828 return D3DRMERR_BADVALUE;
2830 if (This->groups[id].texture)
2831 IDirect3DRMTexture3_Release(This->groups[id].texture);
2835 This->groups[id].texture = NULL;
2839 return IDirect3DRMTexture3_QueryInterface(texture, &IID_IDirect3DRMTexture, (LPVOID*)&This->groups[id].texture);
2842 static DWORD WINAPI IDirect3DRMMeshImpl_GetGroupCount(IDirect3DRMMesh* iface)
2844 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2846 TRACE("(%p)->()\n", This);
2848 return This->nb_groups;
2851 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroup(IDirect3DRMMesh* iface,
2852 D3DRMGROUPINDEX id, unsigned *vertex_count, unsigned *face_count, unsigned *vertex_per_face,
2853 DWORD *face_data_size, unsigned *face_data)
2855 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2857 TRACE("(%p)->(%u,%p,%p,%p,%p,%p)\n", This, id, vertex_count, face_count, vertex_per_face, face_data_size, face_data);
2859 if (id >= This->nb_groups)
2860 return D3DRMERR_BADVALUE;
2863 *vertex_count = This->groups[id].nb_vertices;
2865 *face_count = This->groups[id].nb_faces;
2866 if (vertex_per_face)
2867 *vertex_per_face = This->groups[id].vertex_per_face;
2869 *face_data_size = This->groups[id].face_data_size;
2871 memcpy(face_data, This->groups[id].face_data, This->groups[id].face_data_size);
2876 static HRESULT WINAPI IDirect3DRMMeshImpl_GetVertices(IDirect3DRMMesh* iface,
2877 D3DRMGROUPINDEX id, DWORD index, DWORD count, D3DRMVERTEX *return_ptr)
2879 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2881 TRACE("(%p)->(%u,%u,%u,%p)\n", This, id, index, count, return_ptr);
2883 if (id >= This->nb_groups)
2884 return D3DRMERR_BADVALUE;
2886 if ((index + count - 1) >= This->groups[id].nb_vertices)
2887 return D3DRMERR_BADVALUE;
2892 memcpy(return_ptr, This->groups[id].vertices + index, count * sizeof(D3DRMVERTEX));
2897 static D3DCOLOR WINAPI IDirect3DRMMeshImpl_GetGroupColor(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2899 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2901 TRACE("(%p)->(%u)\n", This, id);
2903 return This->groups[id].color;
2906 static D3DRMMAPPING WINAPI IDirect3DRMMeshImpl_GetGroupMapping(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2908 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2910 FIXME("(%p)->(%u): stub\n", This, id);
2914 static D3DRMRENDERQUALITY WINAPI IDirect3DRMMeshImpl_GetGroupQuality(IDirect3DRMMesh* iface, D3DRMGROUPINDEX id)
2916 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2918 FIXME("(%p)->(%u): stub\n", This, id);
2923 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupMaterial(IDirect3DRMMesh* iface,
2924 D3DRMGROUPINDEX id, LPDIRECT3DRMMATERIAL *material)
2926 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2928 TRACE("(%p)->(%u,%p)\n", This, id, material);
2930 if (id >= This->nb_groups)
2931 return D3DRMERR_BADVALUE;
2936 if (This->groups[id].material)
2937 IDirect3DRMTexture_QueryInterface(This->groups[id].material, &IID_IDirect3DRMMaterial, (void**)material);
2944 static HRESULT WINAPI IDirect3DRMMeshImpl_GetGroupTexture(IDirect3DRMMesh* iface,
2945 D3DRMGROUPINDEX id, LPDIRECT3DRMTEXTURE *texture)
2947 IDirect3DRMMeshImpl *This = impl_from_IDirect3DRMMesh(iface);
2949 TRACE("(%p)->(%u,%p)\n", This, id, texture);
2951 if (id >= This->nb_groups)
2952 return D3DRMERR_BADVALUE;
2957 if (This->groups[id].texture)
2958 IDirect3DRMTexture_QueryInterface(This->groups[id].texture, &IID_IDirect3DRMTexture, (void**)texture);
2965 static const struct IDirect3DRMMeshVtbl Direct3DRMMesh_Vtbl =
2967 /*** IUnknown methods ***/
2968 IDirect3DRMMeshImpl_QueryInterface,
2969 IDirect3DRMMeshImpl_AddRef,
2970 IDirect3DRMMeshImpl_Release,
2971 /*** IDirect3DRMObject methods ***/
2972 IDirect3DRMMeshImpl_Clone,
2973 IDirect3DRMMeshImpl_AddDestroyCallback,
2974 IDirect3DRMMeshImpl_DeleteDestroyCallback,
2975 IDirect3DRMMeshImpl_SetAppData,
2976 IDirect3DRMMeshImpl_GetAppData,
2977 IDirect3DRMMeshImpl_SetName,
2978 IDirect3DRMMeshImpl_GetName,
2979 IDirect3DRMMeshImpl_GetClassName,
2980 /*** IDirect3DRMMesh methods ***/
2981 IDirect3DRMMeshImpl_Scale,
2982 IDirect3DRMMeshImpl_Translate,
2983 IDirect3DRMMeshImpl_GetBox,
2984 IDirect3DRMMeshImpl_AddGroup,
2985 IDirect3DRMMeshImpl_SetVertices,
2986 IDirect3DRMMeshImpl_SetGroupColor,
2987 IDirect3DRMMeshImpl_SetGroupColorRGB,
2988 IDirect3DRMMeshImpl_SetGroupMapping,
2989 IDirect3DRMMeshImpl_SetGroupQuality,
2990 IDirect3DRMMeshImpl_SetGroupMaterial,
2991 IDirect3DRMMeshImpl_SetGroupTexture,
2992 IDirect3DRMMeshImpl_GetGroupCount,
2993 IDirect3DRMMeshImpl_GetGroup,
2994 IDirect3DRMMeshImpl_GetVertices,
2995 IDirect3DRMMeshImpl_GetGroupColor,
2996 IDirect3DRMMeshImpl_GetGroupMapping,
2997 IDirect3DRMMeshImpl_GetGroupQuality,
2998 IDirect3DRMMeshImpl_GetGroupMaterial,
2999 IDirect3DRMMeshImpl_GetGroupTexture
3002 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj)
3004 IDirect3DRMMeshImpl* object;
3006 TRACE("(%p)\n", obj);
3008 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMMeshImpl));
3011 ERR("Out of memory\n");
3012 return E_OUTOFMEMORY;
3015 object->IDirect3DRMMesh_iface.lpVtbl = &Direct3DRMMesh_Vtbl;
3018 *obj = &object->IDirect3DRMMesh_iface;