Re: [osg-users] How to define my own geometry in osgswig?

2008-11-17 Thread Gerwin de Haan
Linh,
Currently in osgswig you cannot directly override osg.Drawables in the
target scripting language.
This is partly because we have not enabled SWIG directors for this
class, which are responsible for such cross-language inheritance.
Also, Drawables are pure virtual/abstract which doesn't play nice with
our directors. As an alternative, you might want to try and enable
Directors for Geometry in osg.i:
%feature(director) osg::Geometry;
I'll consider this a feature request, will try this and see what the
consequences on performance are.
See the pyramid.py example for defining your own geometry without subclassing.
Gerwin


On Mon, Nov 17, 2008 at 8:43 AM, Phan, Linh H [EMAIL PROTECTED] wrote:
 Hi,

   I was wondering if it's possible to draw my own geometry in osgswig, eg
 something like:

 import osg, osgViewer
 class MyCube(osg.Drawable):
 def __init__(self):
 osg.Drawable.__init__(self);   # AttributeError: No constructor
 defined
 def drawImplementation(self, state):
 # draw some geometry
 glutWireCube (1.0)
 def computeBound(self):
 bbox = osg.BoundingBox()
 bbox.set(-2,-2,-2,2,2,2)
 return bbox

 geode = osg.Geode()
 geode.addDrawable(MyCube())
 viewer = osgViewer.Viewer()
 viewer.setSceneData(geode)
 viewer.run()

 I get AttributeError: No constructor defined when I run it.  Is there a
 way to draw my own geometry?

 Thank you,

 Linh

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to define my own geometry in osgswig?

2008-11-17 Thread Phan, Linh H
Hi Gerwin,

  it would be nice if this feature would work since if I have
legacy c++ code that draws an asteroid, for instance, I would like to
be able to just wrap that c++ code up in python and use it in osgswig.  I
tried putting

%feature(director) osg::Geometry;

in osg.i, and I got alot of errors:

cd /C/cygwin-1.7/usr/local/src/buildosgswig/src/python  /c/MinGW/bin/g++.exe  
  -D_osg_EXPORTS -g -I/c/Program Files/OpenSceneGraph2.4/include 
-I/C/cygwin-1.7/home/phan/projs/osgswig-read-only/include -I/c/Python25/include 
  -o CMakeFiles/_osg.dir/osgPYTHON_wrap.obj -c 
/C/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.cxx
In file included from 
c:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.cxx:6679:
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:104: 
error: `PrimitiveFunctor' has not been declared
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:104: 
error: ISO C++ forbids declaration of `arg0' with no type
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:105: 
error: ISO C++ forbids declaration of `pf' with no type
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:106: 
error: `PrimitiveIndexFunctor' has not been declared
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:106: 
error: `virtual bool SwigDirector_Geometry::supports(int) const' and `virtual 
bool SwigDirector_Geometry::supports(int) const' cannot be overloaded
C:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.h:107: 
error: `virtual void SwigDirector_Geometry::accept(int) const' and `virtual 
void SwigDirector_Geometry::accept(int) const' cannot be overloaded
c:/cygwin-1.7/usr/local/src/buildosgswig/src/python/osgPYTHON_wrap.cxx:7569: 
error: `bool SwigDirector_Geometry::supports' is not a static member of `class 
SwigDirector_Geometry'
...

Thank you Gerwin,

Linh

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gerwin de Haan
Sent: Monday, November 17, 2008 12:17 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] How to define my own geometry in osgswig?

Linh,
Currently in osgswig you cannot directly override osg.Drawables in the
target scripting language.
This is partly because we have not enabled SWIG directors for this
class, which are responsible for such cross-language inheritance.
Also, Drawables are pure virtual/abstract which doesn't play nice with
our directors. As an alternative, you might want to try and enable
Directors for Geometry in osg.i:
%feature(director) osg::Geometry;
I'll consider this a feature request, will try this and see what the
consequences on performance are.
See the pyramid.py example for defining your own geometry without subclassing.
Gerwin


On Mon, Nov 17, 2008 at 8:43 AM, Phan, Linh H [EMAIL PROTECTED] wrote:
 Hi,

   I was wondering if it's possible to draw my own geometry in osgswig, eg
 something like:

 import osg, osgViewer
 class MyCube(osg.Drawable):
 def __init__(self):
 osg.Drawable.__init__(self);   # AttributeError: No constructor
 defined
 def drawImplementation(self, state):
 # draw some geometry
 glutWireCube (1.0)
 def computeBound(self):
 bbox = osg.BoundingBox()
 bbox.set(-2,-2,-2,2,2,2)
 return bbox

 geode = osg.Geode()
 geode.addDrawable(MyCube())
 viewer = osgViewer.Viewer()
 viewer.setSceneData(geode)
 viewer.run()

 I get AttributeError: No constructor defined when I run it.  Is there a
 way to draw my own geometry?

 Thank you,

 Linh

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] How to define my own geometry in osgswig?

2008-11-16 Thread Phan, Linh H
Hi,

  I was wondering if it's possible to draw my own geometry in osgswig, eg 
something like:

import osg, osgViewer
class MyCube(osg.Drawable):
def __init__(self):
osg.Drawable.__init__(self);   # AttributeError: No constructor defined
def drawImplementation(self, state):
# draw some geometry
glutWireCube (1.0)
def computeBound(self):
bbox = osg.BoundingBox()
bbox.set(-2,-2,-2,2,2,2)
return bbox

geode = osg.Geode()
geode.addDrawable(MyCube())
viewer = osgViewer.Viewer()
viewer.setSceneData(geode)
viewer.run()

I get AttributeError: No constructor defined when I run it.  Is there a way 
to draw my own geometry?

Thank you,

Linh

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org