Grid System for Panda

Hey All,
I’m a new poster but have been working with panda for a little while…

I’m trying to make a grid system in Panda.

1 Unit = 6 metres and each tile is 6 metres/units

So I’m basically wondering if someone has devised a way to tackle this in panda?


The issue is not importing the models but its getting each tile to align itself correctly with the right model dynamically according to an array or file import. I’m using SQL for my databases but im open to another form of input…

I know this seems like a mouthful but this is my overall aim.

Any help is welcome…

there is no meters or similar in panda or any engine or 3d editor. while some editors give you the assumption that there is a metric, you can forget about it once you export or merge with other files with other metrics.

afaik 3ds max is best left at the default system, blender has none, i dont know about others.

for example: 1 unit in blender is 1 unit in panda3d. you can think 1 unit is 6 meters for yourself. just make sure the object has a sidelength of 1by1 then move every object by 1 in eigther x or y and you have your grid.

 # to find out object sizes you can use:
print model.getTightBounds()
# or
print mode.getBounds().getRadius() # get radius

I’ve already set it all up for 1 unit = 6 metres… that element of the problems is non-existant.

All the peices fit together fine, its tried and tested.

The issue is with the technique in which to implement the code… I’m a games artist so that side is no problem…

i think you got to describe your question a bit better, i dont really understand what you want to know.

I agree Hypnos. The first thing that came to my mind is "What is he calling a “tile”

ok im not well so my communication skills are lacking right now :slight_smile:

ok a tile is a 6m by 6m model that represents a section of the ground. Each tile is 6 panda units by 6 panda units. Therefore 1m = 1 panda unit.

Simple yeh?

So basically now I want to save a construction of these tles that forms a base for the world. The tiles can be replaced then by the player when they are building new buildings, roads etc. on the map.

The tiles will then provide the bassis for pathfinding etc.

Basically think SimCity, Anno1404, Combat Mission Series Map Editor…

If you need examples i can provide some

well there are many ways, and most are comparebly easy.
one way is to use tags to tag your models.
since you have a grid, eah point on the grid has an x,y coordinate.
you can add tags to your loaded models containing that info. so you can access them later on.
placement of it is even esier since you can do setPos(x6,y6,0).

in case you need a poorly written example. i still have some ancient gode of mine somewhere which did that very thing, including dynamic loading/unloading of tiles.

since tiles can cause you to end up with lots of isolated geoms it’s likely you’ll run into big performance issues at first, if that happens, dont worry, the rigid body combiner can solve those.

about saving and loading those worlds. it’s as easy as creating a new file and saving the neccessary informatoin into it. like one line for each tile, each line containing the information tilex,tiley,modelname.
you can also use cpickle(not very secure but very easy to use), rencode , or structs to save the data into a file.

thanks for the advice.

I’ve developed some crude way of doing it so far where the placement is hardcoded (ish) dependent on the name of the tile in the data file. A1 places at 0,0 A2 at 0,6 etc.

The perforamce issues are something I will need to look into long term, especially since my AI code takes up alot of proccesor time in its current state.

I’ll be sure to return to this from time to time and look up ur suggestions.