wolfhece.opengl.py3d
Author: HECE - University of Liege, Pierre Archambeau Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.
Module Contents
- wolfhece.opengl.py3d.print_program_resource_names(program, verbose=False)[source]
Print the active resources in the program
- class wolfhece.opengl.py3d.Cache_WolfArray_plot3D(parent: WolfArray_plot3D, context: wx.glcanvas.GLContext, canvas: CanvasOGL, idx: int = 0)[source]
Cache for the WolfArray_plot3D class
A cache is created for each canvas. The cache is responsible for the OpenGL resources associated to context.
- class wolfhece.opengl.py3d.WolfArray_plot3D(quad_centers: numpy.ndarray, dx: float = 1.0, dy: float = 1.0, origx: float = 0.0, origy: float = 0.0, zscale: float = 0.0, ztexture: numpy.ndarray = None, color_palette: numpy.ndarray = None, color_values: numpy.ndarray = None)[source]
Class to plot data in 3D viewer
reference for texture 2D : https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml
OPENGL
The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image,
and then in successively higher rows of the texture image.
The final element corresponds to the upper right corner of the texture image.
- void glTexImage2D( GLenum target,
GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * data);
NUMPY
shape[0] is the number of rows and shape[1] is the number of columns.
- The “data” buffer is row-major order or column-major order, depending on the value of the order parameter.
row-major order : C order
column-major order : ‘F’ order (Fortran)
- So, in row-major order :
OpenGL Texture width = shape[1]
OpenGL Texture height = shape[0]
- and in column-major order :
OpenGL Texture width = shape[0]
OpenGL Texture height = shape[1]
++ IMPORTANT
We assume that if data is row-major order, the indexing [i,j] is (y, x) and if data is column-major order, the indexing is (x, y)
- Example :
array[m,n] in row-major order is the element at the coordinate (n * dx + dx/2. + origx, m * dy + dy/2. + origy)
array[m,n] in column-major order is the element at the coordinate (m * dx + dx/2. + origx, n * dy + dy/2. + origy)
- So:
the data buffer is the same as it is contiguous in memory. We ** don’t need to transpose ** the data buffer.
Transposition is done by changing the indexing convention.
“texture” calls in shaders is the same for both row-major and column-major order.
– IMPORTANT
- property cache: Cache_WolfArray_plot3D[source]
- class wolfhece.opengl.py3d.CanvasOGL(parent)[source]
Bases:
wx.glcanvas.GLCanvas
- add_array(name: str, array: WolfArray_plot3D)[source]
Add an array to the canvas
- intersect_ray_plane(ray_direction, plane_point)[source]
Calculer l’intersection entre un rayon et un plan horizontal
- intersect_ray_quad(ray_direction, quad_lowerleft, quad_upperright)[source]
Calculer l’intersection entre un rayon et un quad
- rotate_z_center(angle)[source]
Rotate the camera around the z axis, passing at center, by angle degrees
- rotate_x_center(angle)[source]
Rotate the camera around the x axis, passing at center, by angle degrees
- rotate_y_center(angle)[source]
Rotate the camera around the y axis, passing at center, by angle degrees
- add_move_rotation(angle: float, axis: glm.vec3, center: glm.vec3)[source]
Add a rotation to the list of moves
- class wolfhece.opengl.py3d.Wolf_Viewer3D(parent, title)[source]
Bases:
wx.Frame
- add_array(name: str, array: WolfArray_plot3D)[source]
Add an array to the canvas