Panda3d paged geometry?

I wanted to keep this the last thing I’d do. It sounds like a difficult thing to implement. But I can’t save this for the later any longer.
I just have to start building my game world to be able to add other features.

I searched the net for some documentation with not much luck.
I came across this page: ogre3d.org/tikiwiki/PagedGeo … =Libraries
It pretty much sums up what I want to make.

I haven’t used Ogre before, nor I am a C++ user, so though ive read the manual, I can’t read the code to find out how they made it.

I hope you guys can give some tips and techniques used in such systems.

I wish to convert that system to python and Panda3d. The final goal is to post the results in Showcase section. I have few tree models and bunch of textures lying around.

According to the Ogre wiki page,

If you dont want to read their manual, basically you create a PagedGeometry instance and call some of its methods.

If it was in Python, the code could look like these (the quotes are from their manual):

trees = Pagedgeometry()
trees.setCamera(base.camera)
trees.setPageSize(50)
trees.setInfinite()
trees.setBounds()
trees.addDetaillevel('BatchPage', 150, 30)
trees.addDetaillevel('ImpostorPage', 400, 50)

Dont know what they mean by billboards. Maybe sprites? From the images the billboards could go over 300, or even 1000.
Also they say BatchPage is much faster than plain entities/ node(paths). Im guessing they use something like flatten() or rigid bodie combiner. As far as I know those can’t be ‘un-done’, so I would like to hear your opinion.

