Demomaster application framework with wxpython navigator

Return to Showcase

Demomaster application framework with wxpython navigator

Postby clcheung » Sat Mar 21, 2009 6:19 am

As part of my self-learning exercise in panda and 3D application development, I build an application framework that uses wxPython with Panda3D, to allow easy manipulation of panda 3d objects through auto-generated wxPython control GUI interface.

I aim at reusing the framework and the corresponding higher level objects to simplify the development in panda3d.

For example, I can mix the ode objects, shadow manager, and the camera control object together in this sample program:
Image

I have also started to port some shader programs, like the Ocean in ogre, to panda:
Image

Since it is my learning exercise, I collect various demo programs in this forum and including them in my framework: (please let me know if you find any of the sample programs violate distribution licenses and should be removed).

Camera - Split Screen
Fog - Tunnel with a test shader
Geometry - Create various geometries
GeoMipTerrain - Yarr
GeoMipTerrain - Yarr with water
Misc - Carousel
Misc - Disco Light
Misc - Normal Mapping Demo
Misc - Splash Card and LOD
ODE - Demo 1
ODE - Demo 2
ODE - with Shadow Manager
ODE - with Shadow Manager 2
Shaders - Basic Demo
Shaders - Change Shapes
Shaders - Show Models with various effects
Shaders - Show Panda Shaders
Shadow - Shadow Manager from pro-rsoft"
Shadow - Shadow Manager from rollingt70
Texture - Skydome effect
Texture - Waterfall effect
Water - Ocean 2 from Ogre
Water - Use yarr water shader

You can download the version 0.1 from here:
http://code.google.com/p/pandademomaster/downloads/list

It is only tested on my Windows XP machine with NVIDIA 9500 GT. Most of the program assume a powerful video card.

demomaster.py is the main program to run.

I will have active development on this project in near future. Will post more updates soon.

====
There is a bug in CommonFilters.py in version 1.5.4 , most likely you may encountered if you run in Windows XP. You have to apply the fix mentioned here: http://panda3d.org/phpbb2/viewtopic.php?t=5782

====
Mar 23, 2009 version 0.2 released:
This release is mainly including a simplified Ocean 2 demo to see if older PC can run it properly. Note that all nature related demo are all moved to demo_nature.

I've also started to add the grass effect and added a draft version. This grass object will be more generic and other scene can adopt it easily.
====
Version 0.3 Mar 30, 2009 major changes:
1. new skydome added (nature scene like skydome)
2. new grass shader added (support multiple grass models)
3. Preliminary tree models added (using simple polygons)
4. Panda walking on grass fields (grass movement also !)
5. Preliminary Scene Graph navigator added (with grabbing auto shader)
6. Shader – Advance Demo 1 (Reflection, Refraction, Fresnel and Chromatic dispersion effect)
7. Shader – Advance Demo 2 (Dynamic mirror)

Image

Image

Image

Image

Image


============================
Apr 07, 2009
Version 0.4 major changes:
1. add/fix reflection blur on various demo
2. Water surface demos with Vertex Texture Fetching
3. New lady model on grass field

Image

Image

New video:
http://www.youtube.com/watch?v=anxU6wWuClc

Note that you probably need a powerful video card to run the new water demos.


============================
Apr 18, 2009
Version 0.5 major changes:
1. Fix some bugs in water demo, not all
2. Compositor - various 2D filters port reference ogre demo
(can chain multiple filters dynamically)
3. Human model from makehuman, with script base animation (not standard blender animation)

Image

Image

Video
http://www.youtube.com/watch?v=AIE3MC4DZDM

May 12, 2009
Version 0.6 major changes
1. Facial Expression for human model added. Major bug fixes and enhancement on the animation engine.
2. Hair added for human model, experimental.
3. ODE Car, enhanced version of ninth @ http://www.panda3d.org/phpbb2/viewtopic.php?t=5646
car model, sound, skydome, camera views added.
4. “Shaders – Facing Ratio” added
Facing Ratio Shader, from ynjh_jo http://www.panda3d.org/phpbb2/viewtopic ... acingratio
5. Several Morphing Demos added, including Captain Blender
6. More compatible with version 1.6.x
7. PSSM shadow manager added (but not used)

Image

Image

Videos
http://www.youtube.com/watch?v=uvXcrUza5j4
http://www.youtube.com/watch?v=a5Gy578goIQ


June 9, 2009
Version 0.7 release:

Use Psyco if installed
“Misc - Volumetric Light Demo” added (just a simple test)
“Misc – HDR Test” added (just a simple test)
“Shaders – DOF” Depth of Field shader added
Image
“Shaders – Sun” Sun shader added
http://www.youtube.com/watch?v=IZvbeQLfLy4
“Shaders – Compositor” add:
- Heat effect
- Old TV
Image
- Old Movie
- ASCII 2 (an improved version of ASCII)
- Half tone
- Bloom 2
- Tone Mapping

“Misc – Pool Demo” added
Image

Bugs fixes for vtf water demos (to be able to run on 1.6.x)

=================
June 25, 2009
Version 0.8
1. “Shaders – Hatching *” demos added for hatching effects
2. “Shaders – Compositor”
add “Hatching” screen effects
Image
Image
add “Multiple” screen effect
3. Performance tuning for ODE demos
4. “Shaders – Advance Demo 1”
Velvet shader added (seems not working well ?)
Mario, Crystal shader from mavasher added.
5. “Misc - Lens flare” demo added
From Legion - http://www.panda3d.org/phpbb2/viewtopic.php?t=3044
Image
6. Panda GUI option support (now demomaster can run with no wxpython installed). base on treeform's treegui
Image
Image

Run “demomaster.py f f f” if you don’t want wxpython.


Known bugs:
the head of Human 1 will disappear at certain angle
Captain Blender’s texture is not correct
Sound in ode car may not sounds right in 1.5.4.
Last edited by clcheung on Thu Jun 25, 2009 2:55 am, edited 12 times in total.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby rdb » Sat Mar 21, 2009 6:38 am

Two word: total awesomeness :)
This is very cool. Thanks so much for sharing it with us!

One thing: when I clicked something in the listbox (e.g. 'toggle this/that') I can't click it again, I have to click something else first. Might want to make that the list item gets deselected once you clicked it?
rdb
 
Posts: 11173
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby clcheung » Sat Mar 21, 2009 7:05 am

Hi pro-rsoft, I believe you are testing it on Linux ? It behaves well on Windows XP.

I think I need to fix it ... may be I can try it on my Linux virtual machine.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby aurilliance » Sat Mar 21, 2009 7:07 am

sweet! This looks great, clcheung!
-Aaron
User avatar
aurilliance
 
Posts: 111
Joined: Sun Feb 15, 2009 8:35 am
Location: Brisbane, Australia

Postby clcheung » Sat Mar 21, 2009 7:53 am

pro-rsoft wrote:Two word: total awesomeness :)
This is very cool. Thanks so much for sharing it with us!

One thing: when I clicked something in the listbox (e.g. 'toggle this/that') I can't click it again, I have to click something else first. Might want to make that the list item gets deselected once you clicked it?


Well, I have just tried to fix it in a virtualbox Ubuntu (running in Windows XP). Although it can run but I can only 0.2-0.5 FPS. Too slow for me to debug. But I don't have a spare machine to run a native Linux at this moment.

If you click something on the "Functions" listbox, the framework will immediately set the focus to the Panda window. I am not sure if it causes the problem you described here.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby rdb » Sat Mar 21, 2009 8:20 am

The problem is I can't click the same thing twice in the functions box.
rdb
 
Posts: 11173
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby clcheung » Sat Mar 21, 2009 9:01 am

pro-rsoft wrote:The problem is I can't click the same thing twice in the functions box.


I see. Looks like in Linux when a list box item is selected, the second select event will not be delivered again.
Here is a quick fix (not sure if it is the best fix):
Add one more line in wxPanelControl.py:

Code: Select all
    def selectListDemoFunctions(self, evt):
        j = self.wxListDemoFunctions.GetSelection()
        self.executeFunction(j, False)
        self.wxListDemoFunctions.SetSelection(-1)
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby jhocking » Sat Mar 21, 2009 9:58 am

man I want to see that ocean demo! I just downloaded your app (and installed wxPython) and it doesn't run; I'll try later futzing around in the code to see if I can get it working. I'm on OSX 1.5.6.
-Joe Hocking
www.newarteest.com
User avatar
jhocking
 
