void SlaveControl::CollapseControl() { #define ID_TV_GETSELECTED 680 MaxSDK::Array<TrackViewPick> res; SendMessage(trackHWND,WM_COMMAND,ID_TV_GETSELECTED,(LPARAM)&res); if (res.length() == 1) { if (masterPresent) { Control *mc = (Control *) CloneRefHierarchy(master->blendControl); for (int ct = 0; ct < scratchControl->NumMultCurves(); ct++) scratchControl->DeleteMultCurve(ct); scratchControl->AppendMultCurve(mc); } int ct = blockID.Count(); for (int i = 0; i < ct; i++) RemoveControl(0); res[0].client->AssignController(CloneRefHierarchy(scratchControl),res[0].subNum); NotifyDependents(FOREVER,0,REFMSG_CHANGE); NotifyDependents(FOREVER,0,REFMSG_SUBANIM_STRUCTURE_CHANGED); } }
Object* MorphObject::ConvertToType(TimeValue t, Class_ID obtype) { ObjectState os = Eval(t); Object *obj = os.obj->ConvertToType(t,obtype); if (!obj) return NULL; return (Object*)CloneRefHierarchy(obj); }
void OrientConstRotation::Copy(Control *from) { if(GetLocked()==false) { Quat fvalRot; if (from->ClassID()==ClassID()) { OrientConstRotation *ctrl = (OrientConstRotation*)from; // a copy will construct its own pblock to keep the pblock-to-owner 1-to-1. ReplaceReference(ORIENT_ROT_PBLOCK_REF, CloneRefHierarchy(ctrl->pblock)); curRot = ctrl->curRot; baseRotQuatLocal = ctrl->baseRotQuatLocal; baseRotQuatWorld = ctrl->baseRotQuatWorld; flags = ctrl->flags; mLocked = ctrl->mLocked; } else { if(from&&GetLockedTrackInterface(from)) mLocked = GetLockedTrackInterface(from)->GetLocked(); from->GetValue(GetCOREInterface()->GetTime(), &fvalRot, Interval(0, 0)); // to know the object orientation before the firstTimeFlag = 1; baseRotQuatLocal = fvalRot; baseRotQuatLocal.Normalize(); // current controller was active } ivalid.SetEmpty(); NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); } }
void BlockControl::RebuildTempControl() { for (int i =0; i < controls.Count();i++) { if (tempControls[i] == NULL) tempControls[i] = (Control *) CloneRefHierarchy(controls[i]); tempControls[i]->DeleteKeys(TRACK_DOALL); float f = 0.0f; Point3 p(0.0f,0.0f,0.0f); if (tempControls[i]->SuperClassID() == CTRL_FLOAT_CLASS_ID) tempControls[i]->SetValue(0,&f); else if ( (tempControls[i]->SuperClassID() == CTRL_POSITION_CLASS_ID) || (tempControls[i]->SuperClassID() == CTRL_POINT3_CLASS_ID)) tempControls[i]->SetValue(0,&p); } }
void SlavePoint3Control::UpdateSlave() { if (scratchControl == NULL && sub) scratchControl = (Control *) CloneRefHierarchy(sub); if (scratchControl == NULL) return; scratchControl->DeleteKeys(TRACK_DOALL); Point3 f(0.0f,0.f,0.0f); scratchControl->SetValue(0,&f); if (master) master->Update(scratchControl,blockID,subID); }
void SlaveControl::AddControl(int blockid,int subid ) { DbgAssert(master); if (!master) return; blockID.Append(1,&blockid,1); subID.Append(1,&subid,1); SlaveControl *sl = this; master->Blocks[blockid]->externalBackPointers.Append(1,&sl,1); if (sub == NULL) { ReplaceReference(0,CloneRefHierarchy(master->Blocks[blockid]->controls[subid])); } }
void SlaveRotationControl::UpdateSlave() { // CAL-06/03/02: sub could be NULL if (scratchControl == NULL && sub) scratchControl = (Control *) CloneRefHierarchy(sub); if (scratchControl == NULL) return; scratchControl->DeleteKeys(TRACK_DOALL); Quat f; f.Identity(); scratchControl->SetValue(0,&f); if (master) master->Update(scratchControl,blockID,subID); }
void SlaveScaleControl::UpdateSlave() { if (scratchControl == NULL && sub) scratchControl = (Control *) CloneRefHierarchy(sub); if (scratchControl == NULL) return; scratchControl->DeleteKeys(TRACK_DOALL); Quat f; f.Identity(); Point3 p(1.0f,1.0f,1.0f); ScaleValue s(p,f); scratchControl->SetValue(0,&s); if (master) master->Update(scratchControl,blockID,subID); }
void MorphObject::AddNewTarget(INode *node,TimeValue t,int m) { Object *obj = NULL; BOOL delnode = FALSE; switch (m) { case TARG_REF: obj = MakeObjectDerivedObject(node->GetObjectRef()); break; case TARG_INSTANCE: obj = node->GetObjectRef(); break; case TARG_COPY: obj = (Object*)CloneRefHierarchy(node->GetObjectRef()); break; case TARG_MOVE: obj = node->GetObjectRef(); delnode = TRUE; break; default: return; } theHold.Begin(); TSTR name = TSTR(_T("M_")) + node->GetName(); Matrix3 tm = node->GetObjectTM(t)*Inverse(node->GetNodeTM(t)); SetMorphTargetPacket pckt(obj,name,tm); morphCont->SetValue(t,&pckt); if (delnode && ip) { ip->DeleteNode(node); } theHold.Accept(GetString(IDS_RB_PICKMORPHTARGET)); }
int BlockControl::AddControl(HWND hWnd) { //pop up track view selector Interface *ip = GetCOREInterface(); TrackViewPick res; MasterBlockTrackViewFilter filter; if (ip->TrackViewPickDlg(hWnd, &res,&filter )) { //pop frame selector if (res.anim != NULL) { int OK = DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_TRACKPROP), hWnd, TrackPropDlgProc, (LPARAM)this); if (OK) { Control *list; BOOL createdList = FALSE; //check for list control if not add list = BuildListControl(res,createdList); //check if list has a slave control Control *slaveControl; slaveControl = BuildSlave(res,list,createdList); int i = controls.Count(); Control *ctemp = NULL; controls.Append(1,&ctemp,1); tempControls.Append(1,&ctemp,1); ReplaceReference(i,CloneRefHierarchy(res.anim)); //copy relvant keys propStart = propStart * GetTicksPerFrame(); Interval iv(propStart,propStart + (m_end-start)); TrackClipObject *cpy = controls[i]->CopyTrack(iv, TIME_INCLEFT|TIME_INCRIGHT); //nuke all keys controls[i]->DeleteKeys(TRACK_DOALL); //paste back relevant keys iv.Set(0,m_end-start); controls[i]->PasteTrack(cpy, iv, TIME_INCLEFT|TIME_INCRIGHT); tempControls[i] = (Control *) CloneRefHierarchy(res.anim); SlaveControl *sl = (SlaveControl *) slaveControl; backPointers.Append(1,&sl,1); AddBlockName(res.anim,res.client,res.subNum,names); //add slaves controls to the selected tracks and put the original as a sub anim of the slaves //set slave to have reference to master slaveControl->ReplaceReference(1,this); //copy selected track into slave sub slaveControl->ReplaceReference(0,(Control*)CloneRefHierarchy(res.anim)); int bc; #define ID_TV_GETFIRSTSELECTED 680 MaxSDK::Array<TrackViewPick> r; SendMessage(trackHWND,WM_COMMAND,ID_TV_GETFIRSTSELECTED,(LPARAM)&r); bc = r[0].subNum-1; if (res.anim->SuperClassID() == CTRL_FLOAT_CLASS_ID) { float f = 0.0f; tempControls[i]->DeleteKeys(TRACK_DOALL); tempControls[i]->SetValue(0,&f); SlaveFloatControl *slave = (SlaveFloatControl *) slaveControl; slave->scratchControl = (Control *) CloneRefHierarchy(res.anim); //now replace track with slave // int bc = Blocks.Count()-1; slave->blockID.Append(1,&bc,1); slave->subID.Append(1,&i,1); } #ifndef NO_CONTROLLER_SLAVE_POSITION else if (res.anim->SuperClassID() == CTRL_POSITION_CLASS_ID) { Point3 f(0.0f,0.0f,0.0f); tempControls[i]->DeleteKeys(TRACK_DOALL); tempControls[i]->SetValue(0,&f); SlavePosControl *slave = (SlavePosControl *) slaveControl; slave->scratchControl = (Control *) CloneRefHierarchy(res.anim); //now replace track with slave // int bc = Blocks.Count()-1; slave->blockID.Append(1,&bc,1); slave->subID.Append(1,&i,1); } #endif #ifndef NO_CONTROLLER_SLAVE_ROTATION else if (res.anim->SuperClassID() == CTRL_ROTATION_CLASS_ID) { Quat f; f.Identity(); tempControls[i]->DeleteKeys(TRACK_DOALL); tempControls[i]->SetValue(0,&f); SlaveRotationControl *slave = (SlaveRotationControl *) slaveControl; slave->scratchControl = (Control *) CloneRefHierarchy(res.anim); //now replace track with slave slave->blockID.Append(1,&bc,1); slave->subID.Append(1,&i,1); } #endif #ifndef NO_CONTROLLER_SLAVE_SCALE else if (res.anim->SuperClassID() == CTRL_SCALE_CLASS_ID) { Matrix3 f(1); // f.Identity(); tempControls[i]->DeleteKeys(TRACK_DOALL); tempControls[i]->SetValue(0,&f); SlaveScaleControl *slave = (SlaveScaleControl *) slaveControl; slave->scratchControl = (Control *) CloneRefHierarchy(res.anim); //now replace track with slave // int bc = Blocks.Count()-1; slave->blockID.Append(1,&bc,1); slave->subID.Append(1,&i,1); } #endif if (createdList) res.client->AssignController(list,res.subNum); return 1; } } } return 1; }
Control* BlockControl::BuildSlave(TrackViewPick res,Control* list, BOOL createdList) { int count = list->NumSubs()-2; Control *slave = NULL; for (int i = 0; i < count; i++) { if (res.anim->SuperClassID() == CTRL_FLOAT_CLASS_ID) { slave = (Control*)list->SubAnim(i); if (slave->ClassID() == SLAVEFLOAT_CONTROL_CLASS_ID) { return slave; } } else if (res.anim->SuperClassID() == CTRL_POSITION_CLASS_ID) { slave = (Control*)list->SubAnim(i); if (slave->ClassID() == SLAVEPOS_CONTROL_CLASS_ID) { return slave; } } else if (res.anim->SuperClassID() == CTRL_ROTATION_CLASS_ID) { slave = (Control*)list->SubAnim(i); if (slave->ClassID() == SLAVEROTATION_CONTROL_CLASS_ID) { return slave; } } else if (res.anim->SuperClassID() == CTRL_SCALE_CLASS_ID) { slave = (Control*)list->SubAnim(i); if (slave->ClassID() == SLAVESCALE_CONTROL_CLASS_ID) { return slave; } } } BOOL isRotation = FALSE; if (res.anim->SuperClassID() == CTRL_FLOAT_CLASS_ID) slave = (Control*)new SlaveFloatControl; #ifndef NO_CONTROLLER_SLAVE_POSITION else if (res.anim->SuperClassID() == CTRL_POSITION_CLASS_ID) slave = (Control*)new SlavePosControl; #endif #ifndef NO_CONTROLLER_SLAVE_ROTATION else if (res.anim->SuperClassID() == CTRL_ROTATION_CLASS_ID) { slave = (Control*)new SlaveRotationControl; isRotation = TRUE; } #endif #ifndef NO_CONTROLLER_SLAVE_SCALE else if (res.anim->SuperClassID() == CTRL_SCALE_CLASS_ID) slave = (Control*)new SlaveScaleControl; #endif if (createdList) { list->AssignController(CloneRefHierarchy(res.anim),count); list->AssignController(slave,count+1); } else { list->AssignController(slave,count); } return slave; }