CEGUI in Panda3d (WIP)

Return to Panda Features in Development

Postby rdb » Thu May 14, 2009 12:57 am

Is the init_type of your class called (usually in config_blah.cxx) ?
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby nik » Thu May 14, 2009 1:00 pm

Yes, init_type is called.
I'm solving the problem temporarily by using
Code: Select all
TypeRegistry::ptr()->find_type("EventStoreVec2")

instead of
Code: Select all
EventStoreVec2::get_class_type()

, but I still don't understand what's going on.
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby drwr » Tue May 26, 2009 5:20 pm

EventStoreVec2 is a template class. Template classes are sometimes problematic because there might be multiple instances of the same class in different parts of the code, so that EventStoreVec2::get_class_type(), as called in one module, is not the same method as EventStoreVec2::get_class_type(), as called in another module.

This is I think is what's causing problems. To avoid it, try adding an explicit call to EventStoreVec2::init_type() in config_tform.cxx.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby morgul » Sun Jun 28, 2009 2:12 am

Just thought I'd poke this thread, show my interest, and ask if you'd like any help with anything. Just became interested in porting our old (CS based app) CEGUI theme to something in out new panda3d app, and I stumbled across this. Sounds like you're very close to something usable; I'd love to help out where possible.

Any sort of status update on the build issue?
Christopher S. Case
Skewed Aspect
http://dev.skewedaspect.com/projects/precursors
Image
User avatar
morgul
 
Posts: 38
Joined: Sun Dec 28, 2008 1:49 pm
Location: Lubbock, TX

Postby nik » Mon Aug 03, 2009 2:23 pm

