Advertisement

Animadead help required

Started by October 17, 2011 07:03 PM
0 comments, last by AnujKalia 13 years, 1 month ago
I'm working on a 3D game and I want my characters to show some skeletal animation. I found Animadead to be a good library for skeletal animation (till now). I invested some time in getting the Maya exporter and demo programs to work.
However, now I'm getting some problems with textures. I added a simple texture to my model in Maya. However, with Animadead I'm getting my model only "partially textured". Some areas are appearing totally black.


Here's the standard Animadead code that uses u-v coordinates.

#include "supermodel.h"
#include "SDLtexture.h"
#include <windows.h>
#include <GL/gl.h>
#define DEMOSRCDIR

using namespace std;

void TextureLoader::operator()(string file, void *&userdata)
{
string path = DEMOSRCDIR "images/";
string::size_type pos = file.find_last_of("/");
string therest = string(file, pos+1);
path += therest;
userdata = (void *)LoadTexture(path.c_str());
}

SuperModel::SuperModel(ad::Model::Type type, ad::UserFunction *fp) : Model(type, fp)
{
}

SuperModel::~SuperModel()
{
}

void SuperModel::Draw()
{
glColor4f(1,1,1,1);
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);

unsigned int mesh, i, j, k, l;

GenerateRenderPoseMatrices();

for (mesh = 0; mesh < meshes.size(); mesh++)
{
for (i=0; i < meshes[mesh]->numSurfaces; i++)
{
glBindTexture(GL_TEXTURE_2D, (unsigned int)(meshes[mesh]->surfaces.userData));
for (j = 0; j < meshes[mesh]->surfaces.numFaces; j++)
{
for (k=0; k < meshes[mesh]->numBones; k++)
worldBonesTEMP[meshes[mesh]->bones[k]]=worldBones[meshes[mesh]->bones[k]] * meshes[mesh]->inverseBindPose[meshes[mesh]->bones[k]];

glBegin(GL_POLYGON);
for (k = 0; k < meshes[mesh]->surfaces.faces[j].numIndices; k++)
{
ad::SuperVertex *svert = &meshes[mesh]->surfaces.superVerts[ meshes[mesh]->surfaces.faces[j].indices[k] ];

ad::Vector3 pos(svert->x, svert->y, svert->z);
ad::Vector3 norm(svert->a, svert->b, svert->c);
ad::Vector3 ret;
ad::Vector3 ret2;

for (l=0; l < svert->numInfluences; l++)
{
ret+=worldBonesTEMP[svert->weights[l].bone]*pos*svert->weights[l].weight;
ret2+=worldBonesTEMP[svert->weights[l].bone].Rotate(norm) * svert->weights[l].weight;
}

ret2.Normalize();
//printf("(%f,%f)\n",1-svert->u,1-svert->v);
glTexCoord2f(svert->u,1-svert->v);
glNormal3f(ret2.x, ret2.y, ret2.z);
glVertex3f(ret.x, ret.y, ret.z);
}
glEnd();
}
}
}
}



I've added an image which shows the black areas. Anyone with experience in Animadead please help!!
Well I solved it myself..turned out the texture being used was wrong somehow. So I switched from SDL to GLFW...

Does someone know which models I should use with Animadead? Till now I've managed to use the "Krag" model from CreativeCrash. But I can't use most of the models there. In the Animadead window, they appear stretched or broken :angry::(.

Please help!!!!:(:(:(:(:(:(:(

This topic is closed to new replies.

Advertisement