Applying windows to walls?

This is a discussion on Applying windows to walls? within the Game Programming forums, part of the General Programming Boards category; I'm curious how windows are created within walls. If you look at my screenshot here... http://www.imageupload.com/reg/images/1046pic1.JPG ... and there's an ...

  1. #1
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283

    Applying windows to walls?

    I'm curious how windows are created within walls. If you look at my screenshot here...

    http://www.imageupload.com/reg/images/1046pic1.JPG

    ... and there's an exterior area outside, how can I place a window in the far-left wall so I might be able to look through it? I'm using OpenGL, but I'm curious if there's a general explanation in how to go about this. Thanks.

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    I'm not expert at Open GL, but I suspect, you'd just have to build around where you want the window. That's how I've made windows and doors... you just have to indentify the window locations before you draw the walls. I haven't made any real processor expensive maps, but I don't think the few extra polygons should effect the draw speed that much.
    Attached Images Attached Images  
    Last edited by SlyMaelstrom; 09-29-2006 at 06:34 PM.
    Sent from my iPadŽ

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    That screenshot looks like one of the following due to the teture warping in the distance.

    • Ray casting
    • Linear texture mapping that has inherent issue with polies that have large z angles - that is z changes quite rapidly in the poly.


    A window is not an OpenGL construct but more a model construct. A window would most likely be in the model itself and flagged somehow as a transparent surface. You then apply your transparent window texture to the window which would again be another quad but it could have no depth. To render most efficiently you would render the building first and mark the window as drawable in the stencil buffer. Then in the external rendering you would only draw on the drawable stencil buffer portions. This can be done quite easily in DX since it natively supports stencil buffers.

    Another approach would be to use a portal system. You draw the building first and determine if any windows are:

    1. In the frustum
    2. Transparent and see through

    If they are then you continue rendering the outside but you use the window polygon as the new frustum for the rendering. So since you apply clipping and culling relative to this new frustum, rendering is super fast. You have eliminated everything that is obscured by the walls and non-transparent portions of the building. You would do this for all portals (windows/doors, etc) that are in the frustum. This will also correctly render the interior of the building. The rule is simple for portal systems. If the portal is in the frustum you render it's contents or it's node contents using the portal polygon as the new frustum for the render. Wash, rinse, repeat for all portals.

    It's a recursive method, it's fast, and it's near perfect. For outdoor scenes and indoor you would need two renderers. One for inside and one for outside. Outdoor scenes lend themselves best to quad trees or complete models of the outside terrain, albeit a bit smaller than an actual terrain system.

    Half Life 2 is not a flight simulator and as such only has to be good at rendering close up portions of the world. The levels are most likely created in an editor and if you notice in these types of FPS's you rarely if ever have huge long expanses of terrain stretching for miles.

    Now a flight simulator cannot model terrain this way. Most likely a flight sim gathers its data for meshes from the disk at specified load times and caches in terrain textures. It may also get it's height data from raw DEM data or from heightmap data. As such it must employ quad-trees or some other type of algo to render efficiently. Flight sims are great at rendering huge terrain areas, but are still to this day not so good at rendering very small resolute details up close.

    It's very hard to do both well. FarCry comes very close as well as Black and White 2, however, I suspect Black and White 2 may be using brute force just like it's older brother Black and White 1.
    Last edited by VirtualAce; 09-29-2006 at 10:59 PM.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    Yeah... that's basically what I was getting at...
    Sent from my iPadŽ

  5. #5
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    Lots to think about! Thanks for the replies.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  2. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21