PDA

View Full Version : please help!!!



locomo
11-15-2002, 12:58 PM
i have to draw a room (3 walls + floor and ceiling) and a painting on one of the walls (this should

be just a rectangle slightly off the wall, with a picture drawn in it
the default is just a face, i.e. a circle with 2 dots for eyes and a smiling mouth). The room has some to have some

ambient light, so that even without any light source one can see the painting. Now i have to add a lamp to the scene

(a lamp is just a cone with a light source within. One key controls whether or not the light is on, whereas another pair of keys can
be used to move up or down the lamp (up means toward the ceiling, down towards the floor). i have to Set the default

position of the lamp so that the light beam hits the picture

any help will be kindly appreciated
thanks
locomo

bodros
11-15-2002, 02:08 PM
I think you're looking for a spotlight, which is just like a normal light in OpenGL but has a certain cutoff, exponent and direction.

Make the direction point to the painting, make sure the attenuation is set well enough so the light hits the painting. Look at glLight*() for details.
Also, make sure you have the normals defined (unless you're using glu, which does it for you) or you'll see no light, or oddly aimed fractions of light and such.

For the global ambient light you can use glLightModel*(). With that one you can set the global ambient light RGBA.

Hope it helps http://www.opengl.org/discussion_boards/ubb/smile.gif

locomo
11-15-2002, 02:38 PM
Thanx for the suggestions.
my first priority is drawing the room with the walls+ceiling+floor i dont know how to
proceed....

locomo

bodros
11-15-2002, 02:50 PM
I'd draw 5 squares ( 3 walls since you need to look inside from somewhere ). Each square would need 4 vertices, each having an x, y and z. One square could for example be:

glBegin( GL_QUADS ) ;
// Draw the left wall (at x -2.0)
glVertex3f( -2.0, 0, 1 ) ;//left bottom
glVertex3f( -2.0, 0, -1 ) ;//right bottom
glVertex3f( -2.0, 2, -1 ) ;//right up
glVertex3f( -2.0, 2, 1 ) ; //left up

// Draw more walls....

glEnd() ;

...good luck

locomo
11-15-2002, 03:05 PM
Thanks again for your kindly help!!!
I have drawn all the walls...
now the problem i am having is that
i am not able to see em for some reason
please suggest!!!

locomo
11-15-2002, 03:19 PM
when i execute my program i just get the top of the cube...how can i make the program to show the cube as the room !!!

bodros
11-15-2002, 03:29 PM
If you only see the top of the cube, the cube isn't placed right. The camera is (as default) located at 0,0,0 and is directed at the negative part of the z axis.

You could use 0,0,0 as the center of the room, which means the walls would need to be drawn around that point. Note the back wall would need to be drawn with a negative z value so it's placed in front of the camera.

11-15-2002, 06:44 PM
Please choose a more descriptive subject line in the future. I'm really tired of reading posts like, "HELP!!! I'M IN BIG TROUBLE!!!", and I'm sure I'm not the only one. Thanks.

locomo
11-15-2002, 06:55 PM
Well i would always take that into consideration before i post any of my queries...thanx for letting me know.
I would like to thank the person who helped me earlier..