Posts: 206
Joined: Sun Dec 21, 2008 10:22 am
Location: Second City

Postby clcheung » Sat Mar 21, 2009 5:53 pm

jhocking wrote:man I want to see that ocean demo! I just downloaded your app (and installed wxPython) and it doesn't run; I'll try later futzing around in the code to see if I can get it working. I'm on OSX 1.5.6.


Don't miss that ocean demo ! Although it just a port, it spends me so much time to learn how to do it correctly...

Unfortunately I don't have OSX experience. Please let me know your findings and see how can I merge your change to the demo.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby astelix » Sun Mar 22, 2009 6:22 am

holy cow this is sick! fantastic solution clcheung and awesome demo selection.
Last edited by astelix on Sun Mar 22, 2009 9:17 am, edited 2 times in total.
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby jhocking » Sun Mar 22, 2009 8:34 am

hm I can't get it running on WindowsXP either. What exactly do I have to do run this? As in, step by step pretending I'm a total idiot.

I have Panda 1.5.4, installed wxPython (I got the unicode version if that makes any difference), now what?
-Joe Hocking
www.newarteest.com
User avatar
jhocking
 
Posts: 206
Joined: Sun Dec 21, 2008 10:22 am
Location: Second City

Postby clcheung » Sun Mar 22, 2009 9:17 am

jhocking wrote:hm I can't get it running on WindowsXP either. What exactly do I have to do run this? As in, step by step pretending I'm a total idiot.

I have Panda 1.5.4, installed wxPython (I got the unicode version if that makes any difference), now what?


If there is any error message ?

My configuration is, have a separate python 2.5 installed with wxPython. I do not run Panda's python because I have many other python package already installed before I use Panda.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby astelix » Sun Mar 22, 2009 9:22 am

clcheung I gotta issues as well on the oceandemo
it loads till the end, but after that it exit with a segfault message. I tried to see the code but actually no ideas on how to fix it
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby clcheung » Sun Mar 22, 2009 9:39 am

astelix wrote:clcheung I gotta issues as well on the oceandemo
it loads till the end, but after that it exit with a segfault message. I tried to see the code but actually no ideas on how to fix it


Sorry that my experience is also limited. May be the shader is too complicated for your video card ? Have you tried the Ogre Ocean demo program on your machine ?

On top of the Orge ocean shader, I have added quite a number of parameters and I am not sure if it create a burden on it. I also passed the reflection plane to it for it to select a cubemap or reflection plane on the fly. And also, I added a debug colorplane on it. I believe it might create problems.

If you can run the Ogre demo well on your machine, I will reduce the shader program to match the Ogre one and see if it help.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby jhocking » Sun Mar 22, 2009 9:49 am

clcheung wrote:If there is any error message ?


what the hell, I can't copy-paste text from the command prompt window?

Anyway, after a traceback through demomaster.py>wxDemoControl.py>wxPanelControl.py it dumps at
ImportError: No module named wx.lib

hm, that's a problem with my install of wxPython right? I'll try re-installing that.


ADDITION: Incidentally, where exactly is the shader for the ocean demo? When I go into demo-water>shaders there's nothing, and that's the only place that looks logical to me.

ADDITION2: nevermind I found the shader in "share"
Last edited by jhocking on Sun Mar 22, 2009 9:58 am, edited 1 time in total.
-Joe Hocking
www.newarteest.com
User avatar
jhocking
 
Posts: 206
Joined: Sun Dec 21, 2008 10:22 am
Location: Second City

Postby astelix » Sun Mar 22, 2009 9:55 am

clcheung wrote:Have you tried the Ogre Ocean demo program on your machine ?

On top of the Orge ocean shader, I have added quite a number of parameters and I am not sure if it create a burden on it. I also passed the reflection plane to it for it to select a cubemap or reflection plane on the fly. And also, I added a debug colorplane on it. I believe it might create problems.

If you can run the Ogre demo well on your machine, I will reduce the shader program to match the Ogre one and see if it help.


no cheung I ain't no OGRE here. I tried the "yarr with water" demo of your package with success though. I'll investigate further playing with your shader and report back
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby jhocking » Sun Mar 22, 2009 10:04 am

