Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter

A Smarter Symmetrize Mesh Tool

Matthew | October 25, 2014

No Comments

This tool is a “must have” addition to your tools. It’s written by one of my students, Chris Talbott. Enjoy.

/***************************************************
Cut a Mesh in half
Version .01
Author: Chris W.A. Talbott
Chris7Talbott@gmail.com

Designed with character and creature
modeling as the target use in symmetry.

Instructions:
Define a target edge loop to define as center and run script.

Process:
Center will be set on absolute X-value of pivot.
The mesh will be cut into 2 pieces along the edge loop chosen.
The more -X half will be deleted while +X half will be kept.
The remaining half will be mirrored and welded.
Resulting in a perfectly symmetrical mesh. 
***************************************************/

cwat_cutMeshInHalf();

global proc cwat_cutMeshInHalf(){
    
    string $obj[] = `ls -hl`;
    float $centerVal[]= `xform -q -ws -scalePivot $obj[0]`;
    
    //center edgeloop on X val of pivot
    move -a -x $centerVal[0];
    
    //cut mesh along edge and separate into poly islands
    performDetachEdges;
    select $obj;
    SeparatePolygon;

    //center pivots of 2 pieces for evaluation
    string $pieces[] = `ls -sl`;
    select $pieces[0];
    xform -cp;
    select $pieces[1];
    xform -cp;

    //query pivot data
    float $positionPiece1[]= `xform -q -ws -scalePivot $pieces[0]`;
    float $positionPiece2[]= `xform -q -ws -scalePivot $pieces[1]`;
    
    //evaluate piece to keep and piece to delete
    if($positionPiece1[0] < $centerVal[0]){
        select $pieces[0];
        doDelete;
        select $pieces[1];
    }
    else{
        select $pieces[1];
        doDelete;
        select $pieces[0];
    }
  
    //mirror mesh and weld together
    string $goodHalf[] = `ls -sl`;
    xform -ws -piv $centerVal[0] 0 0 $goodHalf;
    string $inst[] = `instance -n $goodHalf`;     
    xform -ws -scale -1 1 1 $inst[0];                
    polyUnite -ch 1 $goodHalf $inst;    
    $goodHalf = `ls -sl`;    
    polyMergeVertex  -d 0.001 -am 1 -ch 1;
    
    //reset piv to original position, soften edges, and delete construction history
    select $goodHalf;    
    xform -ws -piv $centerVal[0] $centerVal[1] $centerVal[2] $goodHalf;
    polySoftEdge -a 180 -ch 1 $goodHalf; 
    delete -ch $goodHalf;
}

Comments are closed.

Twitter

3D Char. Mod. Vol. 1

Subscribers

    395

Recent Testimonials