ipymd.visualise.opengl package¶
Subpackages¶
- ipymd.visualise.opengl.postprocessing package
- ipymd.visualise.opengl.renderers package
- Subpackages
- Submodules
- ipymd.visualise.opengl.renderers.atom module
- ipymd.visualise.opengl.renderers.base module
- ipymd.visualise.opengl.renderers.box module
- ipymd.visualise.opengl.renderers.hexagon module
- ipymd.visualise.opengl.renderers.line module
- ipymd.visualise.opengl.renderers.point module
- ipymd.visualise.opengl.renderers.sphere module
- ipymd.visualise.opengl.renderers.sphere_imp module
- ipymd.visualise.opengl.renderers.triangle module
- ipymd.visualise.opengl.renderers.triangles module
- Module contents
Submodules¶
ipymd.visualise.opengl.buffers module¶
ipymd.visualise.opengl.camera module¶
Module to provide a nice camera for 3d applications
-
class
ipymd.visualise.opengl.camera.
Camera
[source]¶ Our viewpoint on the 3D world. The Camera class can be used to access and modify from which point we’re seeing the scene.
It also handle the projection matrix (the matrix we apply to project 3d points onto our 2d screen).
-
position
¶ Type: np.ndarray(3, float) Default: np.array([0.0, 0.0, 5.0]) The position of the camera. You can modify this attribute to move the camera in various directions using the absoule x, y and z coordinates.
-
a, b, c
Type: np.ndarray(3), np.ndarray(3), np.ndarray(3) dtype=float Default: a: np.ndarray([1.0, 0.0, 0.0]) b: np.ndarray([0.0, 1.0, 0.0]) c: np.ndarray([0.0, 0.0, -1.0]) Those three vectors represent the camera orientation. The
a
vector points to our right, theb
points upwards andc
in front of us.By default the camera points in the negative z-axis direction.
-
pivot
¶ Type: np.ndarray(3, dtype=float) Default: np.array([0.0, 0.0, 0.0]) The point we will orbit around by using
Camera.orbit_x()
andCamera.orbit_y()
.
-
matrix
¶ Type: np.ndarray((4,4), dtype=float) Camera matrix, it contains the rotations and translations needed to transform the world according to the camera position. It is generated from the
a
,``b``,``c`` vectors.
-
projection
¶ Type: np.ndarray((4, 4),dtype=float) Projection matrix, generated from the projection parameters.
-
z_near, z_far
Type: float, float Near and far clipping planes. For more info refer to: http://www.lighthouse3d.com/tutorials/view-frustum-culling/
-
fov
¶ Type: float field of view in degrees used to generate the projection matrix.
-
aspectratio
¶ Type: float Aspect ratio for the projection matrix, this should be adapted when the application window is resized.
-
autozoom
(points)[source]¶ Fit the current view to the correct zoom level to display all points.
The camera viewing direction and rotation pivot match the geometric center of the points and the distance from that point is calculated in order for all points to be in the field of view. This is currently used to provide optimal visualization for molecules and systems
Parameters
- points: np.ndarray((N, 3))
- Array of points.
-
matrix
-
mouse_rotate
(dx, dy)[source]¶ Convenience function to implement the mouse rotation by giving two displacements in the x and y directions.
-
mouse_zoom
(inc)[source]¶ Convenience function to implement a zoom function.
This is achieved by moving
Camera.position
in the direction of theCamera.c
vector.
-
orbit_x
(angle)[source]¶ Same as
orbit_y()
but the axis of rotation is theCamera.b
vector.We rotate around the point like if we sit on the side of a salad spinner.
-
orbit_y
(angle)[source]¶ Orbit around the point
Camera.pivot
by the angle angle expressed in radians. The axis of rotation is the camera “right” vector,Camera.a
.In practice, we move around a point like if we were on a Ferris wheel.
-
projection
-
restore
(state)[source]¶ Restore the camera state, passed as a state dictionary. You can obtain a previous state from the method Camera.state.
-
state
()[source]¶ Return the current camera state as a dictionary, it can be restored with Camera.restore.
-
unproject
(x, y, z=-1.0)[source]¶ Receive x and y as screen coordinates and returns a point in world coordinates.
This function comes in handy each time we have to convert a 2d mouse click to a 3d point in our space.
Parameters
- x: float in the interval [-1.0, 1.0]
- Horizontal coordinate, -1.0 is leftmost, 1.0 is rightmost.
- y: float in the interval [1.0, -1.0]
- Vertical coordinate, -1.0 is down, 1.0 is up.
- z: float in the interval [1.0, -1.0]
- Depth, -1.0 is the near plane, that is exactly behind our screen, 1.0 is the far clipping plane.
Return type: np.ndarray(3,dtype=float) Returns: The point in 3d coordinates (world coordinates).
-
ipymd.visualise.opengl.qchemlabwidget module¶
ipymd.visualise.opengl.qtviewer module¶
ipymd.visualise.opengl.shaders module¶
-
ipymd.visualise.opengl.shaders.
compileShader
(source, shaderType)[source]¶ Compile shader source of given type
source – GLSL source-code for the shader shaderType – GLenum GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc,
returns GLuint compiled shader reference raises RuntimeError when a compilation failure occurs
ipymd.visualise.opengl.textures module¶
Texture data structures