Control* BaseLimitCtrl::GetDefaultControlForDataType() { switch(SuperClassID()) { case CTRL_FLOAT_CLASS_ID: case CTRL_SHORT_CLASS_ID: case CTRL_INTEGER_CLASS_ID: return NewDefaultFloatController(); case CTRL_POINT3_CLASS_ID: return NewDefaultPoint3Controller(); case CTRL_POSITION_CLASS_ID: return NewDefaultPositionController(); case CTRL_ROTATION_CLASS_ID: return NewDefaultRotationController(); case CTRL_SCALE_CLASS_ID: return NewDefaultScaleController(); case CTRL_MATRIX3_CLASS_ID: return NewDefaultMatrix3Controller(); case CTRL_MASTERPOINT_CLASS_ID: return NewDefaultMasterPointController(); case CTRL_POINT4_CLASS_ID: return NewDefaultPoint4Controller(); case CTRL_COLOR24_CLASS_ID: return NewDefaultColorController(); case CTRL_FRGBA_CLASS_ID: return NewDefaultFRGBAController(); case CTRL_MORPH_CLASS_ID: default: return NULL; } }
// REAPPLYANIMATION // Now that we've reparented a node within the hierarchy, re-apply all its animation. void ReapplyAnimation(INode *node, plSampleVec *samples) { Control *controller = node->GetTMController(); Control *rotControl = NewDefaultRotationController(); // we set the default rotation controller type above in RemoveBiped() Control *posControl = NewDefaultPositionController(); // '' '' Control *scaleControl = NewDefaultScaleController(); // '' '' controller->SetRotationController(rotControl); controller->SetPositionController(posControl); controller->SetScaleController(scaleControl); for(int i = 0; i < samples->size(); i++) { nodeTMInfo *info = (*samples)[i]; Matrix3 m = info->fMat3; TimeValue t = info->fTime; #if 1 node->SetNodeTM(t, m); #else AffineParts parts; INode *parent = node->GetParentNode(); Matrix3 parentTM = parent->GetNodeTM(t); Matrix3 invParentTM = Inverse(parentTM); m *= invParentTM; decomp_affine(m, &parts); Quat q(parts.q.x, parts.q.y, parts.q.z, parts.q.w); Point3 p(parts.t.x, parts.t.y, parts.t.z); rotControl->SetValue(t, q); posControl->SetValue(t, p); #endif } IKeyControl *posKeyCont = GetKeyControlInterface(posControl); IKeyControl *scaleKeyCont = GetKeyControlInterface(scaleControl); ReduceKeys<ILinPoint3Key>(node, posKeyCont); EliminateScaleKeys(node, scaleKeyCont); // grrrr ReduceKeys<ILinScaleKey>(node, scaleKeyCont); }
//from IUnReplaceableControl Control * EulerExposeControl::GetReplacementClone() { Control *control = NewDefaultRotationController(); if(control) { // set key per frame Interval range =GetCOREInterface()->GetAnimRange(); TimeValue tpf = GetTicksPerFrame(); SuspendAnimate(); AnimateOn(); Quat v; for(TimeValue t= range.Start(); t<=range.End();t+=tpf) { GetValue(t,&v,Interval(t,t)); control->SetValue(t,&v,1,CTRL_ABSOLUTE); } ResumeAnimate(); } return control; }