Jungle engine

I have been working on a litte engine creating a nearly infinite jungle. Most things are split up in classes, so it may be reused for other projects. It also has some panda’s walking around :slight_smile:

I have also integrated some other code-snipplets found on the forums, as well as some models from the model-downloads.

The sky renderer is a modified version of the nature-demo shader.
I have also integrated my panda-console (F1).
The plants fade-in is also done using a suggestion on the forums.

Forward Left-Mouse
Reverse Right-Mouse
Strafe-Left A
Strafe-Right D
Escape Exit
(More is defined in the cameraControl.py : keybindings)

Thanks to ThomasEgi for helping me optimizing the rendering-performance. I hope i integrated his suggestions correctly.

look below for actual downloads…

The code is not really cleaned up yet. However maybe somebody can use a part of this little project or has some suggestion how to improve things.

Very cool! Even has a day and night cycle!
Unfortunately I only get 5-8 fps. Lowering the number of tiles speeds things up, but it doesn’t look as pretty as a full jungle :smiley: .

Nice ambiance :slight_smile: !

i allowed myself to make a tiny colorchange on the palm texture… looks less like a tree from a beach and more like something tropical now :slight_smile:
just copy over the old file:

still very colorful overall… and with the other plants. guess tuning the texture-tones might have some quite nice results.

@hypnos… dont ask me why… your code is running at 8fps on my machine… but the code i wrote while i catted with you in the irc channel runs with 40, same trees same number same visual. … tried changeing your code but i somehow cant make it work.thought its almost identical with the other one.

Hello again.

I have updated the source and the data(thanks ThomasEgi) and uploaded it again. I have found an error in the flattenStrong (in the conversion from .egg to .bam) so it might run faster now.

I have also changed some of the controls, as i integrated some object handling stuff. there is a white cube at the startpoint which can be picked up. However this only works in bound-mouse mode (press space to toggle)

WASD Movement
Mouse View
Left-Click Pickup
Left-Release Drop
Space bound-mouse / free-mouse toggle

If you have low FPS try out changing TILES and PLANTMAPSIZE in plants.py. TILES is the number of plantsquares built around the player, PLANTMAPSIZE is the size of each tile. Having a big PLANTMAPSIZE and small number of TILES improves FPS when you stand still. On the other side it slows down when you move around. The viewing distance is about TILES * PLANTMAPSIZE.
Usual values for these variables are:
TILES from 1 to 8
PLANTMAPSIZE from 10 to 50

If anybody wants to integrate new plants into the scene:
In plants.py add a new entry to the dictionary plantmodelDict.
the key is a random name, the items is a list of the following entries:

  • Number of occurances ( this is relative to the overall number of occurances of all plants )
  • path to the model (should be an .egg file, they get converted to .bam’s automatically)
  • minScale (minimal scale of the model in the scene)
  • maxScale (maximal scale of the model in the scene)
  • destroySize is currently not in use, just use some number.

New download links:
look below for actual downloads…

uploaded new data version, it was missing a the box.egg

Okay, I feel dumb. But how do you run the program? I’ve looked at each code file and they all seem to only define classes/functions. Which one do I run?


By they way, this looks very cool!


You run:
python main.py

I still get 4-12 fps with the latest version, but as you say, I can lower the number of tiles.

Lauren, thanks for the hint. I had extracted the source to my (crowded) desktop and didn’t see ‘main.py’ (I looked only in the ‘source’ folder).

Also, for anyone else who may be reading, you need to run the Panda version of Python, so it’s (note the extra ‘p’ in ‘ppython’):

ppython main.py

Last but not least – very cool app! Hypnos, thanks for sharing your work.


I have updated the files on the server again. A lot of changes were done on the plant-generation, which possibly make it faster, at least the forest looks denser now.

There is also a new speciality, however it’s only active for the smallest plants. It generates special areas (using the PerlinNoise2) function where some plants grow and other’s dont. It would be possible to have forest-free areas (however fine tuning that takes quite a while so i havent got up to this).

see below for newer versions

the next thing im thinking about is using some level-of-detail to have better graphics.

Wait… Panda has a Perlin noise function? Or you have written one? And you can use it to place different kinds of plants? I could really use that. I will look at your code, thanks.

Panda has one integrated. However it’s not fast enougth to create textures in python. (probably python isnt fast enough)

this might help you if you have PIL installed:

from pandac.PandaModules import Vec2, Vec3
from pandac.PandaModules import PerlinNoise, PerlinNoise2, PerlinNoise3

from PIL import Image
import math

imgSize = (256,256)
img = Image.new('RGBA', imgSize)

noise1 = PerlinNoise2()
noise1.setScale( 2.0 )
noise2 = PerlinNoise2()
noise2.setScale( 5.0 )
noise3 = PerlinNoise2()
noise3.setScale( 0.25 )
noise4 = PerlinNoise2()
noise4.setScale( 0.125 )

for x in xrange(imgSize[0]):
  for y in xrange(imgSize[1]):
    pos = Vec2(1.0/32*x, 1.0/32*y)
    r = int(32)
    g = int(128 + noise1(pos)*16 + noise2(pos)*16 + noise3(pos)*32 + noise4(pos)*16)
    b = int(16)
    img.putpixel((x,y), (r,g,b))


