Merging similar cubes to make larger cube

I am currently working on a basic minecraft like game.
I have a list of coordinates using which i generate cubes using an egg model.
I have however, hit performance issues so i need to start on some basic tweaks. Anything above 10k cubes murders my lappy. :frowning:
IMO, the two main things, i think i need to care of, are;

  1. merging similar adjacent cubes into a single largest possible cube
  2. culling all hidden faces

how do i do the 1st task?
the code i use for rendering cubes is;

mapList = MapMaker().levelParser()
cubeCounter = 0
# mapList = [(0, 0, 0, 64, '0.0', '0.5', '0.134'), (100, 0, 0, 64, '0.0', '0.5', '0.1')]
for i in mapList:
	placeholderNode = render.attachNewNode("Placeholder Node")
	placeholderNode.setPos(i[0], i[1], -i[2])
	placeholderNode.setColor(float(i[4]), float(i[5]), float(i[6]), 0)
	# placeholderNode.setMaterial(myMaterial)
	cubeCounter += 1


is this something i can do via panda3d? or do i have to use some arcane algorithm in python. Any help here will be greatly appreciated.

I guess you are talking about a LOD (Level of Detail) algorithm ?

I am not sure you need to do much LODing as such because you’ve got cubes. You could check if the cube centre pos (with a radius equivalent to your cube edge lenght) is in the current camera view frustum. If it’s not then remove the node from your scenegraph. Because you’re talking about so many cubes I suggest this is done on a background thread. Have a flag that stops any further “LOD” evaluation of the “world” while there is a already a LODing background thread running. This will allow you to keep doing stuff on your foreground thread (your main loop) while you determine in the background what stuff has to be rendered.

Hope that helps a bit.

Hi Chrys
thanks for replying. I am not sure if frustum culling will help me much as I will be showing large vistas on my camera view.
Occlusion culling is what i think is needed.
but then again, i am currently reading up on these methods and dont really know much about them.

For whatever reason, building a Minecraft clone seems to be quite a popular task people assign to themselves. This is a bit surprising, because Minecraft is a challenging thing to implement in a 3-D engine–you have to deal with efficiently combining many thousands of objects into a handful of objects.

This is doable, but it requires some creativity. People have come up with different solutions to this problem. Try searching the forum for “Minecraft” to read about some of their solutions.


It’s just like MMOs in the (not distant) past – popular, considered awesome and brought buckets of money…

its appeal is easy to see. the blocks looks so organised and everything feels so structured.
that’s at least is the lure for me.
the game i am making is a 4X turn based game. When I was conceptualizing it, I came across Dan’s Planet Cute prototypes. Thats what started me off on this look.
if I use Minecraft to describe my game, its just because most people know of it.

Finally, i am using this game as an excuse for me to learn python and game programming in general. i have no illusions of it ever being a AAA title. :slight_smile:

YOu guys forget one big reason for using minecraft as an “idol” -example. The simplicity of its graphics. Programmer art that actually looks ok if it is just cubes. Most people who start doing games are put off by the “it looks shit” feeling while with the “minecraft” approach it has suddently become “cool” to have just cubes. :slight_smile:

Exactly! actually the biggest task in game making, IMHO is the asset creation. Most AAA games look that way not because the programming is super dooper good but because they have an army of fantastic artists churning out models and textures.
the 3d Dot hero/Minecraft/Cubeorld approach frees us from that and allows people who will never be able to do good graaphics to have something decent to look at. :slight_smile: