Dev:2.4/Source/Python/Thinmesh

提供: wiki
< Dev:2.4‎ | Source‎ | Python
移動先: 案内検索

-- KenHughes - 18 Sep 2005

Thin Mesh

Introduction

Thin Mesh is a new Blender python module that will eventually replace the existing NMesh module. It differs from NMesh in that it is a thin wrapper around Blender's mesh data. The API will be similar to the current NMesh API, but will not include methods like GetRaw, PutRaw, etc.

Outline

The first goal is a thin wrapper which can manipulate an existing Blender mesh, but without the ability to change the mesh's structure. The basic sequence/indexing operations will be implemented for this. For example, a user can change the coordinates of a vertex but cannot add or delete vertices. (This goal was accomplished in v1.2 KenHughes - 28 Sep 2005)


The second goal is to add the ability to change the mesh's structure. This might be done using additional sequence/indexing operations like slice assignments or .append and del(), or by the use of special methods.

Status

-- KenHughes - 28 Sep 2005

Until this module gets put into the Blender source tree, the source code and documentation is available on [[1]] for people to download.

Suggestions

  • From LetterRip: a way to access the zbuffer depth so to help in backface culling
  • From ascotan: edges and faces should implement the sequence protocol so that users can access/iterate over the edges in a face, and vertices in an edge (_iterators for faces and edges implemented in v1.3_ -- KenHughes - 28 Sep 2005)

Discussion

  • For the time being, there are no plans to add code to remove data from a mesh. This is per Willian's advice; meshes are used in many places in Blender (example: vertex keys) so modifying just the mesh without updating everything which refers to the mesh would be bad. But I'm exploring ways we might efficiently and safely do this, possibly using some of the existing EditMesh data structures and code.
    • v1.2 supports two method for adding data to the mesh: mesh.addVerts() and mesh.addEdges(). These are experimental, so by all means pound on them to see if they work and if they're useful. I'm planning to add a mesh.addFaces() method also, but have just started working on it.
    • I've been looking into how we might be able to access some of Blender's mesh tools from BPy scripts. This again requires that meshes use the EditMesh data structures since the mesh tools (IIRC) are only available in Edit Mode.