Sign in to follow this  
Salam

OpenGL Skeletal animation, ASSIMP, glm and me in between!

Recommended Posts

What better things to do on a rainy weekend than working on one of my beloved sideprojects, eh?

I am trying to bring skeletal animation in my engine with the kind help of ASSIMP and GLM.

I used http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html as my primary resource, along with: https://www.youtube.com/watch?v=F-kcaonjHf8&index=2&list=PLRIWtICgwaX2tKWCxdeB7Wv_rTET9JtWW

My understanding may not be perfect, but I do hope that the fundamentals are clear to me (This may still not be the case though!).

First of: The model I use for testing purposes is the one from the video-tutorial above.

I exported it with Blender as a .dae/collada file, resulting in it rendering 90° rotated about the x-axis. Blender's collada exporter does not support

Y_UP

I tried to fix this manually by editing the .dae file and "counter-rotating" but to no avail. I did not want to work on this any longer before the animation would work.

This is how it looks like rendered without the bones:

[attachment=35702:model.jpg]

And this is the abomination that has bones :(:

[attachment=35704:withBones.png]

I am pretty sure I messed up the matrices at some point, given the fact that ASSIMP and glm are basically transposes of each other, but I am not entirely sure, hence I ask for your help!

Onto some code then, I say!

 

Creation of the model:

// Sample postprocessing

const aiScene *scene = importer.ReadFile(path,

aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_FlipUVs);



if(!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)

throw new std::runtime_error("Problem loading model: " + path);



this->inverseModelMatrix = glm::inverse(convertMatrix(scene->mRootNode->mTransformation));

The inverseModelMatrix is used later.

...
std::vector<VertexBoneData> bones = loadBones(mesh, baseVertex);
return Mesh(vertices, indices, textures, bones, baseVertex, baseIndex);
std::vector<VertexBoneData> Model::loadBones(aiMesh *mesh, uint baseVertex)

{

std::vector<VertexBoneData> bones;

bones.resize(mesh->mNumVertices);

for(uint a = 0; a < mesh->mNumBones; a++)

{

uint boneIndex = 0;

std::string boneName(mesh->mBones[a]->mName.data);



if (boneMapping.find(boneName) == boneMapping.end()) {

boneIndex = numBones;

numBones++;

BoneInfo bi;

boneInfo.push_back(bi);

boneMapping[boneName] = boneIndex;

boneInfo[boneIndex].boneOffset = convertMatrix(mesh->mBones[a]->mOffsetMatrix);

}

else {

boneIndex = boneMapping[boneName];

}



for (uint w = 0; w < mesh->mBones[a]->mNumWeights; w++)

{

uint vertexId = baseVertex + mesh->mBones[a]->mWeights[w].mVertexId;

float weight = mesh->mBones[a]->mWeights[w].mWeight;

bones[vertexId].AddBoneData(boneIndex, weight);

}

}

return bones;

}

The mesh looks like this:

mesh.hpp

const static int NUM_BONES_PER_VERTEX = 4;

struct VertexBoneData

{

uint ids[NUM_BONES_PER_VERTEX] = {0};

float weights[NUM_BONES_PER_VERTEX] = {0};



void AddBoneData(uint BoneID, float Weight);

};



struct Vertex

{

glm::vec4 position;

glm::vec4 normal;

glm::vec2 textureCoordinates;

};



struct BoneInfo

{

glm::mat4 boneOffset;

glm::mat4 finalTransformation;

};





class Mesh

{

public:

Mesh(std::vector<Vertex> vertices, std::vector<GLuint> indices, std::vector<GLuint> textures,

std::vector<VertexBoneData> bones, uint baseVertex, uint baseIndex);

void render();



private:

std::vector<Vertex> vertices;

std::vector<GLuint> indices;

std::vector<GLuint> textures;

GLuint vaoId, vboId, eboId;



uint baseVertex, baseIndex = 0;

std::vector<VertexBoneData> bones;

GLuint boneBufferId;



void setup();
// Implementation follows http://www.learnopengl.com/#!Model-Loading/Mesh

Mesh::Mesh(std::vector<Vertex> vertices, std::vector<GLuint> indices, std::vector<GLuint> textures,

std::vector<VertexBoneData> bones, uint baseVertex, uint baseIndex) {

this->vertices = vertices;

this->indices = indices;

this->textures = textures;



this->bones = bones;



this->baseVertex = baseVertex;

this->baseIndex = baseIndex;



this->setup();

}



uint POSITION_LOCATION = 0;

uint NORMAL_LOCATION = 1;

uint TEXTURE_COORDINATES_LOCATION = 2;

uint BONES_LOCATION = 3;

uint BONE_WEIGHT_LOCATION = 4;



void Mesh::setup() {

// Create VAO, VBO and ELEMENTBUFFER

glGenVertexArrays(1, &this->vaoId);

glGenBuffers(1, &this->vboId);

glGenBuffers(1, &this->eboId);

glGenBuffers(1, &this->boneBufferId);



// Bind them all

glBindVertexArray(this->vaoId);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->eboId);



// Prepare vertex buffer

glBindBuffer(GL_ARRAY_BUFFER, this->vboId);

glBufferData(GL_ARRAY_BUFFER, this->vertices.size() * sizeof(Vertex), &this->vertices[0], GL_STATIC_DRAW);

// Set vertex attribute pointers

// 0 = pos

glEnableVertexAttribArray(POSITION_LOCATION);

glVertexAttribPointer(POSITION_LOCATION, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid *) 0);

// 1 = normals

glEnableVertexAttribArray(NORMAL_LOCATION);

glVertexAttribPointer(NORMAL_LOCATION, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid *) offsetof(Vertex, normal));

