Sign in to follow this  
teutoburger

How to 3d-model a house inside vs outside

Recommended Posts

Need tips for the general approach of 3d models that have an inside and an outside.

 

I'm trying to add a house to my game world.

I'm building the house mesh procedurally.

 

The player should be able to walk inside the house. At this point, all the normals of the mesh are facing outside.

Which is what I want, when the player is outside, because then the shading works as it should, right?

 

But then, when the player moves inside the house, wouldn't that mess up the shading, inside (normals still facing out)? 

 

I thought about using constructive solid geometry to hollow out the house mesh. Then the primitives would all be facing the player.

So that, inside there are walls with their normals facing inwards, towards player.

 

But this will have the consequence, that we have much higher number of primitives, right?

 

How would you solve this? Am I thinking this too complicated?

 

Can I just use simple walls for the house? No thickness? Just planar? With keeping the shading robust.

 

I guess I could also load a new scene, when player steps inside, but that has its own disadvantage (player can't look out of window, and see the same world they just left.)

 

I guess my question is: how would you solve this? What ways are there to do this?

 

[attachment=33979:house-simple.jpg]

[attachment=33980:house-csg.jpg]

 

 

 

 

Share this post


Link to post
Share on other sites

You want to build the walls and then put the roof over the walls, think of how a house works in the real world.

 

n9XnuGb.png

This is a easy way to do it but not the best way and not the way it's normally done in games, because texturing a object like the walls would waste a lot of space. Although the concept remains the same, build walls and doorways as it would be done in the realworld.

 

Here is a link to how it's done normally: http://wiki.polycount.com/wiki/Modular_environments

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Walls have thickness - that's sort of a requirement if you need to see them from both inside and out. What would a doorway look like as you walk through it, with infinitely thin walls?

 

Your primitive count isn't going to increase by more than 3-4x, some of which will be backface-culled, and if that still represents a problem, you can use portals to cull rooms which aren't visible.

Share this post


Link to post
Share on other sites

Make your wall have some thickness to them, normals on the outside face outwards and normals on the inside face inwards.

 

Culling can be used to reduce what you are drawing, such as walls you cannot see, along with other methods if you run into performance issues.

Share this post


Link to post
Share on other sites

Backface culling - I will look into that.

 

You want to build the walls and then put the roof over the walls, think of how a house works in the real world.  
 

 

But it gets quite complicated when I want to add windows, doors etc. Then I would have a procedure for each of these:

-generate simple wall segment ( have to define 1 cuboid )

-generate wall segment with window ( would be made up of at least 4 cuboids )

-generate wall segment with door ( would be made up of at least 3 cuboids )

 

With constructive solids I have procedures:

-generate wall ( have to define 1 cuboid )

-generate window hole (1 cuboid to stencil out a wall )

-generate door hole ( 1 cuboid to stencil out a wall )

 

yeah I guess it's a one time effort to get the generate-wall-segment-with-window procedure right.

 

I guess it depends: If I want a wall with many different sized holes, CSG could be the way to go.

If I only want a set of standard window sizes, can use the building procedures.

 

Thanks to all. (I'm a noob when in 3d stuff..) 

Share this post


Link to post
Share on other sites
But it gets quite complicated when I want to add windows, doors etc. Then I would have a procedure for each of these: -generate simple wall segment ( have to define 1 cuboid ) -generate wall segment with window ( would be made up of at least 4 cuboids ) -generate wall segment with door ( would be made up of at least 3 cuboids )

 

This makes it sound  like you intend to make a voxel game, if so then yes working like this will be acceptable.

 

if you plan on using polygon models then I will point out that modular models are used in procedural games all the time. Often you would use a grid.

hAzD7OM.png

(Sorry the image didn't upload the first time)

 

The corner would be a 3 grid blocks arranged in a L, the wall, door and window will be a grid object of 5*1. (doesn't matter if the window frame exceeds the grid because it's only visual)

You would then proceed to draw a 2D house blueprint using some procedural rules. For example the smallest length of a wall should be 5+2+2(one wall + 2 corners), you would also need a rule to decide what walls becomes windows and doors. If you need buildings of random size you use levels.

You can use walls of 1*1 however I found that it needs cleaning when done to reduce polygons and a 5*1 wall prevents rooms that are too small.

 

The great thing about this kind of grid building is that you could also make a pixel translator that allows custom buildings.

 

 

Tip generate squares and then use some rules to use them as guides for interesting buildings.

IcQxPKr.png

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Tip generate squares and then use some rules to use them as guides for interesting buildings.

 

Aaaaah!! Thats a very good approach! Using squares, color-coded, and then use those. Thanks! I'll implement it that way.

Thats great! Absolutely! As you say.... it allows for procedural as well as custom "hand-made" buildings. Thanks!

Share this post


Link to post
Share on other sites

Ok, I made a modular approach now. The map image is parsed for modular elements, then each element is constructed from procedures.

 

I wonder, how could I now add a roof to such arbitrarily formed houses?

 

Does anyone have any tips?

 

I guess I could somehow add a new color to indicate corners for a roof. (I'd like it to be a pointed roof, like in my first post.)

I guess I could also just use the corners to define a roof dimension implicitly.

 

[attachment=34091:plan.png][attachment=34089:modular-house.png]

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this