Horde3D

Next-Generation Graphics Engine
It is currently 28.11.2024, 04:42

All times are UTC + 1 hour




Post new topic Reply to topic  [ 75 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject: Re: Python wrapper
PostPosted: 03.03.2010, 22:18 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Thanks a lot for updating it!


Top
 Profile  
Reply with quote  
 Post subject: MatRes.SampTexStr
PostPosted: 04.04.2010, 04:36 
Offline

Joined: 25.03.2010, 03:58
Posts: 13
in
egMaterial.h
MaterialResData
SampTexResI

but in __init__.py
class MatRes(object):
SampTexStr = 407
-> SampTexResI = 407
?


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 04.04.2010, 12:48 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
sellee: I've fixed this bug in the community svn. Thanks for the the report.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 08.04.2010, 08:42 
Offline

Joined: 08.04.2010, 08:30
Posts: 2
Location: Norway
When installing the python bindings I had to make them aware of horde3d myself, since it was installed to /usr/local/lib by default and that wasn't where python assumed they would be. Not saying this is wrong, just possibly something to be aware of. The error message was anything but clear, but at least it led me to the right part of the source file.

When running the samples, I came across a few issues: app.py assumes the resources are in a directory starting with ../../. I had to copy the resources from the sourceforge repo and the python bindings from the community repo. This is a bit wrong, since the log output doesen't say the full path being used and there are no instructions for this as far as I can tell.

I also had to make some modifications to terrain.py to get it working, patch attached.


Attachments:
terrain.py.patch [2.24 KiB]
Downloaded 1334 times
Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 08.04.2010, 10:14 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
Applied patch and added warning message when library is not found as discussed in irc.

The path for resources can be set by using the "--content" parameter.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 30.06.2010, 19:48 
Offline

Joined: 28.06.2010, 23:21
Posts: 4
I'm trying to use Horde with Python on a Windows machine. I'm using r386 from the community SVN (which I successfully built in VS2010) and the most up-to-date version of the \Bindings\Python\horde3d\ and the \Samples\Python\ folders.

When I try running terrain.py, I get the following error:
Code:
  File "C:\Users\...\Documents\Visual Studio 2010\Projects\community-Horde3D\trunk\Horde3D\Samples\Python\app.py", line 25, in <module>
    import horde3d as h3d
  File "C:\Python26\lib\site-packages\horde3d\__init__.py", line 394, in <module>
    _showOverlays = h3d.h3dShowOverlays
  File "C:\Python26\lib\ctypes\__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python26\lib\ctypes\__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'h3dShowOverlays' not found

It looks like the ShowOverlays function is in _init_.py (just below the line where the error occurs). Does anyone have any suggestions?


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 01.07.2010, 09:04 
Offline

Joined: 13.06.2010, 02:11
Posts: 11
fnv wrote:
I'm trying to use Horde with Python on a Windows machine. I'm using r386 from the community SVN (which I successfully built in VS2010) and the most up-to-date version of the \Bindings\Python\horde3d\ and the \Samples\Python\ folders.

When I try running terrain.py, I get the following error:
Code:
  File "C:\Users\...\Documents\Visual Studio 2010\Projects\community-Horde3D\trunk\Horde3D\Samples\Python\app.py", line 25, in <module>
    import horde3d as h3d
  File "C:\Python26\lib\site-packages\horde3d\__init__.py", line 394, in <module>
    _showOverlays = h3d.h3dShowOverlays
  File "C:\Python26\lib\ctypes\__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python26\lib\ctypes\__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'h3dShowOverlays' not found

It looks like the ShowOverlays function is in _init_.py (just below the line where the error occurs). Does anyone have any suggestions?


Looking at the H3D documentation, it seems like in fact that function is now called h3dShowOverlay (singular, not plural). So changing that line to say _showOverlays = h3d.h3dShowOverlay might fix it, although it probably would be a better idea to chane all of the instances of showOverlays to showOverlay, but that's the one that deals with the C function in question.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 01.07.2010, 15:37 
Offline

Joined: 28.06.2010, 23:21
Posts: 4
That was the problem, thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 02.07.2010, 21:07 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
pekuja wrote:
Looking at the H3D documentation, it seems like in fact that function is now called h3dShowOverlay (singular, not plural). So changing that line to say _showOverlays = h3d.h3dShowOverlay might fix it, although it probably would be a better idea to chane all of the instances of showOverlays to showOverlay, but that's the one that deals with the C function in question.

It is exactly the other way round. The function was called showOverlay in Beta4 but renamed (and changed semantically) in the svn trunk.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 04.07.2010, 03:57 
Offline

Joined: 13.06.2010, 02:11
Posts: 11
marciano wrote:
pekuja wrote:
Looking at the H3D documentation, it seems like in fact that function is now called h3dShowOverlay (singular, not plural). So changing that line to say _showOverlays = h3d.h3dShowOverlay might fix it, although it probably would be a better idea to chane all of the instances of showOverlays to showOverlay, but that's the one that deals with the C function in question.

It is exactly the other way round. The function was called showOverlay in Beta4 but renamed (and changed semantically) in the svn trunk.

Ah, sorry about that then. So I guess fnv is not using an up to date build.

On another note, does anyone have good suggestions on integrating a physics engine into a H3D app written in Python? Bullet doesn't have complete Python bindings, so I'm looking at ODE right now. Finding it a bit confusing but probably usable. I think Newton has Python bindings, but it's not open source which limits portability. What do you guys think is the best way to go about this? Should I just write my engine layer in C++ and use whatever libraries I like, then just use Python for actual application code? That seems like it could be a good option, but I just want to know if anyone's gone through this before or otherwise has an informed opinion on it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 04.07.2010, 12:47 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
Hi pekuja,

What are the C-bindings to bullet like? You might be able to make your own bindings the same way horde makes its bindings, by ctypes. I guess take a look at the ctypes documentation to see how it is used and dissect the python bindings horde uses to see how functions and data types cross over to python-land and then apply the same principles by studying the C bindings of bullet.

Making a thin layer over your stuff and then making bindings to that might be a better solution if you'd like your python code to talk to something a little higher level like game objects and components instead. There's a bullet physics extension for horde itself floating about which Volker wrote and I think it was Irdis who updated it to work with the latest horde. I guess just take it and extend it to how you want and then make ctypes bindings to this, or just use it to study how combining to two could be realised.

Good luck, I'll be doing a similar thing as well except with lua (unless I can get horde's game-engine to compile for linux).

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 05.07.2010, 06:07 
Offline

