Sign in to follow this  
AnujKalia

Animadead help required

Recommended Posts

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.
[code]
#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[i].userData));
for (j = 0; j < meshes[mesh]->surfaces[i].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[i].faces[j].numIndices; k++)
{
ad::SuperVertex *svert = &meshes[mesh]->surfaces[i].superVerts[ meshes[mesh]->surfaces[i].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();
}
}
}
}

[/code]

I've added an image which shows the black areas. Anyone with experience in Animadead please help!!

Share this post


Link to post
Share on other sites
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!!!!:(:(:(:(:(:(:(

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