Jump to content
  • Advertisement
Sign in to follow this  
krobin

a small problem about lesson 22

This topic is 4323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There is a small problem in lesson 22(bump and multi-texture), VMatMult function I think. In the text, the description of this function is set v=M*v, but what it originally did in the code is v=v*M. It's wrong since opengl uses v=M*v. Also, for Homogenous Coordinate, we can't simply set v[3]=M[15], we should calculate v[3] as v[0],v[1],v[2]. So, instead of coding VMatMult like this: void VMatMult(GLfloat *M, GLfloat *v) { GLfloat res[4]; res[0]=M[ 0]*v[0]+M[ 1]*v[1]+M[ 2]*v[2]+M[ 3]*v[3]; res[1]=M[ 4]*v[0]+M[ 5]*v[1]+M[ 6]*v[2]+M[ 7]*v[3]; res[2]=M[ 8]*v[0]+M[ 9]*v[1]+M[10]*v[2]+M[11]*v[3];; v[0]=res[0]; v[1]=res[1]; v[2]=res[2]; v[3]=M[15]; } VMatMult should be: void VMatMult(GLfloat *M, GLfloat *v) { GLfloat res[4]; res[0]=M[ 0]*v[0]+M[ 4]*v[1]+M[ 8]*v[2]+M[12]*v[3]; res[1]=M[ 1]*v[0]+M[ 5]*v[1]+M[ 9]*v[2]+M[13]*v[3]; res[2]=M[ 2]*v[0]+M[ 6]*v[1]+M[10]*v[2]+M[14]*v[3]; res[3]=M[ 3]*v[0]+M[ 7]*v[1]+M[11]*v[2]+M[15]*v[3]; v[0]=res[0]; v[1]=res[1]; v[2]=res[2]; v[3]=res[3]; // Homogenous Coordinate }

Share this post


Link to post
Share on other sites
Advertisement
Yes we are aware of this, but i can safely say that we won't be revisiting emboss bump mapping again, because of this we won't fix it right away (but we will take note of it).

v[3]=M[15]; actually works (i think) because m 12,13,14 is always 0 and v[3] 1s always 1 thus making res[3]=0*x+0*y+0*z+m[15]*1=m[15] (as far as i understand it).
Though it's a bit of a hack.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!