| |
- object
-
- ViewPlatform
class ViewPlatform(object) |
|
Mobile Viewing Platform
The ViewPlatform is, loosely speaking, a camera which
sets up the projection and model-view matrices for
an OpenGLContext scene.
Most Context's will have an associated ViewPlatform
thanks to the ViewPlatformMixIn class, which
instantiates the ViewPlatform. Shadow-rendering
Context's will actually use a subclass which
generates "infinite" perspective views required by
the particular stencil-buffer shadowing algorithm.
See:
OpenGLContext.viewplatformmixin.ViewPlatformMixIn
OpenGLContext.shadow.shadowcontext.InfViewPlatform
Attributes:
frustum -- OpenGL-friendly storage of frustum values,
(field of view, aspect ratio, near, far)
position -- object-space position of the viewing
platform, a four-component array
quaternion -- quaternion representing the current
view-orientation for the viewing platform |
|
Methods defined here:
- __init__(self, position=(0, 0, 10), orientation=(0, 1, 0, 0), fieldOfView=1.0471975511965976, aspect=1.0, near=0.01, far=1000)
- Initialize the ViewPlatform
position -- 3D coordinate position of the "camera"
orientation -- VRML97-style 4-component orientation,
that is, axis as three floats followed by radian
rotation as a single float.
fieldOfView -- radian angle field of view
aspect -- float aspect ratio of window, width/height
near -- object-space distance to the near clipping plane
far -- object-space distance to the far clipping plane
- forward(self, distance=0.25)
- Move the platform "forward" in the view direction
That is, the camera moves into the scene by the given
distance.
- getNearFar(self)
- Return the near and far frustum depths
This method isn't actually used in OpenGLContext,
as I use gluUnProject, which uses the information as
encoded in the perspective matrix. There are, however,
instances where knowing the near and far clipping planes
is useful.
Returns the near and far values as set by the
setFrustum method, the last two components of the
self.frustum attribute.
- moveRelative(self, x=0.0, y=0.0, z=0.0)
- Move platform to a position relative to the current position
x,y,z -- float vector along which to be moved from
the current position within the camera orientation
- render(self, mode=None)
- Perform the actual view-platform setup during rendering
This is really quite a trivial function, given the
amount of setup that's been done before-hand. The
gluPerspective function takes care of the perspective-
matrix setup, while self.quaternion (Quaternion)
takes care of the rotation, and positioning is a
simple call to glTranslate.
See:
gluPerspective
OpenGLContext.shadow.shadowcontext.InfViewPlatform
OpenGLContext.shadow.pinfperspective -- alternate
gluPerspective implementation for shadowing contexts
- setFrustum(self, fieldOfView=1.5707963267948966, aspect=1, near=0.01, far=1000)
- Set the current frustum values for the "camera"
fieldOfView -- radian angle field of view
aspect -- float aspect ratio of window, width/height
near -- object-space distance to the near clipping plane
far -- object-space distance to the far clipping plane
- setOrientation(self, orientation)
- Set the current "camera orientation"
orientation -- VRML97-style 4-component orientation,
that is, axis as three floats followed by radian
rotation as a single float.
Alternately, a quaternion.Quaternion instance
representing the orientation. Note that the
orientation will likely be 180 degrees from
what you expect, this method reverses the
rotation value when passed a VRML97-style
orientation.
- setPosition(self, position)
- Set the current "camera position"
position -- 3D coordinate position to which to
teleport the "camera"
- setViewport(self, x, y)
- Set the current viewport/window dimensions
x,y -- integer width and height (respectively) of the window
This method simply updates the frustum attribute to reflect
the new aspect ratio.
- straighten(self)
- Re-orient the camera so the horizon is "level"
Commonly needed after a few camera-relative orientation
changes have built up. This method creates a new
orientation which is solely rotated about the y-axis,
that is, where the camera-relative horizon matches the
object-space horizon.
- turn(self, deltaOrientation=(0, 1, 0, 0.78539816339744828))
- Apply rotation within the current orientation
In essence, this allows you to "turn your head"
which gives you the commonly useful ability to
function from your own frame of reference.
For example:
turn( 1,0,0,angle ) will rotate the camera up
from its current view orientation
turn( 0,1,0,angle ) will rotate the camera about
the current horizon
This method is implemented almost entirely within
the quaternion class. Quaternion's have considerable
advantages for this type of work, as they do not
become "warped" with successive rotations.
Data and non-method functions defined here:
- __dict__ = <dict-proxy object at 0x07687180>
- __doc__ = 'Mobile Viewing Platform\n\n\tThe ViewPlatform is, l...nt\n\t\t\tview-orientation for the viewing platform\n\t'
- __module__ = 'OpenGLContext.viewplatform'
- __weakref__ = <member '__weakref__' of 'ViewPlatform' objects>
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
| |