d3drm: Beginning of Mesh info retrieval.
This commit is contained in:
parent
497be4f83c
commit
a4b622d81a
|
@ -37,6 +37,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const IDirect3DRMMeshBuilderVtbl *lpVtbl;
|
const IDirect3DRMMeshBuilderVtbl *lpVtbl;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
DWORD nb_vertices;
|
||||||
|
D3DVECTOR* pVertices;
|
||||||
|
DWORD nb_normals;
|
||||||
|
D3DVECTOR* pNormals;
|
||||||
|
DWORD nb_faces;
|
||||||
|
DWORD face_data_size;
|
||||||
|
LPVOID pFaceData;
|
||||||
} IDirect3DRMMeshBuilderImpl;
|
} IDirect3DRMMeshBuilderImpl;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -328,7 +335,12 @@ static ULONG WINAPI IDirect3DRMMeshBuilderImpl_Release(IDirect3DRMMeshBuilder* i
|
||||||
TRACE("(%p)\n", This);
|
TRACE("(%p)\n", This);
|
||||||
|
|
||||||
if (!ref)
|
if (!ref)
|
||||||
|
{
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pVertices);
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pNormals);
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pFaceData);
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
@ -417,11 +429,20 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
||||||
const GUID* pGuid;
|
const GUID* pGuid;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
Header* pHeader;
|
Header* pHeader;
|
||||||
|
LPBYTE ptr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
HRESULT ret = D3DRMERR_BADOBJECT;
|
HRESULT ret = D3DRMERR_BADOBJECT;
|
||||||
|
|
||||||
FIXME("(%p)->(%p,%p,%x,%p,%p): partial stub\n", This, filename, name, loadflags, cb, pArg);
|
FIXME("(%p)->(%p,%p,%x,%p,%p): partial stub\n", This, filename, name, loadflags, cb, pArg);
|
||||||
|
|
||||||
|
/* First free allocated buffers of previous mesh data */
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pVertices);
|
||||||
|
This->pVertices = NULL;
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pNormals);
|
||||||
|
This->pNormals = NULL;
|
||||||
|
HeapFree(GetProcessHeap(), 0, This->pFaceData);
|
||||||
|
This->pFaceData = NULL;
|
||||||
|
|
||||||
if (loadflags == D3DRMLOAD_FROMMEMORY)
|
if (loadflags == D3DRMLOAD_FROMMEMORY)
|
||||||
{
|
{
|
||||||
DXFILELOADMEMORY info;
|
DXFILELOADMEMORY info;
|
||||||
|
@ -499,6 +520,22 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_Load(IDirect3DRMMeshBuilder* if
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&ptr);
|
||||||
|
if (hr != DXFILE_OK)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
This->nb_vertices = *(DWORD*)ptr;
|
||||||
|
This->nb_faces = *(DWORD*)(ptr + sizeof(DWORD) + This->nb_vertices * sizeof(D3DVECTOR));
|
||||||
|
This->face_data_size = size - sizeof(DWORD) - This->nb_vertices * sizeof(D3DVECTOR) - sizeof(DWORD);
|
||||||
|
|
||||||
|
TRACE("Mesh: nb_vertices = %d, nb_faces = %d, face_data_size = %d\n", This->nb_vertices, This->nb_faces, This->face_data_size);
|
||||||
|
|
||||||
|
This->pVertices = HeapAlloc(GetProcessHeap(), 0, This->nb_vertices * sizeof(D3DVECTOR));
|
||||||
|
memcpy(This->pVertices, ptr + sizeof(DWORD), This->nb_vertices * sizeof(D3DVECTOR));
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
ret = D3DRM_OK;
|
ret = D3DRM_OK;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -509,6 +546,21 @@ end:
|
||||||
if (pDXFile)
|
if (pDXFile)
|
||||||
IDirectXFile_Release(pDXFile);
|
IDirectXFile_Release(pDXFile);
|
||||||
|
|
||||||
|
if (hr != D3DRM_OK)
|
||||||
|
{
|
||||||
|
/* Clean mesh data */
|
||||||
|
This->nb_vertices = 0;
|
||||||
|
This->nb_normals = 0;
|
||||||
|
This->nb_faces = 0;
|
||||||
|
This->face_data_size = 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;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,9 +802,22 @@ static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_GetVertices(IDirect3DRMMeshBuil
|
||||||
{
|
{
|
||||||
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
||||||
|
|
||||||
FIXME("(%p)->(%p,%p,%p,%p,%p,%p): stub\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
|
TRACE("(%p)->(%p,%p,%p,%p,%p,%p)\n", This, vcount, vertices, ncount, normals, face_data_size, face_data);
|
||||||
|
|
||||||
return E_NOTIMPL;
|
if (vcount)
|
||||||
|
*vcount = This->nb_vertices;
|
||||||
|
if (vertices && This->nb_vertices)
|
||||||
|
memcpy(vertices, This->pVertices, This->nb_vertices * sizeof(D3DVECTOR));
|
||||||
|
if (ncount)
|
||||||
|
*ncount = This->nb_normals;
|
||||||
|
if (normals && This->nb_normals)
|
||||||
|
memcpy(normals, This->pNormals, This->nb_normals * sizeof(D3DVECTOR));
|
||||||
|
if (face_data_size)
|
||||||
|
*face_data_size = This->face_data_size;
|
||||||
|
if (face_data && This->face_data_size)
|
||||||
|
memcpy(face_data, This->pFaceData, This->face_data_size);
|
||||||
|
|
||||||
|
return D3DRM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_GetTextureCoordinates(IDirect3DRMMeshBuilder* iface, DWORD index, D3DVALUE *u, D3DVALUE *v)
|
static HRESULT WINAPI IDirect3DRMMeshBuilderImpl_GetTextureCoordinates(IDirect3DRMMeshBuilder* iface, DWORD index, D3DVALUE *u, D3DVALUE *v)
|
||||||
|
@ -813,18 +878,18 @@ static int WINAPI IDirect3DRMMeshBuilderImpl_GetFaceCount(IDirect3DRMMeshBuilder
|
||||||
{
|
{
|
||||||
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
||||||
|
|
||||||
FIXME("(%p)->(): stub\n", This);
|
TRACE("(%p)->()\n", This);
|
||||||
|
|
||||||
return 0;
|
return This->nb_faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int WINAPI IDirect3DRMMeshBuilderImpl_GetVertexCount(IDirect3DRMMeshBuilder* iface)
|
static int WINAPI IDirect3DRMMeshBuilderImpl_GetVertexCount(IDirect3DRMMeshBuilder* iface)
|
||||||
{
|
{
|
||||||
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
IDirect3DRMMeshBuilderImpl *This = (IDirect3DRMMeshBuilderImpl *)iface;
|
||||||
|
|
||||||
FIXME("(%p)->(): stub\n", This);
|
TRACE("(%p)->()\n", This);
|
||||||
|
|
||||||
return 0;
|
return This->nb_vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
static D3DCOLOR WINAPI IDirect3DRMMeshBuilderImpl_GetVertexColor(IDirect3DRMMeshBuilder* iface, DWORD index)
|
static D3DCOLOR WINAPI IDirect3DRMMeshBuilderImpl_GetVertexColor(IDirect3DRMMeshBuilder* iface, DWORD index)
|
||||||
|
|
|
@ -69,8 +69,15 @@ char data_ok[] =
|
||||||
"}\n"
|
"}\n"
|
||||||
"Mesh Object\n"
|
"Mesh Object\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"0;\n"
|
"4;\n"
|
||||||
"0;\n"
|
"1.0; 0.0; 0.0;,\n"
|
||||||
|
"0.0; 1.0; 0.0;,\n"
|
||||||
|
"0.0; 0.0; 1.0;,\n"
|
||||||
|
"1.0; 1.0; 1.0;;\n"
|
||||||
|
"3;\n"
|
||||||
|
"3; 0, 1, 2;,\n"
|
||||||
|
"3; 1, 2, 3;,\n"
|
||||||
|
"3; 3, 1, 2;;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
static void MeshBuilderTest(void)
|
static void MeshBuilderTest(void)
|
||||||
|
@ -79,6 +86,8 @@ static void MeshBuilderTest(void)
|
||||||
LPDIRECT3DRM pD3DRM;
|
LPDIRECT3DRM pD3DRM;
|
||||||
LPDIRECT3DRMMESHBUILDER pMeshBuilder;
|
LPDIRECT3DRMMESHBUILDER pMeshBuilder;
|
||||||
D3DRMLOADMEMORY info;
|
D3DRMLOADMEMORY info;
|
||||||
|
int val;
|
||||||
|
DWORD val1, val2, val3;
|
||||||
|
|
||||||
hr = pDirect3DRMCreate(&pD3DRM);
|
hr = pDirect3DRMCreate(&pD3DRM);
|
||||||
ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
|
ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
|
||||||
|
@ -101,6 +110,18 @@ static void MeshBuilderTest(void)
|
||||||
hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
|
hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
|
||||||
ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
|
ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
|
||||||
|
|
||||||
|
val = IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder);
|
||||||
|
ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
|
||||||
|
|
||||||
|
val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder);
|
||||||
|
ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
|
||||||
|
|
||||||
|
hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, NULL, &val2, NULL, &val3, NULL);
|
||||||
|
ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
|
||||||
|
ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1);
|
||||||
|
todo_wine ok(val2 == 4, "Wrong number of normals %d (must be 4)\n", val2);
|
||||||
|
todo_wine ok(val3 == 22, "Wrong number of face data bytes %d (must be 22)\n", val3);
|
||||||
|
|
||||||
IDirect3DRMMeshBuilder_Release(pMeshBuilder);
|
IDirect3DRMMeshBuilder_Release(pMeshBuilder);
|
||||||
|
|
||||||
IDirect3DRM_Release(pD3DRM);
|
IDirect3DRM_Release(pD3DRM);
|
||||||
|
|
Loading…
Reference in New Issue