Load bone weights and indices properly for bcres
This commit is contained in:
parent
94554db10c
commit
3b445272db
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -241,7 +241,7 @@ namespace FirstPlugin
|
||||
|
||||
if (FaceGroup.SkinnningMode == SkinnningMode.Rigid)
|
||||
{
|
||||
Matrix4 sb = skeleton.bones[v.boneIds[0]].Transform;
|
||||
Matrix4 sb = skeleton.bones[(int)FaceGroup.BoneIndexList[v.boneIds[0]]].Transform;
|
||||
v.pos = Vector3.TransformPosition(v.pos, sb);
|
||||
v.nrm = Vector3.TransformNormal(v.nrm, sb);
|
||||
}
|
||||
|
@ -168,12 +168,15 @@ namespace FirstPlugin
|
||||
|
||||
private static void SetBoneUniforms(ShaderProgram shader, CMDLWrapper fmdl, SOBJWrapper fshp)
|
||||
{
|
||||
for (int i = 0; i < fmdl.Skeleton.Renderable.bones.Count; i++)
|
||||
foreach (var FaceGroup in fshp.Shape.FaceGroups)
|
||||
{
|
||||
GL.Uniform1(GL.GetUniformLocation(shader.program, String.Format("boneIds[{0}]", i)), i);
|
||||
for (int i = 0; i < FaceGroup.BoneIndexList.Length; i++)
|
||||
{
|
||||
GL.Uniform1(GL.GetUniformLocation(shader.program, String.Format("boneIds[{0}]", i)), i);
|
||||
|
||||
Matrix4 transform = fmdl.Skeleton.Renderable.bones[i].invert * fmdl.Skeleton.Renderable.bones[i].Transform;
|
||||
GL.UniformMatrix4(GL.GetUniformLocation(shader.program, String.Format("bones[{0}]", i)), false, ref transform);
|
||||
Matrix4 transform = fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].invert * fmdl.Skeleton.Renderable.bones[(int)FaceGroup.BoneIndexList[i]].Transform;
|
||||
GL.UniformMatrix4(GL.GetUniformLocation(shader.program, String.Format("bones[{0}]", i)), false, ref transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -23,6 +23,8 @@ out vec3 position;
|
||||
|
||||
out vec3 boneWeightsColored;
|
||||
|
||||
uniform int boneIds[190];
|
||||
|
||||
// Skinning uniforms
|
||||
uniform mat4 bones[190];
|
||||
|
||||
@ -80,16 +82,16 @@ vec3 BoneWeightColor(float weights)
|
||||
float BoneWeightDisplay(ivec4 index)
|
||||
{
|
||||
float weight = 0;
|
||||
if (selectedBoneIndex == index.x)
|
||||
if (selectedBoneIndex == boneIds[index.x])
|
||||
weight += vWeight.x;
|
||||
if (selectedBoneIndex == index.y)
|
||||
if (selectedBoneIndex == boneIds[index.y])
|
||||
weight += vWeight.y;
|
||||
if (selectedBoneIndex == index.z)
|
||||
if (selectedBoneIndex == boneIds[index.z])
|
||||
weight += vWeight.z;
|
||||
if (selectedBoneIndex == index.w)
|
||||
if (selectedBoneIndex == boneIds[index.w])
|
||||
weight += vWeight.w;
|
||||
|
||||
if (selectedBoneIndex == index.x && RigidSkinning == 1)
|
||||
if (selectedBoneIndex == boneIds[index.x] && RigidSkinning == 1)
|
||||
weight = 1;
|
||||
if (selectedBoneIndex == SingleBoneIndex && NoSkinning == 1)
|
||||
weight = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user