Well another update:

Have a look into it. Lot of things changed, code-vise and visible.

for current downloads see the next page

I have tried your latest version. Very cool to see the open spaces in the forrest! The frame rate is also a bit better. Standing still I now get 20 fps. When I move and new terrain has to be generated it is ~8 fps and can go down to 4fps.

Hypnos, all I can say is: Awesome work!
Vegetation looks almost better than FarCry. :slight_smile:
Just a pity of the poor framerate.

Should i modify some code to get it run? i’ve downloaded the 2 zip file and extracted to 2 folders, in the source folder i typed ppython main.py and see a window but disappeare immediately then i copied contents from data folder to source folder, the result just the same, here is the console output:

D:\PandaMystuff\tda-source-v0.7.1>ppython main.py
Warning: DirectNotify: category ‘Interval’ already exists
DirectStart: Starting the game.
Known pipe types:
(3 aux display modules not yet loaded.)
:util(warning): Adjusting global clock’s real time by 0.521589 seconds.
I: pandaInteractiveConsole.init
I: - GUI enabled
I: - Console enabled
D: myInteractiveConsole.init
setting up collision check
:audio(error): createSound(sounds/walking.mp3): File not found.
:gobj(error): Texture::read() - couldn’t read: data/textures/ground/mud-tile.png

:gobj(error): Unable to find texture “data/textures/ground/mud-tile.png” on text
ure_path .;/c/Panda3D-1.3.2/etc/…;/c/Panda3D-1.3.2/etc/…/models or model_path
D:\PandaMystuff\tda-source-v0.7.1\source\heightfield.py:52: DeprecationWarning:
integer argument expected, got float
self.mHeightFieldTesselator.setFocalPoint( posX, posY )
Terrain mesh is 0 triangles.
Traceback (most recent call last):
File “main.py”, line 57, in ?
a = the_days_after()
File “main.py”, line 30, in init
self.heightfield = heightfieldClass( self.camCon.globalPosCameraNode )
File “D:\PandaMystuff\tda-source-v0.7.1\source\heightfield.py”, line 9, in i

File “D:\PandaMystuff\tda-source-v0.7.1\source\heightfield.py”, line 43, in se
File “D:\PandaMystuff\tda-source-v0.7.1\source\heightfield.py”, line 62, in up
self.mHeightFieldNode.setTexture( self.tex0, 1 )
TypeError: Arguments must match one of:
set_texture(NodePath * this, Texture * tex)
set_texture(NodePath * this, TextureStage * stage, Texture * tex)
set_texture(NodePath * this, Texture * tex, int priority)
set_texture(NodePath * this, TextureStage * stage, Texture * tex, int priority)

i am using the Panda3D-1.3.2 under windows xp.

you have to move the whole folder “data” into the “source” folder (so there is a data folder in the source folder)

you see that because of the errors:
Unable to find texture “data/textures/ground/mud-tile.png”

it works, thanks Hypnos. i saw the beautiful jungle just as in Far Cry. awesome indeed!!!

Yes it looks very nice,nice moving sky and overall decent plants and textures, but atm it aint no farcry yet…maybe it approaches farcry1 I dont know as I dont have that game, but farcry2 well maybe not so much…but yeah its def. one of the nicer games using panda for which we are all grateful

I could ponder some improvements for future consideration:

better LOD management maybe, as I have a latest graphics card ( ok not the BEST but a VERY good one at that: 7600 GT nvidia card and its 256mb and pciE ) and im only getting on average about 35 FPS…considering the textures arent’ very high res at all that is abysmal; camera rotates rather slowly which is frustrating though walking in the forest is very smooth; to get fullscreen one has to click LMB then maximize, then LBM again, so maybe a little hint at iniital st artup could make that known ,- that or a menu with options later on in development; I also think while the random placement is nice, that it would be great to more open areas which would give some break on the FPS :wink:

thats about it that I can think of offhand from trying it just now…good work indeed and keep it up :wink:



Thanks for the review :slight_smile:

But that wasnt really considered as a game. It was basically a graphic test how a jungle might look like and what i could archive with panda in a short time.

In the meantime i have been working on some other projects which are more advanced.

One thing that ppl might be interested in was a project for the museum of Art in Zuerich (Switzerland), called Arttransforming. Where we modelled a room of the museum in 3d, transforming the Pictures of the Artists into Rooms, where visitors of the museum could virtuall walk in. (using panda3d as engine)

Another project i created for a 3 weeks course at school was Global Soccer, a soccer game (2 player splitscreen) made in Panda3d, played on a globe.

I have 2 other projects i am still working on, improving the visuals is the mayor task to be done.

and a screenshot of the editor:

All of these projects are currently open-source. The sourcecode can be downloaded under the links or can be found under http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/

Most of these projects were made in courses at the Zürcher Hochschule der Künste (www.zhdk.ch) where i’m currently studying Gamedesign.

If you have suggestions, please leave a message here.

Thats beautiful stuff. Very impressed. Thanks for sharing it with us!