Table of Contents

Module: Mesh ./Mesh.py

The Blender Mesh module

This module provides routines for more extensive mesh manipulation. Later, this Mesh type will also allow interactive access (like in EditMode). In the Publisher, Ngons will also be supported (and converted to triangles on mesh.update(). The following code demonstrates creation of an Ngon.

Example:

        from Blender import Mesh, Object, Scene

        m = Mesh.New()  # new empty mesh
        vlist = []
        vlist.append(m.addVert((-0.0, -1.0, 0.0)))
        vlist.append(m.addVert((1.0, 0.0, 0.0)))
        vlist.append(m.addVert((1.0, 1.0, 0.0)))
        vlist.append(m.addVert((0.0, 3.0, 0.0)))
        vlist.append(m.addVert((-1.0, 2.0, 0.0)))
        vlist.append(m.addVert((-3.0, 1.0, 0.0)))
        vlist.append(m.addVert((-3.0, 3.0, 0.0)))
        vlist.append(m.addVert((-4.0, 3.0, 0.0)))
        vlist.append(m.addVert((-4.0, 0.0, 0.0)))

        f = m.addFace(vlist)

        # do some calculations: top project vertex coordinates to
        # UV coordinates and normalize them to the square [0.0, 1.0]*[0.0, 1.0]

        uvlist = map(lambda x: (x.co[0], x.co[1]), vlist)
        maxx = max(map(lambda x: x[0], uvlist))
        maxy = max(map(lambda x: x[1], uvlist))
        minx = min(map(lambda x: x[0], uvlist))
        miny = min(map(lambda x: x[1], uvlist))

        len = max((maxx - minx), (maxy - miny))
        offx = -minx / len
        offy = -miny / len

        f.uv = map(lambda x: (x[0]/len + offx, x[1]/len + offy), uvlist)  # assign UV coordinates by 'top' projection

        m.update()  # update and triangulate mesh

        ob = Object.New('Mesh')    # create new Object
        ob.link(m)                 # link mesh data
        sc = Scene.getCurrent()    # get current Scene
        sc.link(ob)                # link Object to scene


Functions   
Color
New
get
makeFace
toTriangles
  Color 
Color (
        r,
        g,
        b,
        a=1.0,
        )

  New 
New ()

  get 
get ( name=None )

If name given, the Mesh name is returned if existing, None otherwise.

Exceptions   
SystemError, "get() for Meshes is not yet supported"
  makeFace 
makeFace ( f )

  toTriangles 
toTriangles ( ngon )

Classes   
Face

Face wrapper class

Vert

Vertex wrapper class

rawMesh

Wrapper for raw Mesh data


Table of Contents

This document was automatically generated on Mon Feb 25 13:52:14 2002 by HappyDoc version r1_5