/** * The Rib inner class encapsulates information about the ribs of the SweepShape. * @author rdb * */ import org.joml.*; public class Rib { private Vector3f[] poly; // 3D version of the polygon private Vector3f normal; // outward normal of rib private Vector3f location; // location in the sweep shape private Matrix4f planeRotation; // rotation to get (0,0,1) along normal private float xScale; // xScale before rotation/translation private float yScale; // yScale before rotation/translation private float zRotate; // rotation about the z-axis private Matrix4f transform; // composite transform for all poly pts /** * Constructor */ public Rib( Vector3f[] basePoly, Vector3f loc, Vector2f xyS, float zRot ) { poly = new Vector3f[ basePoly.length ]; location = new Vector3f( loc ); zRotate = zRot; xScale = xyS.x; yScale = xyS.y; //---------------------------------------------- //-------- need to compute the normal !! normal = new Vector3f( 0, 0, 1 ); //-------- need to compute the planeRotation!! planeRotation = new Matrix4f(); // identity //--------------------------------------------- transform = new Matrix4f().translate( location ) // default transform .mul( planeRotation ) .rotate( zRotate, 0, 0, 1 ) .scale( xScale, yScale, 1 ); for ( int i = 0; i < basePoly.length; i++ ) poly[ i ] = transform.transformPosition( basePoly[ i ], new Vector3f() ); } //------------------ toString() -------------------------------------- /** * Useful to have a conversion to String method. */ public String toString() { StringBuffer buf = new StringBuffer( "Rib: " ); for ( Vector3f v: poly ) buf.append( v + " " ); return buf.toString(); } }