🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Ai hunting targets in 3D space

Started by
15 comments, last by h8CplusplusGuru 2 years, 8 months ago

Gnollrunner said:

@undefined With marching cubes nothing crosses cube boundaries. The main downside is you need to use an advanced form of it if you want terrain with sharp corners.

Got any good resources i can look into on this topic?

Advertisement

Try googling feature sensitive marching cubes. If you can't find it, I'll find it for you later when I get home. I'm working on a derivative of it myself.

CelticSir said:
Hmm every example I find to learn quad/octree people use tiny points rather than objects with a 2d/3d bounds when they setup the structure, which is a pain because it then doesn't cover situations where the object overlaps two regions.

There is the concept of ‘loose’ quad/octree which solves this, but i know tutorials are rare.

The idea is to extend bounds, and to store stuff in interior nodes as well, not just leafs.

A node of size 1^3 has an extended bound of 2^3, but center is the same.

If you have an object with a bounding box of 1.8 x 0.7 x 0.3, it goes into that node, because 1.8 is smaller than 2 but larger than 1. The object fits into the extended bounds, while it's center is guaranteed to be inside the not extended node bounds.

Very useful e.g. for collision detection, but i have never used it for path finding. It's more complex than ‘regular’ octree, but if splitting objects or storing them in multiple nodes is no good option, it usually is much more efficient and avoids worst cases.

CelticSir said:
Even a map of 50 by 50 by 50 units becomes 125,000 nodes. It's not doable.

You can merge regions of cubes into larger boxes, similar like a Minecraft game could merge multiple quads with the same texture into one rectangle to reduce poly count. A good algorithm for this is the ‘motorcycle graph’, which also lacks tutorials.

Drawing the algorithm while taking screenshots (the solution evolves as time advances):

We have two objects and too much cells.

From each object corner we advance a motorcycle (name comes from the movie Tron):

Here two motorcycles collide. Usually the one which collides with a trail of another gets deleted. But in this case they collide directly, and we can delete any of the two.

After all motorcycles are gone, the space is divided into few convex cells and we could build a graph for path finding.

It's like building a BSP tree, but much faster. In 3D the lines become planes ofc.

Edit: I forgot to mention the very first collision in the second image, where both motorcycles die because they collided frontally.

A typical 3D land environment has either the same obstacles as the same environment flattened to 2D (e.g. Pokemon-style outdoors with nontrivial navigation have impassable tile edges in a map that translate directly to detailed rocks, hedges, steps etc. in 3D) or less obstacles in most cases of genuinely 3D movement (flying or swimming, zero gravity reaction drives, falling…).

Decomposing a 3D environment into convex regions around obstacles is almost the same as in 2D, with a significant but limited number of additional objects (e.g. 27 regions with two nested boxes with parallel sides vs. 9 with two nested rectangles, possibly consolidated to 7 cuboids and 5 quadrilaterals respectively) but not fundamentally different challenges.

Omae Wa Mou Shindeiru

If you are implementing a fish can you just do subsumption + ray casting?

This topic is closed to new replies.

Advertisement