3
\$\begingroup\$

I want to make a terrain for a RPG game that I'm developing. I started modeling the surface and implementing it to my game, but now I realized that i might be doing everything wrong. So I would like to ask a few questions:

  • How should I make the surface Model?

I'm developing my game without an engine, so I have to do coding for everything (Java, LWJGL). I use Blender to model the surface, and I export it to an .smd model file.

  • How to detect intersections between the surface and other models?

I guess I need to detect intersections, to make the terrain walkable. The problem is that I don't know the best and easiest way to do that. I tried making a triangle-triangle intersection detection algorithm, but it was to hard for me, and I guess I need something faster and simpler.

\$\endgroup\$
1
  • \$\begingroup\$ As already mentioned in the answers, you want to create a heightmap. As you are using Java and LWJGL just as I am, I suggest you watch this tutorial: youtube.com/watch?v=O9v6olrHPwI. Tutorial #22 is about collision detection. Also, sidenote here, if you want to generate heightmaps, L3DT is the best heightmap generator I have found so far (youtube.com/watch?v=oLYFPL4eVeY). \$\endgroup\$
    – joehot200
    Commented Jan 19, 2016 at 9:38

2 Answers 2

5
\$\begingroup\$

You can generate your surface as height map (2D table of heights, regular grid). It might look like this

http://mrdoob.github.com/three.js/examples/webgl_geometry_terrain.html

You probably don't need physical simulation, so you just find the height at certain coordinate and check, if your model is above it /under it. That is only the basic idea and I am sure you can extend it.

\$\endgroup\$
1
  • \$\begingroup\$ That's also what I would recommend: Create a heightmap for the ground and then use separate 3d models for more complex objects like trees or buildings. When actors are supposed to walk on top of them, they could have a simplified invisible shape which modifies the heightmap for game logic purposes but not for rendering (in most cases a simple box will do - such a box around an object is called a "bounding box" and can also be used for collision detection). \$\endgroup\$
    – Philipp
    Commented Jan 22, 2013 at 14:13
3
\$\begingroup\$

One solution is to create a navigation mesh which defines walkable surfaces. This mesh can also be used for pathfinding for AI. There is a C++ library to automatically create a navigation mesh called Recast & Detour.

Recast has been integrated into Blender. Switch the renderer to "Blender Game". In the Scene properties panel you can then find a "Build navigation mesh" button, which creates a navigation mesh for the currently selected objects.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .