How to implement a symmetric 3d field of view algorithm for a roguelike

Truncheon
  • How to implement a symmetric 3d field of view algorithm for a roguelike Truncheon

    I've been thinking about adding 3d support in my roguelike. It would still be top-down like other roguelikes, yet it would have layers, such that things like platforms, tunnels, and bridges, etc, could be added to levels. Whether I do this hinges on whether I can get the fov routine I'm using working with the layers.

    Note that I don't care that it doesn't make sense to some of you that I'm trying to have a 3d field of view routine for a 2d roguelike. The roguelike does have a 3d space, and I want to determine what the player can see, even if what the player can see can't logically be displayed. Let me worry about how to handle that problem.

    I would be grateful for some advice in how to approach this problem. Perhaps this is utterly crazy, and I should just make a 2d roguelike...

    Update:

    I erroneously stated before that the problem with Bresenham's line algorithm was with artefacts. I should have mentioned that I needed the fov routine to be symmetric. Such a requirement can't be met by Bressenham's line algorithm.

  • Make the algorithm symmetric, just implement a way of making sure that two points are always fed to the algorithm in the same order, no matter which is the viewer and which is the viewee. This is for instance easily done by giving all points an id and sorting by that.

  • Real time strategy games routinely deal with this problem (take, for example, Starcraft 1 which was pseudo-3D) - maybe you could find some literature on how they managed it.

    What I would do is probably pre-calculate some form of a 'visibility mesh' (akin to a navigation mesh). Each region of the mesh would link to regions that are visible to it. You should be able to lift a lot of logic from light-map generators (or possibly find a light-map library). Ideally you would place a large amount of lights in 'walkable' areas and calculate the light map for each, following this you would resolve similar areas into a single mesh.

    This would probably result in a large amount of regions near corners - but corridors should be nice and clean.

    To determine if two entities can see each other merely check if the meshes that contain them are connected; and that they are within field of view range.

  • Modifing a FOV algorithm to work in a 3D isn't terribly difficult, you need to have the algorithm take into account all possible directions in a sphere instead of just a circle.

    Are you using a symmetric FOV algorithm now? If not, you should switch to one first, then make the modifications. If you put up the code/more information about the algorithm you are using now, we would be able to help you more.

Tags
c++ roguelikes
Related questions and answers
  • (showed to the player, and given to the scripted actors) in this case would be something like a collection of "what", "where", and "in what orientation". The question My question is: how I can... information from the world about his surroundings. The player can also interact with the world, picking up an object for example. Now, I would like the same thing to be possible for other, scripted actors. They are the player's competition. Instead of navigating the world and performing actions based on human input, a script should decide what they do. An example I want to do this using a 2d

  • Suppose I have a Spacecraft object in 3D space, controllable by the player. I want it to update its own trajectory, so I give it a function for that (actually it might be inside a controller component associated with it). No problem until this point. For this function I want to use a scientifically tested, accurate N-body simulation algorithm (like this). It's my field so I already know how to do that. The challenge is how to make the game activate the function efficiently. This is what I've thought of so far: The algorithm can calculate a lot of time steps in a short time, so I could

  • I need to draw contour around 2d objects in 3d space. I tried drawing lines around object(+points to fill the gap), but due to line width, some part of it(~50%) was covering object. I tried to use stencil buffer, to eliminate this problem, but I got sth like this(contour is green): http://goo.gl/OI5uc (sorry I can't post images, due to my reputation) You can see(where arrow points), that some...? Thanks in advance. EDIT: 1. I don't have normals of objects. 2. Object can be concave. 3. I can't use shaders(see below why).

  • ". As you can see in the picture, a corner will basically cry for a "cap" object. I'm actually cool with it, it's not so hard to add. Hey, I already have a plan for thin columns made out of four connected caps. Sweet. Still, I have some worries regarding possible Field of View and Line of Sight issues. C) The total overhaul variant. Or, I could just create borders and corners as separate containers..., and whether I missed something or not. Important: a character CAN stand on a tile that has walls, regardless of their form. The common thing for all the three variants: the tilemap will be "kept

  • for other players should only be sent to a game client if their player is near the other players (i.e. you shouldn't get health updates for people you can't see on the other side of the map). The main problem is that if you had to compare all the players every time an update is sent, it would just take way too long as the number of players scales (think up to a few thousand players per map and each of them updating up to 3-5 times a second). If the players are in a 2D space (it's 3D but the z difference shouldn't affect visibility) what is the best way to manage the visibility of other players

  • I was thinking about making smaller structures with the fTime variable each so I can have attribute keyframes, light keyframes and buffer keyframes, then make the node structure look like... with different types of objects in the same scene. I was also thinking about making a MeshNode class and then make a Mesh object that contains them, but then I have some conflict on where to store some data... know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I

  • Lately I have been working on a game that i plan to make online. I have used different libraries to make this game as far as i could, but I feel that I should rethink on how Im sertting this game up, so I planned to start over. The libraries that I have used are SFML, OpenGL, and Bullet Physics, along with GLM to load the models. But the problem is that the 3D graphics arent working with the Physics correctly... So my main question is: What would be a good combination of libraries to make an online game with? Im sure that many people have good combinations of libraries for making a game

  • areas of concern I have and wanted to get some opinions on the proper way others have solved them or would solve them. 1. Cyclical Dependencies When I was doing the game in C#, I didn't really have to worry about this since it isn't an issue there. Moving to C++, this has become a fairly major problem and made me think I may have designed things incorrectly. I can't really imagine how to decouple...I've been working on a 2d RPG for awhile now, and I've come to realize I've made some bad design decisions. Theres a few things in particular that are causing me problems, so I was wondering what

  • hey so I've decided to Code my own 2D soft-body physics engine in C++ since apparently none exist and I'm starting only with a general idea/understanding on how physics work and could be simulated: by giving points and connections between points properties such as elasticity, density, mass, shape retention, friction, stickiness, etc. What I want is a starting point: resources and helpful... or ideas. finally I was wondering if it was possible to... use the source code of an existing 3D engine such as Bullet and transform it to be 2D based? use the source code of a 2D Rigid body physics