Joined: 13.06.2010, 02:11
Posts: 11
MistaED wrote:
What are the C-bindings to bullet like? You might be able to make your own bindings the same way horde makes its bindings, by ctypes. I guess take a look at the ctypes documentation to see how it is used and dissect the python bindings horde uses to see how functions and data types cross over to python-land and then apply the same principles by studying the C bindings of bullet.


Yeah, I might be able to do that. The one weird thing the Bullet C-API does is that it uses empty structs as handles. I don't know if that's a problem; it just seems strange. Also the C-API doesn't have a lot of documentation. Just some very basic Doxygen docs and a couple of simple example applications.

MistaED wrote:
Making a thin layer over your stuff and then making bindings to that might be a better solution if you'd like your python code to talk to something a little higher level like game objects and components instead.

Yeah, I am indeed trying to do something like that.

MistaED wrote:
There's a bullet physics extension for horde itself floating about which Volker wrote and I think it was Irdis who updated it to work with the latest horde. I guess just take it and extend it to how you want and then make ctypes bindings to this, or just use it to study how combining to two could be realised.

Yeah, there is an extension, but it seems to have a more object-oriented design, which is harder to make bindings for as far as I know?

MistaED wrote:
Good luck, I'll be doing a similar thing as well except with lua (unless I can get horde's game-engine to compile for linux).

Let us know how that goes. :-)

I think what I'm going to do is I'll look into improving the Python bindings for Bullet. There are some bindings already out there; they're just not complete yet. Probably easier to keep the layer between the libraries and my Python code relatively thin instead of writing big parts of my engine/framework in C++ and add Python scripting, which is another option I was considering.


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 22.07.2010, 01:44 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
It looks like the rename of h3dGetPipelineRenderTargetData (h3dGetRenderTargetData) in r247 broke the bindings. Also the docs could use the rename update.

Fix for the bindings(lines 581-598):

Code:
_h3dGetRenderTargetData = h3d.h3dGetRenderTargetData
_h3dGetRenderTargetData.restype = c_bool
_h3dGetRenderTargetData.argtypes = [c_int, c_char_p, c_int, POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_float), c_int]
def getRenderTargetData(pipelineRes, targetName, bufIndex):
   width = c_int()
   height = c_int()
   compCount = c_int()

   # get values for width, height, compCount to calculate needed buffer size
   _h3dGetRenderTargetData(pipelineRes, targetName, bufIndex, byref(width), byref(height), byref(compCount), None, 0)

   # get data
   bufferSize = 4 * width * height * compCount
   buffer = (c_float * (bufferSize / 4))()
   _h3dGetRenderTargetData(pipelineRes, targetName, buffer, None, None, None, buffer)

   return [x for x in buffer] # FIXME really make a normal list of floats out of this array?
__all__.append('getRenderTargetData')

_________________
Paul


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 30.08.2010, 09:58 
Offline

Joined: 27.08.2010, 11:51
Posts: 1
Hi,

is anybody working on this? This latest patch is not integrated into Community SVN branch :(


Top
 Profile  
Reply with quote  
 Post subject: Re: Python wrapper
PostPosted: 30.08.2010, 10:11 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Normally Codepoet is updating the python bindings. I'm not very familiar with Python. While I was trying to integrate the patch I noticed that the multiplication with 4 seems to be useless, isn't it?
Quote:
bufferSize = 4 * width * height * compCount
buffer = (c_float * (bufferSize / 4))()


shouldn't it be:

Quote:
bufferSize = width * height * compCount
buffer = (c_float * (bufferSize))()


Or is there something in python that prevents buffer from being initialized correctly if bufferSize is not divided by 4?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 75 posts ]  Go to page Previous  1, 2, 3, 4, 5

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group