View Full Version : how to draw a room with walls
I have to draw a simple room with walls and floor, using gl_quads(rectangle)
Could someone tell me how to go about doing that,
11-08-2002, 07:41 AM
How about drawing six quads? This would draw a 2x2x2 room (or cube):
/* Floor */
/* Ceiling */
/* Walls */
Thats exactly what i was trying to do.
well but how can I control their appearance probably by setting their material property or something like that , so that i get that 3D effect in there.
My second problem is how to get a drawing (any kind of painting or frame) on one of those walls....anything i drwa seems to cover the entie room. It has to be inside the room on the wall...
Can someone help?
11-08-2002, 04:37 PM
Maybe you should read an OpenGL tutorial first. =)
Well, you can color the walls by using glColor*(), for example glColor3f(red,green,blue). The values for red, green and blue have to be (0 <= value <= 1). You can use this command for every vertex. Just set the vertex color before calling glVertex*(). If you want the vertex colors to be interpolated within a polygon, you can set the shading model to smooth:
And you want to put things into the room? You can draw them like you've drawn the room itself. Remember the room is 2x2x2, so your objects should be smaller. You can, of course, use floating point numbers for coordinates. Also remember that the y-coordinate for the floor of that room is -1, so you'll want to draw from -1 upwards.
Material color and stuff like that? You'll probably want to add textures (so the polygon appears as a picture). This is such a big topic, I can't explain it all here. There are just a few commands, but to understand all of it, you should read a good texture mapping tutorial. You'll find a lot of links to information resources on this site.
[This message has been edited by mm_freak (edited 11-08-2002).]
Well I already colored my walls and yes read the Red Book too.
But the problem seemed graver than what i expected. At present I have colored each wall with a separate color...because I really dont need to go into texture and all for this project..as you said it is seemingly complicated and I want to concentrate on this part first.
The reason why i color each wall with a separate color is , otherwsie it all blends into the same thing..and then i can no longer make out the room..but just one rectangle....
IS there a way I can not loose the 3D effect and still have all the walls the same color...
moreover i actually have a new post in which i explained how as soon as i enable one light ..everything becomes a grey rectangle.
I think I have too many questions for now.
Thanks for your help though
11-08-2002, 07:06 PM
No problem. Did you enable material colors? I guess not. glEnable(GL_COLOR_MATERIAL) should do the job. But there is a major problem with lighting. OpenGL's lighting is not, as you may have expected, pixel-oriented, but vertex-oriented. A solution would be to split up all walls of that room into about 16 or more polygons. I recommend you to write an algorhythm to split up polygons into many quads. Well... don't use too many, else performance will be lost. The second solution is to calculate the light by yourself, but then you'll need to rely on textures.
11-12-2002, 02:46 AM
Also to make the lights work you need to define normals for each of your walls. Normals are vetors that are perpendicular to the surface you want lit. So for instance the top wall (ceiling I gues http://www.opengl.org/discussion_boards/ubb/smile.gif the normal has to be (0,-1,0) To assign a normal to a vertex you must call the correct function I think gl_normal3f(0,0,-1). This is set for all vertices until you change it to something else.
Rock & Roll
11-26-2011, 02:45 AM
Hello ,, I'v tried this example and it works fine ,but is there a way to create a room similar to this ,,
because in the first one , you cant really differentiate between the back-wall and ceiling or floor ..
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.