Problem with compiling p3d, concerns about CPU usage

I just started learning to use Panda3D, after some time with JME3 (I didn’t want to use Java anymore).

After following the tutorial in the manual, I noticed while running the .py file that a simple panda walking in a small scenery was using about half my CPU. Is that normal ?

I wanted to check if I had this problem with the samples… The sample “naith_alpha1b.p3d” took 70% of my CPU with the most simple level ! Same with the featured ones like Fireflies… Up to 80%.

I tried to convert a .py file I made following the tutorial, with the instructions on panda3d.org/manual/index.php/Using_packp3d
and I got this error :
PackageINfo(warning): after uncompressing, panda3d.cmu_1.9.win_i386.mf still incorrect
Traceback :
File “C:\buildslave\rtdist-windows-i386\build\built\direct\p3d\Apprunner.py” line 842, in addPackageInfo
OSError: Couldn’t download panda3d

I am certain that I downloaded and installed both the Panda3d runtime and SDK.

Then I wanted to check if compiling Naith (as it’s already a p3d) would solve that massive CPU usage. I followed this guide :
panda3d.org/manual/index.ph … _installer
and I kept getting :
Sandard Error : Package panda3D cmu1.7 for win_i386 not known on runtime.panda3D.org
Even though it is there : runtime.panda3d.org/panda3d/cmu_1.7/win32/
And I even have files in
C:\Users\UserName\AppData\Local\Panda3D\hosts\runtime.panda3d.org_96a0ec538744def6\panda3d\cmu_1.7 !

What should I do ?

Hi, welcome to Panda3D! :slight_smile:

Panda uses up all your CPU because it will simply run as fast as it can. Any CPU power not used is wasted, after all, and a gamer typically wants to use all the performance at their disposal.

If you want to tell Panda to use less of your CPU, you can do this by simply adding a sleep() function to yield for a millisecond or so to a task that runs every frame. You can also do this by setting “client-sleep 0.001” in Config.prc. Another thing you could do is enable vsync or limit the FPS in some other way.

I’ll check the naith p3d to see what could be causing the issue, although 1.7 is a very old version of Panda3D.

I have no issues running the naith p3d for myself on Windows. Strange! Which version of the Panda3D Runtime are you using? Are you behind a proxy server, perchance?

Oh, wait, you are only getting the issue when you use pdeploy with the naith p3d? I’m not too surprised that it doesn’t work, since the naith .p3d was made with a very old version of Panda.

In any case, the use of pdeploy would not affect CPU usage: it merely uses as much CPU as it can. It’s not an inherent performance problem in the application. Use the suggestions in my previous forum post to tell Panda to leave more CPU for other applications.

Also see this:

Thanks a lot, I’m not worried that Panda3D would be a bad choice of engine anymore. Now I just have to make it work !

I still have a little problem running p3d files I make, even though the main.py runs perfectly. I turned the sample code on panda3d.org/manual/index.ph … _the_Panda into a .p3d file, but when I try to run it, I get this error (I am on Windows 7) :
:loader(error): Couldn’t load file models/environment.bam: not found on model path (currently “/c/Users/UserName/AppData/Local/Panda3D/start”>

That start folder is empty, and I don’t even want to use it.
As you can see in the code, it’s using relative paths with no .egg extension, the problem is that it’s looking in the wrong folder.
How could I make it try to use the model files I copied in the myapp folder that also contains my main.py file ? Or failing that, the folder where those default models are stored, and successfully found when I run the main.py (C:\Panda3D-1.9.1\models) ? (However if I don’t put the models in the myapp folder, they don’t seem to be included in the .p3d. Obviously I’d like everything needed to be in the .p3d.)

The manual page about the configuration file (panda3d.org/manual/index.ph … ation_File) hasn’t been very helpful.

Thinking it would work a bit like JME3 (registering paths to a file Locator to look for assets in several folders +path given as a string, including the project folder), I created a “models” folder Inside the “myapp” folder where the main.py is (and where I had copied the models).

I managed to create a .p3D, however when I run it I only see a white screen (I do not get any error message in the console). And if I move the default models folder inside the Panda3D folder, running the .py gives the same results so I guess I was wrong about how the assets are found. Still, creating that models folder somehow allowed me to build a non-functionning .p3d file without getting an error message. I would like to know how creating that folder changed anything. It probably only affected the packaging of the P3d file, and when running the p3d it’s still looking in the wrong place (still, no “file not found” error message ?!). if I don’t put that models folder, the p3d closes immediately after launching.

I think I’m even more confused than before.

You need to include the models in order for it to find them. This means copying not just the environment.egg.pz model to a “models” directory in your game folder, but also any textures that it uses. Copying the whole “models” directory into your game folder should certainly do the trick, to be absolutely sure.

The white screen sounds to me like it couldn’t find the textures. But yes, it should give a “file not found” error either at packp3d time or at time of running it, so that’s a bit strange.

However, there’s an easier way. Since this is part of the default set of models, you may use “-r models” on the packp3d command-line. This will make packp3d automatically include the default set of models.
One caveat is that you need to then remove the “models/” prefix from the path when loading them in the Python file which is needed for packp3d to find them in the default models set.

I managed to make it all work just before I saw your message, but you explained a few things better than I had :smiley:

I had read in the manual that textures links Inside the .egg were automatically taken care of when making a .p3d. I still copied that maps folder to be safe, and it worked. panda3d.org/manual/index.php/Using_packp3d

At first I thought it has something to do with the ModelPath (interesting stuff on prc model directories, looks like you helpa lot here) . I’m still not quite sure what had happened, but satisfied enough to sleep. Finally.

so -r moves copies the default models to the “root” of the p3d file ?

Anyway, thanks a lot for your answers, in other threads too ;D

Great, glad you got it to work. :slight_smile:

Not quite; it indicates that the .p3d wants to use one of the optional packages that are provided.
panda3d.org/manual/index.ph … g_packages
These are provided as separate packages so that a deployed program will not include optional Panda components that it doesn’t need.