2011-06-22 20:24:01 +02:00
|
|
|
/*
|
|
|
|
* Skin Info operations specific to D3DX9.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Dylan Smith
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "d3dx9_36_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
|
|
|
|
|
2011-06-22 20:24:20 +02:00
|
|
|
struct bone
|
|
|
|
{
|
2011-06-22 20:24:28 +02:00
|
|
|
char *name;
|
2011-06-22 20:24:35 +02:00
|
|
|
D3DXMATRIX transform;
|
2011-06-22 20:24:20 +02:00
|
|
|
DWORD num_influences;
|
|
|
|
DWORD *vertices;
|
|
|
|
FLOAT *weights;
|
|
|
|
};
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
|
|
|
ID3DXSkinInfo ID3DXSkinInfo_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
DWORD fvf;
|
|
|
|
D3DVERTEXELEMENT9 vertex_declaration[MAX_FVF_DECL_SIZE];
|
|
|
|
DWORD num_vertices;
|
|
|
|
DWORD num_bones;
|
2011-06-22 20:24:20 +02:00
|
|
|
struct bone *bones;
|
2013-09-25 09:58:14 +02:00
|
|
|
};
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static inline struct d3dx9_skin_info *impl_from_ID3DXSkinInfo(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3dx9_skin_info, ID3DXSkinInfo_iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_QueryInterface(ID3DXSkinInfo *iface, REFIID riid, void **out)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ID3DXSkinInfo))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
2013-09-25 09:58:14 +02:00
|
|
|
*out = iface;
|
2011-06-22 20:24:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static ULONG WINAPI d3dx9_skin_info_AddRef(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&skin->ref);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", skin, refcount);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return refcount;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&skin->ref);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", skin, refcount);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
2013-01-03 23:46:48 +01:00
|
|
|
DWORD i;
|
2013-09-25 09:58:14 +02:00
|
|
|
|
|
|
|
for (i = 0; i < skin->num_bones; ++i)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, skin->bones[i].name);
|
|
|
|
HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices);
|
|
|
|
HeapFree(GetProcessHeap(), 0, skin->bones[i].weights);
|
2011-06-22 20:24:20 +02:00
|
|
|
}
|
2013-09-25 09:58:14 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, skin->bones);
|
|
|
|
HeapFree(GetProcessHeap(), 0, skin);
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return refcount;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetBoneInfluence(ID3DXSkinInfo *iface,
|
2013-09-20 10:41:46 +02:00
|
|
|
DWORD bone_num, DWORD num_influences, const DWORD *vertices, const float *weights)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:20 +02:00
|
|
|
struct bone *bone;
|
|
|
|
DWORD *new_vertices = NULL;
|
|
|
|
FLOAT *new_weights = NULL;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-20 10:41:46 +02:00
|
|
|
TRACE("iface %p, bone_num %u, num_influences %u, vertices %p, weights %p.\n",
|
|
|
|
iface, bone_num, num_influences, vertices, weights);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_num >= skin->num_bones || !vertices || !weights)
|
2011-06-22 20:24:20 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
if (num_influences) {
|
|
|
|
new_vertices = HeapAlloc(GetProcessHeap(), 0, num_influences * sizeof(*vertices));
|
|
|
|
if (!new_vertices)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
new_weights = HeapAlloc(GetProcessHeap(), 0, num_influences * sizeof(*weights));
|
|
|
|
if (!new_weights) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, new_vertices);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(new_vertices, vertices, num_influences * sizeof(*vertices));
|
|
|
|
memcpy(new_weights, weights, num_influences * sizeof(*weights));
|
|
|
|
}
|
2013-09-25 09:58:14 +02:00
|
|
|
bone = &skin->bones[bone_num];
|
2011-06-22 20:24:20 +02:00
|
|
|
bone->num_influences = num_influences;
|
|
|
|
HeapFree(GetProcessHeap(), 0, bone->vertices);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bone->weights);
|
|
|
|
bone->vertices = new_vertices;
|
|
|
|
bone->weights = new_weights;
|
|
|
|
|
|
|
|
return D3D_OK;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetBoneVertexInfluence(ID3DXSkinInfo *iface,
|
|
|
|
DWORD bone_num, DWORD influence_num, float weight)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, bone_num %u, influence_num %u, weight %.8e stub!\n",
|
|
|
|
iface, bone_num, influence_num, weight);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static DWORD WINAPI d3dx9_skin_info_GetNumBoneInfluences(ID3DXSkinInfo *iface, DWORD bone_num)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, bone_num %u.\n", iface, bone_num);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_num >= skin->num_bones)
|
2011-06-22 20:24:20 +02:00
|
|
|
return 0;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return skin->bones[bone_num].num_influences;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_GetBoneInfluence(ID3DXSkinInfo *iface,
|
|
|
|
DWORD bone_num, DWORD *vertices, float *weights)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:20 +02:00
|
|
|
struct bone *bone;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, bone_num %u, vertices %p, weights %p.\n",
|
|
|
|
iface, bone_num, vertices, weights);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_num >= skin->num_bones || !vertices)
|
2011-06-22 20:24:20 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
bone = &skin->bones[bone_num];
|
2011-06-22 20:24:20 +02:00
|
|
|
if (!bone->num_influences)
|
|
|
|
return D3D_OK;
|
|
|
|
|
|
|
|
memcpy(vertices, bone->vertices, bone->num_influences * sizeof(*vertices));
|
|
|
|
if (weights)
|
|
|
|
memcpy(weights, bone->weights, bone->num_influences * sizeof(*weights));
|
|
|
|
|
|
|
|
return D3D_OK;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_GetBoneVertexInfluence(ID3DXSkinInfo *iface,
|
|
|
|
DWORD bone_num, DWORD influence_num, float *weight, DWORD *vertex_num)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, bone_num %u, influence_num %u, weight %p, vertex_num %p stub!\n",
|
|
|
|
iface, bone_num, influence_num, weight, vertex_num);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_GetMaxVertexInfluences(ID3DXSkinInfo *iface, DWORD *max_vertex_influences)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, max_vertex_influences %p stub!\n", iface, max_vertex_influences);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static DWORD WINAPI d3dx9_skin_info_GetNumBones(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return skin->num_bones;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_FindBoneVertexInfluenceIndex(ID3DXSkinInfo *iface,
|
|
|
|
DWORD bone_num, DWORD vertex_num, DWORD *influence_index)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, bone_num %u, vertex_num %u, influence_index %p stub!\n",
|
|
|
|
iface, bone_num, vertex_num, influence_index);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_GetMaxFaceInfluences(struct ID3DXSkinInfo *iface,
|
2012-10-25 21:21:38 +02:00
|
|
|
struct IDirect3DIndexBuffer9 *index_buffer, DWORD num_faces, DWORD *max_face_influences)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, index_buffer %p, num_faces %u, max_face_influences %p stub!\n",
|
|
|
|
iface, index_buffer, num_faces, max_face_influences);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetMinBoneInfluence(ID3DXSkinInfo *iface, float min_influence)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, min_influence %.8e stub!\n", iface, min_influence);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static float WINAPI d3dx9_skin_info_GetMinBoneInfluence(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p stub!\n", iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetBoneName(ID3DXSkinInfo *iface, DWORD bone_idx, const char *name)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:28 +02:00
|
|
|
char *new_name;
|
|
|
|
size_t size;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-02 09:45:44 +02:00
|
|
|
TRACE("iface %p, bone_idx %u, name %s.\n", iface, bone_idx, debugstr_a(name));
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_idx >= skin->num_bones || !name)
|
2011-06-22 20:24:28 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
size = strlen(name) + 1;
|
|
|
|
new_name = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!new_name)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
memcpy(new_name, name, size);
|
2013-09-25 09:58:14 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, skin->bones[bone_idx].name);
|
|
|
|
skin->bones[bone_idx].name = new_name;
|
2011-06-22 20:24:28 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static const char * WINAPI d3dx9_skin_info_GetBoneName(ID3DXSkinInfo *iface, DWORD bone_idx)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-02 09:45:44 +02:00
|
|
|
TRACE("iface %p, bone_idx %u.\n", iface, bone_idx);
|
2011-06-22 20:24:28 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_idx >= skin->num_bones)
|
2011-06-22 20:24:28 +02:00
|
|
|
return NULL;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return skin->bones[bone_idx].name;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetBoneOffsetMatrix(ID3DXSkinInfo *iface,
|
2013-09-20 10:41:46 +02:00
|
|
|
DWORD bone_num, const D3DXMATRIX *bone_transform)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-20 10:41:46 +02:00
|
|
|
TRACE("iface %p, bone_num %u, bone_transform %p.\n", iface, bone_num, bone_transform);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_num >= skin->num_bones || !bone_transform)
|
2011-06-22 20:24:35 +02:00
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
skin->bones[bone_num].transform = *bone_transform;
|
2011-06-22 20:24:35 +02:00
|
|
|
return D3D_OK;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static D3DXMATRIX * WINAPI d3dx9_skin_info_GetBoneOffsetMatrix(ID3DXSkinInfo *iface, DWORD bone_num)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, bone_num %u.\n", iface, bone_num);
|
2011-06-22 20:24:35 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (bone_num >= skin->num_bones)
|
2011-06-22 20:24:35 +02:00
|
|
|
return NULL;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return &skin->bones[bone_num].transform;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_Clone(ID3DXSkinInfo *iface, ID3DXSkinInfo **skin_info)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, skin_info %p stub!\n", iface, skin_info);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_Remap(ID3DXSkinInfo *iface, DWORD num_vertices, DWORD *vertex_remap)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, num_vertices %u, vertex_remap %p stub!\n", iface, num_vertices, vertex_remap);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetFVF(ID3DXSkinInfo *iface, DWORD fvf)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE];
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, fvf %#x.\n", iface, fvf);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
hr = D3DXDeclaratorFromFVF(fvf, declaration);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
return iface->lpVtbl->SetDeclaration(iface, declaration);
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_SetDeclaration(ID3DXSkinInfo *iface, const D3DVERTEXELEMENT9 *declaration)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
int count;
|
|
|
|
|
2013-09-20 10:41:46 +02:00
|
|
|
TRACE("iface %p, declaration %p.\n", iface, declaration);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
if (!declaration)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
for (count = 0; declaration[count].Stream != 0xff; count++) {
|
|
|
|
if (declaration[count].Stream != 0) {
|
|
|
|
WARN("Invalid vertex element %u; contains non-zero stream %u\n",
|
|
|
|
count, declaration[count].Stream);
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
memcpy(skin->vertex_declaration, declaration, count * sizeof(*declaration));
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (FAILED(hr = D3DXFVFFromDeclarator(skin->vertex_declaration, &skin->fvf)))
|
|
|
|
skin->fvf = 0;
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static DWORD WINAPI d3dx9_skin_info_GetFVF(ID3DXSkinInfo *iface)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
return skin->fvf;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface,
|
|
|
|
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE])
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface);
|
2011-06-22 20:24:12 +02:00
|
|
|
UINT count = 0;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("iface %p, declaration %p.\n", iface, declaration);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
while (skin->vertex_declaration[count++].Stream != 0xff);
|
|
|
|
memcpy(declaration, skin->vertex_declaration, count * sizeof(declaration[0]));
|
2011-06-22 20:24:12 +02:00
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms,
|
2013-09-03 09:47:25 +02:00
|
|
|
const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-03 09:47:25 +02:00
|
|
|
FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n",
|
|
|
|
iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
2012-11-28 22:11:44 +01:00
|
|
|
DWORD options, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap,
|
|
|
|
ID3DXBuffer **vertex_remap, DWORD *max_face_infl, DWORD *num_bone_combinations,
|
|
|
|
ID3DXBuffer **bone_combination_table, ID3DXMesh **mesh_out)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, mesh_in %p, options %#x, adjacency_in %p, adjacency_out %p, face_remap %p, vertex_remap %p, "
|
|
|
|
"max_face_infl %p, num_bone_combinations %p, bone_combination_table %p, mesh_out %p stub!\n",
|
|
|
|
iface, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
|
|
|
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static HRESULT WINAPI d3dx9_skin_info_ConvertToIndexedBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in,
|
2012-11-28 22:11:44 +01:00
|
|
|
DWORD options, const DWORD *adjacency_in, DWORD *adjacency_out, DWORD *face_remap,
|
|
|
|
ID3DXBuffer **vertex_remap, DWORD *max_face_infl, DWORD *num_bone_combinations,
|
|
|
|
ID3DXBuffer **bone_combination_table, ID3DXMesh **mesh_out)
|
2011-06-22 20:24:12 +02:00
|
|
|
{
|
2013-09-25 09:58:14 +02:00
|
|
|
FIXME("iface %p, mesh_in %p, options %#x, adjacency_in %p, adjacency_out %p, face_remap %p, vertex_remap %p, "
|
|
|
|
"max_face_infl %p, num_bone_combinations %p, bone_combination_table %p, mesh_out %p stub!\n",
|
|
|
|
iface, mesh_in, options, adjacency_in, adjacency_out, face_remap, vertex_remap,
|
|
|
|
max_face_infl, num_bone_combinations, bone_combination_table, mesh_out);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
static const struct ID3DXSkinInfoVtbl d3dx9_skin_info_vtbl =
|
|
|
|
{
|
|
|
|
d3dx9_skin_info_QueryInterface,
|
|
|
|
d3dx9_skin_info_AddRef,
|
|
|
|
d3dx9_skin_info_Release,
|
|
|
|
d3dx9_skin_info_SetBoneInfluence,
|
|
|
|
d3dx9_skin_info_SetBoneVertexInfluence,
|
|
|
|
d3dx9_skin_info_GetNumBoneInfluences,
|
|
|
|
d3dx9_skin_info_GetBoneInfluence,
|
|
|
|
d3dx9_skin_info_GetBoneVertexInfluence,
|
|
|
|
d3dx9_skin_info_GetMaxVertexInfluences,
|
|
|
|
d3dx9_skin_info_GetNumBones,
|
|
|
|
d3dx9_skin_info_FindBoneVertexInfluenceIndex,
|
|
|
|
d3dx9_skin_info_GetMaxFaceInfluences,
|
|
|
|
d3dx9_skin_info_SetMinBoneInfluence,
|
|
|
|
d3dx9_skin_info_GetMinBoneInfluence,
|
|
|
|
d3dx9_skin_info_SetBoneName,
|
|
|
|
d3dx9_skin_info_GetBoneName,
|
|
|
|
d3dx9_skin_info_SetBoneOffsetMatrix,
|
|
|
|
d3dx9_skin_info_GetBoneOffsetMatrix,
|
|
|
|
d3dx9_skin_info_Clone,
|
|
|
|
d3dx9_skin_info_Remap,
|
|
|
|
d3dx9_skin_info_SetFVF,
|
|
|
|
d3dx9_skin_info_SetDeclaration,
|
|
|
|
d3dx9_skin_info_GetFVF,
|
|
|
|
d3dx9_skin_info_GetDeclaration,
|
|
|
|
d3dx9_skin_info_UpdateSkinnedMesh,
|
|
|
|
d3dx9_skin_info_ConvertToBlendedMesh,
|
|
|
|
d3dx9_skin_info_ConvertToIndexedBlendedMesh,
|
2011-06-22 20:24:12 +02:00
|
|
|
};
|
|
|
|
|
2012-11-27 22:10:56 +01:00
|
|
|
HRESULT WINAPI D3DXCreateSkinInfo(DWORD num_vertices, const D3DVERTEXELEMENT9 *declaration,
|
|
|
|
DWORD num_bones, ID3DXSkinInfo **skin_info)
|
2011-06-22 20:24:01 +02:00
|
|
|
{
|
2011-06-22 20:24:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END();
|
2013-09-25 09:58:14 +02:00
|
|
|
struct d3dx9_skin_info *object = NULL;
|
2011-06-22 20:24:01 +02:00
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
TRACE("num_vertices %u, declaration %p, num_bones %u, skin_info %p.\n",
|
|
|
|
num_vertices, declaration, num_bones, skin_info);
|
2011-06-22 20:24:12 +02:00
|
|
|
|
|
|
|
if (!skin_info || !declaration)
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl;
|
2011-06-22 20:24:12 +02:00
|
|
|
object->ref = 1;
|
|
|
|
object->num_vertices = num_vertices;
|
|
|
|
object->num_bones = num_bones;
|
|
|
|
object->vertex_declaration[0] = empty_declaration;
|
|
|
|
object->fvf = 0;
|
|
|
|
|
2011-06-22 20:24:20 +02:00
|
|
|
object->bones = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num_bones * sizeof(*object->bones));
|
|
|
|
if (!object->bones) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto error;
|
2011-06-22 20:24:12 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:58:14 +02:00
|
|
|
if (FAILED(hr = d3dx9_skin_info_SetDeclaration(&object->ID3DXSkinInfo_iface, declaration)))
|
|
|
|
goto error;
|
2011-06-22 20:24:20 +02:00
|
|
|
|
2011-06-22 20:24:12 +02:00
|
|
|
*skin_info = &object->ID3DXSkinInfo_iface;
|
|
|
|
|
|
|
|
return D3D_OK;
|
2011-06-22 20:24:20 +02:00
|
|
|
error:
|
|
|
|
HeapFree(GetProcessHeap(), 0, object->bones);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
2011-06-22 20:24:01 +02:00
|
|
|
}
|
|
|
|
|
2012-11-27 22:10:56 +01:00
|
|
|
HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD num_vertices, DWORD fvf, DWORD num_bones, ID3DXSkinInfo **skin_info)
|
2011-06-22 20:24:01 +02:00
|
|
|
{
|
2011-06-22 20:24:12 +02:00
|
|
|
HRESULT hr;
|
|
|
|
D3DVERTEXELEMENT9 declaration[MAX_FVF_DECL_SIZE];
|
2011-06-22 20:24:01 +02:00
|
|
|
|
2011-06-22 20:24:12 +02:00
|
|
|
TRACE("(%u, %x, %u, %p)\n", num_vertices, fvf, num_bones, skin_info);
|
|
|
|
|
|
|
|
hr = D3DXDeclaratorFromFVF(fvf, declaration);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return D3DXCreateSkinInfo(num_vertices, declaration, num_bones, skin_info);
|
2011-06-22 20:24:01 +02:00
|
|
|
}
|