Well re-installing wxPython took care of that error (I think I had it installed on the wrong version of Python before, this time I made sure it went with Panda's Python) but now it gets the same error as I get when I try it on OSX:

There's a whole bunch of lines that say "Listing .\something" and then "Compile result True" and finally "No application founded"
-Joe Hocking
www.newarteest.com
User avatar
jhocking
 
Posts: 206
Joined: Sun Dec 21, 2008 10:22 am
Location: Second City

Postby astelix » Sun Mar 22, 2009 11:21 am

it is indeed the shader, cheung
if i comment out this line
Code: Select all
self.waterNP.setShader(loader.loadShader( 'ocean2.sha' ))

in the ocean2.py script I reach the end of the script loading without errors, but of course I miss the show. Unfortunately I ain't the knowledge to fix a shader but FYI the "shader wave demo" works very nice here on both the waves deformations and also the yarr water demo runs nice as well so it is just a matter to merge the wave shader with the sea shader of the yarr and voila'
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby clcheung » Sun Mar 22, 2009 8:33 pm

jhocking wrote:Well re-installing wxPython took care of that error (I think I had it installed on the wrong version of Python before, this time I made sure it went with Panda's Python) but now it gets the same error as I get when I try it on OSX:

There's a whole bunch of lines that say "Listing .\something" and then "Compile result True" and finally "No application founded"


Hi jhocking,

Let me explain the logic of the program may be it can help to track down the problem.

1. It will first compiling all the python programs found under the current directories and below. That's why you see "Listing ...." lines.

2. It will then look for all compiled files, one level down the current directories. e.g. demo_water\ocean2demo.pyc
If it is a subclass of demobase.Demobase, it will be added to the available demo list.

3. It will then create the container demomaster.Container of the demo program.

You have to look into importer.ImportCompiledObjects to check why there is no compiled object found. I suggest you put some print line statement in that function to see why no such objects found.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby clcheung » Sun Mar 22, 2009 8:40 pm

astelix wrote:it is indeed the shader, cheung
if i comment out this line
Code: Select all
self.waterNP.setShader(loader.loadShader( 'ocean2.sha' ))

in the ocean2.py script I reach the end of the script loading without errors, but of course I miss the show. Unfortunately I ain't the knowledge to fix a shader but FYI the "shader wave demo" works very nice here on both the waves deformations and also the yarr water demo runs nice as well so it is just a matter to merge the wave shader with the sea shader of the yarr and voila'


hi astelix,

The ocean2.py 's sea shader makes an ocean like water and yarr water shader make a pond like water surface. The ocean2.sha can support both effects, but may be it is too complicated to be run on your machine. I will post a stripped down version of the ocean2 and see if it helps.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby clcheung » Sun Mar 22, 2009 10:52 pm

version 0.2 released, see the top post.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby astelix » Mon Mar 23, 2009 3:59 am

now that works (both oceandemo and oceandemo2) and I say it was worth the time spent 'cos is really awesome! very nice the addition of the nature-grass demo either.

just to not make you rest too much I gotta another bug to sendya, related to all the demos that concern the shadowcaster2 - here's the traceback:
Code: Select all
Traceback (most recent call last):
  File "demomaster.py", line 373, in <module>
    run()
  File "linuxroot/usr/share/panda3d/direct/src/showbase/ShowBase.py", line 2266, in run
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 965, in run
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 903, in step
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 802, in __stepThroughList
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 721, in __executeTask
  File "demomaster.py", line 197, in InitDemoLater
    demo.InitScene()
  File "./demo_ode/ode1.py", line 57, in InitScene
    self.LoadLights()
  File "./demo_ode/ode4.py", line 73, in LoadLights
    self.changeLightPos(None)
  File "./demo_ode/ode4.py", line 80, in changeLightPos
    self.sMgr.castercam.setPos(v[0],v[1],v[2])
AttributeError: ShadowManager instance has no attribute 'castercam'
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby clcheung » Mon Mar 23, 2009 5:21 am

That's great to know that you can run it properly. Panda is very good in portability ! Well, I live in Hong Kong, my time is now 6:00 pm, too early to take a rest.

I am a bit lazy in porting the shadow manager class. It checks whether the hardware is capable to run it:

Code: Select all
    def shaderSupported(self):
        return base.win.getGsg().getSupportsBasicShaders() and \
               base.win.getGsg().getSupportsDepthTexture() and \
               base.win.getGsg().getSupportsShadowFilter()

    def __init__(self, scene = base.render, fov = 40, near = 10, far = 100, hardness=0.2):
        if not self.shaderSupported():
            return


But I have not put the code to notify user about it. It is likely your hardware does not support ShadowFilter or DepthTexture ? So the castercam is not created. Can you verify ?

I will put more checking there.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby astelix » Mon Mar 23, 2009 5:46 am

clcheung wrote:I am a bit lazy in porting the shadow manager class. It checks whether the hardware is capable to run it:

Code: Select all
    def shaderSupported(self):
        return base.win.getGsg().getSupportsBasicShaders() and \
               base.win.getGsg().getSupportsDepthTexture() and \
               base.win.getGsg().getSupportsShadowFilter()

    def __init__(self, scene = base.render, fov = 40, near = 10, far = 100, hardness=0.2):
        if not self.shaderSupported():
            return


But I have not put the code to notify user about it. It is likely your hardware does not support ShadowFilter or DepthTexture ? So the castercam is not created. Can you verify ?

I will put more checking there.

it return me 0 but let me tellya that the other manager works and looks pretty nice and could be a reliable substitute
My Rig:
P3D 1.7.0@WinXP & Kubuntu 10.04- Athlon 64 5200 X2 ~ Radeon 3200HD (integrated)
User avatar
astelix
 
Posts: 866
Joined: Mon Mar 27, 2006 4:36 pm
Location: Milano, ITA

Postby clcheung » Mon Mar 23, 2009 7:08 am

astelix wrote:
clcheung wrote:I am a bit lazy in porting the shadow manager class. It checks whether the hardware is capable to run it:

Code: Select all
    def shaderSupported(self):
        return base.win.getGsg().getSupportsBasicShaders() and \
               base.win.getGsg().getSupportsDepthTexture() and \
               base.win.getGsg().getSupportsShadowFilter()

    def __init__(self, scene = base.render, fov = 40, near = 10, far = 100, hardness=0.2):
        if not self.shaderSupported():
            return


But I have not put the code to notify user about it. It is likely your hardware does not support ShadowFilter or DepthTexture ? So the castercam is not created. Can you verify ?

I will put more checking there.

it return me 0 but let me tellya that the other manager works and looks pretty nice and could be a reliable substitute


The second shadow manager can take a scene with auto shader, it is supposed to be more flexible. But I believe it need more fine tuning.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby rdb » Mon Mar 23, 2009 10:33 am

Sidenote: the shadows sample program and my version of the shadow manager do not require support for depth textures. Also, I believe they both don't require the shadow filter either.
rdb
 
Posts: 11173
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby clcheung » Mon Mar 23, 2009 7:34 pm

pro-rsoft wrote:Sidenote: the shadows sample program and my version of the shadow manager do not require support for depth textures. Also, I believe they both don't require the shadow filter either.


I see. I will fix the code in the coming release.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby clcheung » Mon Mar 30, 2009 7:46 am

Version 0.3 released.
User avatar
clcheung
 
Posts: 574
Joined: Wed Jan 21, 2009 7:23 am

Postby rdb » Mon Mar 30, 2009 8:15 am

Sweet, good job! You might just wanna consider enabling anisotropic filtering for the grass, otherwise some nasty artifacts are visible.
Also, a better transparency mode for the trees wouldn't be a bad idea.
rdb
 
Posts: 11173
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Nemesis#13 » Mon Mar 30, 2009 5:08 pm

it doesn't run here very well. i get some strange artifacts on all samples, although the panda3d internal samples all run fine outside your app.

any chance to get your samples collection being independent of the surrounding WX stuff?

other bugs found so far:
-you can't run it from any other directory. maybe this helps:
Code: Select all
os.chdir(sys.path[0])

-the control window is not scalable in width
-closing it fails (you have to terminate the panda3D window instead)

my configuration:
-GNU/Linux
-Nvidia 7600GS with 180.29 drivers
-Panda 1.5.4
-Python 2.6.1
-wxpython/wxgtk 2.8.9.2

screenshots on request. maybe i've just overseen something..
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Next

Return to Showcase

Who is online

Users browsing this forum: No registered users and 1 guest