Module NMesh
[frames | no frames]

Module NMesh

The Blender.NMesh submodule.

Mesh Data

This module provides access to Mesh Data objects in Blender.

Example:
 import Blender
 from Blender import NMesh, Material
 #
 me = NMesh.GetRaw("Plane")       # get the mesh data called "Plane"

 if not me.materials:             # if there are no materials ...
   newmat = Material.New()        # create one ...
   me.materials.append(newmat)    # and append it to the mesh's list of mats

 print me.materials               # print the list of materials
 mat = me.materials[0]            # grab the first material in the list
 mat.R = 1.0                      # redefine its red component
 for v in me.verts:               # loop the list of vertices
   v.co[0] *= 2.5                 # multiply the coordinates
   v.co[1] *= 5.0
   v.co[2] *= 2.5
 me.update()                      # update the real mesh in Blender

Classes
NMCol This object is a list of ints: [r, g, b, a] representing an rgba colour.
NMesh This object gives access to mesh data in Blender.
NMFace This object holds mesh face data.
NMVert This object holds mesh vertex data.

Function Summary
NMCol Col(col)
Get a new mesh rgba color.
NMFace Face(vertexList)
Get a new face object.
NMesh GetRaw(name)
Get the mesh data object called namefrom Blender.
NMesh GetRawFromObject(name)
Get the raw mesh data object from the Object in Blender called name.
  New()
Create a new mesh object.
None or Object PutRaw(nmesh, name, recalculate_normals)
Put an NMesh object back in Blender.
NMVert Vert(x, y, z)
Get a new vertex object.

Variable Summary
readonly dictionary FaceFlags - The available face selection flags.
readonly dictionary FaceModes - The available face modes.
readonly dictionary FaceTranspModes - The available face transparency modes.

Function Details

Col(col=[255, 255, 255, 255])

Get a new mesh rgba color.
Parameters:
col - A list [red, green, blue, alpha] of int values in [0, 255].
           (type=list)
Returns:
A new NMCol (mesh rgba color) object.
           (type=NMCol)

Face(vertexList=None)

Get a new face object.
Parameters:
vertexList - A list of up to 4 NMVerts (mesh vertex objects).
           (type=list)
Returns:
A new NMFace object.
           (type=NMFace)

GetRaw(name=None)

Get the mesh data object called name from Blender.
Parameters:
name - The name of the mesh data object.
           (type=string)
Returns:
It depends on the 'name' parameter:
  • (name) - The NMesh wrapper of the mesh called name, None if not found.
  • () - A new (empty) NMesh object.

           (type=NMesh)

GetRawFromObject(name)

Get the raw mesh data object from the Object in Blender called name.
Parameters:
name - The name of an Object of type "Mesh".
           (type=string)
Returns:
The NMesh wrapper of the mesh data from the Object called name.
           (type=NMesh)

Warning: This function gets deformed mesh data, already modified for rendering (think "display list"). It also doesn't let you overwrite the original mesh in Blender, so if you try to update it, a new mesh will be created.

New()

Create a new mesh object. rtype: NMesh
Returns:
A new (empty) NMesh object.

PutRaw(nmesh, name=None, recalculate_normals=1)

Put an NMesh object back in Blender.
Parameters:
nmesh
           (type=NMesh)
name - The name of the mesh data object in Blender which will receive this nmesh data. It can be an existing mesh data object or a new one.
           (type=string)
recalculate_normals - If non-zero, the vertex normals for the mesh will be recalculated.
           (type=int)
Returns:
It depends on the 'name' parameter:
  • name refers to an existing mesh data obj already linked to an object: return None.
  • name refers to a new mesh data obj or an unlinked (no users) one: return the created Blender Object wrapper.

           (type=None or Object)

Vert(x=0, y=0, z=0)

Get a new vertex object.
Parameters:
x - The x coordinate of the vertex.
           (type=float)
y - The y coordinate of the vertex.
           (type=float)
z - The z coordinate of the vertex.
           (type=float)
Returns:
A new NMVert object.
           (type=NMVert)

Variable Details

FaceFlags

The available face selection flags.
  • SELECT - selected.
  • HIDE - hidden.
  • ACTIVE - the active face.
Type:
readonly dictionary

FaceModes

The available face modes.
  • ALL - set all modes at once.
  • BILLBOARD - always orient after camera.
  • HALO - halo face, always point to camera.
  • DINAMYC - respond to collisions.
  • INVISIBLE - invisible face.
  • LIGHT - dinamyc lighting.
  • OBCOL - use object colour instead of vertex colours.
  • SHADOW - shadow type.
  • SHAREDVERT - apparently unused in Blender.
  • SHAREDCOL - shared vertex colours (per vertex).
  • TEX - has texture image.
  • TILES - uses tiled image.
  • TWOSIDE - two-sided face.
Type:
readonly dictionary

FaceTranspModes

The available face transparency modes. Note: these are ENUMS, they can't be combined (and'ed, or'ed, etc) like a bit vector.
  • SOLID - draw solid.
  • ADD - add to background (halo).
  • ALPHA - draw with transparency.
  • SUB - subtract from background.
Type:
readonly dictionary

Generated by Epydoc 1.1 on Wed Aug 13 19:17:14 2003 http://epydoc.sf.net