I wanted to make a program that anyone could sit down and use, just to mess around. I decided to make it a little house builder, in which the user would start out with a wall, and be able to move the different walls around, and place some rooms once the border of the house is set.
The border of the house is an array of Wall structures that are heirarchichally modeled. The program also makes use of per-pixel shading, and allows the user to choose 3 different material types for the walls.
The basic game camera is carried over from Program 4 and is controlled as follows:
'W' and 'S' move the camera forward and backward, respectively (parallel to X-Z plane)
'A' and 'D' strafe the camera left and right, respectively (parallel to X-Z plane)
Left Clicking on the screen and dragging the mouse will allow the user to change the angle of the camera:
Dragging the mouse up will angle the camera up and dragging the mouse down will angle the camera down
Dragging the mouse right will angle the camera right and dragging the mouse left will angle the camera left
Using the Right mouse click will bring up the menu options:
Additional keyboard controls are used to change the positions of the walls:
'O' will decrease the angle of the wall along the Y axis (Picture below)
'L' will increase the angle of the wall along the Y axis (Picture below)
When placing rooms, other keystrokes will allow you to change the position of the first wall of a room (more about rooms later):
'Y' and 'H' will move the wall forward and backward on the Z axis, respectively
'G' and 'J' will move the wall left and right on the X axis, respectively
In order to acheive heirarchichal Modeling, I declaired a single wall as a struct with elements:
I would use an array of wall structs to keep track of each model transform easily
In order to place multiple rooms, I made an additional Room Structure with the elements:
The loops for heirarchichal modeling work as follows:
For each wall in the house {
The user can use the right click menu to place walls, rooms and change the camera height.
After gettting the desired angle using 'O' or 'L' the user can set the wall into place using the 'place wall' option
Clicking Place Wall will spawn another wall aligned with the previous wall, and the user will now be able to change the angle of the new wall(example below)
If it turns out you do not like the placement of one of your previous walls, the user can use the 'previous wall' option
The Previous Wall option will remove the current wall, and cycle back to the previous wall, allowing the user to go all the way back to the original wall(example below)
Some houses have Walls without windows, to facilitate this necessity, the 'wall type' option has been added
The user can choose whether or not they want a window using the Wall Type submenu. (example below; left wall is 'flat' type, right wall is 'windowed' type)
Walls actually have two sides, and each side can be given a different color.
The outer wall is brown by default, and the material can be changed with the 'Outer Material' submenu (examples below)
The inner wall is grey by by default, and the material can be changed with the 'Inner Material' submenu (examples below)
!!!!~~~**** IMPORTANT NOTE ****~~~~!!!!
Due to the way the walls are modeled, the best results occur when the user establishes angles that make sense.
For example, if the user orients walls such that the 'outside' is actually on the inside, then the walls may end up switched around.
Sadly I don't have any screenshots of this, but feel free to play around with EXTREME! angles and see what happens.
Once the user has placed all of their walls, they can move on to making rooms!
With the last wall in place, the user can select the 'Room Mode' option, which will place the first wall of a room where the initial wall is located (example below)
!!!!~~~**** ANOTHER IMPORTANT NOTE ****~~~!!!!
If the user clicks on Room Mode, then the walls representing the boarder of the house are set in place and cannot be moved.
If the user clicks on room mode, but wants to change the border of the hosue, they will sadly have to start over.
Whoever thought this would be a good program design probably needs to get their head examined.
Moving on, once the user enters Room Mode, the user can use the 'Y' 'H' 'G' and 'J' keys to move the initial wall, according to the specified controls.
For example, holding the 'H' key for a little bit moves the wall along the Z axis (picture below)
Once the initial wall has been placed, the user can use the Place Wall, Previous Wall Wall Type and Material options just as before (example below)
The user can then select a new room to place another room in their house. Yay!
Finally, when you are all done placing your walls and rooms, you can show off to your friends and loved ones!
One handy sub menu that is included with the house builder is the View Mode.
The program defaults to Build Mode, which is useful when you are placing new Walls and rooms.
Tour mode will lower the camera, to simulate walking through the house as a normal sized person.
Now you have all the info you need to build a house in my House Builder, go out there and show them what you've got! Or something.
Here is what I was able to create in just a few minutes, I kind of like it!
Here are some geometric problems I could not overcome. But I still love my creation.
I wanted to make something that I could just fool around with, so I do like my final result. Given even more time I would have liked to do multiple floors, doors, actual floors/ceilings/roof, and wall scaling.
I am certainly proud of my heirarchichal modeling. It is a simple implementation but it allows for a lot of parts to be modeled very quickly.
The executable is available for download. To run the house builder: a.out