BOOL Cal3DObjPick::Pick(IObjParam *ip, ViewExp *vpt) { if (vpt->HitCount() == 0) return FALSE; INode *node; if ((node = vpt->GetClosestHit()) != NULL) { #if MAX_PRODUCT_VERSION_MAJOR > 8 RefResult ret = sound->ReplaceReference(1, node); #else RefResult ret = sound->MakeRefByID(FOREVER, 1, node); #endif SetPickMode(NULL); // sound->iObjParams->SetCommandMode(sound->previousMode); // sound->previousMode = NULL; sound->Cal3DPickButton->SetCheck(FALSE); HWND hw = sound->hRollup; Static_SetText(GetDlgItem(hw, IDC_NAME), sound->audioClip->GetName()); return FALSE; } return FALSE; }
void dCustomKinematicController::Init (NewtonBody* const body, const dMatrix& matrix) { CalculateLocalMatrix(matrix, m_localMatrix0, m_localMatrix1); m_autoSleepState = NewtonBodyGetAutoSleep(body) ? true : false; NewtonBodySetSleepState(body, 0); SetPickMode(1); SetLimitRotationVelocity(10.0f); SetTargetMatrix(matrix); SetMaxLinearFriction(1.0f); SetMaxAngularFriction(1.0f); // set as soft joint SetSolverModel(2); }
CustomKinematicController::CustomKinematicController(NewtonBody* const body, const dVector& handleInGlobalSpace) :CustomJoint(6, body, NULL) { dMatrix matrix; // get the initial position and orientation NewtonBodyGetMatrix (body, &matrix[0][0]); m_autoSlepState = NewtonBodyGetSleepState (body); NewtonBodySetAutoSleep (body, 0); m_localHandle = matrix.UntransformVector (handleInGlobalSpace); matrix.m_posit = handleInGlobalSpace; SetPickMode (1); SetTargetMatrix (matrix); SetMaxLinearFriction(1.0f); SetMaxAngularFriction(1.0f); }
BOOL ParentObjPick::Pick(IObjParam *ip,ViewExp *vpt) { if (vpt->HitCount() == 0) return FALSE; INode *node; if ((node = vpt->GetClosestHit()) != NULL && parent->ReplaceReference(1, node) == REF_SUCCEED) { SetPickMode(NULL); // parent->iObjParams->SetCommandMode(parent->previousMode); // parent->previousMode = NULL; parent->ParentPickButton->SetCheck(FALSE); HWND hw = parent->hRollup; Static_SetText(GetDlgItem(hw,IDC_TRIGGER_OBJ), parent->triggerObject->GetName()); return FALSE; } return FALSE; }
BOOL CALLBACK AnchorDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, AnchorObject *th) { TCHAR text[MAX_PATH]; int c, camIndex, i, type; HWND cb; Tab<INode *> cameras; switch (message) { case WM_INITDIALOG: th->ParentPickButton = GetICustButton(GetDlgItem(hDlg, IDC_PICK_PARENT)); th->ParentPickButton->SetType(CBT_CHECK); th->ParentPickButton->SetButtonDownNotify(TRUE); th->ParentPickButton->SetHighlightColor(GREEN_WASH); th->ParentPickButton->SetCheck(FALSE); th->dlgPrevSel = -1; th->hRollup = hDlg; if (th->triggerObject) Static_SetText(GetDlgItem(hDlg, IDC_TRIGGER_OBJ), th->triggerObject->GetName()); th->pblock->GetValue(PB_AN_TYPE, th->iObjParams->GetTime(), type, FOREVER); th->isJump = type == 0; EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); GetCameras(th->iObjParams->GetRootNode(), &cameras); c = cameras.Count(); cb = GetDlgItem(hDlg, IDC_CAMERA); camIndex = -1; for (i = 0; i < c; i++) { // add the name to the list TSTR name = cameras[i]->GetName(); int ind = ComboBox_AddString(cb, name.data()); ComboBox_SetItemData(cb, ind, cameras[i]); if (cameras[i] == th->cameraObject) camIndex = i; } if (camIndex != -1) ComboBox_SelectString(cb, 0, cameras[camIndex]->GetName()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), th->description.data()); Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->URL.data()); Edit_SetText(GetDlgItem(hDlg, IDC_PARAMETER), th->parameter.data()); if (pickMode) SetPickMode(th); return TRUE; case WM_DESTROY: if (pickMode) SetPickMode(th); //th->iObjParams->ClearPickMode(); //th->previousMode = NULL; ReleaseICustButton(th->ParentPickButton); return FALSE; case WM_MOUSEACTIVATE: return FALSE; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BOOKMARKS: { // do bookmarks TSTR url, cam, desc; if (GetBookmarkURL(th->iObjParams, &url, &cam, &desc)) { // get the new URL information; Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), url.data()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), desc.data()); } } break; case IDC_CAMERA: if (HIWORD(wParam) == CBN_SELCHANGE) { cb = GetDlgItem(hDlg, IDC_CAMERA); int sel = ComboBox_GetCurSel(cb); INode *rtarg; rtarg = (INode *)ComboBox_GetItemData(cb, sel); th->ReplaceReference(2, rtarg); } break; case IDC_HYPERLINK: th->isJump = IsDlgButtonChecked(hDlg, IDC_HYPERLINK); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_SET_CAMERA: th->isJump = !IsDlgButtonChecked(hDlg, IDC_SET_CAMERA); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_PICK_PARENT: // Pick an object from the scene // Set the pickmode... switch (HIWORD(wParam)) { case BN_BUTTONDOWN: SetPickMode(th); /* if (th->previousMode) { // reset the command mode th->iObjParams->SetCommandMode(th->previousMode); th->previousMode = NULL; } else { th->previousMode = th->iObjParams->GetCommandMode(); theParentPick.SetAnchor(th); th->iObjParams->SetPickMode(&theParentPick); } */ break; } return TRUE; case IDC_ANCHOR_URL: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), text, MAX_PATH); th->URL = text; } break; case IDC_DESC: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_DESC), text, MAX_PATH); th->description = text; } break; case IDC_PARAMETER: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_PARAMETER), text, MAX_PATH); th->parameter = text; } break; default: return FALSE; } } return FALSE; }
BOOL CALLBACK RollupDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam , TouchSensorObject* th) { if ( !th && message != WM_INITDIALOG ) return FALSE; switch ( message ) { case WM_INITDIALOG: // SetDlgFont( hDlg, th->iObjParams->GetAppHFont() ); th->TouchSensorPickButton = GetICustButton(GetDlgItem(hDlg,IDC_PICK)); th->TouchSensorPickButton->SetType(CBT_CHECK); th->TouchSensorPickButton->SetButtonDownNotify(TRUE); th->TouchSensorPickButton->SetHighlightColor(GREEN_WASH); th->TouchSensorPickButton->SetCheck(FALSE); th->ParentPickButton = GetICustButton(GetDlgItem(hDlg,IDC_PICK_PARENT)); th->ParentPickButton->SetType(CBT_CHECK); th->ParentPickButton->SetButtonDownNotify(TRUE); th->ParentPickButton->SetHighlightColor(GREEN_WASH); th->ParentPickButton->SetCheck(FALSE); // Now we need to fill in the list box IDC_LIST th->hRollup = hDlg; BuildObjectList(th); // EnableWindow(GetDlgItem(hDlg, IDC_DEL), // (th->objects.Count() > 0)); th->dlgPrevSel = -1; if (th->triggerObject) Static_SetText(GetDlgItem(hDlg,IDC_TRIGGER_OBJ), th->triggerObject->GetName()); if (pickMode) SetPickMode(NULL); return TRUE; case WM_DESTROY: if (pickMode) SetPickMode(NULL); // th->iObjParams->ClearPickMode(); // th->previousMode = NULL; ReleaseICustButton( th->TouchSensorPickButton ); ReleaseICustButton( th->ParentPickButton ); return FALSE; case WM_MOUSEACTIVATE: // th->iObjParams->RealizeParamPanel(); return FALSE; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: // th->iObjParams->RollupMouseMessage(hDlg,message,wParam,lParam); return FALSE; case WM_COMMAND: switch( LOWORD(wParam) ) { case IDC_PICK: // Pick an object from the scene // Set the pickmode... switch (HIWORD(wParam)) { case BN_BUTTONDOWN: if (pickMode == PARENT_PICK_MODE) { SetPickMode(NULL); th->ParentPickButton->SetCheck(FALSE); } theTSPick.SetTouchSensor(th); SetPickMode(&theTSPick, TOUCH_PICK_MODE); /* if (th->previousMode) { // reset the command mode th->iObjParams->SetCommandMode(th->previousMode); th->previousMode = NULL; } else { th->previousMode = th->iObjParams->GetCommandMode(); thePick.SetTouchSensor(th); th->iObjParams->SetPickMode(&thePick); } */ break; } break; case IDC_PICK_PARENT: // Pick an object from the scene // Set the pickmode... switch (HIWORD(wParam)) { case BN_BUTTONDOWN: if (pickMode == TOUCH_PICK_MODE) { SetPickMode(NULL); th->TouchSensorPickButton->SetCheck(FALSE); } thePPick.SetTouchSensor(th); SetPickMode(&thePPick, PARENT_PICK_MODE); /* if (th->previousMode) { // reset the command mode th->iObjParams->SetCommandMode(th->previousMode); th->previousMode = NULL; } else { th->previousMode = th->iObjParams->GetCommandMode(); theParentPick.SetTouchSensor(th); th->iObjParams->SetPickMode(&theParentPick); } */ break; } break; case IDC_DEL: { // Delete the object from the list int index = SendMessage(GetDlgItem(hDlg,IDC_LIST), LB_GETCURSEL, 0, 0); if (index != LB_ERR) { TouchSensorObj *obj = (TouchSensorObj *) SendDlgItemMessage(hDlg, IDC_LIST, LB_GETITEMDATA, index, 0); for (int i = 0; i < th->objects.Count(); i++) { if (obj == th->objects[i]) { // remove the item from the list SendDlgItemMessage(hDlg, IDC_LIST, LB_DELETESTRING, (WPARAM) index, 0); th->dlgPrevSel = -1; // Remove the reference to obj->node th->DeleteReference(i+2); // remove the object from the table th->objects.Delete(i, 1); th->pblock->SetValue(PB_TS_NUMOBJS, th->iObjParams->GetTime(), th->objects.Count()); break; } } EnableWindow(GetDlgItem(hDlg, IDC_DEL), (th->objects.Count() > 0)); if (th->objects.Count() <= 0) { th->iObjParams->RedrawViews(th->iObjParams->GetTime()); } } } break; case IDC_LIST: switch(HIWORD(wParam)) { case LBN_SELCHANGE: { int sel = SendMessage(GetDlgItem(hDlg,IDC_LIST), LB_GETCURSEL, 0, 0); if (th->dlgPrevSel != -1) { // save any editing TouchSensorObj *obj = (TouchSensorObj *) SendDlgItemMessage(hDlg, IDC_LIST, LB_GETITEMDATA, th->dlgPrevSel, 0); obj->ResetStr(); SendMessage(GetDlgItem(hDlg,IDC_LIST), LB_DELETESTRING, th->dlgPrevSel, 0); int ind = SendMessage(GetDlgItem(hDlg, IDC_LIST), LB_ADDSTRING, 0, (LPARAM)obj->listStr.data()); SendMessage(GetDlgItem(hDlg,IDC_LIST), LB_SETITEMDATA, (WPARAM)ind, (LPARAM)obj); SendMessage(GetDlgItem(hDlg,IDC_LIST), LB_SETCURSEL, sel, 0); } th->dlgPrevSel = sel; if (sel >= 0) { TouchSensorObj *obj = (TouchSensorObj *) SendDlgItemMessage(hDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); assert(obj); } else { } th->iObjParams->RedrawViews(th->iObjParams->GetTime()); } break; case LBN_SELCANCEL: break; } break; } return FALSE; default: return FALSE; } }
BOOL CALLBACK RollupDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, Cal3DObject *th) { if (!th && message != WM_INITDIALOG) return FALSE; switch (message) { case WM_INITDIALOG: { TimeValue t = 0; SendMessage(GetDlgItem(hDlg, IDC_CAL_CFG_URL), WM_SETTEXT, 0, (LPARAM)th->cal3d_cfg.data()); EnableWindow(GetDlgItem(hDlg, IDC_CAL_CFG_URL), TRUE); th->hRollup = hDlg; if (pickMode) SetPickMode(th); return TRUE; } case WM_DESTROY: if (pickMode) SetPickMode(th); // th->iObjParams->ClearPickMode(); // th->previousMode = NULL; RELEASE_SPIN(animationIDSpin); RELEASE_SPIN(actionIDSpin); RELEASE_BUT(Cal3DPickButton); return FALSE; case CC_SPINNER_BUTTONDOWN: { int id = LOWORD(wParam); switch (id) { case IDC_ANIMATION_SPIN: case IDC_ACTION_SPIN2: theHold.Begin(); return TRUE; default: return FALSE; } } break; case CC_SPINNER_BUTTONUP: { if (!HIWORD(wParam)) { theHold.Cancel(); break; } int id = LOWORD(wParam); switch (id) { case IDC_ANIMATION_SPIN: case IDC_ACTION_SPIN2: if (th->getCoreHelper()) th->getCoreHelper()->setState(th->animationIDSpin->GetIVal(), 0.0); theHold.Accept(GetString(IDS_DS_PARAMCHG)); return TRUE; default: return FALSE; } } case CC_SPINNER_CHANGE: { int animID; int id = LOWORD(wParam); TimeValue t = 0; // not really needed...yet switch (id) { case IDC_ANIMATION_SPIN: case IDC_ACTION_SPIN2: if (!HIWORD(wParam)) theHold.Begin(); //actionID = th->actionIDSpin->GetIVal(); //th->animationIDSpin->SetValue(animID, FALSE); //th->actionIDSpin->SetValue(actionID, FALSE); animID = th->animationIDSpin->GetIVal(); if (th->getCoreHelper()) th->getCoreHelper()->setState(animID, 0.0); if (!HIWORD(wParam)) theHold.Accept(GetString(IDS_DS_PARAMCHG)); return TRUE; default: return FALSE; } } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CAL_CFG_URL: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: int len = (int)SendDlgItemMessage(hDlg, IDC_CAL_CFG_URL, WM_GETTEXTLENGTH, 0, 0); TSTR temp; temp.Resize(len + 1); SendDlgItemMessage(hDlg, IDC_CAL_CFG_URL, WM_GETTEXT, len + 1, (LPARAM)temp.data()); #if MAX_PRODUCT_VERSION_MAJOR > 14 th->setURL(temp.ToUTF8().data()); #else th->setURL((char *)temp); #endif break; } break; } return FALSE; default: return FALSE; } return FALSE; }