Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualkgs

Posted 12 November 2013 - 09:49 PM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

Like this,the right image is the correct animation, the cube in left image means the bone

temp.png

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
	XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);
	XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
	//boneInv is what I think offset matrix, is it wrong?
	m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
	//drawBone(mBoneTransforms[i][frameCount % 120);
}
frameCount++;
//Draw mesh
//HLSL Code
PixelShaderInput SimpleVertexShader(VertexShaderInput input)
{
    PixelShaderInput vertexShaderOutput;

    float weights[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
    weights[0] = input.Weights.x;
    weights[1] = input.Weights.y;
    weights[2] = input.Weights.z;
    weights[3] = 1.0f - weights[0] - weights[1] - weights[2];
	
    float4 pos = float4(input.pos, 1.0f);
    float4 norm = float4(normalize(input.norm), 0.0f);
    for (int i = 0; i < 4; ++i)
    {
        pos += weights[i] * mul(pos, gBoneTransform[input.BoneIndices[i]]);
	norm += weights[i] * mul(norm, gBoneTransform[input.BoneIndices[i]]);
    }

    pos = mul(pos, model);
    pos = mul(pos, view);
    pos = mul(pos, projection);
    norm = mul(norm, model);

    vertexShaderOutput.pos = pos;
    vertexShaderOutput.tex = input.tex;
    vertexShaderOutput.norm = normalize(norm.xyz);
    return vertexShaderOutput;
}
Can anyone help me?
Any help would be appreciated.
Thank you!

#8kgs

Posted 12 November 2013 - 08:53 PM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

Like this,the right image is the correct animation, the cube in left image means the bone

temp.png

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
	XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);
	XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
	//boneInv is what I think offset matrix, is it wrong?
	m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
	//drawBone(mBoneTransforms[i][frameCount % 120);
}
frameCount++;
//Draw mesh
//HLSL Code
PixelShaderInput SimpleVertexShader(VertexShaderInput input)
{
    PixelShaderInput vertexShaderOutput;

	float weights[5] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
	weights[0] = input.Weights.x;
	weights[1] = input.Weights.y;
	weights[2] = input.Weights.z;
	weights[3] = input.Weights.w;
	weights[4] = 1.0f - weights[0] - weights[1] - weights[2] - weights[3];
    float4 pos = float4(input.pos, 1.0f);
	float4 norm = float4(normalize(input.norm), 0.0f);
	for (int i = 0; i < 4; ++i)
	{
		pos += weights[i] * mul(pos, gBoneTransform[input.BoneIndices[i]]);
		norm += weights[i] * mul(norm, gBoneTransform[input.BoneIndices[i]]);
	}

    pos = mul(pos, model);
    pos = mul(pos, view);
    pos = mul(pos, projection);
	norm = mul(norm, model);

    vertexShaderOutput.pos = pos;
    vertexShaderOutput.tex = input.tex;
    vertexShaderOutput.norm = normalize(norm.xyz);
    return vertexShaderOutput;
}
Can anyone help me?
Any help would be appreciated.
Thank you!

#7kgs

Posted 12 November 2013 - 08:09 PM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

Like this,the right side is the correct animation

temp.png

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
	XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);
	XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
	//boneInv is what I think offset matrix, is it wrong?
	m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
	//drawBone(mBoneTransforms[i][frameCount % 120);
}

 

 

 

 

frameCount++;
//Draw mesh
//HLSL Code
PixelShaderInput SimpleVertexShader(VertexShaderInput input)
{
    PixelShaderInput vertexShaderOutput;

	float weights[5] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
	weights[0] = input.Weights.x;
	weights[1] = input.Weights.y;
	weights[2] = input.Weights.z;
	weights[3] = input.Weights.w;
	weights[4] = 1.0f - weights[0] - weights[1] - weights[2] - weights[3];
    float4 pos = float4(input.pos, 1.0f);
	float4 norm = float4(normalize(input.norm), 0.0f);
	for (int i = 0; i < 4; ++i)
	{
		pos += weights[i] * mul(pos, gBoneTransform[input.BoneIndices[i]]);
		norm += weights[i] * mul(norm, gBoneTransform[input.BoneIndices[i]]);
	}

    pos = mul(pos, model);
    pos = mul(pos, view);
    pos = mul(pos, projection);
	norm = mul(norm, model);

    vertexShaderOutput.pos = pos;
    vertexShaderOutput.tex = input.tex;
    vertexShaderOutput.norm = normalize(norm.xyz);
    return vertexShaderOutput;
}
Can anyone help me?
Any help would be appreciated.
Thank you!

#6kgs

Posted 12 November 2013 - 08:06 PM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

Like this,the right side is the correct animation

temp.png

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

 

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);   
XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
//boneInv is what I think offset matrix, is it wrong?
m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
//drawBone(mBoneTransforms[i][frameCount % 120);
}
frameCount++;
//Draw mesh
 
Can anyone help me?
Any help would be appreciated.
Thank you!

#5kgs

Posted 12 November 2013 - 09:37 AM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

 

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);   
XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
//boneInv is what I think offset matrix, is it wrong?
m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
//drawBone(mBoneTransforms[i][frameCount % 120);
}
frameCount++;
//Draw mesh
 
Can anyone help me?
Any help would be appreciated.
Thank you!

#4kgs

Posted 12 November 2013 - 09:37 AM

I'm working on a skinned mesh demo.

And I have successfully export my own mesh from 3ds max.

But in my meshviewer program,only first frame is correct.

 

I have got all bone matrix saved in mBoneTransforms[m][n].The m indicate m-th bone, the n means the n-th frame, each data in  mBoneTransforms is a matrix

 

following is my code:

The drawCube(float4x4 world) method is used to drawing bones.And this completely represent the animation correctly.

So my bone animation is correctly, skinned animation is wrong

 

 

static int frameCount = 0;
for (int i = 0; i < mYHMMesh.boneInfo.BoneCount; i++)
{
XMFLOAT4X4 boneInv = floatToXMFLOAT(mBoneTransforms[i][0]);   
XMStoreFloat4x4(&boneInv, XMMatrixInverse(NULL, XMLoadFloat4x4(&boneInv)));
//boneInv is what I think offset matrix, is it wrong?
m_constantBufferData.boneTransform[i] = mul(mBoneTransforms[i][frameCount % 120], XMFLOATTofloat4x4(boneInv));
//drawBone(mBoneTransforms[i][frameCount % 120);
}
frameCount++;
 
Can anyone help me?
Any help would be appreciated.
Thank you!

PARTNERS