Package schrodinger :: Package graphics3d :: Module common
[hide private]
[frames] | no frames]

Module common

Utility functions for the graphics3d package.

The common module contains functions commonly used by the graphics3d modules. This includes the Group class, which is one clients use as a container for actual drawing primitive instances (like Arrow, etc.). See the Group class' docstring for more details.

If you are adding new primtive modules, then you need do nothing other than conform to the list of required methods in your new primitive class:

_draw() (Code to draw out the primitive) _glSetup() (static, Configures the GL state for the specific primitive) _glReset() (static, Resets the GL state back to what it was prior to drawing)

This code will automatically keep track of and handle each instance that is added to a Group instance. For information on how to create a Group and add intances to the Group, see the class docstring for Group and the method docstring for Group's add() method, respectively.

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  Primitive
All 3D objects derive from this class.
  Group
Class to group a bunch of primitives and draw them out.
Functions [hide private]
 
get_normalized(v)
Calculate and return normalized vector.
 
get_cross(v, w)
Get the cross product of v and w Arguments: v, w: Each is a list of 3 float values Returns: List of 3 floating values representing the cross product.
 
create_normal(vertices)
Method to create a normal for the polygon defined by specified vertices.
 
color_arg_to_rgb(colorarg)
Returns a tuple of (r, g, b) [range 0.0-1.0 inclusive for each].
 
_opengl_level_changed()
Private function to deal with change of OpenGL level.
Variables [hide private]
  version = "$Revision: 1.14 $"
  maestro = None
hash(x)
  TRANSPARENCY_MIN = 0.0
  TRANSPARENCY_MAX = 1.0
  OPACITY_MIN = 0.0
  OPACITY_MAX = 1.0
  OPACITY_DEFAULT = 1.0
  BOUNDING_BOX_INIT_VALUE = 100000000.0
  BOUNDING_BOX_ADJUST_VALUE = 0.1
  _all_groups = []
Function Details [hide private]

get_normalized(v)

 

Calculate and return normalized vector.

Arguments:
   v: List containing 3 floating values of x, y, z
Returns:
   List of 3 floating values reprsenting the normalized vector.

create_normal(vertices)

 

Method to create a normal for the polygon defined by specified
vertices.

Arguments:
   vertices: List of floating value lists of [x, y, z] representing
             a vertex.
Returns:
   List of 3 floating values representing the normal 

FIXME: We use only the first three vertices to calculate the normal
       and currently ignore the rest.  Other vertices won't matter if all
       the vectors are in a plane, which is going to the be case most
       of the time. 

color_arg_to_rgb(colorarg)

 

Returns a tuple of (r, g, b) [range 0.0-1.0 inclusive for each].

Arguments:

colorarg:     Can be one of the following types -
                  Color:   Color object instance
                  string:  Color name
                  integer: Color index

_opengl_level_changed()

 

Private function to deal with change of OpenGL level. Client code should never need to call this. This function CANNOT be renamed as it is invoked from within Maestro.