If i unmark the ‘load font’ or ‘open file’ the packp3d file wont run anymore.(Runs fine as simple py file with load font and open file)
from pandac.PandaModules import TextNode
#tahoma = loader.loadFont('tahoma.egg')
info='just some info'
Next thing i found:
this line runs fine as py but crashes in p3d
Heres the function the line is in:
for i in range(lnr):
while not gotit:
print 'set pos:',x-x1,y-y1
print 'get pos:',x,y
for x in range(x1,x1+size):
for y in range(y1,y1+size):
tahoma = loader.loadFont('tahoma.egg')
Replace this with:
tahoma = loader.loadFont('tahoma')
This is necessary because egg files are implicitly converted to bam files inside the p3d file, so you can’t use the .egg extension to name them. But if you omit the extension, the default is .egg when you run interactively, but .bam when you run in the p3d file.
Replace this with:
file=open(base.appRunner.multifileRoot + '/info.txt', 'r')
This is necessary because when you run the p3d file, your current directory is not the same place as the root directory of your p3d file. Any files that you load directly like this have to be referenced from their correct path. (I don’t think it’s a good idea to make the current directory be the same as the p3d file, because what would happen then if you tried to write to a file in the current directory?)
I don’t see a problem with this, assuming that img has been properly loaded with an image of an appropriate size. Since you don’t do any bounds checking, though, it’s hard to be sure. And in the fully-optimized mode in which a p3d file runs, an exceeded bounds in the image will result in a hard crash, not a Python exception.
In what way does this line crash?
I tired to pinpoint it more preciely
col=img.getXelA(0,0)#this line is enough to make it crash
And i found the solution:
and it works
p3d does not like loading stuff directly as PNMImage
It’s the same problem: your current directory is not the root of the p3d file, so you just have to replace this:
self.path = base.appRunner.multifileRoot + '/gfxdata/textures/'
It works when you use loader.loadTexture(), though, because the plugin adds the multifileRoot to the model-path, so loadTexture() can find it there. But PNMImage.read() doesn’t do any auto-searching.
Thank you drwr.
One more tiny issue:
this does not affect nodes anymore
I use it to sort the order of gui grabbable objs
by putting config.prc file in the same dir as main.py i cant still affect the window size and i cant really make sense of the sentence in the manual:
‘Any prc files within the toplevel of the application folder will be loaded automatically at runtime, as if $PANDA_PRC_DIR were set to your application folder name; you don’t need to load them explicitly in your Python code’
Ah, this is indeed a bug: we have not defined gui-popup in the plugin environment. I will add that config setting.
The default window size in the plugin environment is controlled by the environment itself. If you embed in a web page, it’s controlled by the web page. If you run via the panda3d executable, it’s passed in by the -s parameter to panda3d. The application is free to ignore this size, but you have to do it with a dynamically loaded config file, or by explicitly requesting a particular size when you call openWindow().
Some people like to write code to load a prc file with an explicit call to loadPrcFile(). You generally don’t need to do that in the plugin environment (unless you want to override something like the window settings).
Does it mean it will work in a new release of the runtime? or i still need to modify my code or some conf somehow?
Some more problems:
I red the manual but cant make sense of it.
panda3d.org/manual/index.php/P … g_settings
Currently if my p3d crashes it just closes and i cant see any log or console info.
'log_basename Specifies the log file within Panda3D/log to write to for this app ’
There are no log folder no start folder no prc folder in the Panda3D directory. Must i create them manually?
And i mean the default c:\programfiles…\Panda3D
Currently im creating the p3d file with this command line:
panda3d packp3d.p3d -o myopia.p3d -d Myopia -r ode -m client.py (takes approx 2 sec to build so this is nice)
what should i add so it would create the log and load custom prc settings?:
-c log_basename=mylog -c prc_name=myprc
where mylog and myprc are manually created folders under Panda3D/log folder?
File pathing structure problems:
I would like the game structure to be:
I would like the user to be able to create content and upload it so i need the separate folders where users can put their language files(txt format) flag images(png) and custom model and textures.
But the p3d file does not create these folders anymore? or does it create them inside it self?
Cos it saves the changes and restarting the application loads correct data(at least for the character).
i could add a browse method yet i dont see the need for it, as what can be uploaded has very strict rules anyways.
God does not punish the stupid, at least not that often
It will just work in the next release. But in the meantime, you can work around it yourself by adding the line:
cull-bin gui-popup 60 unsorted
to your app’s prc file (that is, a .prc file in the app’s root directory).
Ah, my apologies. You are looking in the wrong place for the log info. The Panda3D directory it is referring to is under %LocalAppData% directory, which is c:\Documents and Settings<your name>\Local Settings\Application Data\Panda3D on Windows XP, or c:\Users<your name>\AppData\Local on Vista or Win7. In this folder you will find all of your log output, and also the directory in which you can install your personal prc files. (Note that these prc files are different from the application’s built-in prc file. This is where the end-user will install personal configuration options, not where the application will configure itself. The application configures its own defaults by putting a prc file in the root of its own p3d file.)
You will also find local files created by your app in the Panda3D/start folder. So this is where your app might store its local data store for the user to store content.
Thank you David, all good but the .prc and bin
I run my app as py file, all good.
I copy the config.prc to Myapp folder, same folder as my main.py(client.py in my case is). I add the line to config.prc: cull-bin gui-popup 60 unsorted
I build the p3d with this line:
panda3d packp3d.p3d -o Myopia.p3d -d Myopia -r ode -m client.py
I start the p3d file, gui obj dont pop up.
Actually no changes in the config.prc(the one in the same folder as main.py)affect the p3d. I cant even make the p3d file run in full screen.
Am i putting the config.prc to the wron dir? or is there something else im missing?
Ah, my apologies. Certain config variable settings may only be defined at application startup; if they are read later, they have no effect. As it happens, cull-bin is one of those variables. Since the p3d file is read after application startup, it doesn’t help to define cull-bin in the application’s prc file; you have to define it at runtime instead with code like this:
cbMgr = CullBinManager.getGlobalPtr()
cbMgr.addBin('gui-popup', cbMgr.BTUnsorted, 60)
Similarly, you cannot set the application to fullscreen (or set its size or placement) in the app prc file, because the window mode and size is specified by the plugin code.
But most other config variables do have effect there. For instance, you can put:
in your app’s prc file, and it will enable the fps meter in the corner at startup. To prove that you have loaded your app’s prc file, you can print:
in your code; it will list the prc files it has read.
Does that really not even work with the new runtime fullscreen toggling code?
Oh, sure–you can change to fullscreen with python code. You just can’t put “fullscreen 1” in your Config.prc and expect it to be respected there.
Thank you David, got the prc and bin working.
If i run panda3d.exe on one of my machines it shows ‘Usage: lots of inf
Optionas:lots of inf’
in the console.
If i try to run panda3d.exe on my other machine it says ‘The system cannot execute the specified program.’
And the there is no panda3d folder in document and setting/user/loacal settings/app data so no logs or anything.
Both machines have winXp and panda runtime ver 9.10.
Hmm, are you sure that panda3d.exe is on your path? What happens if you double-click on a p3d file?
yes its on the path as it recognizes them as panda p3d files and displays them with correct icon.
if i double click:
Error executing program!
if i drag drop into browser:
This applications has failed to start because the application configuration is incorrect.Reinstalling the application may fix this problem.
I have tryed reinstalling but nothing changed
So it seems to me it has something to do with this specific computer.(i hope im wrong)
Can you try installing the .NET Framework 3.5?
Thank you that did the magic.
#save windowed props
It switches to fullscreen if run as py file, but as p3d it keeps the decorations, and it seems it just does wp.setSize(w,h),so not really a fullscreen.
And it does not change back to correct window size.
Am i using it wrong?
So far i have been using code from this thread:
discourse.panda3d.org/viewtopic … 5b33fc531b
And that worked fine, both as py and p3d(with p3d it does sometimes silent closes)