Jump to content
  • Advertisement
Sign in to follow this  
bluntman

Procedural Placement of Objects

This topic is 3751 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to procedurally place objects on the surface of a planet, what are the methods for doing this so that the placement of objects is always the same? I can't evaluate all the object positions for the entire planet because it would be too many. I am currently using various fractal techniques to generate the planets surface, using a geometry clipmap. I am thinking of placing all the objects on a certain clipmap level, evaluating some kind of function for each grid square on that level to decide what objects to place in it and where to place them. But I can't immediately see how to make the placement consistent so that if I come back to the same place later the object placement will be the same! I have heard mentioned before about evaluating a 3D fractal function in the same way as for the terrain generation to decide placement, anyone know anything about this method? I have tried googling for procedural placement of geometry but to no avail. It is also not covered in "Texturing and Modelling: A Procedural Approach" either, disappointingly.

Share this post


Link to post
Share on other sites
Advertisement
Assuming you have a random number generator that can be seeded, it's not very hard at all. Simply seed the generator with a number unique to the map area each time before you randomly generate its contents. The seed number can be created with a fractal noise function or it can be just the number of the map cell on a grid. As long as you always use the same seed number for the same area the results will be the same. This'll work regardless of the details of the object generation system, as long as all the randomness comes from the seeded RNG.

Note that if you have any kind of dynamic objects that the player might move or destroy etc, a system like this won't remember the new state of the object if you leave and then come back.

Share this post


Link to post
Share on other sites
Ah but the problem is the grid isn't repeatable, when I leave an area then come back it won't be aligned in the same way. The origin of the grid is set when the camera gets close enough to the planet to spawn the clipmap, and the grid is also not something that covers the entire planet, it is relative only to the camera position. The way it is generated (i.e. to map onto a sphere) means it isn't possible for it to be static. Thanks for the reply though!
Yeah I already generate the surface using a seeded random number generator (stdlib rand()) to feed the fractal generators. I use a method something like this to create and place my cloud particles, but for them it doesn't matter if they aren't in the same positions. But if I have a rock the size of a house, it needs to always appear in the same place! For the trees it doesn't matter so much, but I would prefer them to always appear in the same place, so the player could, for instance, stash an item by burying it under a particular tree on a particular planet then be able to find it again under the same tree.
One thing that is static is the underlying planet sphere, this is always aligned the same, so maybe I could map the coordinates of the sphere into a temporary clip-map like structure then for each segment of the planet that falls inside this clip-map I could generate the procedural content.

Share this post


Link to post
Share on other sites


You could use a standard grid (coords as seed for the generated contents) and then take your camera coordinates and figure out which grid squares will/may be viewed ('window' of all 3x3 neighbors or 2x2 set for a particular point+ facing if the camera doesnt move fast). You would then generate allthe objects in those grid squares and if there a a few extra not seen its may not be a big problem.
If excess is a problem then use a finer grid and make your window 5x5 10x10 ... whatever -- and generate all those individual squares' contents.


I did this kind of system (totally coordinate based random seeds) before but found no cohesion in larger terrain patterns (river systems and shorelines and mountain ranges as an example).
I had to implement a world seedmap which activated templates of various terrain pattens and local 'theme' coefficients for the contents. The world map was pre-generated with generating functions that created the larger patterns (and backtracked to resolve illogical patterns). The local details are then generated from the seeds (and got more variation WITHING each grid square by mutating it with the adjacent squares attributes (which you CAN also do with
random seeds since you can always generate their values from coordinates).


For local cohesion the generating functions (within a grid square) can use templates for groupings of related objects (ie- cluster of trees) and simple fitting scripts to make somewhat logical placements.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!