d3drm: Make IDirect3DRMMeshBuilderImpl_Load handle normals and texture coordinates.
Implement IDirect3DRMMeshBuilderImpl_GetTextureCoordinates.
This commit is contained in:
parent
739c1177d9
commit
e0756602a4
|
@ -34,6 +34,11 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
||||
|
||||
typedef struct {
|
||||
D3DVALUE u;
|
||||
D3DVALUE v;
|
||||
} Coords2d;
|
||||
|
||||
typedef struct {
|
||||
const IDirect3DRMMeshBuilderVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
|
@ -44,6 +49,8 @@ typedef struct {
|
|||
DWORD nb_faces;
|
||||
DWORD face_data_size;
|
||||
LPVOID pFaceData;
|
||||
DWORD nb_coords2d;
|
||||
Coords2d* pCoords2d;
|
||||
} IDirect3DRMMeshBuilderImpl;
|
||||
|
||||
typedef struct {
|
||||
|
@ -54,8 +61,11 @@ typedef struct {
|
|||
|
||||
static const struct IDirect3DRMMeshBuilderVtbl Direct3DRMMeshBuilder_Vtbl;
|
||||
|
||||
static const GUID GUID_Header = { 0x3D82AB43, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
static const GUID GUID_Mesh = { 0x3D82AB44, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
static const GUID GUID_Header = { 0x3D82AB43, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
static const GUID GUID_Mesh = { 0x3D82AB44, 0x62DA, 0x11CF, { 0xAB, 0x39, 0x00, 0x20, 0xAF, 0x71, 0xE4, 0x33 } };
|
||||
static const GUID GUID_MeshTextureCoords = { 0xF6F23F40, 0x7686, 0x11CF, { 0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3 } };
|
||||
static const GUID GUID_MeshMaterialList = { 0xF6F23F42, 0x7686, 0x11CF, { 0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3 } };
|
||||
static const GUID GUID_MeshNormals = { 0xF6F23F43, 0x7686, 0x11CF, { 0x8F, 0x52, 0x00, 0x40, 0x33, 0x35, 0x94, 0xA3 } };
|
||||
|
||||
static char templates[] = {
|
||||
"xof 0302txt 0064"
|
||||
|
@ -426,6 +436,8 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
LPDIRECTXFILE pDXFile = NULL;
|
||||
LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
|
||||
LPDIRECTXFILEDATA pData = NULL;
|
||||
LPDIRECTXFILEOBJECT pObject = NULL;
|
||||
LPDIRECTXFILEDATA pData2 = NULL;
|
||||
const GUID* pGuid;
|
||||
DWORD size;
|
||||
Header* pHeader;
|
||||
|
@ -442,6 +454,8 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
This->pNormals = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This->pFaceData);
|
||||
This->pFaceData = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This->pCoords2d);
|
||||
This->pCoords2d = NULL;
|
||||
|
||||
if (loadflags == D3DRMLOAD_FROMMEMORY)
|
||||
{
|
||||
|
@ -536,6 +550,73 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
|||
This->pFaceData = HeapAlloc(GetProcessHeap(), 0, This->face_data_size);
|
||||
memcpy(This->pFaceData, ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR) + sizeof(DWORD), This->face_data_size);
|
||||
|
||||
while (1)
|
||||
{
|
||||
hr = IDirectXFileData_GetNextObject(pData, &pObject);
|
||||
if (hr == DXFILEERR_NOMOREOBJECTS)
|
||||
{
|
||||
FIXME("no more object\n");
|
||||
break;
|
||||
}
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
hr = IDirectXFileObject_QueryInterface(pObject, &IID_IDirectXFileData, (void**)&pData2);
|
||||
IDirectXFileObject_Release(pObject);
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
hr = IDirectXFileData_GetType(pData2, &pGuid);
|
||||
if (hr != DXFILE_OK)
|
||||
{
|
||||
IDirectXFileData_Release(pData2);
|
||||
goto end;
|
||||
}
|
||||
|
||||
FIXME("toto: Found object type whose GUID = %s\n", debugstr_guid(pGuid));
|
||||
|
||||
if (!IsEqualGUID(pGuid, &GUID_MeshNormals))
|
||||
{
|
||||
DWORD tmp;
|
||||
|
||||
hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
This->nb_normals = *(DWORD*)ptr;
|
||||
tmp = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_normals * sizeof(D3DVECTOR));
|
||||
|
||||
FIXME("MeshNormals: nb_normals = %d, nb_faces_normals = %d\n", This->nb_normals, tmp);
|
||||
|
||||
This->pNormals = HeapAlloc(GetProcessHeap(), 0, This->nb_normals * sizeof(D3DVECTOR));
|
||||
memcpy(This->pNormals, ptr + sizeof(DWORD), This->nb_normals * sizeof(D3DVECTOR));
|
||||
}
|
||||
else if(!IsEqualGUID(pGuid, &GUID_MeshTextureCoords))
|
||||
{
|
||||
hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
|
||||
if (hr != DXFILE_OK)
|
||||
goto end;
|
||||
|
||||
This->nb_coords2d = *(DWORD*)ptr;
|
||||
|
||||
FIXME("MeshTextureCoords: nb_coords2d = %d\n", This->nb_coords2d);
|
||||
|
||||
This->pCoords2d = HeapAlloc(GetProcessHeap(), 0, This->nb_coords2d * sizeof(Coords2d));
|
||||
memcpy(This->pCoords2d, ptr + sizeof(DWORD), This->nb_coords2d * sizeof(Coords2d));
|
||||
|
||||
}
|
||||
else if(!IsEqualGUID(pGuid, &GUID_MeshMaterialList))
|
||||
{
|
||||
FIXME("MeshMaterialList not supported yet, ignoring...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
FIXME("Unknown GUID %s, ignoring...\n", debugstr_guid(pGuid));
|
||||
}
|
||||
|
||||
IDirectXFileData_Release(pData2);
|
||||
}
|
||||
|
||||
ret = D3DRM_OK;
|
||||
|
||||
end:
|
||||
|
@ -546,19 +627,22 @@ end:
|
|||
if (pDXFile)
|
||||
IDirectXFile_Release(pDXFile);
|
||||
|
||||
if (hr != D3DRM_OK)
|
||||
if (ret != D3DRM_OK)
|
||||
{
|
||||
/* Clean mesh data */
|
||||
This->nb_vertices = 0;
|
||||
This->nb_normals = 0;
|
||||
This->nb_faces = 0;
|
||||
This->face_data_size = 0;
|
||||
This->nb_coords2d = 0;
|
||||
HeapFree(GetProcessHeap(), 0, This->pVertices);
|
||||
This->pVertices = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This->pNormals);
|
||||
This->pNormals = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This->pFaceData);
|
||||
This->pFaceData = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This->pCoords2d);
|
||||
This->pCoords2d = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -826,7 +910,13 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_GetTextureCoordinates(IDirect3D
|
|||
|
||||
FIXME("(%p)->(%d,%p,%p): stub\n", This, index, u, v);
|
||||
|
||||
return E_NOTIMPL;
|
||||
if (index >= This->nb_coords2d)
|
||||
return D3DRMERR_NOTFOUND;
|
||||
|
||||
*u = This->pCoords2d[index].u;
|
||||
*v = This->pCoords2d[index].v;
|
||||
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
||||
static int WINAPI IDirect3DRMMeshBuilderImpl_AddVertex(IDirect3DRMMeshBuilder* iface, D3DVALUE x, D3DVALUE y, D3DVALUE z)
|
||||
|
|
Loading…
Reference in New Issue