I can get my original pose of the model, just standing there with his arms out. (since everything is an identity, vertex positions dont change in the shader)
However when i try to get the pose, it gets messed up with
pBone->m_transform == pNode->mTransformation [this was always set]
pBone->m_offset == pMesh->mBones[bone]->mOffsetMatrix [i set this to identity matrix if the node had no bone]
My shaders are
#version 130constint MAX_BONES_PER_MESH =100;
uniform mat4 mvp_matrix;
uniform float alpha;
uniform mat4 bone_matrix[MAX_BONES_PER_MESH];
in vec3 in_vertex;
in vec3 in_colour;
in vec2 in_texCoord0;
in vec3 in_normal;
in ivec4 in_boneID;
in vec4 in_boneWeight;
out vec4 colour;
out vec2 texCoord0;
out vec3 normal;
voidmain(void)
{
vec4 position = vec4(in_vertex, 1.0);
if (in_boneWeight != vec4(0.0, 0.0, 0.0, 0.0))
{
mat4 aniMatrix = bone_matrix[in_boneID[0]] * in_boneWeight[0];
aniMatrix += bone_matrix[in_boneID[1]] * in_boneWeight[1];
aniMatrix += bone_matrix[in_boneID[2]] * in_boneWeight[2];
aniMatrix += bone_matrix[in_boneID[3]] * in_boneWeight[3];
position = aniMatrix * position;
}
gl_Position = mvp_matrix * position;
colour = vec4(in_colour, alpha);
texCoord0 = in_texCoord0;
normal = in_normal;
}
and
#version 130
uniform sampler2D texture0;
in vec4 colour;
in vec2 texCoord0;
in vec3 normal;
out vec4 out_colour;
voidmain(void)
{
out_colour = texture(texture0, texCoord0.st) * colour;
}
From assimp what information do I need to store. atm I have a struct
struct BONED_MODEL_SKELETON_BONE
{
int m_id;
char m_name[MAX_BONE_NAME];
float m_transform[16];
float m_boneOffset[16];
int m_numChildren;
};
which exists for each node, I have all the keyframe info too, but I want to get it working without
adding in the animation.
I solved the problem above by removing the float xx = x * x; etc lines and plugging them straight into the equation.
My matrices now match that of the example. However I still can't get rid of the distortions.
I checked every final transformation for each bone against the assimp example and at the same animation time our final transformations matched.
So then i checked the vertices had the correct boneID and weight assigned to them. Mine match the assimp example too.
I checked I was using the correct types, ivec4 for boneIDs (4 ints) and vec4 for weights (4 floats). I also check I used glVertexAttribIPointer for the boneIDs as they're int.
I rechecked my shader which seems correct too me.
I not sure where I'm going wrong or what else to check next.
When i first made my static models i flipped the vertex z and y's because the blender file i used had them flipped. I totally forgot I did this!! Ofc the vectors and quaternions i left the same for animation. Which meant all my transforms looked like the other program I was trying to match and it was my vertices wrong!!!!!!!!
So sorry :|
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to get my model to show. Currently I am having trouble and cant get it to show correctly.
If i have
I can get my original pose of the model, just standing there with his arms out. (since everything is an identity, vertex positions dont change in the shader)
However when i try to get the pose, it gets messed up with
Am i doing something wrong here or do you think it will be elsewhere, does this look remotely right?
The code before it called once per frame with
which is called with the rootbone from the bonedmodel
My data is extracted from assimp:
pBone->m_transform == pNode->mTransformation [this was always set]
pBone->m_offset == pMesh->mBones[bone]->mOffsetMatrix [i set this to identity matrix if the node had no bone]
My shaders are
and
From assimp what information do I need to store. atm I have a struct
which exists for each node, I have all the keyframe info too, but I want to get it working without
adding in the animation.
// ===========================================================================
can anyone help me or notice anything immediately wrong by design. Can post more info if needed!
Ive tried reading a few guides I cant wrap my head around some things, any guides/tutorials you guys recommend?
ty for any help at all!
I managed to get it working without the animator. My current code is
However I've found my rotation matrix isn't correct. I compared it with an example for Assimp.
The output was
The code I currently use for creating my matrix from a quaternion is
Anyone notice anything wrong?
Ty for any help
I solved the problem above by removing the float xx = x * x; etc lines and plugging them straight into the equation.
My matrices now match that of the example. However I still can't get rid of the distortions.
I checked every final transformation for each bone against the assimp example and at the same animation time our final transformations matched.
So then i checked the vertices had the correct boneID and weight assigned to them. Mine match the assimp example too.
I checked I was using the correct types, ivec4 for boneIDs (4 ints) and vec4 for weights (4 floats). I also check I used glVertexAttribIPointer for the boneIDs as they're int.
I rechecked my shader which seems correct too me.
I not sure where I'm going wrong or what else to check next.
Ty for any help
I figured it out, it was such a silly mistake :(
When i first made my static models i flipped the vertex z and y's because the blender file i used had them flipped. I totally forgot I did this!! Ofc the vectors and quaternions i left the same for animation. Which meant all my transforms looked like the other program I was trying to match and it was my vertices wrong!!!!!!!!
So sorry :|
Great that you figured out on your own what went wrong. And one hint: don't compare floats with equal. See http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm . Always keep in mind that there is a absolute rounding error you have to use called epsilon.
Kimmi