Module Geometry
[frames | no frames]

Module Geometry

The Blender.Geometry submodule.

Geometry

This new module provides access to a geometry function.
Function Summary
Vector LineIntersect2D(vec1, vec2, vec3, vec4)
Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
list PolyFill(polylines)
Takes a list of polylines and calculates triangles that would fill in the polylines.

Function Details

LineIntersect2D(vec1, vec2, vec3, vec4)

Takes 2 lines vec1, vec2 for the 2 points of the first line and vec2, vec3 for the 2 points of the second line.
Returns:
a 2D Vector for the intersection or None where there is no intersection.
           (type=Vector)

PolyFill(polylines)

Takes a list of polylines and calculates triangles that would fill in the polylines. Multiple lines can be used to make holes inside a polyline, or fill in 2 seperate lines at once.
Parameters:
polylines
           (type=List of lists containing vectors, each representing a closed polyline.)
Returns:
a list if tuples each a tuple of 3 ints representing a triangle indexing the points given.
           (type=list)

Notes:

  • 2D Vectors will have an assumed Z axis of zero, 4D Vectors W axis is ignored.
  • The order of points in a polyline effect the direction returned triangles face, reverse the order of a polyline to flip the normal of returned faces.

    Example:

    The example below creates 2 polylines and fills them in with faces, then makes a mesh in the current scene:
     import Blender
     Vector= Blender.Mathutils.Vector
    
     # Outline of 5 points
     polyline1= [Vector(-2.0, 1.0, 1.0), Vector(-1.0, 2.0, 1.0), Vector(1.0, 2.0, 1.0), Vector(1.0, -1.0, 1.0), Vector(-1.0, -1.0, 1.0)]
     polyline2= [Vector(-1, 1, 1.0), Vector(0, 1, 1.0), Vector(0, 0, 1.0), Vector(-1.0, 0.0, 1.0)]
     fill= Blender.Geometry.PolyFill([polyline1, polyline2])
    
     # Make a new mesh and add the truangles into it
     me= Blender.Mesh.New()
     me.verts.extend(polyline1)
     me.verts.extend(polyline2)
     me.faces.extend(fill) # Add the faces, they reference the verts in polyline 1 and 2
    
     scn = Blender.Scene.GetCurrent()
     ob = scn.objects.new(me)
     Blender.Redraw()
    


Generated by Epydoc 2.1 on Sun Feb 11 13:30:19 2007 http://epydoc.sf.net