Thursday, July 5, 2012

invisible shapes!

Today I finished up two mechanics.

The first is the "invisible placement map" mechanic, although I had to use 3d shapes now instead of a map.  This is the mechanic for when a user tries to place a wind farm somewhere, the camera position is checked against these invisible shapes, and if a shape is under the user then that shape represents a reason for not placing that wind farm there.

I had to switch from a map to shapes because I ran into a problem with the map idea.  My original plan was to try and lay an invisible image onto the terrain, much like a height map, and check the values of this map for why you should or should not build here.  The advantage of this was that the image should stretch with the terrain if a programmer wanted to stretch the terrain to make it bigger.  Also it would be very easy to create this map, since you could use a painting program to make and modify it.  However, JME3 does not like unknown maps at all, and would throw exceptions when a map that did not have the correct name was added.  Further, if I tried to replace some other map that was not being used with my placement map, JME3 would turn on that unused map and the terrain would look very strange.  This is the reason I decided to go with 3d shapes instead.  I made another txt file reader that reads in from a config file all the different shapes that are in any level.  Then, in a class I wrote, these objects are spawned through out the world according to the config's parameters.  Then it is simple to do a ray cast straight down from the camera to see if any of these shapes are hit.

The second mechanic I accomplished is to make a system for displaying the remaining time left in the level.  I decided to add this to the HUD on the cockpit, since it looked nice this way.  There isn't an end game screen yet, but it should be simple to make as it is just like the starting screens I made a few days ago.

Both of these new features can be seen in this video.  Note: The output of why a user cant build there on the HUD is just for testing.  The final way for the user to get this information will be from an interactive beacon that he must go near (and eventually land on) to get this information.



No comments:

Post a Comment