// 2 = texture coordinates

glEnableVertexAttribArray(TEXTURE_COORDINATES_LOCATION);

glVertexAttribPointer(TEXTURE_COORDINATES_LOCATION, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid *) offsetof(Vertex, textureCoordinates));



// Prepare bone buffer

glBindBuffer(GL_ARRAY_BUFFER, this->boneBufferId);

glBufferData(GL_ARRAY_BUFFER, this->bones.size() * sizeof(VertexBoneData), &this->bones[0], GL_STATIC_DRAW);

// Set bone attributes

// 3 = bones

glEnableVertexAttribArray(BONES_LOCATION);

glVertexAttribIPointer(BONES_LOCATION, 4, GL_INT, sizeof(VertexBoneData), (const GLvoid *) 0);

// 4 = bone weights

glEnableVertexAttribArray(BONE_WEIGHT_LOCATION);

glVertexAttribPointer(BONE_WEIGHT_LOCATION, 4, GL_FLOAT, GL_FALSE, sizeof(VertexBoneData), (const GLvoid *) (NUM_BONES_PER_VERTEX * 4));



// indices

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->eboId);

glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->indices.size() * sizeof(GLuint), &this->indices[0], GL_STATIC_DRAW);





glBindVertexArray(0);

// Unbind Element buffer AFTER VAO (else it's unbound when vao is activated!)

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

}



void Mesh::render() {

glBindVertexArray(this->vaoId);

glDrawElementsBaseVertex(

GL_TRIANGLES,

this->indices.size(),

GL_UNSIGNED_INT,

(void *) (sizeof(uint) * baseIndex),

baseVertex

);



glBindVertexArray(0);

}



void VertexBoneData::AddBoneData(uint BoneID, float Weight) {

for (uint i = 0; i < NUM_BONES_PER_VERTEX; i++) {

if (weights[i] == 0) {

ids[i] = BoneID;

weights[i] = Weight;

return;

}

}

}

Here I want to point out that I did not miss the I in

glVertexAttribIPointer

for the boneIds!

 

That would be the construction of the mesh with the bones!

Later down the line I want to get the transformation within an animation. So now comes a lot of code, basically like the one from ogldev with a bit more return-typiness.

 

