here a little sample that shows how worth is to use the RigidBodyCombiner object to optimize a huge amount of meshes:
# -*- coding: utf-8 -*-
"""
Rigid Body Combiner example
by: Fabius Astelix
issue: 2009-12-10
pass 'rbc' or '1' from the console to see rigid body applied or pass nothing to see how much the framerate drops without it
"""
#############################################################################
# IMPORTS
#############################################################################
#python imports
import random, sys
#panda3D imports
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import RigidBodyCombiner, NodePath, Vec3
from direct.interval.IntervalGlobal import *
#############################################################################
# GLOBALS
#############################################################################
import direct.directbase.DirectStart
base.setFrameRateMeter(True)
info=[
"Rigid Body Combiner;rigid body combiner is now APPLIED, check the framerate there ->;re-launch it from console without parameter to see\nhow slow is without RBC applied",
"NO Rigid Body Combiner;rigid body combiner is NOT APPLIED, check how low is the framerate ->;re-launch it from console with parameter '1' or '#t' to see\nhow much the framerate increases with RBC applied",
]
#========================================================================
#
#infotext setup
infotext={}
infotext['title']=OnscreenText(text = 'title', pos = (0, .92), scale = 0.08, mayChange=True, fg=(1,1,1,1), bg=(0,0,1,.7))
infotext['content']=OnscreenText(text = 'content', pos = (0, 0.84), scale = 0.05, mayChange=True, fg=(1,1,0,1), bg=(0,0,0,.5))
infotext['hint']=OnscreenText(text = 'hint', pos = (0, -0.90), scale = 0.06, mayChange=True, fg=(1,1,1,1), bg=(1,0,0,.7))
def setinfo(text):
title,content,hint=text.split(";")
infotext['title'].setText(title)
infotext['content'].setText(content)
infotext['hint'].setText(hint)
if __name__ == '__main__':
WITH_RBC=(len(sys.argv)> 1) and (sys.argv[1] in ['rbc', '1', '#t'])
setinfo(info[0 if WITH_RBC else 1])
if WITH_RBC:
rbc = RigidBodyCombiner("rbc")
rbcnp = NodePath(rbc)
rbcnp.reparentTo(render)
else:
rbcnp=base.render.attachNewNode("norbc")
for i in range(2000):
pos = Vec3(random.uniform(-100, 100),
random.uniform(-100, 100),
random.uniform(-100, 100))
f = loader.loadModel("box.egg")
f.setPos(pos)
f.reparentTo(rbcnp)
if WITH_RBC: rbc.collect()
rbcnp.setY(350)
myInterval1=rbcnp.hprInterval(30.0,Vec3(0,360,0))
myParallel=Parallel(myInterval1)
myParallel.loop()
run()