Hi!
I have written an app which shows some roller conveyors (up to hundred of them) which can be different size, color, etc,… To paint a conveyor I load a simple cube model and a cylinder model which are copied several times. One conveyor is drawn with 4 cubes and around 10 cylinders.
This works very well, it is very easy to implement with Panda3D, and actually it uses not much CPU. But I have seen that when I add lots of conveyors and I move the camera to a spot where several (maybe 20) conveyors are shown in the screen, the frame rate starts to slow down and it can go down to 5fps when some hundred of conveyors are shown, but the CPU use is still quite low. No lighting, shaders,…
I am running in a DELL laptop:
i5 CPU
M560 2.67GHZ
3,42 GB of RAM
Intel HD Graphics
I wonder if I am doing something wrong, or I can do some cloning of models instead of loading, or is simply the graphic card which can not handle so many geometries.
I paste a code example to see if someone can help me…
Thanks a lot!
from panda3d.core import Vec4,LineSegs
from direct.showbase.ShowBase import ShowBase
class PandaWorld(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.setFrameRateMeter(True)
#grid
GridMax = 50
segs = LineSegs( )
segs.setThickness( 1.0 )
segs.setColor( Vec4(1,1,1,1) )
for i in range(-GridMax,GridMax,1):
segs.moveTo(i,-GridMax,0)
segs.drawTo(i,+GridMax,0)
segs.moveTo(-GridMax,i,0)
segs.drawTo(+GridMax,i,0)
render.attachNewNode(segs.create())
# Show conveyors
for i in range(20):
for k in range(20):
self.createConveyor().setPos(i*2,k*2,0)
def createConveyor(self, length=2.0, width=0.8, height=0.5, radius=0.05, color=[1.0,0.0,0.0,1.0]):
node = render.attachNewNode("conveyor")
# Structure
for i in range(2):
side = self.loader.loadModel("cube")
side.setScale(length, 0.05, radius*2)
side.setColor(color[0],color[1],color[2],color[3])
side.reparentTo(node)
side.setPos(0,-width/2-0.03+i*(width+0.06),height/2-radius)
for j in range(2):
foot = self.loader.loadModel("cube")
foot.setScale(0.1, 0.05, height-0.1)
foot.setColor(color[0],color[1],color[2],color[3])
foot.reparentTo(node)
foot.setPos(-length/2+0.1+j*(length-0.2),-width/2-0.03+i*(width+0.06),-0.05)
# Cylinders
offset = 0.025
num_cyl = int(length/(radius*2)/2)
dist = (length-offset*2-radius*2)/(num_cyl-1)
for i in range(num_cyl):
cyl = self.loader.loadModel("cylinder")
cyl.setScale(width, radius*2, radius*2)
cyl.setColor(0.2,0.2,0.2,1.0)
cyl.reparentTo(node)
cyl.setPos(offset-length/2+radius+i*dist,0,height/2-radius)
cyl.setHpr(90,0,0)
# Return nodepath
return node
app = PandaWorld()
app.run()