std::vector<glm::mat4> Model::boneTransform(const std::string &path, float timeInSeconds)
{
glm::mat4 identity;

Assimp::Importer importer;

// Sample postprocessing
const aiScene *scene = importer.ReadFile(path,
aiProcess_Triangulate | aiProcess_GenNormals | aiProcess_FlipUVs);

if(!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
throw new std::runtime_error("Problem loading model: " + path);

aiAnimation *anim = scene->mAnimations[0];

std::vector<glm::mat4> transforms;
if(anim == nullptr) return transforms;

float ticksPerSecond = (float) scene->mAnimations[0]->mTicksPerSecond != 0 ? scene->mAnimations[0]->mTicksPerSecond : 25.0f;
float timeInTicks = timeInSeconds * ticksPerSecond;
float animationTime = fmod(timeInTicks, (float)scene->mAnimations[0]->mDuration);

readNodeHierarchy(animationTime, scene, scene->mRootNode, identity);
transforms.resize(this->numBones);

for(uint i = 0; i < this->numBones; i++) {
transforms[i] = boneInfo[i].finalTransformation;
}

return transforms;
}
aiQuaternion Model::calculateInterpolatedRotation(float AnimationTime, const aiNodeAnim *pNodeAnim)
{
// we need at least two values to interpolate...
if (pNodeAnim->mNumRotationKeys == 1) {
aiQuaternion quat = aiQuaternion(pNodeAnim->mRotationKeys[0].mValue);
return quat;
}

aiQuaternion quat;

uint RotationIndex = FindRotation(AnimationTime, pNodeAnim);
uint NextRotationIndex = (RotationIndex + 1);
assert(NextRotationIndex < pNodeAnim->mNumRotationKeys);
float DeltaTime = (float)(pNodeAnim->mRotationKeys[NextRotationIndex].mTime - pNodeAnim->mRotationKeys[RotationIndex].mTime);
float Factor = (AnimationTime - (float)pNodeAnim->mRotationKeys[RotationIndex].mTime) / DeltaTime;
assert(Factor >= 0.0f && Factor <= 1.0f);
const aiQuaternion& StartRotationQ = pNodeAnim->mRotationKeys[RotationIndex].mValue;
const aiQuaternion& EndRotationQ = pNodeAnim->mRotationKeys[NextRotationIndex].mValue;
aiQuaternion::Interpolate(quat, StartRotationQ, EndRotationQ, Factor);

quat.Normalize();

return quat;
}

void Model::readNodeHierarchy(float animationTime, const aiScene *scene, const aiNode *node, const glm::mat4 &parentTransform)
{
std::string nodeName(node->mName.data);

const aiAnimation* pAnimation = scene->mAnimations[0];

glm::mat4 nodeTransform = convertMatrix(node->mTransformation);

const aiNodeAnim* pNodeAnim = findNodeAnim(pAnimation, nodeName);

if (pNodeAnim)
{
// Interpolate scaling and generate scaling transformation matrix
aiVector3D scaling = calculateInterpolatedScaling(animationTime, pNodeAnim);
glm::vec3 scale = glm::vec3(scaling.x, scaling.y, scaling.z);
glm::mat4 scaleMatrix = glm::scale(glm::mat4(1.0f), scale);

// Interpolate rotation and generate rotation transformation matrix
aiQuaternion RotationQ = calculateInterpolatedRotation(animationTime, pNodeAnim);
glm::quat rotation(RotationQ.x, RotationQ.y, RotationQ.z, RotationQ.w);
glm::mat4 rotationMatrix = glm::toMat4(rotation);

// Interpolate translation and generate translation transformation matrix
aiVector3D Translation = calculateInterpolatedPosition(animationTime, pNodeAnim);
glm::vec3 translation = glm::vec3(Translation.x, Translation.y, Translation.z);
glm::mat4 translationMatrix = glm::translate(glm::mat4(1.0f), translation);

// Combine the above transformations
nodeTransform = translationMatrix * rotationMatrix * scaleMatrix;
// TODO Check if inverting multiplication here is correct
//nodeTransform = scaleMatrix * rotationMatrix * translationMatrix;
}

glm::mat4 globalTransformation = parentTransform * nodeTransform;
// TODO Check if inverting multiplication here is correct
//glm::mat4 globalTransformation = nodeTransform * parentTransform;

if (boneMapping.find(nodeName) != boneMapping.end()) {
uint BoneIndex = boneMapping[nodeName];
boneInfo[BoneIndex].finalTransformation = inverseModelMatrix * globalTransformation * boneInfo[BoneIndex].boneOffset;
// TODO Check if inverting multiplication here is correct
// boneInfo[BoneIndex].finalTransformation = boneInfo[BoneIndex].boneOffset * globalTransformation * inverseModelMatrix;
}

for (uint i = 0 ; i < node->mNumChildren ; i++) {
readNodeHierarchy(animationTime, scene, node->mChildren[i], globalTransformation);
}
}

const aiNodeAnim* Model::findNodeAnim(const aiAnimation* pAnimation, const std::string nodeName)
{
for (uint c = 0 ; c < pAnimation->mNumChannels ; c++) {
const aiNodeAnim* pNodeAnim = pAnimation->mChannels[c];

if (std::string(pNodeAnim->mNodeName.data) == nodeName) {
return pNodeAnim;
}
}

return nullptr;
}

aiVector3D Model::calculateInterpolatedScaling(float animationTime, const aiNodeAnim *animatedNode)
{
if (animatedNode->mNumScalingKeys == 1) {
return animatedNode->mScalingKeys[0].mValue;
}

uint index = FindScaling(animationTime, animatedNode);
uint nextIndex = (index + 1);
assert(nextIndex < animatedNode->mNumScalingKeys);
float deltaTime = (float)(animatedNode->mScalingKeys[nextIndex].mTime - animatedNode->mScalingKeys[index].mTime);
float factor = (animationTime - (float)animatedNode->mScalingKeys[index].mTime) / deltaTime;
assert(factor >= 0.0f && factor <= 1.0f);
const aiVector3D& Start = animatedNode->mScalingKeys[index].mValue;
const aiVector3D& End = animatedNode->mScalingKeys[nextIndex].mValue;
aiVector3D Delta = End - Start;
aiVector3D end = Start + factor * Delta;

return end;
}

uint Model::FindScaling(float AnimationTime, const aiNodeAnim* pNodeAnim)
{
assert(pNodeAnim->mNumScalingKeys > 0);

for (uint i = 0 ; i < pNodeAnim->mNumScalingKeys - 1 ; i++) {
if (AnimationTime < (float)pNodeAnim->mScalingKeys[i + 1].mTime) {
return i;
}
}

assert(0);

return 0;
}

uint Model::FindRotation(float AnimationTime, const aiNodeAnim* pNodeAnim)
{
assert(pNodeAnim->mNumRotationKeys > 0);

for (uint i = 0 ; i < pNodeAnim->mNumRotationKeys - 1 ; i++) {
if (AnimationTime < (float)pNodeAnim->mRotationKeys[i + 1].mTime) {
return i;
}
}

assert(0);

return 0;
}

aiVector3D Model::calculateInterpolatedPosition(float animationTime, const aiNodeAnim *pNodeAnim)
{
if (pNodeAnim->mNumPositionKeys == 1) {
return pNodeAnim->mPositionKeys[0].mValue;
}

uint PositionIndex = FindPosition(animationTime, pNodeAnim);
uint NextPositionIndex = (PositionIndex + 1);
assert(NextPositionIndex < pNodeAnim->mNumPositionKeys);
float DeltaTime = (float)(pNodeAnim->mPositionKeys[NextPositionIndex].mTime - pNodeAnim->mPositionKeys[PositionIndex].mTime);
float Factor = (animationTime - (float)pNodeAnim->mPositionKeys[PositionIndex].mTime) / DeltaTime;
assert(Factor >= 0.0f && Factor <= 1.0f);
const aiVector3D& Start = pNodeAnim->mPositionKeys[PositionIndex].mValue;
const aiVector3D& End = pNodeAnim->mPositionKeys[NextPositionIndex].mValue;
aiVector3D Delta = End - Start;
return Start + Factor * Delta;
}

uint Model::FindPosition(float animationTime, const aiNodeAnim *pNodeAnim)
{
for (uint i = 0 ; i < pNodeAnim->mNumPositionKeys - 1 ; i++) {
if (animationTime < (float)pNodeAnim->mPositionKeys[i + 1].mTime) {
return i;
}
}

assert(0);

return 0;
}

 

In there I think I screwed up with the matrices. You can see the comments where I am unsure, but maybe I missed a line altogether.

 

Oh, convertMatrix is important to! It returns the matrix transposed!

 

/**
* 
* @param aiMat 
* @return transposed version of the aiMat to fit into glm's style of doing things 
*/
glm::mat4 Model::convertMatrix(const aiMatrix4x4 &aiMat)
{
return {
aiMat.a1, aiMat.b1, aiMat.c1, aiMat.d1,
aiMat.a2, aiMat.b2, aiMat.c2, aiMat.d2,
aiMat.a3, aiMat.b3, aiMat.c3, aiMat.d3,
aiMat.a4, aiMat.b4, aiMat.c4, aiMat.d4
};
}

Maybe that one is wrong? At least in combination with the rest it's important.

 

Now onto the shader and the rendering:

#version 330 core

layout (location = 0) in vec3 position;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 textureCoordinates;
layout (location = 3) in ivec4 boneIds;
layout (location = 4) in vec4 boneWeights;

out vec4 vertexPosition;
out vec4 vertexNormal;
out vec2 vertexTextureCoordinates;

uniform mat4 normalMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelMatrix;

const int MAX_BONES = 100;
uniform mat4 bones[MAX_BONES];

void main()
{
mat4 boneTransform = bones[boneIds[0]] * boneWeights[0];
boneTransform += bones[boneIds[1]] * boneWeights[1];
boneTransform += bones[boneIds[2]] * boneWeights[2];
boneTransform += bones[boneIds[3]] * boneWeights[3];

vec4 posL = boneTransform * vec4(position, 1);
gl_Position = modelViewProjectionMatrix * posL;

vec4 normalL = boneTransform * vec4(normal, 0);
vertexNormal = (modelMatrix * normalL);
vertexPosition = (modelMatrix * posL);
}

 

Pretty much like ogldev's version. I initialize the

bones
uniform-array like this:

for(unsigned int a = 0; a < 100; a++) {
std::stringstream name;
name << "bones[" << a << "]";
attributes.boneLocations[a] = glGetUniformLocation(attributes.shaderId, name.str().c_str());
}

 

Rendering looks like this:

 

std::vector<glm::mat4> transforms = this->appearance.model->boneTransform("../res/models/demo_character_tm.dae", animationTime);

for(uint index = 0; index < transforms.size(); index++) {
//glm::mat4 mat = glm::transpose(transforms[index]);

glm::mat4 mat = transforms[index];

glUniformMatrix4fv(
this->appearance.boneLocations[index],
1,
GL_FALSE, // TODO WAS GL_TRUE
//glm::value_ptr(transforms[index])
//&transforms[index][0][0]
glm::value_ptr(mat)
);
}

Again, not sure if it makes sense to set GL_TRUE for transposed (looks like hell then, even more!)

 

I know this is a lot of code... I tried to provide only the relevant parts, but the problem for me is, that the whole bone-rendering/animation stuff seems so overwhelming that there simply is a lot of code involved.

If you need any more code, please let me know.

 

Thanks to anyone having a look at this. I am really grateful for any hint you can give me!

Enjoy the rest of your weekends everybody!

 

Share this post


Link to post
Share on other sites

Sadly not. As I don't know which operating system you use I simply provide my cmake build for linux.

I only stripped some other models I used for testing. The one provided was released under public domain.

Once you're ready to go: if the application runs

1) Move around so you can face the (only) entity

