Hey there! As the title suggests, I want to talk about how I managed to turn image A into this breathtaking and awesome composition of objects in image B.

tile
image A
procedurally placed objects
image B

Nice, but why?

As a solo developer, I have to focus on getting my game up and running therefore lacking the time to manage all this nitty gritty artistic stuff. Given the devastating lack of man power, I do have to search for other alternatives, which at least in this case are my (hopefully) sufficient coding skills.

So how did you do it?

I spawned a bunch of points given a fixed distance and placed a set amount of different object at those locations until the maximum number of objects was reached or no more free points were available.

TL;DR (if code -> pseudo code)

For each tile, which will have objects on it, I generated tighly packed points with Poisson Disc Sampling.

poisson disc sampling
poisson points in red

The object are picked less random than they are from a custom class which governs which specific objects are placed on a tile. I call this one TileSet.

class TileSet
   string setName
   TileFeatures[] features

Each TileSet consists of several TileFeatures which define the object, their number per tile and all alternate objects which just differ in appearance (you can have several stones, which are all stones but look different).

class TileFeatures
   string featureName
   int numberPerTile
   Objects[] altMeshes

Afterwards the algorithms iterates over all points and places an object if its current amount is less than its maximum allowed number or there are no more free points.

placing algorithm example

for Point in PoissonPoints
   for TileFeature in TileSet
      if number of already placed TileFeature less numberPerTile
         place any object in altMeshes of TileFeature
      else
         continue with next TileFeature

And that is it!

Bottom Line

I think that this whole idea is pretty easy, but the results are nevertheless impressive given that I did not have to do anything except for writing code.

And with some nice tweaks and other rules I can use this to apply all sort of different object to any sort of ground (like stuff on a desk etc).

All in all I am pretty happy with the result.

I hope you liked this post and see you next time for another awesome game dev stuff post.

procedurally placed objects
different object compositions
walk cycle animation Next post #1 blender stuff | scaling animations

One thought on “#1 game dev stuff | object placement”

Comments are closed.