| | |
- ViewPlatformMixin
class ViewPlatformMixin |
| |
Mix-in for Context classes providing ViewPlatform support
The viewplatform module provides a ViewPlatform object
which provides generic "camera" support for OpenGLContext.
This mix-in provides Context classes with automatic support
for instantiating and using these objects. In particular,
it overrides the Viewpoint customization point, dispatching
the call to the platform's render method.
In addition, the ViewPlatformMixin includes support for the
view-platform-specific examine manager (which rotates the
view platform about an object-space center).
The getViewPlatform method performs the actual instantiation
of the ViewPlatform, which allows a sub-classes to use
different view-platform classes with minimal interference.
Finally, the ViewPlatformMixin performs "default" registration
of various event handlers using the setupDefaultEventCallbacks
customization point. These provide the default navigation
controls for OpenGLContext Contexts.
Attributes:
platform -- the view platform instantiated by the
context, or None if there is not yet a view
platform instantiated (the platform is normally
instantiated during the first rendering pass)
initialPosition -- the initial view position used
by the platform.
See: ViewPlatform.setPosition
initialOrientation -- the initial view orientation
used by the platform.
See: ViewPlatform.setOrientation
STEPDISTANCE -- relative distance that each forward/
backward/left/right step should move the camera,
single float value.
TURNANGLE -- relative rotational distance that each
"turn" should rotate the camera, single float
value in radians. |
| |
Methods defined here:
- ViewPort(self, width, height)
- Set the size of the OpenGL rendering viewport for the context
Because the ViewPlatform provide support for
"constant aspect ratio" in scenes, it is necessary
to keep the ViewPlatform updated regarding the current
aspect ratio of the ViewPort. This implementation
merely calls the platform's setViewport, then
calls the super-class ViewPort method.
XXX
Unfortunately, because Context objects may be
old-style classes, we can't use super(), so
this implementation actually calls
context.Context.ViewPort directly.
- Viewpoint(self, mode=None)
- Customization point: Sets up the projection matrix
This implementation potentially instantiates the
view platform object, and then calls the object's
render method with the mode as argument.
- backward(self, event)
- (callback) Move platform backward by STEPDISTANCE
triggers redraw after completion
- down(self, event)
- (callback) Move platform downward by STEPDISTANCE
triggers redraw after completion
- forward(self, event)
- (callback) Move platform forward by STEPDISTANCE
triggers redraw after completion
- getViewPlatform(self)
- Customization Point: Instantiate ViewPlatform for this context
The default implementation is to instantiate a
viewplatform.ViewPlatform with position equal to
self.initialPosition and orientation equal to
self.initialOrientation.
See:
OpenGLContext.shadow.shadowcontext for
example where this method is overridden
- left(self, event)
- (callback) Move platform left by STEPDISTANCE
triggers redraw after completion
- right(self, event)
- (callback) Move platform right by STEPDISTANCE
triggers redraw after completion
- setupDefaultEventCallbacks(self)
- Customization point: Setup application default callbacks
This method binds a large number of callbacks which support
the OpenGLContext default camera-manipulation modes. In
particular:
* unmodified arrow keys for x,z (in camera coordinate
space) movement
* Alt+arrow keys for x,y (in camera coordinate space)
movement
* Ctrl+up/down arrow keys for rotating the head backward/
forward
* Mouse-button-2 (right) for entering "examine" mode
* '-' for straightening the view platform
- startExamineMode(self, event)
- (callback) Create an examine mode interaction manager
This callback creates an instance of
examinemanager.ExamineManager, which will manage
the user interaction during an "examination" of
the scene.
XXX
Currently the "center" determination is broken,
so rotation tends to occur around random points.
I haven't yet figured out why :(
- straighten(self, event)
- (callback) Straightens the platform orientation
Attempts to make the orientation equal to the
y-axis orientation of the current orientation.
In other words, tries to make the camera's horizon
equal to the object-space horizon (the x,z plane)
without altering the y-axis orientation.
See:
OpenGLContext.viewplatform.ViewPlatform.straighten
triggers redraw after completion
- turndown(self, event)
- (callback) Rotates "head" forward (looks downward) by TURNANGLE
triggers redraw after completion
- turnleft(self, event)
- (callback) Rotates "head" to the left by TURNANGLE
triggers redraw after completion
- turnright(self, event)
- (callback) Rotates "head" to the right by TURNANGLE
triggers redraw after completion
- turnup(self, event)
- (callback) Rotates "head" backward (looks upward) by TURNANGLE
triggers redraw after completion
- up(self, event)
- (callback) Move platform upward by STEPDISTANCE
triggers redraw after completion
Data and non-method functions defined here:
- STEPDISTANCE = 0.25
- TURNANGLE = 0.098174770424681035
- __doc__ = 'Mix-in for Context classes providing ViewPlatfor...e the camera, single float\n\t\t\tvalue in radians.\n\t'
- __module__ = 'OpenGLContext.viewplatformmixin'
- initialOrientation = (0, 1, 0, 0)
- initialPosition = (0, 0, 10)
- platform = None
- slider = None
| |