mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-27 03:53:24 +00:00
multiple morph animation support
This commit is contained in:
@@ -28,7 +28,7 @@ namespace vb01{
|
||||
|
||||
shapeKeyFactors = new float[numShapeKeys];
|
||||
for(int i = 0; i < numShapeKeys; i++)
|
||||
shapeKeyFactors[i] = 1;
|
||||
shapeKeyFactors[i] = 0;
|
||||
}
|
||||
|
||||
Mesh::~Mesh(){
|
||||
@@ -102,9 +102,9 @@ namespace vb01{
|
||||
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, size, (void*)(offsetof(Vertex, boneIndices)));
|
||||
glEnableVertexAttribArray(6);
|
||||
for(int i = 0; i < numShapeKeys; i++){
|
||||
glVertexAttribPointer(7 + i, 3, GL_FLOAT, GL_FALSE, size, (void*)(offsetof(Vertex, shapeKeyOffsets) + 3 * i * sizeof(float)));
|
||||
glEnableVertexAttribArray(7 + i);
|
||||
}
|
||||
glVertexAttribPointer(7, 3, GL_FLOAT, GL_FALSE, size, (void*)(offsetof(Vertex, shapeKeyOffsets)));
|
||||
glEnableVertexAttribArray(7);
|
||||
}
|
||||
|
||||
void Mesh::update(){
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace vb01{
|
||||
struct Vertex{
|
||||
Vector3 pos, norm, tan, biTan;
|
||||
Vector2 uv;
|
||||
//Vector4 weights;
|
||||
//float *weights=nullptr;
|
||||
float weights[4]{0, 0, 0, 0};
|
||||
int boneIndices[4]{-1, -1, -1, -1};
|
||||
Vector3 shapeKeyOffsets[100];
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ layout (location=3) in vec3 aTan;
|
||||
layout (location=4) in vec3 aBiTan;
|
||||
layout (location=5) in vec4 aWeight;
|
||||
layout (location=6) in ivec4 aBoneIndices;
|
||||
layout (location=7) in vec3[numShapeKeys] aShapeKeyOffsets;
|
||||
layout (location=7) in vec3 aShapeKeyOffsets[numShapeKeys];
|
||||
|
||||
out vec3 fragPos;
|
||||
out vec3 norm;
|
||||
@@ -85,6 +85,9 @@ void main(){
|
||||
if(aWeight[i] > 0)
|
||||
anyWeights = true;
|
||||
|
||||
for(int i = 0; i < numShapeKeys; i++){
|
||||
vertPos.xyz += aShapeKeyOffsets[i] * shapeKeyFactors[i];
|
||||
}
|
||||
if(animated && anyWeights){
|
||||
for(int i = 0; i < numBones; i++){
|
||||
transform[i] = createTranslationMatrix(bones[i].pos);
|
||||
@@ -111,9 +114,6 @@ void main(){
|
||||
vertPos.xyz = v0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < numShapeKeys; i++){
|
||||
vertPos.xyz += aShapeKeyOffsets[i] * shapeKeyFactors[i];
|
||||
}
|
||||
|
||||
gl_Position = proj * view * model * vertPos;
|
||||
fragPos = vec3(model * vertPos);
|
||||
|
||||
Reference in New Issue
Block a user