howto create boundaries around map? DONT allow swimming

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

howto create boundaries around map? DONT allow swimming

Post by Georgian »

hi,
i have my project on island and i want to create something like a boundary around a map so that my camera will be forbidden to go in water or jump of a dock into water any ideas?

thanks.
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You could do a tile/cell based approach where you create a very low-level 'map' of your environment by simply having a boolean 2D array which you then mark in each cell of the array whether that part of the world is allowed to be entered. Here's a little pic to show what i mean:

Image

So the grid is just overlaid on a sketch of what your island might look like and then the crosses mean cells you're not allowed to enter (didnt fill them all in)

get the idea?
Image Image Image
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

Post by Georgian »

thanks i get the idea :)
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I have another idea...
you can create an invisible (full transparent) mesh for the border and add it to the physics (collision)...
so if you try to pass the border you hit the invisible "wall" and can't go further... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

That's a good idea too. I suppose it could depend on how complicated that mesh would end up as to how well that would perform. I imagine the grid would be better performance as it's just working it out the cell you're in from your position and then checking a boolean value which i imagine would be quicker than doing collision detection on what could be a huge mesh.
Image Image Image
roxaz
Posts: 575
Joined: Tue Jan 23, 2007 8:35 pm
Location: LT

Post by roxaz »

and you could check object coordinates and compare to predefined min x;y and max x;y every frame, and then if object goes out or bounds - kick it back or freeze it or do whatever you want :)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Actualy he can combinate those two aproaches, split that invisible mesh in to sectors, then test in what sector camera is and make collision detection with appropirate part of invisible mesh ...if that sector contain it al all. That way he can keep performance high.
JRowe47
Posts: 55
Joined: Sat Jun 30, 2007 9:09 am

Post by JRowe47 »

If water is done per height level, then simply don't allow the camera/player object to go below a certain level...

rough pseudo logic:

if the next "step"(frame) would take you below the shoreline, then return to last camera/player object position.

Devise some method of preventing choppiness when at a border height (running into the shoreline, for example.)

This method would have the advantage of being applicable to other maps, requiring only data that already exists, and 0 custom work done to achieve the desired results.

Also, no matter what, you'll need invisible walls around docks and structures that extend over the water. Instead of implementing physics, however, simply do a "zoned" approach. Create a zone area, with 3 lines representing the "walls" that restrict movement.


If the player/camera is "inside" the lines, then prevent motion beyond them. Make sure you make it slippery when you contact a border, so that the camera doesn't stick in one spot.

No other check should be needed.
Georgian
Posts: 60
Joined: Sat Mar 31, 2007 12:55 pm

Post by Georgian »

well thanks for ideas all of them are good, and the easyest would be JRowe47's idea about water level, but i also have a volcano on top of island so i think ill be using the grids. or invisible walls, ill try to make my islands boxlike.
using Visual Studio 2003 , I use 3D Max 7, I love irrlicht its a really good and easy engine
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

well a better idea would be to check if the player is above the land and stop moving him when he leaves the land. just do a raycast down
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply