view 1000 times a same object(optimization)

Hello,
is there a way to optimize the display of 1000 same object (1000 ralph egg for example) ?

for load and anim object i use this :

for i in range(0, 1000):
   object.reparentTo(render)
   object.loop("walk")

Hardware instancing + hardware skinning (animation), but you need to write your own shader for that.

Hi-

You can see [url]Hardware Instancing GLSL snippet] for a snippet for static objects using HW instancing and culling/lighting.

I plan to provide a snippet for animated models as well i.e.using HW instancing and HW skinning as suggested by wezu.

thanks for your answer, i found other solution here :
panda3d.org/manual/index.php/Instancing
see “Advanced Instancing”

Was is difference between hardware instancing ?
i have a problem, i have grey window, but my models not appear what ?

from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import loadPrcFileData
from direct.actor.Actor import Actor
from direct.showbase.DirectObject import DirectObject
from direct.interval.IntervalGlobal import Sequence
from panda3d.core import NodePath, Vec4

class RoamingRalphDemo(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        dancer = Actor("./models/ralph/ralph.egg.pz", {"kick":"./models/ralph/ralph-run.egg.pz"})
        dancer.loop("kick")
        dancer.setPos(0,0,0)
        chorusline = NodePath('chorusline')
        for i in range(50):
          placeholder = chorusline.attachNewNode("Dancer-Placeholder")
          placeholder.setPos(i*5,0,0)
          dancer.instanceTo(placeholder)
demo = RoamingRalphDemo()
demo.run()

i see your link, but i can not to load TestInterrogate, it’s possible to use this without c++ ?

Regarding :

“Advanced instancing” as described in the manual is a way to structure your scene graph to decrease the number of CPU calculation for the animation. This method is only suitable for animated model and doesn’t leverage on the HW instancing capability of the GPU,since everything is still done as the CPU level. This means that with this method, your CPU still sends 150x per frame your model to the GPU. See “Instancing: an Important Caveat” of the manual page.

On the other side, HW instancing allows to send the model only once to the GPU,which is far more effective.Unfortunately, the P3D standard shader does not manage HW instancing (maybe in 1.10 :slight_smile: ?) and so you need to write a specific shader for that.

Also :

Your code doesn’t include the last part of what is described in the manual page. In your code, your model / chorus line is never reparented to render. That is why you can’t see anything.
So add these lines just below the dancer.instanceTo(placeholder) line.

    for i in range(3):
                placeholder = render.attachNewNode("Line-Placeholder")
                placeholder.setPos(0,i*10,0)
                chorusline.instanceTo(placeholder)

I also advise to use a “self.dancer” variable everywhere in the code instead of only “dancer”. Without the “self”, the animation was not starting on my computer.

Finally:

Strange. I downloaded my sample to check and everything is running fine on my computer.
You don’t need to have a C++ compiler on your computer to make it work. The C++ code has been wrapped up to directly be accessible through Python. In addition, by default, the code is using the Python culling code (you can switch to the C++ through F1).

Thank you for these explanations

i have this error for your program:

  File "main.py", line 17, in <module>
    from TestInterrogate import *
ImportError: DLL load failed: The specified module could not be found.

I use panda3D with python 3.4 64bits on windows 10 64bits
i have 2015 32 and 64bits MS C++ redistributable

You are welcome.

rdb would have more insights on this but I suspect that this is caused because I used 1.9.2 x64 to produce the TestInterrogate module. As you use Python 3.4 whereas P3D 1.9.2 uses Python 2.7, this may prevent your environment to load the .pyd file i.e. the TestInterrogate file.

To quickly make the snippet work, you can just comment the line “from TestInterrogate import *”. But you should not press ‘F1’ because it will not find the TestInterrogate .pyd file. Since the culling part is done in Python, the code will not be as fast as with C++.

I don’t have tested this (so no guaranty!), but you can try to produce a new TestInterrogate.pyd file by using the tobspr’s Module Builder tool - see [url]Panda Module Builder] (explanations on how to use it are provided there),since I have provided the C++ code. Once you have regenerated the .pyd file, you can try the snippet again.