Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


k.pedersen

Member Since 15 Mar 2012
Offline Last Active Apr 17 2012 10:38 AM

#4924596 How to animate a 3ds Max model in my OpenGL program?

Posted by k.pedersen on 23 March 2012 - 06:05 AM

If you don't need boned animation and you are using the fixed function pipeline in OpenGL, you might want to give the following free and open-source Obj Wavefront model library a try.

http://public.sangui...id=libwavefront

It can read in basic animation files and simply transforms and rotates the parts making up the model (if it has been exported with objects or groups).

I wrote it for my University dissertation and it tends to be good enough for the majority of my projects so it might help you too if you do decide to go with Wavefront Obj.


#4923343 [SOLVED]Perspective Correct Texture Coordinates (Frag Shader)

Posted by k.pedersen on 19 March 2012 - 10:51 AM

The following is the texture coordinate related code that I use. I have missed off the vertex and normal stuff so not to spam everyone with lots of code.

Does this appear to be correct?

Defines
GLuint coodBuffer;
GLuint inTexCoord;
std::vector<float> coords;

Load
inTexCoord = glGetAttribLocation(shaderProgram, "in_tex_coord");
glGenBuffersARB(1, &coordBuffer);

for(int i = 0; faces.size(); i++)
{
  coords.push_back(faces.at(i)->getA()->getU());
  coords.push_back(faces.at(i)->getA()->getV());

  coords.push_back(faces.at(i)->getB()->getU());
  coords.push_back(faces.at(i)->getB()->getV());

  coords.push_back(faces.at(i)->getC()->getU());
  coords.push_back(faces.at(i)->getC()->getV());
}

glBindBufferARB(GL_ARRAY_BUFFER_ARB, coordBuffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, coords.size() * sizeof(float), &coords[0], GL_STATIC_DRAW_ARB);

Draw
glEnableVertexAttribArray(inTexCoord);
glBindBuffer(GL_ARRAY_BUFFER_ARB, coordBuffer);
glVertexAttribPointerARB(inTexCoord, 2, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLES, 0, faces.size() * 3);
glDisableVertexAttribArray(inTexCoord);

I have also attempted to use

glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);

But it makes no difference. I assume this hint only has an effect when using fixed functionality?

Edit:
From Madhed's software rendering suggestion, I tried it on a different machine (with newer gfx card) and it all works perfectly.
I noticed that it ran slower using shaders than just using the fixed function pipeline suggesting that it is indeed doing some sort of software emulation.
The graphics card in question is an intel GMA 945 running on Fedora 15's Xorg.

Hmm, I guess I am forced to stick with the fixed function pipeline with this card? So much for compatibility... lol

Thank you everyone for your help. Really appreciated! I have marked the topic as solved.

Attached Thumbnails

  • working.png



PARTNERS