Virtual File system and p3d files

hi buddies

I´m try to use virtualfilesystem and p3d files. I configure my vfs to mount a folder in my server.

from direct.directbase import DirectStart
from pandac.PandaModules import *
from direct.task.Task import Task

from sys import exit

vfs=VirtualFileSystem.getGlobalPtr()
vfs.mount(VirtualFileMountHTTP("http://localhost/sistemas/pandaWEb/modelos/"), "/modelos", 0)
getModelPath().appendDirectory("/modelos")

katana=loader.loadModel("/modelos/katana/katana")
katana.reparentTo(render)

pln=render.attachNewNode(PointLight("plight"))
pln.node().setColor(Vec4(4, 4, 4, 1))
render.setLight(pln)

render.setShaderAuto()

#base.disableMouse()
base.camera.setPos(0,-20, 0)
base.setFrameRateMeter(True)
base.setBackgroundColor(.133,.133,.333,1)
base.accept("escape", exit)
base.run()

It´s runs fine in a .py code. But when i change this file in .p3d …


  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Messenger.py", line 410, in _
_dispatch
  File "C:\panda3d-1.7.0\built_cmu\direct\p3d\AppRunner.py", line 493, in __star
tIfReady
  File "VFSImporter", line 153, in load_module
  File "C:\Users\master\Desktop\projects_pandaweb\game02\katana_web.py", line 11
, in <module>
    katana=loader.loadModel("/modelos/katana/katana")
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Loader.py", line 169, in load
Model
IOError: Could not load model file(s): ['/modelos/katana/katana']

Who the hell? :confused:
And yes … my server is running :wink:

No ideas?

Try loading “/modelos/katana/katana.egg” instead of “/modelos/katana/katana”.

The problem is that in a p3d file, eggs are automatically converted to bams, so the default-model-extension is change from .egg to .bam. This means you can use the extensionless filename to load an egg file in your production environment, or a bam file in the p3d environment.

But when you load from a website like this, it is still an egg file, of course, so you have to name it explicitly.

David

Hi david

Didn´t work :frowning:
I change katana.egg to katana.bam and nothing too.
I try :

vfs=VirtualFileSystem.getGlobalPtr()
vfs.mount(VirtualFileMountHTTP("http://localhost/sistemas/pandaWEb/modelos/"), "/modelos", 0)
getModelPath().appendDirectory(".")

print "*"*10
print vfs.ls(Filename("/modelos"))
print "-"*10
print vfs.exists(Filename("/modelos/katana/katana.bam") )
print "*"*10

my output is

**********
/modelos
None
**********
1
**********

I didn´t understood this. The folder “/modelos” has nothing … but “/modelos/katana/katana.bam” exists … dizzy … :open_mouth:

HTTP has no convention for listing the contents of a folder, so that’s why ls() doesn’t work on an HTTP-mounted folder. Still, the bam file exists, so you ought to be able to load it from that path. Does that not work?

David

Saddly not :frowning:

My complete code:


from direct.directbase import DirectStart
from pandac.PandaModules import *
from direct.task.Task import Task

from sys import exit

vfs=VirtualFileSystem.getGlobalPtr()
vfs.mount(VirtualFileMountHTTP("http://localhost/sistemas/pandaWEb/modelos/"), "/modelos", 0)
getModelPath().appendDirectory(".")

print "*"*10
print vfs.ls(Filename("/modelos/katana/"))
print "-"*10
print vfs.exists(Filename("/modelos/katana/katana.bam") )
print "*"*10

katana=loader.loadModel("/modelos/katana/katana")
katana.reparentTo(render)

pln=render.attachNewNode(PointLight("plight"))
pln.node().setColor(Vec4(4, 4, 4, 1))
render.setLight(pln)

render.setShaderAuto()


#base.disableMouse()
base.camera.setPos(0,-20, 0)
base.setFrameRateMeter(True)
base.setBackgroundColor(.133,.133,.333,1)
base.accept("escape", exit)
base.run()

My complete output:

DirectStart: Starting the game.
:display: loading display module: libpandagl.dll
:display: loading display module: libpandadx9.dll
:display: loading display module: libpandadx8.dll
:display: loading display module: libtinydisplay.dll
Known pipe types:
  wglGraphicsPipe
  wdxGraphicsPipe9
  wdxGraphicsPipe8
  TinyWinGraphicsPipe
  TinyOffscreenGraphicsPipe
(all display modules loaded.)
:display:windisplay: OS version: 6.1.2.7600
:display:windisplay:
:display:windisplay: max Mhz 2664000000, current Mhz 2664000000
:ShowBase: Default graphics pipe is wglGraphicsPipe (OpenGL).
:display: Unable to set window properties: !undecorated
:ShowBase: Successfully opened window of type wglGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: __dev__ == 0
**********
/modelos/katana
None
----------
1
**********
:loader: Reading /modelos/katana/katana.bam
:util:bam(error): Bam file is version 6.24.
:util:bam(error): This program can only load version 6.14 through 6.22 bams.
:loader(error): Couldn't load file /modelos/katana/katana.bam: invalid.
Traceback (most recent call last):
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Messenger.py", line 352, in _
_taskChainDispatch
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Messenger.py", line 410, in _
_dispatch
  File "C:\panda3d-1.7.0\built_cmu\direct\p3d\AppRunner.py", line 493, in __star
tIfReady
  File "VFSImporter", line 153, in load_module
  File "C:\Users\master\Desktop\projects_pandaweb\game02\katana_web.py", line 17
, in <module>
    katana=loader.loadModel("/modelos/katana/katana")
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Loader.py", line 169, in load
Model
IOError: Could not load model file(s): ['/modelos/katana/katana']
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
  File "C:\panda3d-1.7.0\built_cmu\direct\p3d\AppRunner.py", line 411, in run
  File "C:\panda3d-1.7.0\built_cmu\direct\task\Task.py", line 496, in run
  File "C:\panda3d-1.7.0\built_cmu\direct\task\Task.py", line 454, in step
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Messenger.py", line 352, in _
_taskChainDispatch
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Messenger.py", line 410, in _
_dispatch
  File "C:\panda3d-1.7.0\built_cmu\direct\p3d\AppRunner.py", line 493, in __star
tIfReady
  File "VFSImporter", line 153, in load_module
  File "C:\Users\master\Desktop\projects_pandaweb\game02\katana_web.py", line 17
, in <module>
    katana=loader.loadModel("/modelos/katana/katana")
  File "C:\panda3d-1.7.0\built_cmu\direct\showbase\Loader.py", line 169, in load
Model
IOError: Could not load model file(s): ['/modelos/katana/katana']
:TaskManager: TaskManager.destroy()
:display: Closing wglGraphicsWindow
Failure on startup.

the folder localhost/sistema/pandaWEb/modelos/katana contents :

katana.bam,
color.png,
normal.png
and height.png

:unamused:

Thanx david

Do you see these error messages:

:util:bam(error): Bam file is version 6.24.
:util:bam(error): This program can only load version 6.14 through 6.22 bams. 

This tells you that you have generated your bam file with a version of Panda that is newer than the 1.7.0 version that is part of the p3d runtime.

Remember, the bam file format is version-dependent. If you are going to put bam files on your webserver, you have to generate them with the same version of Panda3D that will be running them, and right now the p3d runtime is strictly 1.7.0.

David

Yeah … you´re right :smiley:
Thre´s planned some changes in webplugin for next version of Panda3d?
Thanx again … and again

Yes, the next release of Panda3D will also update the plugin version.

David