Mesh Manipulation Toolbox for Matlab

Mesh is a 3D object constructed from polygons (named faces) that share edges. Matlab contains functions for plotting 3d objects, specifically meshes.

This project won the Distiguished Project Award of VISL 2005

Abstract
Mesh is a 3D object constructed from polygons (named faces) that share edges. Matlab contains functions for plotting 3d objects, specifically meshes. Matlab does not contain mesh manipulation tools which are crucial for the computer graphics and computational geometry community. The goal of this project is to create a set of tools (functions and toolbars) to add to Matlab mesh manipulations capabilities.

1

Data structures:
1. Mesh
We use Matlab to represent a mesh in the following way:
Structure containing the fields:
i. type: ‘mesh’
ii. vertices: Nx3 matrix (x,y,z in columns)
iii. tri: Mx3 matrix (indices of vertices in vertices list)
for segnmented meshes, the structure have additonal field:
iv. labels: Mx1 matrix.

2

2. Skeleton
Skeleton is associated with a mesh and used to manipulate the mesh easily. Skeleton is basically Directed tree: The vertices are named Joints, and The edges are named Bones. Each bone E=(u,v) is associated with its start joint u.
Each joint has its own local coordinate system, such that The bone assigned with the joint is on X axis of the local coordinate system. The root’s local coordinate system is the global system (of the figure).

3
Functions:

General
offread read off file and return mesh structure
vecRotTans given two vectors, return the rotation matrix from vec1 to vec2
Visualization
meshPlot plots mesh in current figure
skelPlot plot a skeleton in current figure
skelPlotBone plot single bone (as cone) from boneBase to boneEnd
skelShowAxes plot local coordinate system of given joint is skel
Elements picking
offChooseVertices returns all vertices belong to same segment in given mesh
offGinput interactivlly select data from mesh with mouse
Skeleton creation
skelFromSegments creates skeleton and tree based on segmented mesh
skelToolBar interactively create and edit skeletons, trees and skinMappings
Mesh and skeleton deformation
meshApplySkelDeform apply deformation on mesh according to given skeleton
meshApplyJointDeform apply the transformation represented by rotAxis and rotAngle on given joint in skel
skelGetRotation get the rotation parameters of given joint in skel
skelSetRotation set the rotation parameters of given joint in skel
skelMatchSkeletons match the configuration of two skeletons with the same structure
skelRotateJoint apply rotation of a given joint in skeleton
skelInterpolate interpolate skel position between to given skeleton positions
Convertion functions
axisAngle2rotMat given rotation presented by axis and angle, returns the rotation matrix that represents the same rotation
rotMat2axisAngle given rotation matrix, returns the same rotation represented as axis-angle form
tree2skel converts tree data structure to skeleton data structure
skel2tree converts skeleton data structure to tree

 

Toolbars

Toolbars:

skelToolbar Intuitive tool to create skeletons manually. Define joints, bones, parent-child relations, and
skin mapping. Enable deformation of the mesh directly from the figure.
animToolbar Skeleton manipulation for animation. Change the skeleton configuration at specific frames (Key Frames) and
interpolate the transition between frames.

4

 

Example

%read off file and plot the mesh:
origmesh=offread(‘segmented\child4.off’);
meshplot(origmesh);
5

%build skeleton to the mesh and plot it:
origskel=skelfromsegments(origmesh,1);
figure;skelplot(origskel,1);
6
%show local coord. systems of some joints:
h8=skelShowAxes(origskel,8,’r’);
h12=skelShowAxes(origskel,12,’g’);
h1=skelShowAxes(origskel,1,’b’);
7
%apply rotation to some joints:
skel1=skelRotateJoint(origskel,13,[0 1 0], -rad(80));
skel1b=skelRotateJoint(skel1,8,skelConvertAxis(skel1,[0 1 0],8,3), rad(50));
figure;skelplot(skel1b);
8
%match the mesh to the new skeleton:
mesh1=meshApplySkelDeform(origmesh,origskel,origskel.skinMapping,skel1b);
meshplot(mesh1);
9
More examples can be found in the project documentation.

Acknowledgments

Many thanks go to our project supervisor Sagi Katz and to the Ollendorff Minerva Center which supported this project.