2) just hit "TAB" twice (!) then you are in another camera mode

3) If you now roll your mousewheel UP it should start the animation (so animation is bound to mousewheel at the moment). It is hacky, so no modulo used, which means it crashes if you roll it downwards initially or up for too long.

But this should give an impression!

If you find the mistake you'll have my eternal gratitude and if you're interested I have quite a bag of unused game keys from humble bundles lying around where you could pick some (again, if you're interested, not trying to bribe anyone :))

 

edit: also I did not clean up the code much. I am totally aware it's a mess, partly. It's basically a playground for me. I am not a C++ developer by day and I think one sees that.

Edited by Salam

Share this post


Link to post
Share on other sites

CMake is totally fine, I use it on Linux too. And I don't mind messy code, but is this actually the version you described? I had to add a call to initWindow() and mouse wheel didn't seem to do much. Just tested it quickly though, I'll check this out better later today.

Share this post


Link to post
Share on other sites

Ok, I gave it a better try and seems like the main problem is in Model.cpp, line 263. glm::quat expects w,x,y,z for its constructor's parameters, and you've typed x,y,z,w. You should also probably enable depth testing somewhere with glEnable(GL_DEPTH_TEST). The model is still rotated 90 degrees by x-axis though, but that's some another problem.

I'd suggest making helper functions for converting all the required types to glm (just like you have the convertMatrix function), I did it like this the last time I used assimp:

static inline glm::vec3 vec3_cast(const aiVector3D &v) { return glm::vec3(v.x, v.y, v.z); } 
static inline glm::vec2 vec2_cast(const aiVector3D &v) { return glm::vec2(v.x, v.y); } // it's aiVector3D because assimp's texture coordinates use that
static inline glm::quat quat_cast(const aiQuaternion &q) { return glm::quat(q.w, q.x, q.y, q.z); } 
static inline glm::mat4 mat4_cast(const aiMatrix4x4 &m) { return glm::transpose(glm::make_mat4(&m.a1)); }

Also a tip for sending the bone transforms, instead of looping through the array, you can send everything at once, like this:

glUniformMatrix4fv(glGetUniformLocation(program, "BoneMatrices"), transforms.size(), GL_FALSE, glm::value_ptr(transforms[0]));

Hopefully this helped!

Edited by Sponji

Share this post


Link to post
Share on other sites

Hey, first of: Big thanks!

Secondly then I screwed up somewhere.

I got rid of the .git dir and some cmake cache etc. I tried out the program before, but I assume that afterwards I changed something and packaged then... I am sorry for the inconvenience, I can check in the evening.

Also the mousewheel code was gone because of these changes, probably. I did not try to hide anything, but also to provide a minimal example. So I got rid of the Raycaster and other implementations that (I thought) are not necessary for the example.

But in the Raycaster there would be the GL_DEPTH_TEST, afair.

Regarding the quat... yes, this is a relict which I found somewhere as a possible solution and I forgot about reverting this.

That optimization is super, thanks!

 

But as far as I understood you the model is still incorrect, right? I mean basically the feet are in the head or is that resolved with the quat? Because then I will bite myself.

 

The rotation... yes, I have no idea how to solve that with blender so far as the collada exporter does not allow for Y_UP and rotating around the x-axis does not change anything once exported :(

Share this post


Link to post
Share on other sites

The model and animation seemed to work nicely for me, and the only modifications I made to that zip were just 1) that one quaternion line 2) adding that missing call to initWindow before creating the GL context 3) and adding glEnable(GL_DEPTH_TEST). And I realized that the mouse wheel worked after all, I just didn't expect it to update time directly :P

