Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ShadyWRX

Light and Quadrics

This topic is 5675 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

ok.... I made a fruit bowl, and 2 oranges, but the light lights up the fruitbowl when it is underneath it, and the oranges become dark, and when the light is above the fruit bowl, the bowl is dark and the oranges light up.... i think my fruitbowl faces are inside out... i used Quadric Cylinders void mmFruitBowl(GLfloat baseHeight,GLfloat topHeight, GLfloat baseRadius, GLfloat midRadius, GLfloat topRadius, int slices) { gluCylinder(quad,baseRadius,midRadius,baseHeight,slices,32); glTranslatef(0.0,0.0,baseHeight); gluCylinder(quad,midRadius,topRadius,topHeight,slices,32); glTranslatef(0.0,0.0,-1*(baseHeight)); glRotatef(180,1.0,0.0,0.0); gluDisk(quad,0,baseRadius,slices,32); } int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing { GLfloat LightAmbient[]= { 0.0f, 0.0f, 0.0f, 1.0f }; // Ambient Light Values GLfloat LightDiffuse[]= {1.0f,1.0f,1.0f,0.0f }; // Diffuse Light Values GLfloat LightSpec[]= {1.0f,1.0f,1.0f,0.0f }; GLfloat LightPosition[]= { 0.0f+lx, 0.0f+ly, 0.0f+lz, 0.0f }; // Light Position glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, LightSpec); glLightfv(GL_LIGHT0, GL_POSITION,LightPosition); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0,0.0f,-6.0f); glBindTexture(GL_TEXTURE_2D, texture[0]); mmFruitBowl(0.5f,1.25f,2.0f,2.1f,3.0f,64); glBindTexture(GL_TEXTURE_2D, texture[2]); glTranslatef(-0.75f,0.75f,1.0f); gluSphere(quad,1.0f,32,32); glTranslatef(1.5f,-1.5f,0.0f); gluSphere(quad,1.0f,32,32); } that is my code segment... I tried scaling my fruitbowl inside out, so that the outter surface is my inner surface, but it didnt work too well... also i might have done it wrong... all i did was glScalef(-1.0,1.0,1.0); Grrrr... all i want is the right surfaces to be light up realistically! ANy help... :-/

Share this post


Link to post
Share on other sites
Advertisement
you need to reverse the direction of your normals. I cannot remember how to do with with quadrics, but check the glu header, and you should be able to find the necessary functions. The spheres should have the normals facing outward. The fruit bowl normals should face inward. If you want to light both the inside and outside of the bowl, you may need to draw the inside and outside seperately.

Share this post


Link to post
Share on other sites
thanks

i figured if i wanted light in and out i would have to draw an inside and an outside, and now i know that i just have to draw the fruit bowl 2x and reverse one of the normals... thanks

Sweet i Found it too! yay...

void gluQuadricOrientation( GLUquadricObj *quadobj,
GLenum orientation );
If orientation is GLU OUTSIDE then quadrics will be drawn with normals
pointing outward. If orientation is GLU INSIDE then the normals will point
inward

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!