treeLoader = TreeLoader(trees, TBounds(0, 0, 1500, 1500)
# And add a entity at the desired position/rotation/scale
treeLoader.addTree(myModel, position, hpr, scale)

No idea what compression technique it is.

trees.setPageLoader(treeLoader)

We could put this in a panda task:

trees.update()

The system has a separate way of handling grass, it also has a way to add shadowmaps to grass and trees, but that one is probably beyond my knowledge.

i think they mean quads/planes when they say billboards here?
Im not really a fan of using billboards for grass. many games use it, but in my opinion its pretty noticeable and looks fake.

I would like to know about your opinion on what additional/unique optimizations can be used for the grass.

I don’t really like the idea of having density maps for trees and big vegetations. There are games with huge worlds where say, you have to look for treasure hidden under a specific tree. But I like the idea of using them for grass. I think there is a code snippets somewhere here on the forums which I could use as a reference.
---------------------------------------
Now, for positioning the trees, I could make a Blender script which would export positions, rotations ans scales of objects (empties?) to a simple text file, and shoot a collision ray for each tree in the beginning to get the z position.

Theres nothing mentioned about the terrain loading. Should we only use geomipterrains in this case?

For the BatchPage trees… how would you use RigidBodyCombiner in this case?

I would like to know of any optimization techniques which could be used in implementing such a system.

Im sorry for the huge post and I know this sounds pretty ambitious, but I hope the advice and techniques posted on this page can be helpful to others as well and will share all my results with the community.

I’ve done basically the same thing here :
[how to make these kind shodow?)

It’s grid based, so what I do is instance/copy the terrain chunks around the avatar from the pool to the scenegraph.

This is the relevant piece in updateDropShadow() :

      if self.CH.getAirborneHeight()<.1:
         minx = max( 0, int((w.terrainMinX+pos[0]-self.radius)/GRIDX) )
         miny = max( 0, int((w.terrainMinY+pos[1]-self.radius)/GRIDY) )
         maxx = min( int((w.terrainMinX+pos[0]+self.radius)/GRIDX), w.XSIZE-1 )
         maxy = min( int((w.terrainMinY+pos[1]+self.radius)/GRIDY), w.YSIZE-1 )
         idx = ( (minx,maxx), (miny,maxy) )
         if self.DSidx!=idx:
            self.DSidx=idx
            self.dropShadowGeom.removeChildren()
            ds = self.dropShadowGeom.attachNewNode('')
            for yi in range(miny,maxy+1):
                for xi in range(minx,maxx+1):
                    gnp = w.glist[xi][yi]
                    if gnp:
                       gnp.instanceTo(ds,0)
            ds.flattenStrong()

Enter debug mode and see how the white terrain chunks around the avatar are attached and removed from scenegraph.

What is that?

I have the Ogre3D source, and Ogitor Editor to, they include the PagedGeometry; also have source for an open source game project called DungeonHack
[dungeonhack.sourceforge.net/Main_Page]
That uses the PagedGeometry in its infinite terrain game in development. Took a bit work to download all the parts involved and compile, also had to fix a few things for it to work for me, but it lays out terrain and trees and grass (with movement) very fast as you move yourself (FPS character) across the terrain.
The impostor trees look good but sometimes are shaded lighter than they should given an evening sun position, then when they switch to actual entity they get darker.
But all in all it’s pretty cool.
I do program in C++ and I was thinking of looking at the code and see how it could be used with Panda…

tim

Okay…

I didnt think of an exact copy. So you can share any of your optimization tricks, basically.

This kind of thing is planned to be supported in my terrain system, but is not done yet (its hardly started): https://github.com/Craig-Macomber/Panda3D-Terrain-System

Its mostly a matter of generating/loading tiles of mesh information, and flattening tiles of meshes at different LODs, and transitioning between LODs.

The problem here is, flattening is a one way operation, correct?

Ive put some base code for this we can work from.
The thing is I havent actually posted any opensource project before for others to be able to download/ modify. Where would you suggest me to host the project?

You can always host it at panda3dprojects.com/ .

I havent gotten an email. I think its about a month now. The problem is I changed my email and Im thinking the confirmation wasnt resend to the new one, and the old one doesnt exist any more.

I’m sure I approved it. I’ll resend the information in PM.

You should log in to your p3dp account and change your e-mail address, though.

Thanks.

Okay, back on topic. Right now for positioning the trees Im thinking of using an image. I couldnt find any info about this on the web, so if anyone has any tips/suggestions, please post it here.
Right now Im thinking of something lik this: basically Red, Blue and Green pixels mark trees on the vegetation map. The value of each determines the size of the tree. Thus there can be 3 types of trees. Yep, not very smart.

You have four channels; (assuming you don’t use 16-bits images) you have 4294967296 possibilities per pixel. They can surely be used more efficiently than that.

In your approach, there can be multiple trees of different types per pixel. Let’s assume that that’s impossible - there cannot be two trees at the same location.

With that in mind, you could do something like this: have the Red channel represent the type of the tree, and have the Green channel represent the size of the tree. Blue could be the rotation, and Alpha perhaps a colour tint or position randomisation so.

This would allow for 256 types of trees. That’s a lot better than 3. :wink:

Cool.
maybe I should make a Blender3d script which will export a png from the scene.
I think it would give more control than making one in a image editor.

Okay, another thing, a detail map is just a texture which is applied on top of the original terrain texture? But wont simply tiling a small detail texture over a huge terrain be a preformance issue? Or is there some other way of doing it?

EDIT: btw, anyone know how to convert Ogre .mesh files to something usable?
Wont look good without those trees

Not an issue. The texture sampling time does not depend on texture scale (except for a bit of cache performance). Having a highly tiled texture adds a multiply to the UV before sampling, and thats it. Sampling is done per pixel on screen, not per pixel on the texture. Adding a detail texture does add one more texture sample per pixel per frame, but thats not too bad.

OK then.
I still cant find a way to convert the .meshes to something else. What should I do?

Hi

About converting Ogre mesh files to egg.
There is a addon for blender called “blenderimport” located in the ogre3d web site addons page:

http://www.ogre3d.org/developers/addons

This adds an Ogre import to the list of importers in the Blender import drop down menu.

Then you can use the Chicken addon to export the egg file.

http://chicken-export.sourceforge.net/

I’ve used it on several .mesh files; I use to play with Ogre3d some months ago before I got started on Panda3d…

tim

Yeah Ive read about it, but that site sucks. The page you linked just has the description of that importer. Theres no link, which is weird, Ive also found this page: ogre3d.org/tikiwiki/BlenderI … ture=Tools but again I dont see any download

And the svn link is dead: ogreaddons.svn.sourceforge.net/v … _import.py

:unamused:

try this
it worked for me:

https://ogreaddons.svn.sourceforge.net/svnroot/ogreaddons/trunk/blenderimport/

it’s on the site under the title:
How to obtain the add-ons
and it’s really small print, for what ever reason ???