Morgul, sorry for not replying (somehow I didn't receive a reply notification).

Here is the status:

I'm happy with the C++ code that I have now.

The Python wrapper was more problematic. There are several Python wrappers for CEGUI out there. The Python-Ogre project seems to be the only one that's still maintained.

The problem with it is that it depends on Ogre3d, so using these wrappers pulls in Ogre as a dependency. However, it should not be a problem to remove the Ogre dependencies out of the wrapper libs.

Anyways, I got it to work today with the Python-Ogre wrappers. I'll package what I have now and send out a patch and more info later today.

Nik
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby nik » Mon Aug 03, 2009 5:35 pm

Here is a patch:
http://paste.ubuntu.com/246744

Instructions for ppremake:

1. [SEE POST BELOW ON HOW TO SPEED THIS UP]
Get Python-Ogre. Start with this one, because you'll need to link to the CEGUI lib that it uses.
Download and build (or use the Windows binary release). Building takes a while (hours).
Run the demos (at least demos/cegui/Demo_CEGUI_NewGui.py should work).

2. Get the Silly Image Codec. Compile and install.

3. Apply the patch to the Panda3d source tree.

The parts for MyConfig.pp will probably fail. Find the CEGUI library and headers that Python-Ogre uses, and set CEGUI_IPATH and CEGUI_LPATH to point there.

In my case, I have this in MyConfig.pp:
Code: Select all
#define CEGUI_LPATH /Users/nik/Library/Frameworks/CEGUI.framework/


4. Verify that CEGUI libs are found by PPremake:
Code: Select all
cd dtool
ppremake
# Results should contain "+ CEGUI"


5. Build and install libpcegui for Panda3d:
Code: Select all
cd panda/src/cegui
ppremake
make
make install
genPyCode


6. Copy the datafiles directory from the Python-Ogre demos directory into panda/src/cegui.

7. Run python_test.py and ogre_font_demo.py - you should have a working CEGUI.

Those who use Panda3d from C++ don't need the Python wrappers from Python-Ogre, so they can skip step 1 and build CEGUI from source instead.
It would be nice if someone could go through this and post feedback.

Thanks,

Nik

(edit: added step 6)
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby nik » Thu Aug 06, 2009 7:33 pm

I've modified Python-Ogre to not depend on Ogre. The wrappers can now be built much faster (half an hour on a slower machine).
Here is how to build it from source on Ubuntu 9.04 or OSX:

Code: Select all
mkdir ~/pycegui; cd ~/pycegui
# Checkout Python-Ogre tree from SVN
svn co https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/trunk/python-ogre python-ogre -r 984

# Build the prerequisites. They get installed in ~/pycegui/root/usr/lib/
python python-ogre/BuildModule.py -r -b cmake gccxml boost pyplusplus pygccxml


Here is a patch for the Python-Ogre tree: http://paste.ubuntu.com/248927/.
Apply it to the ~/pycegui/python-ogre folder.

Then build CEGUI, generate and build Python wrappers:
Code: Select all
python python-ogre/BuildModule.py -r -b cegui
# Generate wrappers
python python-ogre/BuildModule.py -g cegui
# Compile wrappers - this takes a while.
python python-ogre/BuildModule.py -c cegui
# If there are no errors (a few warnings are normal), install:
python python-ogre/BuildModule.py -b install


Now you should see a file ~/pycegui/root/usr/lib/python2.6/site-packages/ogre/gui/CEGUI/_cegui_.so

Export the env. vars:
Code: Select all
export LD_LIBRARY_PATH=/home/$USER/pycegui/root/usr/lib/:$LD_LIBRARY_PATH
export PYTHONPATH=/home/$USER/pycegui/root/usr/lib/python2.6/site-packages:$PYTHONPATH


Now follow steps 2...7 in the post above to setup tha panda tree. Panda's CEGUI_LPATH must point to ~/pycegui/root/usr/lib/.

Then run the test:

Code: Select all
cd panda/src/cegui
python ogre_font_demo.py
OR
python python_test.py


Reference:http://wiki.python-ogre.org/index.php/LinuxBuildV2

Thanks,

Nik
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby rdb » Fri Aug 07, 2009 1:19 am

Hm, what about using interrogate to create the interfaces, like we do with most Panda stuff? Does the user of PandaCegui need to use the Cegui original classes?
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby nik » Fri Aug 07, 2009 11:01 am

I've thought about it. There are about 160 classes to be wrapped, with many properties. It's not a trivial task.

The user of CEGUI does need all of these classes to interact with it.

We could search for _cegui_.so in CEGUI_LIBS as a way to detect if the Python wrappers for CEGUI are installed.
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby rdb » Fri Aug 07, 2009 11:35 am

Hum, well, what about putting the Cegui includes between BEGIN_PUBLISH and END_PUBLISH blocks? At least cegui follows our Python coding convention.
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby nik » Mon Aug 10, 2009 6:25 pm

interrogate chokes on various things (typedefs of std::stream, classes inheriting from std::iterators...).

Is there a way to exclude parts of a file from being interrogated?
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby drwr » Mon Aug 10, 2009 6:46 pm

No, but you might be able to satisfy interrogate by defining enough of the iostream interface in parser-inc/iostream, which is the header file that interrogate reads to understand iostreams. Presently, that file defines the stream classes in the default namespace, but you could modify it to put them in the std namespace instead, more correctly.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby nik » Sat Aug 22, 2009 11:09 am

I don't see the need to convert the wrappers to interrogate. The way described above works for me. Why duplicate the work already done by someone else?

Besides, I don't have the time to look into interrogate.

Should someone else need to do this, they would need to wrap most of the headers in the CEGUI's include directory.

Nik
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby treeform » Sat Aug 22, 2009 1:53 pm

If you make it work with interrogate it would be trivial to include CEGUI with panda3d and have other people fix bugs with it, and have it become part of panda3d.
User avatar
treeform
 
Posts: 2106
Joined: Sat May 05, 2007 5:15 pm
Location: SF, CA

Postby rdb » Tue Aug 25, 2009 10:57 pm

Yeah, it would be silly to ship Panda3D with python-ogre.

I can do the interrogate work, though, if you want.
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby zuck » Fri Aug 28, 2009 9:41 am

Well, I'm not nik but...Yes, please! :P
Emanuele Bertoldi
zuck
 
Posts: 115
Joined: Wed Dec 10, 2008 12:37 pm
Location: Udine, ITA

Postby nik » Sun Aug 30, 2009 6:09 pm

Sure, that would be great, thanks!

Nik

(What's with the reply notifications not working?)
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby sneftel » Mon Aug 31, 2009 10:08 am

On a related note, is there documentation for Interrogate out there? I've seen the It's The Panda Show! webisode about Interrogate, and I've read the interrogate.exe usage help, but I'm still relatively clueless on the overall process of integrating a third party library into Panda, as well as the details of playing nice with Interrogate (ref-counting, ownership semantics, that kind of thing). I've integrated CEGUI into preexisting game engines before, and I'd be quite happy to help out here, and it occurs to me that some facets of CEGUI, like its approach to event publishing, probably wouldn't be automagically and perfectly handled by Interrogate.
sneftel
 
Posts: 28
Joined: Wed Aug 12, 2009 8:12 am

Postby rdb » Mon Aug 31, 2009 10:29 am

Hm, have you already seen this manual page? It might help you a little bit further:
http://www.panda3d.org/wiki/index.php/Interrogate
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby drwr » Mon Aug 31, 2009 10:36 am

It's true there's not a lot of that sort of documentation. Interrogate isn't often used to directly instrument a third-party library that wasn't built with interrogate in mind. It's an incredibly useful tool for automatically instrumenting simple interfaces, but there are certain fancy C++ tricks that just don't automatically translate into other languages.

Off the top of my head, the rules are:
- Methods that return pointers or references are presumed to retain ownership.
- Methods that accept pointers or references are presumed not to take ownership.
- Methods that return concrete objects will implicitly construct a new wrapper object, which does keep its own ownership. A valid copy constructor is required.
- Objects that inherit from Panda's ReferenceCount are automatically reference-counted properly, superceding the first two rules. Obviously this rule doesn't help at all for third-party libraries.
- Objects that inherit from Panda's TypedObject are automatically downcast to the appropriate type on the Python side. Also not useful for third parties.
- A method that returns NULL will actually return None. The reverse conversion is not performed, for safety reasons; there is thus no way to pass a NULL pointer into a method.
- Raw pointers to primitive types, like int, float, etc., are not supported. Methods that receive or return these parameters are not instrumented.
- Nested classes and template classes are supported. Templates may need to be explicitly instantiated in a .N file.
- STL iterators generally aren't supported, but other STL operations can be used (cf. Panda's PointerToArray class). STL basic_string and wide_string class is automatically converted to and from Python string and unicode objects.
- Function pointers are obviously not supported. Void pointers are not supported.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby sneftel » Mon Aug 31, 2009 10:44 am

If Interrogate isn't ideal for 3rd party code (which makes sense... I'm pretty sure CEGUI doesn't go out of its way to put PUBLISHED: in its classes), would the solution be to make a thin, Panda-compliant wrapper around CEGUI to do that stuff? Without support for function pointers (let alone member function pointers), CEGUI wouldn't otherwise have any way of firing events.
sneftel
 
Posts: 28
Joined: Wed Aug 12, 2009 8:12 am

Postby rdb » Mon Aug 31, 2009 10:52 am

Of course there are ways to use function pointers in a code that is parsed by Interrogate, you just need to make a function that receives a PyObject pointer and use the Python API to call that function.
I rarely respond to PMs
rdb
 
Posts: 8636
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby drwr » Mon Aug 31, 2009 12:24 pm

Making a thin, Panda-compliant wrapper is the way we most commonly expose a third-party library via interrogate. But nik pointed out above that CEGUI has a huge interface, so it may not be easy to make a thin, Panda-compliant wrapper around it.

Depending on CEGUI's interface design, interrogate might not be the best choice to instrument it. Maybe we can talk to the team who designed the wrappers for python-ogre, and see if they'd be willing to spin python-CEGUI into its own project.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby sneftel » Mon Aug 31, 2009 3:21 pm

It's huge, but the widely used part of it is not huge. One major reason CEGUI's interface is so bulging is because it technically gives you a huge degree of flexibility. Falagard, its XML-based skinning system, is not integrated into the core, but rather plugs in, so there's a lot of exposed interfaces purely for the purpose of writing one's own skinning interface. Moreover, there's hundreds of Property classes, CEGUI's special little way of being data-driven, which would have no place in an exposed Python interface.

One would just need to expose the widget classes (assuming and hiding the use of Falagard), plus maybe a couple dozen miscellaneous classes like Font and Imageset. Actually, it looks like that's exactly what CEGUIPython is doing.
sneftel
 
Posts: 28
Joined: Wed Aug 12, 2009 8:12 am

Postby nik » Sun Sep 20, 2009 10:28 am

A small update:

I've contacted the Python-Ogre developers, and Andy Miller, their lead developer, was very quick to respond.

The thread is here:
http://groups.google.com/group/python-ogre-developers/browse_thread/thread/588b6d5bd2afce07

Nik
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby drwr » Sun Sep 20, 2009 1:14 pm

Good news!

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Gogg » Mon Oct 12, 2009 8:26 am

I'm interested in using this, but I would like it to work with DirectX. Is there any plan to support it? Can I help? Also does what is done so far work with cegui 0.7?
User avatar
Gogg
 
Posts: 475
Joined: Thu Sep 24, 2009 1:06 pm

Postby Gogg » Tue Oct 13, 2009 9:30 am

Gogg wrote:I'm interested in using this, but I would like it to work with DirectX. Is there any plan to support it? Can I help? Also does what is done so far work with cegui 0.7?


Sorry to double-post, but disregard this. First, I'm gonna try to use panda's gui first. Second, pro-rsoft told me how to integrate cegui and it doesn't look that hard now that there are callbacks for it.
User avatar
Gogg
 
Posts: 475
Joined: Thu Sep 24, 2009 1:06 pm

Postby nik » Mon Oct 19, 2009 6:08 pm

The latest implementation should work on both DirectX and OpenGL. The renderer translates Cegui's quads into Panda's polygons, and then Panda3d renders these with either OpenGL or DirectX.

It would be nice if you would try it out and post the results. I'll be checking this thread more often, since the reply notifications are not working for me at all.

Nik
nik
 
Posts: 38
Joined: Fri Oct 10, 2008 4:01 pm

Postby Nique » Mon Jan 25, 2010 2:15 pm

Anybody succeeded to get this working with panda 1.6 or 1.7 ?

i tried the above steps (on a windows pc with GNU32 etc) and got to the step of compiling the wrappers

Code: Select all
# Compile wrappers - this takes a while.
python python-ogre/BuildModule.py -c cegui


Now, in the log.out file:
Code: Select all
01-25 04:34 PythonOgre.BuildModule INFO     Compiling Source code for cegui
01-25 04:34 PythonOgre.BuildModule DEBUG    Spawning 'scons -j3 PROJECTS=cegui' in 'D:\Projects\Games\Libraries\Temp\python-ogre'
01-25 04:34 PythonOgre.BuildModule WARNING  Task Failed
01-25 04:34 PythonOgre.BuildModule DEBUG   
01-25 04:34 PythonOgre.BuildModule DEBUG   Scons The Name Specified Is Not Recognized


So i search for scons.. but and got it inside at python/..(blah)../site-packages/scons but i have no idea how to get this working.

Is there any human readable guide / steps guid to do this (since its months ago since the last post).

thank you
Nique
 
Posts: 12
Joined: Sat Jan 23, 2010 8:27 am

PreviousNext

Return to Panda Features in Development

Who is online

Users browsing this forum: No registered users and 0 guests