I’m new to panda. I played for a while with pygame and decided that I want to give 3D a shot. So a this moment, I’m still in the learning stage and I need a ‘learningproject’. I stumbled on the internet on a game called ‘Minecraft’ http://www.minecraft.net. (You can try a free version on the website, it’s a browsergame) I found the concept of a world made of blocks very fascinating. It’s great and simple at the same time. I think that it couldn’t be very hard to program a think like this. The world is devides in a 3D array of static blocks. Those blocks can have various types (rock, soil, air, water, wood…) and you’re world change with the type of blocks that change (eg. If you dig soil, the soil block becomes a airblock) Nothing is moving, (so no physics involved) The only thing that moves is you and maybe some other creatures.
What do you guys think, would it be a good ‘project’ to learn the concepts of 3D programming/panda? (off course not as complex as that game ‘minecraft’. let’s stay realistic ) I was searching the forums (‘blocks’, ‘cubes’,…) for some example code/approaches but I didn’t find anything useful. Maybe you guys know some simmilar project done in the past with some example code? Or maybe some hints? Some idea to create this ‘world of blocks’?
Hello and welcome to Panda
Having a previous experience in pyGame will definetly help you to start up but your best friends will be the manual, exemples shipped with panda and the forum.
This is not that hard to implement. you’ll find good collision tutorials in the showcase part of the forum.
why not? Everything is possible but each project takes time.
Apparently, you already have the game idea, pick a small piece of it and give it a try.
Why a small piece ? Because you’ll quickly get confused and tired about creating a game if you start programming on the fly. You need to fix objectives to yourself and follow them.
For exemple, you can start by creating few cubes, putting one of top of each other and texture them. After that, create a cube when you push space bar, then create a 2d button on your screen which will do the job of the space bar… ect…
well the problem i see with this game… the management of blocks themselves. gpu’s arent made to deal with thousands of individual cubes. you need to do some performance tricks. but dont worry, those are available in panda, thought they still require some brain to use.
I was thinking about starting to generate a small world (say 161616 blocks) with the lower 8 planes as soil blocks and the upper 8 airblocks.
Some small questions (i’m pretty new to this 3D stuff)
You can’t create a simple cube with a plain color with panda? (Like I should create a retangular in pygame) I need to import a cube egg modelfile for each cube (that I create for example in blender)?
I’ve read some lines about voxels and octtree as datastructures. Should I dive into that? Or can I just store my cubeobjects in some list of lists of lists structure (maybe not that efficient)?
well octrees are an option, especially for large environments. for 16x16x16 lists will do just fine. while you can procedurally create geometry in panda its rather advanced stuff.
easiest way to get a cube in panda is indeed to export the default-cube from blender.
panda will automatically cache the file so dont be afraid of the loadModel() line.
i highly encourage you to load only those blocks who are on the border between solid and void space. and also make use of flattenStrong after you’r done with all the loading. or your gpu will choke due to the high number of geoms.
I thought that a simple blocky world would be easy to start. But it seems not with those render problems when you load many visible cubes. I think that an octree is the way to go. But as a noob I’m still trying to understand it. I understand that you have a tree with each node/cube divide in eight branches/smaller cubes and those smaller cubes are again diveded in 8 smaller cubes, and so on. So what is the big idea for faster rendering. You only render the cubes of the (sub)branch you’re character is standing, so you can modify the cubes arround you. All the other visible branches of blocks furter away are collapsed to one (world)object that is rendered in one piece. Is this right?
Is there some native implementation of an octree datastructure in panda? I’ve searched the manual but couldn’t find anything. I’ve found some old octree script thing on the forum, but i don’t know if it fits my purpose. They were talking of converting an egg file to an octree or something. But I want to create a octree form many different cubetypes egg files and not converting one egg file to a octree. (Or did I read wrong?)
EDIT: Oh, do you guys know the cube 2 engine. It’s an game engine based on a octree blockworld. It seems that would be perfect for my purpose. To bad I don’t know C/C++ What do you guys think of this engine (if you know it) Maybe it’t to narrow/specific to learn. I would be stuck with block for every game/3D project.
Hi, quick question.
EgiThomas, you suggested to use flattenstrong. But this turns al my block into one mesh. The problem here is that nothing can move anymore this why (eg: a moving waterblock or picking a rockblock away).
I’ve read in the manual about geomipterrain. and of rigidbody counter. Wouldn’t that be a better solution for rendering that many cubes in my case?
Also, you said this:
What do you mean excactely with this? Do you mean that when I have 8 layers of soilblocks, I should only load the upper layer of blocks? Isn’t it so that only the visible block are rendered (so the layers I can’t see are not rendered) and will not consume my gpu. Or am I totally wrong on this? I’m really a noob in 3d. ^^ You know a lot more of this stuff then me, that’s for sure.
I have implemented an octree in python (or something very similar, you should be able to use it in a 2, 3, 4, etc. dimensional grid). Creates branches/leaves on demand, and recycles branches/leaves as they are not needed anymore. I have plans to make it threadsafe… but I would not recommend using it in a multithreaded env. yet.
Put it on Google docs in case you’re interested:
docs.google.com/document/pub?id= … OJxUez49-Y
Limitations: grid must be equal size in all dimensions, and the size must be a power of 2.
ow, thanks a lot.
I will look into it later on (now I have exams)
I never used an oct tree before. Do you have an idea from which size (AxBxC) on you get a significant speed advantage in comparison with normal lists of lists of lists? Just an rough estimate?
I am guessing that the list of lists (of lists) is fully populated based on the dimensions of the area, and in that case I don’t think you will see any speed increase. This technique is more for saving space in RAM, since you only have to materialize the container as needed. This takes some overhead to manage, as well as accessing the items contained within. Also, I don’t think this tree will help with your rendering speed as-is. Right now it is only made to behave as a grid, but it could probably be adapted to assist with “cube” culling…