This module provides a 3D graphics scene graph structure.
Primitive displaying a text field in the scene.
This module provides classes to handle a perspective projection in 3D.
Transform matrix to handle camera position and orientation.
Parameters: |
|
---|
Set the rotation of the point of view.
Parameters: |
|
---|---|
Raises RuntimeError: | |
if the direction and up are parallel. |
Move the camera relative to the image plane.
Parameters: |
|
---|
First-person rotation of the camera towards the direction.
Parameters: |
|
---|
Rotate the camera around a point.
Parameters: |
|
---|
Combination of camera projection and position.
See Perspective and CameraExtrinsic.
Parameters: |
|
---|
Change camera to have the bounds in the viewing frustum.
It updates the camera position and depth extent. Camera sight direction and up are not affected.
Parameters: | bounds (numpy.ndarray: ((xMin, yMin, zMin), (xMax, yMax, zMax))) – The axes-aligned bounds to include. |
---|
This module provides the base scene structure.
This module provides the classes for describing a tree structure with rendering and picking API. All nodes inherit from Base. Nodes with children are provided with PrivateGroup and Group classes. Leaf rendering nodes should inherit from Elem.
A scene node with common features.
Visibility flag of the node
True to make node pickable
Tuple of scene nodes, from the tip of the tree down to this node.
If this tree is attached to a Viewport, then the Viewport is the first element of path.
Transform from object to normalized device coordinates.
Do not forget perspective divide.
Transform from object to scene.
Combine transforms up to the Viewport (not including it).
Returns the bounds of this node aligned with the axis, with or without transform applied.
Parameters: |
|
---|---|
Returns: | The bounds: ((xMin, yMin, zMin), (xMax, yMax, zMax)) or None if no bounds. |
Return type: | numpy.ndarray of float |
Called before the rendering to prepare OpenGL resources.
Override in subclass.
A cut plane in a 3D texture: hackish implementation...
A 3D mesh with color from a 3D texture.
This module provides a simple generic notification system.
Base class for object with notification mechanism.
Register a listener.
Adding an already registered listener has no effect.
Parameters: | listener (callable) – The function or method to register. |
---|
Create a property that adds notification to an attribute.
Parameters: |
|
---|---|
Returns: | A property with getter and setter |
This module provides functions to add to shaders.
Class providing a function to add to a GLProgram shaders.
Description of a clipping plane and rendering.
Convention: Clipping is performed in camera/eye space.
Parameters: |
|
---|
Description of a directional Phong light.
Parameters: |
|
---|
This module provides interaction to plug on the scene graph.
Click or drag interaction for a given button.
Camera rotation using an arcball-like interaction.
Picking on click and pan camera on drag.
StateMachine like class, just handling wheel events.
Manages focus across multiple event handlers
On press an event handler can acquire focus. By default it looses focus when all buttons are released.
Combine wheel, selectPan and rotate state machine.
Plane rotation using arcball interaction.
Arcball ref.: Ken Shoemake. ARCBALL: A user interface for specifying three-dimensional orientation using a mouse. In Proc. GI ‘92. (1992). pp. 151-156.
Pan a plane along its normal on drag.
Set of vertices with normals and colors.
Parameters: |
|
---|
Returns the number of vertices of current attributes.
It returns None if there is no attributes.
Set attribute with provided array.
Parameters: |
|
---|
Returns the numpy.ndarray corresponding to the name attribute.
Parameters: |
|
---|---|
Returns: | The corresponding array or None if no corresponding attribute. |
Return type: | numpy.ndarray |
Enable and bind attribute(s) for a specific program.
This MUST be called with OpenGL context active and after prepareGL2 has been called.
Parameters: |
|
---|
A set of segments
Width of the line in pixels.
Smooth line rendering enabled (bool, default: True)
Set of dashed lines
This MUST be defined as a set of lines (no strip or loop).
Rectangular box
Rectangular box with RGB OX, OY, OZ axes
Parameters: | color – RGBA color of the box |
---|
A plane using its parent bounds to display a contour.
If plane is outside the bounds of its parent, it is not visible.
Cannot set the transform attribute of this primitive. This primitive never has any bounds.
A set of data points with an associated value and size.
A set of points with an associated color and size.
Data points on a regular grid with an associated value and size.
A set of spheres.
Spheres are rendered as circles using points. This brings some limitations: - Do not support non-uniform scaling. - Assume the projection keeps ratio. - Do not render distorion by perspective projection. - If the sphere center is clipped, the whole sphere is not displayed.
A conventional 3D mesh
A group using 2-pass rendering and glDepthRange to avoid Z-fighting
Primitive displaying a text field in the scene.
Description of a font.
Parameters: |
|
---|
Name of the font (str)
Font size in points (int)
Font size in points (int)
True for italic (bool)
Text field as a 2D texture displayed with bill-boarding
Parameters: |
|
---|
RGBA color of the text: 4 float in [0, 1]
RGBA background color of the text field: 4 float in [0, 1]
True to always display text on top of the scene (default: False)
Horizontal anchor position of the text field (str).
Either ‘left’ (default), ‘center’ or ‘right’.
Vertical anchor position of the text field (str).
Either ‘top’, ‘baseline’ (default), ‘center’ or ‘bottom’
This module provides 4x4 matrix operation and classes to handle them.
Creates matrix to look in direction from position.
Parameters: |
|
---|---|
Returns: | Corresponding matrix. |
Return type: | numpy.ndarray of shape (4, 4) |
Creates matrix to look at center from position.
See gluLookAt.
Parameters: |
|
---|---|
Returns: | Corresponding matrix. |
Return type: | numpy.ndarray of shape (4, 4) |
Creates a frustum projection matrix.
See glFrustum.
Creates a perspective projection matrix.
Similar to gluPerspective.
Parameters: |
|
---|---|
Returns: | Corresponding matrix. |
Return type: | numpy.ndarray of shape (4, 4) |
Creates an orthographic (i.e., parallel) projection matrix.
See glOrtho.
4x4 rotation matrix from angle and axis.
Parameters: |
|
---|
4x4 rotation matrix from quaternion.
Parameters: | quaternion – Array-like unit quaternion stored as (x, y, z, w) |
---|
4x4 shear matrix: Skew two axes relative to a third fixed one.
shearFactor = tan(shearAngle)
Parameters: |
|
---|
Transform which is the inverse of another one.
Static: It never gets updated.
Transform that is a snapshot of a list of Transforms
It does not keep reference to the list of Transforms.
Parameters: | iterable – Iterable of Transform used for initialization |
---|
4x4 translation matrix.
Orthographic (i.e., parallel) projection which keeps aspect ratio.
Clipping planes are adjusted to match the aspect ratio of the size attribute.
The left, right, bottom and top parameters defines the area which must always remain visible. Effective clipping planes are adjusted to keep the aspect ratio.
Parameters: |
|
---|
Set the clipping planes of the projection.
Parameters are adjusted to keep aspect ratio. If a clipping plane coord is not provided, it uses its current value
Parameters: |
|
---|
Coord of the left clipping plane.
Coord of the right clipping plane.
Coord of the bottom clipping plane.
Coord of the top clipping plane.
Orthographic projection with pixel as unit.
Provides same coordinates as widgets: origin: top left, X axis goes left, Y axis goes down.
Parameters: |
|
---|
Perspective projection matrix defined by FOV and aspect ratio.
Parameters: |
|
---|
This module provides functions to generate indices, to check intersection and to handle planes.
Generates lines indices from triangle indices.
This is generating lines indices for the edges of the triangles.
Parameters: |
|
---|---|
Returns: | The indices to draw the edges of the triangles as lines. |
Return type: | 1D numpy.ndarray of uint16 or uint32. |
Return vertices of lines representing normals at given positions.
Parameters: |
|
---|---|
Returns: | Array of vertices to draw corresponding lines. |
Return type: | numpy.ndarray with shape: (nbPoints * 2, 3) |
Convert indexed GL primitives to unindexed ones.
Given indices in arrays and the OpenGL primitive they represent, return the unindexed equivalent.
Parameters: |
|
---|---|
Returns: | Converted arrays |
Return type: | tuple of numpy.ndarray |
Return normal for each triangle.
Parameters: | positions (numpy.ndarray of shape (NbTriangles*3, 3)) – Serie of triangle’s corners |
---|---|
Returns: | Normals corresponding to each position. |
Return type: | numpy.ndarray of shape (NbTriangles, 3) |
Generate an array of 2D positions from 2 arrays of 1D coordinates.
Parameters: |
|
---|---|
Returns: | Array of grid coordinates. |
Return type: | numpy.ndarray with shape: (len(dim0Array), len(dim1Array), 2) |
Generate indices to draw a grid of vertices as a triangle strip.
Vertices are expected to be stored as row-major (i.e., C contiguous).
Parameters: |
|
---|---|
Returns: | The vertex indices |
Return type: | 1D numpy.ndarray of uint32 |
Generate indices to draw a grid of vertices as lines.
Vertices are expected to be stored as row-major (i.e., C contiguous).
Parameters: |
|
---|---|
Returns: | The vertex indices. |
Return type: | 1D numpy.ndarray of uint32 |
Return the angle between 2 vectors.
Parameters: |
|
---|---|
Returns: | The angles in radians in [0, pi] if norm is None else in [0, 2pi]. |
Return type: | float or numpy.ndarray of shape (NbVectors,) |
Compute the intersection of a segment with a plane.
Parameters: |
|
---|---|
Returns: | The intersection points. The number of points goes from 0 (no intersection) to 2 (segment in the plane) |
Return type: | list of numpy.ndarray |
Return intersection points between a box and a plane.
Parameters: |
|
---|---|
Returns: | The found intersection points |
Return type: | numpy.ndarray with 2 dimensions |
Object handling a plane and notifying plane changes.
Parameters: |
|
---|
This module provides a class to control a viewport on the rendering window.
The Viewport describes a Viewport rendering a scene. The attribute scene is the root group of the scene tree. RenderContext handles the current state during rendering.
Handle a current rendering context.
An instance of this class is passed to rendering method through the scene during render.
User should NEVER use an instance of this class beyond the method it is passed to as an argument (i.e., do not keep a reference to it).
Parameters: |
|
---|
Push a Transform on the transform stack.
Parameters: |
|
---|
Rendering a single scene through a camera in part of a framebuffer.
Parameters: | framebuffer (int) – The framebuffer ID this viewport is rendering into |
---|
Shape (height, width) of the viewport in pixels.
This is a convenient wrapper to the inverse of size.
Perform the rendering of the viewport
Parameters: | glContext (Context) – The context used for rendering |
---|
Update camera depth extent to fit the scene bounds.
Only near and far planes are updated. The scene might still not be fully visible (e.g., if spanning behind the viewpoint with perspective projection).
Change camera to have the whole scene in the viewing frustum.
It updates the camera position and depth extent. Camera sight direction and up are not affected.
Rotate the camera around center of the scene.
Parameters: |
|
---|
Move the camera relative to the image plane.
Parameters: |
|
---|
Convert position from window to normalized device coordinates.
If window coordinates are int, they are moved half a pixel to be positioned at the center of pixel.
Parameters: |
|
---|---|
Returns: | (x, y) Normalize device coordinates in [-1, 1] or None. Origin center, x to the right, y goes upward. |
Convert position from normalized device coordinates (NDC) to window.
Parameters: |
|
---|---|
Returns: | (x, y) window coordinates or None. Origin top-left, x to the right, y goes downward. |
This module provides a class for Viewports rendering on the screen.
The Window renders a list of Viewports in the current framebuffer. The rendering can be performed in an off-screen framebuffer that is only updated when the scene has changed and not each time Qt is requiring a repaint.
The Context and ContextGL2 represent the operating system OpenGL context and handle OpenGL resources.
Correspond to an operating system OpenGL context.
User should NEVER use an instance of this class beyond the method it is passed to as an argument (i.e., do not keep a reference to it).
Parameters: | glContextHandle – System specific OpenGL context handle. |
---|
Set the state of the OpenGL context to reflect OpenGL state.
This should not be called from the scene graph, only in the wrapper that handle the OpenGL context to reflect its state.
Parameters: | isCurrent (bool) – The state of the system OpenGL context. |
---|
Handle a system GL2 context.
User should NEVER use an instance of this class beyond the method it is passed to as an argument (i.e., do not keep a reference to it).
Parameters: | glContextHandle – System specific OpenGL context handle. |
---|
Cache program within context.
WARNING: No clean-up.
Create a VBO in this context with the data.
Current limitations:
Automatically discards the VBO when the returned VertexBuffer istance is deleted.
Parameters: |
|
---|---|
Returns: | The VertexBuffer created in this context. |
Create a VBO from data and returns the associated VBOAttrib.
Automatically discards the VBO when the returned VBOAttrib istance is deleted.
Parameters: |
|
---|---|
Returns: | A VBOAttrib instance created in this context. |
OpenGL Framebuffer where to render viewports
Parameters: | mode (str) – Rendering mode to use:
|
---|
Shape (height, width) of the window in pixels.
This is a convenient wrapper to the reverse of size.
Framebuffer ID used to perform rendering