Share this post


Link to post
Share on other sites

Cool, thanks a bunch. I will try in the evening and bite my ass if this was really it. (As I always assumed there is still something wrong with my understanding how to multiply assimp and glm matrices etc.)

I will create a helper for glm and assimp conversion.

Thanks again for your time and effort! If you're interested in some games I can go through my catalogue and see what keys are still unused :)

Share this post


Link to post
Share on other sites
[quote]I tried to fix this manually by editing the .dae file[/quote] Don't ever consider doing that. Not only are you likely to mess up, but what will you do when you have 25 or 30 models in your game? What if you have 200? Things must go somewhat automated, or you are doomed. No hand-editing files. Have you considered just rotating the model [b]and[/b] the bones (your image looks like you only rotated the mesh, and left the skeleton) in Blender prior to exporting? I know it's annoying having to do that, but it takes a mere 6 keystrokes. I'm not sure why Blender only exports Collada as Z_UP, in my opinion that's the worst possible choice out of two possible options, but it is what it is, gotta live with it.

Share this post


Link to post
Share on other sites

 

I tried to fix this manually by editing the .dae file

Don't ever consider doing that. Not only are you likely to mess up, but what will you do when you have 25 or 30 models in your game? What if you have 200? Things must go somewhat automated, or you are doomed. No hand-editing files.

Have you considered just rotating the model and the bones (your image looks like you only rotated the mesh, and left the skeleton) in Blender prior to exporting? I know it's annoying having to do that, but it takes a mere 6 keystrokes.

I'm not sure why Blender only exports Collada as Z_UP, in my opinion that's the worst possible choice out of two possible options, but it is what it is, gotta live with it.

 

Once I figured out how to modify the .dae file I would actually have tried to automate that process and provide some kind of tool for myself and maybe even open source it so others can benefit. Also it helps me to understand the .dae format.

But I agree, of course it would be very tedious to do this by hand every time.

I am not a C++ pro and certainly no visual computing guru but I am a software engineer by heart and only do stuff by hand when I try to understand something or am 100% sure I will only do this once or twice :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this