| | |
- OpaqueRenderPass(VisitingRenderPass)
-
- OpaqueRenderPass
- TransparentRenderPass(RenderPass)
-
- TransparentRenderPass
class OpaqueRenderPass(OpaqueRenderPass) |
| |
Opaque rendering pass for gl2ps |
| |
- Method resolution order:
- OpaqueRenderPass
- OpaqueRenderPass
- VisitingRenderPass
- RenderPass
- RenderVisitor
- Visitor
- object
Methods defined here:
- ContextRenderSetup(self, node)
- Set up the context for rendering prior to scene rendering
Only diff from base class is _not_ setting mode to GL_RENDER
- SceneGraphBackground(self, node)
- Don't draw a background
The background objects draw themselves about 1m from
the viewer's eye, so they tend to entirely obscure the
scene.
- shouldDraw(self)
- Always want to draw when we invoke the exporter
Data and non-method functions defined here:
- __doc__ = 'Opaque rendering pass for gl2ps'
- __module__ = 'OpenGLContext.gl2psrenderpass'
Data and non-method functions inherited from OpaqueRenderPass:
- lighting = 1
- selectNames = 0
- transform = 1
- transparent = 0
- visible = 1
Methods inherited from VisitingRenderPass:
- __call__(self)
- Do the rendering pass
Visits the context and all of its children if the
shouldDraw method returns a true value.
Returns self.visible if the visiting sequence
occurred, otherwise returns 0
- children(self, node)
- Get children to visit for a node
Adds (experimental, slow, and currently incorrect)
frustum-culling check to filter out children who
are not within the frustum. Will only be enabled
if the context defines a true attribute:
USE_FRUSTUM_CULLING
Data and non-method functions inherited from VisitingRenderPass:
- frustum = None
- frustumCulling = -1
Methods inherited from RenderPass:
- OnInit(self)
- Initialization customization point
- __getattr__(self, key)
- Defer to the overall pass on attribute lookup failure
- __init__(self, overall, passCount=0)
- Initialise the per-mode render-pass object
overall -- the OverallPass instance which is driving
this RenderPass instance. Attributes of the
OverallPass are made available via the __getattr__
hook.
passCount -- the index of this pass within the
OverallPass, an integer representing the
number of passes which have come before us.
The initializer calls OnInit when it is finished
to allow for easy sub-class customization.
Data and non-method functions inherited from RenderPass:
- __dict__ = <dict-proxy object at 0x0716AB88>
- __weakref__ = <member '__weakref__' of 'RenderPass' objects>
- cache = None
- lightingAmbient = 1
- lightingDiffuse = 1
- selectForced = 0
- stencil = 0
Methods inherited from RenderVisitor:
- Context(self, node)
- Render the Context object
calls:
ContextRenderSetup(node)
ContextSetupDisplay(node)
ContextSetupBindables(node)
- ContextSetupBindables(self, node)
- Set up the bindable objects (viewpoints, backgrounds, lights)
If the Context object has a non-null scenegraph, as
returned by getSceneGraph(), then this method will
do nothing, as the scenegraph will be responsible for
setting up the bindable nodes.
If the Context does not have the scenegraph, then we
look for a Context.SetupBindables method, and call
that with context.SetupBindables(self)
If the Context does not have a SetupBindables method
or a scenegraph, we call:
context.Viewpoint ( self )
context.Background( self )
context.Lights ( self )
- ContextSetupDisplay(self, node)
- Establishes rendering parameters for context's rendering pass
This method runs even when there is a scenegraph
(Re-)establishes common rendering parameters which
may have been left in unexpected states. If the Context
object has a SetupDisplay method, we call that. Otherwise
we enable depth testing, set the depth test to GL_LESS,
enable face-culling, and set face-culling to cull back-faces.
- Grouping(self, node)
- Render a grouping node, return a finalisation token
Grouping notes are primarily of interest during selection
rendering passes, where they push and pop names on the
OpenGL name stack. There are a number of selection-specific
attributes on the RenderPass object which determine whether
or not an individual Grouping node's name is pushed onto
the stack.
Grouping nodes also keep track of their individual
"sensitivity" (by monitoring whether or not they have a
mouse-sensor child). Sensitive Grouping nodes alter the
RenderPass's selection-specific attributes to manipulate
their children's selection-mode rendering.
- Rendering(self, node)
- Render a rendering node (Shape)
At the moment, this just calls node.Render( self )
- SceneGraph(self, node)
- Render a scenegraph object (SetupBindables)
This method is only called if the Context returns
a non-null value from getSceneGraph(), as it only
is called when a Scenegraph instance is encountered.
If a Scenegraph is active, we do not use the code in
ContextSetupBindables, so the Scenegraph is responsible
for setting up all of the bindable nodes it wishes
to have rendered.
calls:
SceneGraphCamera(node)
SceneGraphLights(node)
SceneGraphBackground(node)
- SceneGraphCamera(self, node)
- Setup the camera/viewpoint from the scenegraph
XXX
At the moment, there is no Viewpoint support in
OpenGLContext, so this method merely calls the
Context's Viewpoint method.
- SceneGraphDefaultlight(self, lightID)
- Create the default headlight
VRML browsers generally have a default lighting scheme
where, if there are no lights in the scene, a headlight
is created pointing from the viewpoint forward into the scene.
The light paths found by the OverallPass are used to
transform the individual light objects to their appropriate
positions in the scene.
XXX
This code is not quite right, instead of creating
a headlight, it is just creating a simple light pointing
forward from 0,0,10. What we want is a light that always
points forward from the current viewpoint in the current
view direction.
- SceneGraphLights(self, node)
- Render lights for a scenegraph
The default implementation limits you to eight active
lights, despite the fact that many OpenGL renderers
support more than this. There have been problems with
support for calculating light IDs beyond eight, so I
have limited the set for now.
This method relies on the pre-scanning pass implemented
by the renderpass.OverallPass object. That is not
a particularly desirable dependency, but eliminating it
will likely be quite messy.
- Transform(self, node)
- Render a transform object, return a finalisation token
This method attempts to catch model-view matrix overflows
and gracefully handle them. It returns "tokens" which reset
the model-view matrix to the previous condition. This is
part of the Visitor API.
Note:
Most Transforming nodes are also Grouping nodes,
so both the Transform method and the Grouping method
will be run for those nodes.
- buildVMethods(self)
- Add scenegraph-package-specific class:method mappings
Data and non-method functions inherited from RenderVisitor:
- contextBaseClass = None
Methods inherited from Visitor:
- visit(self, node)
- Visit an individual node, dispatch to methods as necessary
The visiting algorithm is fairly involved compared
to the classic computer science Visitor algorithm.
First we call preVisit( node ), and if the
result of that is true, we continue processing.
This allows you to use preVisit to do such things
as processing every node in the scenegraph.
If we are visiting the node: (preVisit returned true)
* add the node to self.currentStack
* retrieve the "vmethods" for the node
* call each vmethod with the node as argument
o if the vmethod returns a finalization token
we store that token for finalization
* we determine the children to visit for the node
* for each child, we call visit recursively
* during finalization (after children are finished
processing)
o if we have any finalization tokens, we call
those tokens
o we call postVisit( node )
o we restore the previous self.currentStack
Note: this is the "production" version of visit
which only logs errors, not "info" level traces,
this avoids the 100's of 1000's of calls generated
by the huge number of iterations.
- vmethods(self, obj)
- Get all relevant "virtual methods" as unbound methods
Returns *all* registered vmethods for the classes in the
given object's class's __mro__
This version caches the unbound methods in a per-visitor-
class dictionary, which should make it at least a little
faster.
Class methods inherited from Visitor:
- addChildrenMethod(self, type, function) from type
- Register function for determining children for a given type
XXX
Methods are stored in the _childrenMethods dictionary,
which is currently class-static, I would rather this
were an instance variable, but that makes registration
something you need to do for every new instance, while
normally you only want to override for very special
sub-classes (I haven't yet discovered a case where I
want to do it).
Note:
This is currently a class method due to the class-
static nature!
Data and non-method functions inherited from Visitor:
- _childrenMethods = {}
Methods inherited from object:
- __delattr__(...)
- x.__delattr__('name') <==> del x.name
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __hash__(...)
- x.__hash__() <==> hash(x)
- __reduce__(...)
- helper for pickle
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setattr__(...)
- x.__setattr__('name', value) <==> x.name = value
- __str__(...)
- x.__str__() <==> str(x)
Data and non-method functions inherited from object:
- __class__ = <type 'type'>
- __new__ = <built-in method __new__ of type object at 0x1E0BD978>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class TransparentRenderPass(TransparentRenderPass) |
| |
Transparent rendering pass for gl2ps |
| |
- Method resolution order:
- TransparentRenderPass
- TransparentRenderPass
- RenderPass
- object
Methods defined here:
- ContextRenderSetup(self, node)
- Set up the context for rendering prior to scene rendering
We don't want to do anything at all here...
Data and non-method functions defined here:
- __doc__ = 'Transparent rendering pass for gl2ps'
- __module__ = 'OpenGLContext.gl2psrenderpass'
Methods inherited from TransparentRenderPass:
- ContextSetupDisplay(self, node)
- Establishes rendering parameters for the rendering pass
This particular transparent-geometry-rendering algorithm
uses glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),
which requires back-to-front sorting of geometry to
produce proper results. It is one of the most
reliable methods for producing transparent geometry
effects.
Note:
Although this is the same name as a customization point
for the RenderVisitor API, this object is not a
RenderVisitor. This method is called directly by the
__call__ method.
- ContextShutdown(self)
- Clears the transparency-specific rendering parameters
Called after the entire rendering pass has completed,
this method is responsible for "cleaning up" after the
transparent-rendering pass. It also clears the list
of transparent objects build up by the OpaqueRenderPass.
Note:
Although this is the same name as a customization point
for the RenderVisitor API, this object is not a
RenderVisitor. This method is called directly by the
__call__ method.
- Render(self, node)
- Render a shape node as transparent geometry
This method knows how to render a Shape node as transparent
geometry. Basically that consists of calling the geometry's
render method with transparent = 1
Note:
Although this is the same name as a customization point
for the RenderVisitor API, this object is not a
RenderVisitor. This method is called directly by the
__call__ method.
- __call__(self)
- Render all registered transparent objects
Objects are projected into screen coordinates,
sorted according to their local origin depth,
then rendered with the model view matrix active
at transparent-object registration (during the
OpaqueRenderPass).
See:
OverallPass.addTransparent
OverallPass.getTransparent
- shouldDraw(self)
- Checks to see if there are registered transparent objects
If there are none, then the entire pass will be skipped.
Data and non-method functions inherited from TransparentRenderPass:
- lighting = 1
- selectNames = 0
- transform = 0
- transparent = 1
- visible = 1
Methods inherited from RenderPass:
- OnInit(self)
- Initialization customization point
- __getattr__(self, key)
- Defer to the overall pass on attribute lookup failure
- __init__(self, overall, passCount=0)
- Initialise the per-mode render-pass object
overall -- the OverallPass instance which is driving
this RenderPass instance. Attributes of the
OverallPass are made available via the __getattr__
hook.
passCount -- the index of this pass within the
OverallPass, an integer representing the
number of passes which have come before us.
The initializer calls OnInit when it is finished
to allow for easy sub-class customization.
Data and non-method functions inherited from RenderPass:
- __dict__ = <dict-proxy object at 0x072F73F8>
- __weakref__ = <member '__weakref__' of 'RenderPass' objects>
- cache = None
- lightingAmbient = 1
- lightingDiffuse = 1
- selectForced = 0
- stencil = 0
Methods inherited from object:
- __delattr__(...)
- x.__delattr__('name') <==> del x.name
- __getattribute__(...)
- x.__getattribute__('name') <==> x.name
- __hash__(...)
- x.__hash__() <==> hash(x)
- __reduce__(...)
- helper for pickle
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setattr__(...)
- x.__setattr__('name', value) <==> x.name = value
- __str__(...)
- x.__str__() <==> str(x)
Data and non-method functions inherited from object:
- __class__ = <type 'type'>
- __new__ = <built-in method __new__ of type object at 0x1E0BD978>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
| |