Thread: [PyOpenGL-Users] scene graph examples?
Brought to you by:
mcfletch
From: brett h. <bha...@ya...> - 2004-03-29 19:55:28
|
Hi, I could not find any examples using the scene graph nodes in openglcontext 2.0. All of the examples found in tests/ seem to only show how to use direct opengl calls. None of the examples i looked at showed how to work with the scene graph nodes. How do i do something simple like: create a new group, transform, and model, and then render it? I am expecting it would work something like... from OpenGLContext.scenegraph.basenodes import * BaseContext, MainFunction = testingcontext.getInteractive() g = Group() t = Transform() geo = Box() t.tranform(1,2,3) g.addChildren(t) t.addChildren(geo) viewer = BaseContext viewer.setSceneGraphData(g) MainFunction(viewer) -brett __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html |
From: Mike C. F. <mcf...@ro...> - 2004-03-29 22:07:52
|
Samples using scenegraphs (directly instantiated, not loading from a file): glelathe.py indexedfaceset_lit_npf.py indexedfaceset_lit_npv.py mouseover.py particles_simple.py point_and_click.py selectrendermode.py simplerotate.py wx_with_controls.py Most of the tests are actually using scenegraph nodes, they just don't use the actual scenegraph *hierarchy*, as they are testing lower-level functionality. OpenGLContext is strongly OO, it's not like VPython where you create "script" modules. You get things done by sub-classing the BaseContext (which is a class, not an instantiation of a class), then overriding methods such as OnInit and getSceneGraph. Here's your expectation translated: #! /usr/bin/env python from OpenGLContext import testingcontext BaseContext, MainFunction = testingcontext.getInteractive() from OpenGLContext.scenegraph.basenodes import * scene = sceneGraph( children = [ Group( DEF = 'g', children = [ Transform( DEF = 't', translation = ( 1,2,3 ), children = [ Shape( geometry = Box(), # follows VRML97 standard, so normally # want the material Node so that there # will be lighting applied... appearance=Appearance( material = Material(), ), ), ], ), ], ), ], ) class TestContext( BaseContext ): def OnInit( self ): self.sg = scene def getSceneGraph( self ): return self.sg if __name__ == "__main__": MainFunction ( TestContext) I'll look at adding this kind of stuff to this page when I get a chance: http://pyopengl.sourceforge.net/context/vrml97.html since it's likely the "right" place for it. HTH, Mike brett hartshorn wrote: >Hi, > >I could not find any examples using the scene graph nodes in openglcontext 2.0. All of the >examples found in tests/ seem to only show how to use direct opengl calls. None of the examples i >looked at showed how to work with the scene graph nodes. > >How do i do something simple like: create a new group, transform, and model, and then render it? >I am expecting it would work something like... > >from OpenGLContext.scenegraph.basenodes import * >BaseContext, MainFunction = testingcontext.getInteractive() > >g = Group() >t = Transform() >geo = Box() > >t.tranform(1,2,3) > >g.addChildren(t) >t.addChildren(geo) > >viewer = BaseContext >viewer.setSceneGraphData(g) >MainFunction(viewer) > > >-brett > > _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |
From: brett h. <bha...@ya...> - 2004-03-30 01:22:10
|
Hi Mike, Is there a way to build the scenegraph *hierarchy* in a cleaner way? Your example has some crazy indentation going on. It would be nice to have it more DOM like, ie: node.appendChild(child) thanks, -brett --- "Mike C. Fletcher" <mcf...@ro...> wrote: > Samples using scenegraphs (directly instantiated, not loading from a file): > glelathe.py > indexedfaceset_lit_npf.py > indexedfaceset_lit_npv.py > mouseover.py > particles_simple.py > point_and_click.py > selectrendermode.py > simplerotate.py > wx_with_controls.py > > Most of the tests are actually using scenegraph nodes, they just don't > use the actual scenegraph *hierarchy*, as they are testing lower-level > functionality. OpenGLContext is strongly OO, it's not like VPython > where you create "script" modules. You get things done by sub-classing > the BaseContext (which is a class, not an instantiation of a class), > then overriding methods such as OnInit and getSceneGraph. > > Here's your expectation translated: > > #! /usr/bin/env python > from OpenGLContext import testingcontext > BaseContext, MainFunction = testingcontext.getInteractive() > from OpenGLContext.scenegraph.basenodes import * > > scene = sceneGraph( > children = [ > Group( > DEF = 'g', > children = [ > Transform( > DEF = 't', > translation = ( 1,2,3 ), > children = [ > Shape( > geometry = Box(), > # follows VRML97 standard, so normally > # want the material Node so that there > # will be lighting applied... > appearance=Appearance( > material = Material(), > ), > ), > ], > ), > ], > ), > ], > ) > class TestContext( BaseContext ): > def OnInit( self ): > self.sg = scene > def getSceneGraph( self ): > return self.sg > > if __name__ == "__main__": > MainFunction ( TestContext) > > I'll look at adding this kind of stuff to this page when I get a chance: > http://pyopengl.sourceforge.net/context/vrml97.html > since it's likely the "right" place for it. > > HTH, > Mike > > brett hartshorn wrote: > > >Hi, > > > >I could not find any examples using the scene graph nodes in openglcontext 2.0. All of the > >examples found in tests/ seem to only show how to use direct opengl calls. None of the > examples i > >looked at showed how to work with the scene graph nodes. > > > >How do i do something simple like: create a new group, transform, and model, and then render > it? > >I am expecting it would work something like... > > > >from OpenGLContext.scenegraph.basenodes import * > >BaseContext, MainFunction = testingcontext.getInteractive() > > > >g = Group() > >t = Transform() > >geo = Box() > > > >t.tranform(1,2,3) > > > >g.addChildren(t) > >t.addChildren(geo) > > > >viewer = BaseContext > >viewer.setSceneGraphData(g) > >MainFunction(viewer) > > > > > >-brett > > > > > _______________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://members.rogers.com/mcfletch/ > > __________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html |
From: Mike C. F. <mcf...@ro...> - 2004-03-30 03:03:52
|
Sure, append to the children... t.children.append( someShape ) HTH, Mike brett hartshorn wrote: >Hi Mike, > >Is there a way to build the scenegraph *hierarchy* in a cleaner way? >Your example has some crazy indentation going on. It would be nice to have it more DOM like, ie: >node.appendChild(child) > >thanks, >-brett > > _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |