Matrix3 plStaticEnvLayer::IGetViewTM( int i ) { Matrix3 m; m.IdentityMatrix(); switch( i ) { case kTopFace: m.RotateX( -M_PI ); break; case kBottomFace: break; case kLeftFace: m.RotateX( -.5f * M_PI ); m.RotateY( -.5f * M_PI ); break; case kRightFace: m.RotateX( -.5f * M_PI ); m.RotateY( +.5f * M_PI ); break; case kFrontFace: m.RotateX( -.5f * M_PI ); m.RotateY( M_PI ); break; case kBackFace: m.RotateX( -.5f * M_PI ); break; } return m; }
StretchDeformer::StretchDeformer(TimeValue t, ModContext &mc, float stretch, float amplify, int naxis, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { Matrix3 mat; Interval valid; // if (from==to) doRegion = FALSE; this->doRegion = doRegion; this->from = from; this->to = to; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch ( naxis ) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } SetAxis( mat ); assert (mc.box); bbox = *mc.box; CalcBulge(naxis, stretch, amplify); }
BendDeformer::BendDeformer( TimeValue t, ModContext &mc, float angle, float dir, int naxis, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { this->doRegion = doRegion; this->from = from; this->to = to; Matrix3 mat; Interval valid; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch (naxis) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } mat.RotateZ(DegToRad(dir)); SetAxis(mat); assert (mc.box); bbox = *mc.box; CalcR(naxis,DegToRad(angle)); // Turn this off for a sec. this->doRegion = FALSE; float len = to-from; float rat1, rat2; if (len==0.0f) { rat1 = rat2 = 1.0f; } else { rat1 = to/len; rat2 = from/len; } Point3 pt; tmAbove.IdentityMatrix(); tmAbove.Translate(Point3(0.0f,0.0f,-to)); tmAbove.RotateY(DegToRad(angle * rat1)); tmAbove.Translate(Point3(0.0f,0.0f,to)); pt = Point3(0.0f,0.0f,to); tmAbove.Translate((Map(0,pt*invtm)*tm)-pt); tmBelow.IdentityMatrix(); tmBelow.Translate(Point3(0.0f,0.0f,-from)); tmBelow.RotateY(DegToRad(angle * rat2)); tmBelow.Translate(Point3(0.0f,0.0f,from)); pt = Point3(0.0f,0.0f,from); tmBelow.Translate((Map(0,pt*invtm)*tm)-pt); this->doRegion = doRegion; }
TwistDeformer::TwistDeformer( TimeValue t, ModContext &mc, float angle, int naxis, float bias, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { this->doRegion = doRegion; this->from = from; this->to = to; if (bias!=0.0f) { this->bias = 1.0f-(bias+100.0f)/200.0f; if (this->bias < 0.00001f) this->bias = 0.00001f; if (this->bias > 0.99999f) this->bias = 0.99999f; this->bias = float(log(this->bias)/log(0.5)); doBias = TRUE; } else { this->bias = 1.0f; doBias = FALSE; } Matrix3 mat; Interval valid; time = t; tm = modmat; invtm = modinv; mat.IdentityMatrix(); switch ( naxis ) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } SetAxis( mat ); assert (mc.box); bbox = *mc.box; CalcHeight(naxis,DegToRad(angle)); }
SkewDeformer::SkewDeformer( ModContext &mc, float amount, float dir, int naxis, float from, float to, int doRegion, Matrix3& modmat, Matrix3& modinv) { this->doRegion = doRegion; this->from = from; this->to = to; Matrix3 mat; mat.IdentityMatrix(); switch (naxis) { case 0: mat.RotateY( -HALFPI ); break; //X case 1: mat.RotateX( HALFPI ); break; //Y case 2: break; //Z } mat.RotateZ(DegToRad(dir)); tm = modmat * mat; invtm = Inverse(mat) * modinv; assert (mc.box); bbox = *mc.box; float len = 0.0f; if (!doRegion) { switch (naxis) { case 0: len = bbox.pmax.x - bbox.pmin.x; break; case 1: len = bbox.pmax.y - bbox.pmin.y; break; case 2: len = bbox.pmax.z - bbox.pmin.z; break; } } else { len = to-from; } if (len==0.0f) len = 0.000001f; amountOverLength = amount/len; }