wiki:GraphicsAPI

Version 5 (modified by Tom Goddard, 11 years ago) ( diff )

--

Graphics API

The Chimera 2 graphics API enables rendering of molecules and density maps. Here is some info on how Hydra is providing these interfaces.

Here are the Python classes in the Hydra graphics module (taken from graphics/init.py) that are used by other modules:

  • Drawing
  • View
  • Camera
  • Lighting
  • Material
  • Texture
  • Pick
  • Cross_Fade
  • Motion_Blur

These classes handle representing the scene, rendering it, and selecting parts of it. The "scene graph" is the geometric shapes, colors and transparency including hierarchy and instancing, also including the concept of selected part, all handled by the Drawing class. A Drawing can have any number of child Drawings, to any depth, in a tree. Some classes handle the rendering (View, Camera, Lighting, Cross_Fade, Motion_Blur) including effects like silhouette edges, shadows, ambient occlusion, depth cuing, cross fades, and also camera modes like mono, shutter glasses stereo, or oculus rift. Also image save including supersampling, the graphics redraw loop, and interactive center of rotation are managed by View. Selecting objects using a mouse click is handled by View and Drawing.

Private OpenGL classes

The Hydra graphics module also has many private classes like Render, Shader, Framebuffer, Bindings, ... that are lower level OpenGL Python classes. Those are not used outside the graphics module currently. All the OpenGL is in one file graphics/opengl.py wrapped to make the OpenGL use more object oriented. No other code directly makes OpenGL calls.

Complexity

The public API classes above have a total of about 170 methods and there are about 110 private methods and functions. I didn't make a distinction between private and public methods so maybe many of those 170 methods of public classes are in fact private. The public classes also have many attributes (maybe 50 total) that are public in the current Hydra design. So this graphics module is pretty complex (3400 lines of Python, 280 lines of OpenGL shader code).

A first step to see how much complexity there is in the public interfaces is to mark all the private methods with leading underscores.

To get a uniform style some decision should be made about when public class attributes (or properties) are used and when methods are used. It is a mish mash in Hydra.

Dependencies

The Hydra graphics module depends on matrix and vector math provided by the geometry module. The main geometry object is a Place which is a coordinate frame (origin position and 3 axis vectors). Points and vectors are simply numpy arrays. The graphics module depends on numpy, pyopengl, math, but no Hydra modules besides geometry and map_cpp. The map_cpp module is C++ used to accelerate some numpy operations, currently just 3, intercept under a mouse click for picking, hiding mesh edges, and blending images. These routines are in map_cpp which has about 100 routines for density map operations because I was too lazy to make a separate C++ module for these graphics operations.

WebGL

None of the Hydra graphics API was developed with retargeting to WebGL with a client (web browser) / server model.

Note: See TracWiki for help on using the wiki.