Re: [PyOpenGL-Users] scene graph examples?
Brought to you by:
mcfletch
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/ |