void plExportDlgImp::IDoExport() { fExporting = true; // Hide the window, since we don't get control back until the export is done ShowWindow(fDlg, SW_HIDE); // Do the export char exportPath[MAX_PATH]; GetDlgItemText(fDlg, IDC_CLIENT_PATH, exportPath, sizeof(exportPath)); strcat(exportPath, "Export.prd"); // For export time stats DWORD exportTime = timeGetTime(); if (fExportFile) IExportCurrentFile(exportPath); else { hsFolderIterator sourceDir(fExportSourceDir); while (sourceDir.NextFileSuffix(".max")) { char exportFile[MAX_PATH]; sourceDir.GetPathAndName(exportFile); if (GetCOREInterface()->LoadFromFile(exportFile)) IExportCurrentFile(exportPath); } } fLastExportTime = (timeGetTime() - exportTime) / 1000; IDestroy(); fExporting = false; }
bool DxStdMtl2::CreateAndLoadEffectData() { ResetDXStates(); if(IsDxMaterialEnabled(map)) { bool useLPRT; TCHAR filename[MAX_PATH]; _tcscpy(filename,GetCOREInterface()->GetDir(APP_PLUGCFG_DIR)); _tcscat(filename,"\\DXDisplay.ini"); useLPRT = GetPrivateProfileInt(_T("Settings"),_T("LPRTEnabled"),0,filename) ? true : false; if(!pd3dDevice) pd3dDevice = GetDevice(); if(!pd3dDevice) return false; if(pEffectParser) { pEffectParser->DestroyParser(); pEffectParser = NULL; } elementContainer.DeleteAllElements(); UpdateSceneLights(); DWORD numberOfPSinst = 0; //lets make sure we get the correct code for the GFX card.. IHLSLCodeGenerator::CodeVersion code = GetPixelShaderSupport(pd3dDevice,numberOfPSinst); if(code == IHLSLCodeGenerator::PS_1_X) return false; IHLSLCodeGenerator * codeGen = IHLSLCodeGenerator::GetHLSLCodeGenerator(); Tab<INode*> lights; for(int j=0;j<sceneLights.Count();j++){ INode * Light = sceneLights[j]->GetLightNode(); lights.Append(1, &Light); } TCHAR * effectString = codeGen->GenerateEffectFile(map,lights,code,bTransparency,numberOfPSinst,useLPRT); if(!pEffectParser) CreateEffectParser(); if(pEffectParser && effectString){ pEffectParser->SetUseLPRT(useLPRT); pEffectParser->LoadEffect(pd3dDevice,this,effectString,false,true); pEffectParser->ParseEffectFile(pd3dDevice,NULL,this); PatchInLightNodes(); LoadTextureData(codeGen); } delete codeGen; IRenderMesh * rm = mpMeshCache->GetActiveRenderMesh(m_CurCache); if(rm) rm->Invalidate(); GetCOREInterface()->ForceCompleteRedraw(FALSE); } return true; }
void plCreateMenu() { #if MAX_VERSION_MAJOR <= 11 AddPlasmaExportMenu(); #endif IMenuManager* pMenuMan = GetCOREInterface()->GetMenuManager(); bool newlyRegistered = pMenuMan->RegisterMenuBarContext(kMyMenuContextId, kMenuName); // Is the Max menu version the most recent? bool wrongVersion = GetPrivateProfileIntW(L"Menu", L"Version", 0, plMaxConfig::GetPluginIni().WideString().data()) < kMenuVersion; if (wrongVersion) { // Delete the old version of the menu IMenu *oldMenu = pMenuMan->FindMenu(kMenuName); if (oldMenu) pMenuMan->UnRegisterMenu(oldMenu); // Update the menu version wchar_t buf[12]; snwprintf(buf, arrsize(buf), L"%d", kMenuVersion); WritePrivateProfileStringW(L"Menu", L"Version", buf, plMaxConfig::GetPluginIni().WideString().data()); } if (wrongVersion || newlyRegistered) { IMenu *pMainMenu = pMenuMan->GetMainMenuBar(); if (!pMainMenu) { hsAssert(0, "Main menu not found"); return; } // Get our action table ActionTable* pActionTable = GetCOREInterface()->GetActionManager()->FindTable(kActionId); if (!pActionTable) { hsAssert(0, "Action table not found"); return; } // Create the Plasma menu IMenu* pPlasmaMenu = GetIMenu(); pPlasmaMenu->SetTitle(kMenuName); // Register the new menu with the system pMenuMan->RegisterMenu(pPlasmaMenu, 0); ///////////////////////////////////////////////// // Add the menu items // IMenuItem* pMenuItem; #if MAX_VERSION_MAJOR >= 12 // Add the export action to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionExport)); pPlasmaMenu->AddItem(pMenuItem); #endif // Add the save selected action to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionSaveSel)); pPlasmaMenu->AddItem(pMenuItem); // Add the merge action to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionMerge)); pPlasmaMenu->AddItem(pMenuItem); // Add the component copy action to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionCompCopy)); pPlasmaMenu->AddItem(pMenuItem); // Add a separator pMenuItem = GetIMenuItem(); pMenuItem->ActAsSeparator(); pPlasmaMenu->AddItem(pMenuItem); // Add the component manager to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionComponent)); pPlasmaMenu->AddItem(pMenuItem); // Add the resource collector to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionResCollect)); pPlasmaMenu->AddItem(pMenuItem); // Add the texture search to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionTexSearch)); pPlasmaMenu->AddItem(pMenuItem); // Add the age description to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionAgeDesc)); pPlasmaMenu->AddItem(pMenuItem); // Add a separator pMenuItem = GetIMenuItem(); pMenuItem->ActAsSeparator(); pPlasmaMenu->AddItem(pMenuItem); // Add the Lock Selected to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionLock)); pPlasmaMenu->AddItem(pMenuItem); // Add the Unlock Selected to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionUnlock)); pPlasmaMenu->AddItem(pMenuItem); // Add the Reset Selected to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionReset)); pPlasmaMenu->AddItem(pMenuItem); // Add the SelectNonRenderables to the menu pMenuItem = GetIMenuItem(); pMenuItem->SetActionItem(pActionTable->GetAction(kActionSelectNonRenderables)); pPlasmaMenu->AddItem(pMenuItem); // Create a new menu item to hold the sub-menu IMenuItem* pSubMenuItem1 = GetIMenuItem(); //menu in menu bar... pSubMenuItem1->SetSubMenu(pPlasmaMenu); pMainMenu->AddItem(pSubMenuItem1); pMenuMan->UpdateMenuBar(); // Save the dang menu, in case Max crashes const char *uiDir = GetCOREInterface()->GetDir(APP_UI_DIR); char path[MAX_PATH]; sprintf(path, "%s\\%s", uiDir, "MaxMenus.mnu"); pMenuMan->SaveMenuFile(path); } }
// Generate all the optimzation and geometry data void morphChannel::buildFromNode( INode *node , BOOL resetTime, TimeValue t, BOOL picked ) { // fix for defect 1346773 - Crash deleting progressive morph target if (NULL == node ) { return; } if(resetTime) t = GetCOREInterface()->GetTime(); ObjectState os = node->EvalWorldState(t); int tPc = os.obj->NumPoints(); int x,id = 0; Point3 DeltP; double wtmp; Point3 tVert; if(tPc!=mp->MC_Local.Count) { mNumPoints = 0; mActive = FALSE; mInvalid = TRUE; goto CantLoadThis; } if(!mp->MC_Local.CacheValid) goto CantLoadThis; mInvalid = FALSE; // if the channel hasn't been edited yet, change the 'empty' // name to that of the chosen object. if( !mModded || picked) mName = node->GetName(); // Set the data into the morphChannel mActive = TRUE; mModded = TRUE; // Prepare the channel AllocBuffers(tPc, tPc); mSel.SetSize(tPc); mSel.ClearAll(); mNumPoints = 0; for(x=0;x<tPc;x++) { tVert = os.obj->GetPoint(x); wtmp = os.obj->GetWeight(x); // calculate the delta cache DeltP.x=(tVert.x-mp->MC_Local.oPoints[x].x)/100.0f; DeltP.y=(tVert.y-mp->MC_Local.oPoints[x].y)/100.0f; DeltP.z=(tVert.z-mp->MC_Local.oPoints[x].z)/100.0f; mDeltas[x] = DeltP; mWeights[x] = os.obj->GetWeight(x); mSel.Set( x, os.obj->IsPointSelected(x)?1:0); mPoints[x] = tVert; mNumPoints++; } // Update *everything* mp->NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); mp->NotifyDependents(FOREVER,PART_ALL,REFMSG_SUBANIM_STRUCTURE_CHANGED); mp->Update_channelFULL(); mp->Update_channelParams(); CantLoadThis: tPc=0; }
BOOL plPlasmaMAXLayer::HandleBitmapSelection(int index /* = 0 */) { static ICustButton* bmSelectBtn; PBBitmap *pbbm = GetPBBitmap( index ); #ifdef MAXASS_AVAILABLE MaxAssInterface* maxAssInterface = GetMaxAssInterface(); #endif // If the control key is held, we want to get rid of this texture if ((GetKeyState(VK_CONTROL) & 0x8000) && pbbm != nil) { char msg[512]; sprintf(msg, "Are you sure you want to change this bitmap from %s to (none)?", pbbm->bi.Name()); if (hsMessageBox(msg, "Remove texture?", hsMessageBoxYesNo) == hsMBoxYes) { SetBitmap(nil, index); return TRUE; } return FALSE; } // if we have the assetman plug-in, then try to use it, unless shift is held down #ifdef MAXASS_AVAILABLE else if(maxAssInterface && !(GetKeyState(VK_SHIFT) & 0x8000)) { jvUniqueId assetId; GetBitmapAssetId(assetId, index); char filename[MAX_PATH]; if (maxAssInterface->OpenBitmapDlg(assetId, filename, sizeof(filename))) { SetBitmapAssetId(assetId, index); BitmapInfo bi; bi.SetName(filename); SetBitmap(&bi, index); return TRUE; } } #endif else { BitmapInfo bi; if( pbbm != NULL ) bi.SetName( pbbm->bi.Name() ); BOOL selectedNewBitmap = TheManager->SelectFileInput(&bi, GetCOREInterface()->GetMAXHWnd(), _T("Select Bitmap Image File")); if (selectedNewBitmap) { #ifdef MAXASS_AVAILABLE // Set the assetId to empty so our new, unmanaged texture will take jvUniqueId emptyId; SetBitmapAssetId(emptyId, index); #endif SetBitmap(&bi, index); return TRUE; } } return FALSE; }
BOOL WeightTableWindow::WtExecute(int id) { BOOL iret = FALSE; switch (id) { //edit case IDC_COPY : { SetCopyBuffer(); iret = TRUE; UpdatePasteButton(); break; } case IDC_PASTE : { PasteCopyBuffer(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTALL: { SetAllSelections(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTNONE: { ClearAllSelections(); InvalidateViews(); iret = TRUE; break; } case IDC_SELECTINVERT: { InvertSelections(); InvalidateViews(); iret = TRUE; break; } //sets case IDC_CREATE : { DialogBoxParam (hInstance, MAKEINTRESOURCE(IDD_WEIGHTTABLE_CUSTOMLISTNAME),hWnd, AddCustomListDlgProc, (LPARAM)this); iret = TRUE; break; } case IDC_DELETE : { if (GetActiveSet() >2) DeleteCustomList(GetActiveSet()); iret = TRUE; // PasteCopyBuffer(); // InvalidateViews(); break; } //options case IDC_AFFECTEDBONES_CHECK : { if (GetAffectedBonesOnly()) SetAffectedBonesOnly(FALSE); else SetAffectedBonesOnly(TRUE); iret = TRUE; break; } case IDC_UPDATEONMOUSEUP_CHECK2 : { if (GetUpdateOnMouseUp()) SetUpdateOnMouseUp(FALSE); else SetUpdateOnMouseUp(TRUE); iret = TRUE; break; } case IDC_FLIPFLOPUI_CHECK2 : { if (GetFlipFlopUI()) SetFlipFlopUI(FALSE); else SetFlipFlopUI(TRUE); iret = TRUE; break; } case IDC_ATTRIBUTE_CHECK2 : { if (GetShowAttributes()) SetShowAttributes(FALSE); else SetShowAttributes(TRUE); iret = TRUE; break; } case IDC_GLOBAL_CHECK2 : { if (GetShowGlobals()) SetShowGlobals(FALSE); else SetShowGlobals(TRUE); iret = TRUE; break; } case IDC_REDUCELABELS_CHECK2 : { if (GetReduceLabels()) SetReduceLabels(FALSE); else SetReduceLabels(TRUE); iret = TRUE; break; } case IDC_SHOWEXCLUSION_CHECK : { if (GetShowExclusion()) SetShowExclusion(FALSE); else SetShowExclusion(TRUE); iret = TRUE; break; } case IDC_SHOWLOCK_CHECK : { if (GetShowLock()) SetShowLock(FALSE); else SetShowLock(TRUE); iret = TRUE; break; } case IDC_NAMELISTGLOBAL_DROP : { if (GetAffectSelectedOnly()) SetAffectSelectedOnly(FALSE); else SetAffectSelectedOnly(TRUE); iret = TRUE; break; } case IDC_JBUIMETHOD : { if (GetJBMethod()) SetJBMethod(FALSE); else SetJBMethod(TRUE); iret = TRUE; break; } case IDC_SHOWMENU : { if (GetShowMenu()) SetShowMenu(FALSE); else SetShowMenu(TRUE); iret = TRUE; break; } case IDC_SHOWSETUI : { if (GetShowSetUI()) SetShowSetUI(FALSE); else SetShowSetUI(TRUE); iret = TRUE; break; } case IDC_SHOWOPTIONSUI : { if (GetShowOptionsUI()) SetShowOptionsUI(FALSE); else SetShowOptionsUI(TRUE); iret = TRUE; break; } case IDC_SHOWCOPYPASTEUI : { if (GetShowCopyPasteUI()) SetShowCopyPasteUI(FALSE); else SetShowCopyPasteUI(TRUE); iret = TRUE; break; } case IDC_DRAGMODE : { if (GetDragLeftMode()) SetDragLeftMode(FALSE); else SetDragLeftMode(TRUE); iret = TRUE; break; } case IDC_DEBUGMODE : { if (GetDebugMode()) SetDebugMode(FALSE); else SetDebugMode(TRUE); iret = TRUE; break; } case IDC_SHOWMARKER : { if (GetShowMarker()) SetShowMarker(FALSE); else SetShowMarker(TRUE); iret = TRUE; break; } //5.1.01 case IDC_RIGHTJUSTIFY: { if (GetRightJustify()) SetRightJustify(FALSE); else SetRightJustify(TRUE); break; } } IMenuBarContext* pContext = (IMenuBarContext*) GetCOREInterface()->GetMenuManager()->GetContext(kWeightTableMenuBar); if (pContext) pContext->UpdateWindowsMenu(); return iret; }
INT_PTR CALLBACK RigidBodyWorld::Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { RigidBodyWorld* const world = (RigidBodyWorld *)GetWindowLong (hWnd, GWLP_USERDATA); RigidBodyWorldDesc* const desc = (RigidBodyWorldDesc*) RigidBodyWorldDesc::GetDescriptor(); switch (msg) { case WM_INITDIALOG: { RigidBodyWorld* const world = (RigidBodyWorld *)lParam; SetWindowLong(hWnd, GWLP_USERDATA, (LONG)world); world->m_myWindow = hWnd; world->RigidBodyWorld::InitUI(hWnd); break; } case WM_DESTROY: { world->StopsSimulation (); world->RigidBodyWorld::DestroyUI(hWnd); break; } case WM_ENABLE: { //EnableWindow(obj->m_worldPaneHandle, (BOOL) wParam); break; } case WM_TIMER: { world->UpdatePhysics (); break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_MAKE_RIGIDBODY: { world->StopsSimulation (); Interface* const ip = GetCOREInterface(); int selectionCount = ip->GetSelNodeCount(); for (int i = 0; i < selectionCount; i ++) { INode* const node = ip->GetSelNode(i); Object* const obj = node->GetObjOrWSMRef(); if (obj) { world->AttachRigiBodyController (node); } } world->UpdateViewPorts(); break; } case IDC_DELETE_RIGIDBODY: { world->StopsSimulation (); Interface* const ip = GetCOREInterface(); int selectionCount = ip->GetSelNodeCount(); for (int i = 0; i < selectionCount; i ++) { INode* const node = ip->GetSelNode(i); world->DetachRigiBodyController (node); } world->UpdateViewPorts (); break; } case IDC_SHOW_GIZMOS: { world->StopsSimulation (); for (NewtonBody* body = NewtonWorldGetFirstBody(desc->m_newton); body; body = NewtonWorldGetNextBody(desc->m_newton, body)) { INode* const node = (INode*)NewtonBodyGetUserData(body); RigidBodyController* const bodyInfo = (RigidBodyController*)desc->GetRigidBodyControl(node); _ASSERTE (bodyInfo); bodyInfo->m_hideGizmos = FALSE; } world->UpdateViewPorts(); break; } case IDC_HIDE_GIZMOS: { world->StopsSimulation (); for (NewtonBody* body = NewtonWorldGetFirstBody(desc->m_newton); body; body = NewtonWorldGetNextBody(desc->m_newton, body)) { INode* const node = (INode*)NewtonBodyGetUserData(body); RigidBodyController* const bodyInfo = (RigidBodyController*)desc->GetRigidBodyControl(node); _ASSERTE (bodyInfo); bodyInfo->m_hideGizmos = TRUE; } world->UpdateViewPorts(); break; } case IDC_SELECT_ALL: { world->StopsSimulation (); world->m_selectionChange = false; Interface* const ip = GetCOREInterface(); ip->ClearNodeSelection(FALSE); for (NewtonBody* body = NewtonWorldGetFirstBody(desc->m_newton); body; body = NewtonWorldGetNextBody(desc->m_newton, body)) { INode* const node = (INode*)NewtonBodyGetUserData(body); ip->SelectNode(node, 0); } world->m_selectionChange = true; world->SelectionSetChanged (ip, NULL); world->UpdateViewPorts(); break; } case IDC_REMOVE_ALL: { world->StopsSimulation (); Interface* const ip = GetCOREInterface(); ip->ClearNodeSelection(FALSE); for (NewtonBody* body = NewtonWorldGetFirstBody(desc->m_newton); body; ) { INode* const node = (INode*)NewtonBodyGetUserData(body); body = NewtonWorldGetNextBody(desc->m_newton, body); world->DetachRigiBodyController (node); } world->UpdateViewPorts(); break; } case IDC_MINUMIN_SIMULATION_RATE: { world->StopsSimulation (); desc->m_minFps = world->m_minFps->GetFloat(); break; } case IDC_GRAVITY_X: case IDC_GRAVITY_Y: case IDC_GRAVITY_Z: { world->StopsSimulation (); dVector gravity (world->m_gravity[0]->GetFloat(), world->m_gravity[1]->GetFloat(), world->m_gravity[2]->GetFloat(), 0.0f); //world->m_gravity[0]->SetText(gravity.m_x, 1); //world->m_gravity[1]->SetText(gravity.m_y, 1); //world->m_gravity[2]->SetText(gravity.m_z, 1); desc->m_gravity = desc->m_systemMatrix.RotateVector(gravity.Scale(float (GetMasterScale(UNITS_METERS)))); break; } case IDC_PREVIEW_WORLD: { if (IsDlgButtonChecked(hWnd, IDC_PREVIEW_WORLD) == BST_CHECKED) { world->Undo(); unsigned timeOut = unsigned (1000.0f / desc->m_minFps); SetTimer(hWnd, TIMER_ID, timeOut, NULL); } else { world->StopsSimulation (); } break; } case IDC_STEP_WORLD: { world->StopsSimulation (); world->Undo(); world->UpdatePhysics (); break; } } break; } default: return FALSE; } return TRUE; }
void ConeAngleManipulator::GenerateShapes(TimeValue t) { Point3 direction; float distance, angle, aspect; BOOL useSquare; mValid = FOREVER; mpPblock->GetValue(kConeAngleAngle, t, angle, mValid); mpPblock->GetValue(kConeAngleDistance, t, distance, mValid); mpPblock->GetValue(kConeAngleDirection, t, direction, mValid); mpPblock->GetValue(kConeAngleUseSquare, t, useSquare, mValid); mpPblock->GetValue(kConeAngleAspect, t, aspect, mValid); ClearPolyShapes(); // Create the circle at the base of the cone float ta = (float)tan(0.5 * angle); float rad = distance * ta; IManipulatorMgr* pMM = (IManipulatorMgr*) GetCOREInterface(MANIP_MGR_INTERFACE); assert(pMM); if (!useSquare) { // Use a circle gizmo GizmoShape* pGizmo = pMM->MakeCircle(Point3(0.0f, 0.0f, -distance), rad, 28); AppendGizmo(pGizmo, 0, GetUnselectedColor()); delete pGizmo; // if a stand-alone manip, draw the struts if (!mhTarget) { pGizmo = pMM->MakeGizmoShape(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(rad, 0.0f, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(-rad, 0.0f, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(0.0f, rad, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(0.0f, -rad, -distance)); AppendGizmo(pGizmo, 0, GetUnselectedColor(), GetUnselectedColor()); delete pGizmo; } } else { // Use a square gizmo float radAspect = rad * (float) sqrt(aspect); float radInvAspect = radAspect / aspect; GizmoShape* pGizmo = pMM->MakeGizmoShape(); pGizmo->AppendPoint(Point3(-radAspect, -radInvAspect, -distance)); pGizmo->AppendPoint(Point3(-radAspect, radInvAspect, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3( radAspect, -radInvAspect, -distance)); pGizmo->AppendPoint(Point3( radAspect, radInvAspect, -distance)); AppendGizmo(pGizmo, 0, GetUnselectedColor()); delete pGizmo; pGizmo = pMM->MakeGizmoShape(); pGizmo->AppendPoint(Point3(-radAspect, radInvAspect, -distance)); pGizmo->AppendPoint(Point3( radAspect, radInvAspect, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(-radAspect, -radInvAspect, -distance)); pGizmo->AppendPoint(Point3( radAspect, -radInvAspect, -distance)); AppendGizmo(pGizmo, 0, GetUnselectedColor()); delete pGizmo; // if a stand-alone manip, draw the struts if (!mhTarget) { pGizmo = pMM->MakeGizmoShape(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(-radAspect, -radInvAspect, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3(-radAspect, radInvAspect, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3( radAspect, -radInvAspect, -distance)); pGizmo->StartNewLine(); pGizmo->AppendPoint(Point3(0,0,0)); pGizmo->AppendPoint(Point3( radAspect, radInvAspect, -distance)); AppendGizmo(pGizmo, 0, GetUnselectedColor(), GetUnselectedColor()); delete pGizmo; } } }
//From MtlBase void BerconTile::Reset() { TimeValue t = GetCOREInterface()->GetTime(); if (texout) texout->Reset(); else ReplaceReference( OUTPUT_REF, GetNewDefaultTextureOutput()); for (int i=0; i<TILE_NSUBTEX; i++) DeleteReference(i+2); pblock->SetValue( noise_color1, t, Color(1.f, 1.f, 1.f)); pblock->SetValue( noise_color2, t, Color(0.f, 0.f, 0.f)); pblock->SetValue( noise_color3, t, Color(.5f, .5f, .5f)); pblock->SetValue( noise_map1_on, t, TRUE); pblock->SetValue( noise_map2_on, t, TRUE); pblock->SetValue( noise_map2_on, t, TRUE); pblock->SetValue( distortion_str, t, .1f); pblock->SetValue( use_distortion, t, FALSE); pblock->SetValue( lock_edge, t, TRUE); pblock->SetValue( tile_style, t, 3); pblock->SetValue( tile_size, t, 1.0f); pblock->SetValue( tile_width, t, 4.f); pblock->SetValue( tile_height, t, 2.f); pblock->SetValue( edge_width, t, .1f); pblock->SetValue( edge_height, t, .1f); pblock->SetValue( tile_width2, t, 0.f); pblock->SetValue( tile_height2, t, 0.f); pblock->SetValue( edge_width2, t, 0.f); pblock->SetValue( edge_height2, t, 0.f); pblock->SetValue( soften, t, 2); pblock->SetValue( soften_rad, t, .1f); pblock->SetValue( pb_round, t, TRUE); pblock->SetValue( round_rad, t, .1f); pblock->SetValue( pb_map_uv, t, FALSE); pblock->SetValue( pb_uv_channel, t, 1); pblock->SetValue( pb_auto, t, 2); pblock->SetValue( pb_randX, t, 0.f); pblock->SetValue( pb_randY, t, 0.f); pblock->SetValue( pb_randSX, t, 0.f); pblock->SetValue( pb_randSY, t, 0.f); pblock->SetValue( pb_lock, t, 1); pblock->SetValue( pb_rotUV, t, 0); pblock->SetValue( pb_randRot, t, 180.f); pblock->SetValue( pb_center, t, 0); pblock->SetValue( pb_center_channel, t, 2); pblock->SetValue( pb_flipX, t, 1); pblock->SetValue( pb_flipY, t, 1); pblock->SetValue( pb_randZ, t, 1); pblock->SetValue(pb_pattern, t, L"0,1,1/.5,.5,1"); // Maps for (int i=2; i<4; i++) pbMap->SetValue(i, t, TRUE); berconXYZ.reset(pbXYZ, ivalid, 1, 0, 0, 0); ivalid.SetEmpty(); }
void SetThing(ReferenceTarget *m) { tile = (BerconTile*)m; tile->EnableStuff(GetCOREInterface()->GetTime()); }
int TapeHelpCreationManager::proc( HWND hwnd, int msg, int point, int flag, IPoint2 m ) { int res = TRUE; TSTR targName; ViewExp& vpx = createInterface->GetViewExp(hwnd); assert( vpx.IsAlive() ); DWORD hideflags; switch ( msg ) { case MOUSE_POINT: switch ( point ) { case 0: { pt0 = m; assert( tapeObject ); if ( createInterface->SetActiveViewport(hwnd) ) { return FALSE; } if (createInterface->IsCPEdgeOnInView()) { res = FALSE; goto done; } // if helpers were hidden by category, re-display them hideflags = GetCOREInterface()->GetHideByCategoryFlags(); if(hideflags & (HIDE_HELPERS)) { hideflags = hideflags & ~(HIDE_HELPERS); GetCOREInterface()->SetHideByCategoryFlags(hideflags); hideflags = GetCOREInterface()->GetHideByCategoryFlags(); } if ( attachedToNode ) { // send this one on its way tapeObject->EndEditParams( (IObjParam*)createInterface, 0, NULL); macroRec->EmitScript(); // Get rid of the reference. if (tapeNode) DeleteReference(0); // new object CreateNewObject(); // creates tapeObject } needToss = theHold.GetGlobalPutCount()!=lastPutCount; theHold.Begin(); // begin hold for undo mat.IdentityMatrix(); // link it up INode *l_tapeNode = createInterface->CreateObjectNode( tapeObject); attachedToNode = TRUE; assert( l_tapeNode ); createCB = tapeObject->GetCreateMouseCallBack(); createInterface->SelectNode( l_tapeNode ); // Create target object and node targObject = (Object*) createInterface->CreateInstance(GEOMOBJECT_CLASS_ID,Class_ID(TARGET_CLASS_ID,0)); targObject->SetAFlag(A_OBJ_LONG_CREATE); assert(targObject); targNode = createInterface->CreateObjectNode( targObject); assert(targNode); targName = l_tapeNode->GetName(); targName += GetString(IDS_DB_DOT_TARGET); macroRec->Disable(); targNode->SetName(targName); macroRec->Enable(); // hook up camera to target using lookat controller. createInterface->BindToTarget(l_tapeNode,targNode); // Reference the new node so we'll get notifications. theHold.Suspend(); ReplaceReference( 0, l_tapeNode); theHold.Resume(); // Position camera and target at first point then drag. mat.IdentityMatrix(); //mat[3] = vpx.GetPointOnCP(m); #ifdef _3D_CREATE mat.SetTrans( vpx.SnapPoint(m,m,NULL,SNAP_IN_3D) ); #else mat.SetTrans(vpx.SnapPoint(m,m,NULL,SNAP_IN_PLANE)); #endif createInterface->SetNodeTMRelConstPlane(tapeNode, mat); createInterface->SetNodeTMRelConstPlane(targNode, mat); tapeObject->Enable(1); ignoreSelectionChange = TRUE; createInterface->SelectNode( targNode,0); ignoreSelectionChange = FALSE; res = TRUE; } break; case 1: if (Length(m-pt0)<2) goto abort; //mat[3] = vpx.GetPointOnCP(m); #ifdef _3D_CREATE mat.SetTrans( vpx.SnapPoint(m,m,NULL,SNAP_IN_3D) ); #else mat.SetTrans(vpx.SnapPoint(m,m,NULL,SNAP_IN_PLANE)); #endif macroRec->Disable(); createInterface->SetNodeTMRelConstPlane(targNode, mat); macroRec->Enable(); ignoreSelectionChange = TRUE; createInterface->SelectNode( tapeNode); ignoreSelectionChange = FALSE; createInterface->RedrawViews(createInterface->GetTime()); theHold.Accept(IDS_DS_CREATE); targObject->ClearAFlag(A_OBJ_LONG_CREATE); res = FALSE; // We're done break; } break; case MOUSE_MOVE: //mat[3] = vpx.GetPointOnCP(m); #ifdef _3D_CREATE mat.SetTrans( vpx.SnapPoint(m,m,NULL,SNAP_IN_3D) ); #else mat.SetTrans(vpx.SnapPoint(m,m,NULL,SNAP_IN_PLANE)); #endif macroRec->Disable(); createInterface->SetNodeTMRelConstPlane(targNode, mat); macroRec->Enable(); createInterface->RedrawViews(createInterface->GetTime()); macroRec->SetProperty(tapeObject, _T("target"), // JBW 4/23/99 mr_create, Class_ID(TARGET_CLASS_ID, 0), GEOMOBJECT_CLASS_ID, 1, _T("transform"), mr_matrix3, &mat); res = TRUE; break; case MOUSE_FREEMOVE: SetCursor(LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CROSS_HAIR))); #ifdef _OSNAP //Snap Preview #ifdef _3D_CREATE vpx.SnapPreview(m,m,NULL, SNAP_IN_3D); #else vpx.SnapPreview(m,m,NULL, SNAP_IN_PLANE); #endif #endif break; case MOUSE_PROPCLICK: // right click while between creations createInterface->RemoveMode(NULL); break; case MOUSE_ABORT: abort: assert( tapeObject ); tapeObject->EndEditParams( (IObjParam*)createInterface,0,NULL); macroRec->Cancel(); theHold.Cancel(); // deletes both the camera and target. // Toss the undo stack if param changes have been made if (needToss) GetSystemSetting(SYSSET_CLEAR_UNDO); tapeNode = NULL; targNode = NULL; createInterface->RedrawViews(createInterface->GetTime()); CreateNewObject(); attachedToNode = FALSE; res = FALSE; } done: return res; }
void APITestUtil::CombinedTests() { // now let's build a test object NURBSSet nset; Matrix3 mat; mat.IdentityMatrix(); // build an independent point int indPnt = MakeTestPoint(nset); // now a constrained point int ptPnt = MakeTestPointCPoint(nset, indPnt); // build a cv curve int cvCrv = MakeTestCVCurve(nset, mat); // and a constrained point on that curve int crvPnt = MakeTestCurveCPoint(nset, cvCrv); // now a point curve int ptCrv = MakeTestPointCurve(nset, mat); // Blend the two curves int blendCrv = MakeTestBlendCurve(nset, cvCrv, ptCrv); // make an offset of the CV curve int offCrv = MakeTestOffsetCurve(nset, cvCrv); // make a Transform curve of the point curve int xformCrv = MakeTestXFormCurve(nset, ptCrv); // make a mirror of the blend int mirCrv = MakeTestMirrorCurve(nset, blendCrv); // make a fillet curve (It makes it's own point curves to fillet) int fltCrv = MakeTestFilletCurve(nset); // make a chamfer curve (It makes it's own point curves to fillet) int chmCrv = MakeTestChamferCurve(nset); // build a cv surface int cvSurf = MakeTestCVSurface(nset, mat); // and a constrained point on that surface int srfPnt = MakeTestSurfCPoint(nset, cvSurf); // Curve Surface intersection point. int cvCrv2 = MakeTestCVCurve(nset, RotateXMatrix(PI/2.0f) * TransMatrix(Point3(0, 0, -175))); int srfIntPoint = MakeTestCurveSurface(nset, cvSurf, cvCrv2); // Now an Iso Curve on the CV surface int isoCrv1 = MakeTestIsoCurveU(nset, cvSurf); // Now an Iso Curve on the CV surface int isoCrv2 = MakeTestIsoCurveV(nset, cvSurf); // Now a Surface Edge Curve on the CV surface int surfEdgeCrv = MakeTestSurfaceEdgeCurve(nset, cvSurf); // build a CV Curve on Surface int cvCOS = MakeTestCurveOnSurface(nset, cvSurf); // build a Point Curve on Surface int pntCOS = MakeTestPointCurveOnSurface(nset, cvSurf); // build a Surface Normal Offset Curve int cnoCrf = MakeTestSurfaceNormalCurve(nset, cvCOS); // Make a curve-curve intersection point int curveCurve = MakeTestCurveCurve(nset, isoCrv1, isoCrv2, TRUE); // build a point surface int ptSurf = MakeTestPointSurface(nset, mat); // Blend the two surfaces int blendSurf = MakeTestBlendSurface(nset, cvSurf, ptSurf); // Offset of the blend int offSurf = MakeTestOffsetSurface(nset, blendSurf); // Transform of the Offset int xformSurf = MakeTestXFormSurface(nset, offSurf); // Mirror of the transform surface int mirSurf = MakeTestMirrorSurface(nset, xformSurf); // Make a Ruled surface between two curves int rulSurf = MakeTestRuledSurface(nset, cvCrv, ptCrv); // Make a ULoft surface int uLoftSurf = MakeTestULoftSurface(nset, ptCrv, offCrv, xformCrv); // Make a Extrude surface int extSurf = MakeTestExtrudeSurface(nset, xformCrv); // Make a lathe int lthSurf = MakeTestLatheSurface(nset); // these will build their own curves to work with // UV Loft int uvLoftSurf = MakeTestUVLoftSurface(nset); // 1 Rail Sweep int oneRailSurf = MakeTest1RailSweepSurface(nset); // 2 Rail Sweep int twoRailSurf = MakeTest2RailSweepSurface(nset); // MultiCurveTrim Surface int multiTrimSurf = MakeTestMultiCurveTrimSurface(nset); // Now make the curves and surfaces that we'll use later for the join tests int jc1, jc2, js1, js2; AddObjectsForJoinTests(nset, jc1, jc2, js1, js2); int bc, bs; AddObjectsForBreakTests(nset, bc, bs); Object *obj = CreateNURBSObject(mpIp, &nset, mat); INode *node = mpIp->CreateObjectNode(obj); node->SetName(GetString(IDS_TEST_OBJECT)); NURBSSet addNset; // build a point surface int addptSurf = AddTestPointSurface(addNset); // add an iso curve to the previously created CV Surface NURBSId id = nset.GetNURBSObject(cvSurf)->GetId(); int addIsoCrv = AddTestIsoCurve(addNset, id); AddNURBSObjects(obj, mpIp, &addNset); // now test some changing functionality // Let's change the name of the CVSurface NURBSObject* nObj = nset.GetNURBSObject(cvSurf); nObj->SetName(_T("New CVSurf Name")); // testing only, no need to localize // now let's change the position of one of the points in the point curve NURBSPointCurve* ptCrvObj = (NURBSPointCurve*)nset.GetNURBSObject(ptCrv); ptCrvObj->GetPoint(0)->SetPosition(0, Point3(10, 160, 0)); // moved from 0,150,0 // now let's change the position and weight of one of the CVs // in the CV Surface NURBSCVSurface* cvSurfObj = (NURBSCVSurface*)nset.GetNURBSObject(cvSurf); cvSurfObj->GetCV(0, 0)->SetPosition(0, Point3(-150.0, -100.0, 20.0)); // moved from 0,0,0 cvSurfObj->GetCV(0, 0)->SetWeight(0, 2.0); // from 1.0 // now let's do a transform of a curve. NURBSIdTab xfmTab; NURBSId nid = nset.GetNURBSObject(jc1)->GetId(); xfmTab.Append(1, &nid); Matrix3 xfmMat; xfmMat = TransMatrix(Point3(10, 10, -10)); SetXFormPacket xPack(xfmMat); NURBSResult res = Transform(obj, xfmTab, xPack, xfmMat, 0); // Now let's Join two curves NURBSId jc1id = nset.GetNURBSObject(jc1)->GetId(), jc2id = nset.GetNURBSObject(jc2)->GetId(); JoinCurves(obj, jc1id, jc2id, FALSE, TRUE, 20.0, 1.0f, 1.0f, 0); // Now let's Join two surfaces NURBSId js1id = nset.GetNURBSObject(js1)->GetId(), js2id = nset.GetNURBSObject(js2)->GetId(); JoinSurfaces(obj, js1id, js2id, 1, 0, 20.0, 1.0f, 1.0f, 0); // Break a Curve NURBSId bcid = nset.GetNURBSObject(bc)->GetId(); BreakCurve(obj, bcid, .5, 0); // Break a Surface NURBSId bsid = nset.GetNURBSObject(bs)->GetId(); BreakSurface(obj, bsid, TRUE, .5, 0); mpIp->RedrawViews(mpIp->GetTime()); nset.DeleteObjects(); addNset.DeleteObjects(); // now do a detach NURBSSet detset; Matrix3 detmat; detmat.IdentityMatrix(); // build a cv curve int detcvCrv = MakeTestCVCurve(detset, detmat); // now a point curve int detptCrv = MakeTestPointCurve(detset, detmat); // Blend the two curves int detblendCrv = MakeTestBlendCurve(detset, detcvCrv, detptCrv); Object *detobj = CreateNURBSObject(mpIp, &detset, detmat); INode *detnode = mpIp->CreateObjectNode(detobj); detnode->SetName("Detach From"); BOOL copy = TRUE; BOOL relational = TRUE; NURBSIdList detlist; NURBSId oid = detset.GetNURBSObject(detblendCrv)->GetId(); detlist.Append(1, &oid); DetachObjects(GetCOREInterface()->GetTime(), detnode, detobj, detlist, "Detach Test", copy, relational); mpIp->RedrawViews(mpIp->GetTime()); }
DisplayState BendManip::MouseLeavesObject(TimeValue t, ViewExp* pVpt, IPoint2& m, ManipHitData* pHitData) { mouseWithin = FALSE; GetCOREInterface()->NodeInvalidateRect(node); return kFullRedrawNeeded; }
BOOL plComponentDlg::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: fhDlg = hDlg; IAddComponentsRecur(GetDlgItem(hDlg, IDC_TREE), (plMaxNode*)GetCOREInterface()->GetRootNode()); ICreateMenu(); ICreateRightClickMenu(); return TRUE; case WM_SIZING: IPositionControls((RECT*)lParam, wParam); return TRUE; case WM_ACTIVATE: if (LOWORD(wParam) == WA_INACTIVE) plMaxAccelerators::Enable(); else plMaxAccelerators::Disable(); return TRUE; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL) { ShowWindow(hDlg, SW_HIDE); fInterface->UnRegisterDlgWnd(hDlg); return TRUE; } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ATTACH) { IAttachTreeSelection(); return TRUE; } else if (HIWORD(wParam) == EN_KILLFOCUS && LOWORD(wParam) == IDC_COMMENTS) { IGetComment(); return TRUE; } // "Refresh" menu item else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REFRESH) { IRefreshTree(); return TRUE; } // "Remove unused components" menu item else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REMOVE_UNUSED) { IRemoveUnusedComps(); return TRUE; } // Item selected from 'New' menu else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) >= MENU_ID_START) { ClassDesc *desc = plComponentMgr::Inst().Get(LOWORD(wParam)-MENU_ID_START); // If this is a component type (not a category) if (desc) { // Create an object of that type and a node to reference it Object *obj = (Object*)GetCOREInterface()->CreateInstance(desc->SuperClassID(), desc->ClassID()); INode *node = GetCOREInterface()->CreateObjectNode(obj); plComponentBase *comp = (plComponentBase*)obj; node->Hide(!comp->AllowUnhide()); node->Freeze(TRUE); // Add the new component to the tree HWND hTree = GetDlgItem(hDlg, IDC_TREE); HTREEITEM item = IAddComponent(hTree, (plMaxNode*)node); TreeView_SelectItem(hTree, item); TreeView_EnsureVisible(hTree, item); } } break; case WM_NOTIFY: NMHDR *nmhdr = (NMHDR*)lParam; if (nmhdr->idFrom == IDC_TREE) { switch (nmhdr->code) { case TVN_SELCHANGED: { NMTREEVIEW *tv = (NMTREEVIEW*)lParam; IGetComment(); bool isComponent = IIsComponent(tv->itemNew.lParam); // If the new selection is a component, enable the attach button and comment field EnableWindow(GetDlgItem(hDlg, IDC_ATTACH), isComponent); SendDlgItemMessage(hDlg, IDC_COMMENTS, EM_SETREADONLY, !isComponent, 0); if (isComponent) { fCommentNode = (plMaxNode*)tv->itemNew.lParam; TSTR buf; fCommentNode->GetUserPropBuffer(buf); SetDlgItemText(hDlg, IDC_COMMENTS, buf); } else { fCommentNode = nil; SetDlgItemText(hDlg, IDC_COMMENTS, ""); } return TRUE; } break; case TVN_BEGINLABELEDIT: // If this isn't a component, don't allow the edit if (!IIsComponent(((NMTVDISPINFO*)lParam)->item.lParam)) { SetWindowLong(hDlg, DWL_MSGRESULT, TRUE); return TRUE; } // The edit box this creates kills the focus on our window, causing // accelerators to be enabled. Add an extra disable to counteract that. plMaxAccelerators::Disable(); return TRUE; // Finishing changing the name of a component case TVN_ENDLABELEDIT: { NMTVDISPINFO *di = (NMTVDISPINFO*)lParam; char* text = di->item.pszText; // If the name was changed... if (text && *text != '\0') { // Update the name of the node plMaxNode *node = IGetTreeSelection(); node->SetName(text); // Update the name in the panel too if (plComponentUtil::Instance().IsOpen()) plComponentUtil::Instance().IUpdateNodeName(node); // Make sure Max knows the file was changed SetSaveRequiredFlag(); // Return true to keep the changes SetWindowLong(hDlg, DWL_MSGRESULT, TRUE); } plMaxAccelerators::Enable(); } return TRUE; // User double-clicked. Select the objects the selected component is attached to. case NM_DBLCLK: ISelectTreeSelection(); return TRUE; case NM_RCLICK: IOpenRightClickMenu(); return TRUE; case TVN_KEYDOWN: // User pressed delete if (((NMTVKEYDOWN*)lParam)->wVKey == VK_DELETE) { IDeleteComponent(IGetTreeSelection()); return TRUE; } break; } } break; } return FALSE; }
void DxStdMtl2::LoadTextureData(IHLSLCodeGenerator * codeGen) { Bitmap * bmap; BitmapInfo stBI; TimeValue t = GetCOREInterface()->GetTime(); int nWidth,nHeight; int numberOfTextures = elementContainer.NumberofElementsByType(EffectElements::kEleTex); for(int i=0; i<numberOfTextures;i++) { bool bBump; TextureElement * texEle = static_cast<TextureElement*>(elementContainer.GetElementByType(i,EffectElements::kEleTex)); TSTR mapType = texEle->GetMapName(); Texmap *texmap = codeGen->GetShaderDefinedTexmap(map,mapType.data(),bBump); if(texmap) { BMM_Color_64 *p; nWidth = nHeight = DIMDEFAULT; BitmapDimensions(nWidth,nHeight,texmap); // load and create the D3D texture; /* if(texmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0)) { BitmapTex *pBT; Bitmap *pTex; pBT = (BitmapTex *)texmap; pTex = pBT->GetBitmap(t); if (pTex) { nWidth = getClosestPowerOf2(pTex->Width()); nHeight = getClosestPowerOf2(pTex->Height()); } } */ stBI.SetType(BMM_TRUE_32); stBI.SetWidth(nWidth); stBI.SetHeight(nHeight); bmap = TheManager->Create(&stBI); if (bmap) { // LPDIRECT3DTEXTURE9 pRenderTex = texEle->GetD3DTexture(); texmap->RenderBitmap(t, bmap, MAPSCALE3D * 2.0f); p = new BMM_Color_64[nWidth*nHeight]; for (int y = 0; y < nHeight; y++) bmap->GetLinearPixels(0, y, nWidth, p + y * nWidth); if(texEle->pTex) { D3DSURFACE_DESC stLD; texEle->pTex->GetLevelDesc(0, &stLD); if (stLD.Width != nWidth || stLD.Height != nHeight) { SAFE_RELEASE(texEle->pTex); } } if(!texEle->pTex) pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pTex, NULL); if(texEle->pTex) { PIXELFMT *pT; D3DLOCKED_RECT stLR; texEle->pTex->LockRect(0, &stLR, 0, 0); pT = (PIXELFMT *)stLR.pBits; for (int i = 0; i < nWidth * nHeight; i++) { pT[i].r = p[i].r >> 8; pT[i].g = p[i].g >> 8; pT[i].b = p[i].b >> 8; pT[i].a = p[i].a >> 8; } texEle->pTex->UnlockRect(0); if(bBump && texmap->ClassID() != GNORMAL_CLASS_ID) { // LPDIRECT3DTEXTURE9 normalTex = texEle->GetD3DBumpTexture(); if(texEle->pBumpTex) { D3DSURFACE_DESC stLD; texEle->pBumpTex->GetLevelDesc(0, &stLD); if (stLD.Width != nWidth || stLD.Height != nHeight) { SAFE_RELEASE(texEle->pBumpTex); } } if(!texEle->pBumpTex) pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pBumpTex, NULL); D3DXComputeNormalMap(texEle->pBumpTex,texEle->pTex,NULL, NULL, D3DX_CHANNEL_RED,30.0f); if(texEle->GetParamHandle()) { pEffectParser->LoadTexture(texEle->pBumpTex, texEle->GetParameterName()); // pEffect->SetTexture(texEle->GetParamHandle(),texEle->pBumpTex); // D3DXSaveTextureToFile("c:\\temp\\normal_notgnormal.dds", D3DXIFF_DDS, texEle->pBumpTex, NULL); SAFE_RELEASE(texEle->pBumpTex); } } else { if(texEle->GetParamHandle()) { pEffectParser->LoadTexture(texEle->pTex, texEle->GetParameterName()); // pEffect->SetTexture(texEle->GetParamHandle(),texEle->pTex); // D3DXSaveTextureToFile("c:\\temp\\normal_gnormal.dds", D3DXIFF_DDS, texEle->pTex, NULL); SAFE_RELEASE(texEle->pTex); } } } bmap->DeleteThis(); } delete p; } else {
void SideBarUI::Setup(HINSTANCE hInstance, HWND rollupHWND, const MCHAR *iniFile) { //setup rollup mRollupHwnd = rollupHWND; GetCOREInterface()->RegisterDlgWnd ( mRollupHwnd ); IRollupWindow *irollup = GetIRollup(rollupHWND); if(NULL == irollup) { return; } irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP1),SideBar1RollupDialogProc, GetString(IDS_QUICKTRANSFORM),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP2),SideBar1RollupDialogProc, GetString(IDS_RESHAPEELEMENTS),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP3),SideBar1RollupDialogProc, GetString(IDS_STITCH),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP4),SideBar1RollupDialogProc, GetString(IDS_EXPLODE),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP5),SideBar1RollupDialogProc, GetString(IDS_PEEL),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP6),SideBar1RollupDialogProc, GetString(IDS_ARRANGEELEMENTS),(LPARAM)mMod ); irollup->AppendRollup(hInstance,MAKEINTRESOURCE(IDD_SIDEBAR_ROLLUP7),SideBar1RollupDialogProc, GetString(IDS_ELEMENTPROPERTIES),(LPARAM)mMod ); for (int i = 0; i < 7; i++) irollup->Show(i); UnwrapCustomUI* pUIManager = mMod->GetUIManager(); if(NULL == pUIManager) { return; } bool bResult = pUIManager->GetIniFileCache().InitCacheFromIniFile(TSTR(iniFile)); //quick transform if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,100,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_1_TOOLBAR)) > 0) LoadInActions(100); else SetDefaults(100,irollup->GetPanelDlg(0)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,101,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_2_TOOLBAR)) > 0) LoadInActions(101); else SetDefaults(101,irollup->GetPanelDlg(0)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,102,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_3_TOOLBAR)) > 0) LoadInActions(102); else SetDefaults(102,irollup->GetPanelDlg(0)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,103,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_4_TOOLBAR)) > 0) LoadInActions(103); else SetDefaults(103,irollup->GetPanelDlg(0)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,104,irollup->GetPanelDlg(0),GetDlgItem(irollup->GetPanelDlg(0),IDC_S1_5_TOOLBAR)) > 0) LoadInActions(104); else SetDefaults(104,irollup->GetPanelDlg(0)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,110,irollup->GetPanelDlg(1),GetDlgItem(irollup->GetPanelDlg(1),IDC_S2_1_TOOLBAR)) > 0) LoadInActions(110); else SetDefaults(110,irollup->GetPanelDlg(1)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,120,irollup->GetPanelDlg(2),GetDlgItem(irollup->GetPanelDlg(2),IDC_S3_1_TOOLBAR)) > 0) LoadInActions(120); else SetDefaults(120,irollup->GetPanelDlg(2)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,130,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_1_TOOLBAR)) > 0) LoadInActions(130); else SetDefaults(130,irollup->GetPanelDlg(3)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,131,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_2_TOOLBAR)) > 0) LoadInActions(131); else SetDefaults(131,irollup->GetPanelDlg(3)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,132,irollup->GetPanelDlg(3),GetDlgItem(irollup->GetPanelDlg(3),IDC_S4_3_TOOLBAR)) > 0) LoadInActions(132); else SetDefaults(132,irollup->GetPanelDlg(3)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,140,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_1_TOOLBAR)) > 0) LoadInActions(140); else SetDefaults(140,irollup->GetPanelDlg(4)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,141,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_2_TOOLBAR)) > 0) LoadInActions(141); else SetDefaults(141,irollup->GetPanelDlg(4)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,142,irollup->GetPanelDlg(4),GetDlgItem(irollup->GetPanelDlg(4),IDC_S5_0_TOOLBAR)) > 0) LoadInActions(142); else SetDefaults(142,irollup->GetPanelDlg(4)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,150,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_1_TOOLBAR)) > 0) LoadInActions(150); else SetDefaults(150,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,151,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_2_TOOLBAR)) > 0) LoadInActions(151); else SetDefaults(151,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,152,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_3_TOOLBAR)) > 0) LoadInActions(152); else SetDefaults(152,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,153,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_4_TOOLBAR)) > 0) LoadInActions(153); else SetDefaults(153,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,154,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_5_TOOLBAR)) > 0) LoadInActions(154); else SetDefaults(154,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,155,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_6_TOOLBAR)) > 0) LoadInActions(155); else SetDefaults(155,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,156,irollup->GetPanelDlg(5),GetDlgItem(irollup->GetPanelDlg(5),IDC_S6_7_TOOLBAR)) > 0) LoadInActions(156); else SetDefaults(156,irollup->GetPanelDlg(5)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,160,irollup->GetPanelDlg(6),GetDlgItem(irollup->GetPanelDlg(6),IDC_S7_1_TOOLBAR)) > 0) LoadInActions(160); else SetDefaults(160,irollup->GetPanelDlg(6)); if (bResult && pUIManager->LoadSingleFromIniFile(iniFile,161,irollup->GetPanelDlg(6),GetDlgItem(irollup->GetPanelDlg(6),IDC_S7_2_TOOLBAR)) > 0) LoadInActions(161); else SetDefaults(161,irollup->GetPanelDlg(6)); ReleaseIRollup(irollup); //add the toolbars }
ULONG LocalRequirements(int subMtlNum) { #if 1 ULONG flags = fogBG ? ( fogObjDepth ? 0 : MTLREQ_NOATMOS ) : MTLREQ_NOATMOS; // > 10/9/02 - 2:38pm --MQM-- // if the tone operator is active, we need to match it's // "process background" flag for our material requirements. // otherwise we will have a matte-plane that gets tone-op'd // hovering over a background plane that doesn't. ToneOperatorInterface* toneOpInterface = static_cast<ToneOperatorInterface*>( GetCOREInterface(TONE_OPERATOR_INTERFACE) ); if ( toneOpInterface ) { ToneOperator *pToneOp = toneOpInterface->GetToneOperator(); if ( pToneOp ) { if ( !pToneOp->GetProcessBackground() ) flags |= MTLREQ_NOEXPOSURE; // <-- new MTLREQ flag to disable toneop } } return flags; #else return fogBG ? ( fogObjDepth ? 0 : MTLREQ_NOATMOS ) : MTLREQ_NOATMOS; #endif }
BOOL plDistribComponent_old::Distribute(plDistribInstTab& replicants, plExportProgressBar& bar, plDistTree* distTree) { return false; BOOL retVal = true; GetCOREInterface()->DisableSceneRedraw(); Clear(); plDistributor distrib; distrib.SetTheInterface(GetCOREInterface()); distrib.SetSpacing(fCompPB->GetFloat(kSpacing)); distrib.SetSpacingRange(fCompPB->GetFloat(kRndPosRadius) * 0.01f * distrib.GetSpacing() * 0.5f); Point3 align(fCompPB->GetFloat(kAlignVecX), fCompPB->GetFloat(kAlignVecY), fCompPB->GetFloat(kAlignVecZ)); align.FNormalize(); distrib.SetAlignmentVec(align); distrib.SetAlignmentWeight(fCompPB->GetFloat(kAlignWgt)); distrib.SetPolarRange(fCompPB->GetFloat(kPolarRange)); distrib.SetAzimuthRange(fCompPB->GetFloat(kAzimuthRange)); distrib.SetOverallProb(fCompPB->GetFloat(kOverallProb)); distrib.SetPolarBunch(fCompPB->GetFloat(kPolarBunch)); Point3 scaleLo(fCompPB->GetFloat(kScaleLoX), fCompPB->GetFloat(kScaleLoY), fCompPB->GetFloat(kScaleLoZ)); Point3 scaleHi(fCompPB->GetFloat(kScaleHiX), fCompPB->GetFloat(kScaleHiY), fCompPB->GetFloat(kScaleHiZ)); distrib.SetScaleRange(scaleLo, scaleHi); ULONG scaleLock = plDistributor::kLockNone; if( fCompPB->GetInt(kLockScaleXYZ) ) scaleLock = plDistributor::kLockX | plDistributor::kLockY | plDistributor::kLockZ; else if( fCompPB->GetInt(kLockScaleXY) ) scaleLock = plDistributor::kLockX | plDistributor::kLockY; distrib.SetScaleLock(scaleLock); distrib.SetProbabilityChan(kProbColorChanStrings[fCompPB->GetInt(kProbColorChan)].fValue); ISetProbTexmap(distrib); // Setup the new params here. FISH... Point3 probVec(fCompPB->GetFloat(kAngProbX), fCompPB->GetFloat(kAngProbY), fCompPB->GetFloat(kAngProbZ)); distrib.SetAngleProbVec(probVec); distrib.SetAngleProbHi(fCompPB->GetFloat(kAngProbHi)); distrib.SetAngleProbLo(fCompPB->GetFloat(kAngProbLo)); distrib.SetProbabilityRemapFromLo(fCompPB->GetFloat(kRemapFromLo)); distrib.SetProbabilityRemapFromHi(fCompPB->GetFloat(kRemapFromHi)); distrib.SetProbabilityRemapToLo(fCompPB->GetFloat(kRemapToLo)); distrib.SetProbabilityRemapToHi(fCompPB->GetFloat(kRemapToHi)); if( !fCompPB->GetInt(kSeedLocked) ) fCompPB->SetValue(kSeed, TimeValue(0), fCompPB->GetInt(kNextSeed)); distrib.SetRandSeed(fCompPB->GetInt(kSeed)); distrib.SetFade(GetFade()); if( fCompPB->GetInt(kWindBoneActive) ) distrib.SetBone(fCompPB->GetINode(kWindBone)); distrib.SetRigid(!IsFlexible()); // FISH HACK, get this passed in from Cluster distrib.SetDistTree(distTree); distrib.SetIsolation(GetIsolation()); int numReps = fCompPB->Count(kTemplates); int i; for( i = 0; i < numReps; i++ ) { INode* temp = fCompPB->GetINode(kTemplates, TimeValue(0), i); if( temp ) distrib.AddReplicateNode(temp); } int numTarg = NumTargets(); for( i = 0; i < numTarg; i++ ) { if( GetTarget(i) ) { if( !distrib.Distribute(GetTarget(i), replicants, fDistCache, bar) ) { retVal = false; break; } } } fCompPB->SetValue(kNextSeed, TimeValue(0), int(distrib.GetRandSeed())); BOOL redrawDissed = GetCOREInterface()->IsSceneRedrawDisabled(); GetCOREInterface()->EnableSceneRedraw(); GetCOREInterface()->ForceCompleteRedraw(FALSE); return retVal; }
void PlugMgrUtility::LoadClass(ClassDesc* cd) // ensure deferred plugin class is loaded - JBW 7.4.00 { ClassDirectory& cdir = GetCOREInterface()->GetDllDir().ClassDir(); cdir.FindClassEntry(cd->SuperClassID(), cd->ClassID())->FullCD(); }
/////////////////////////////////////////////////////////////////////////////////////////////////// // AlembicImport_vis /////////////////////////////////////////////////////////////////////////////////////////////////// void AlembicImport_SetupVisControl(std::string const &file, std::string const &identifier, AbcG::IObject &obj, INode *pNode, alembic_importoptions &options) { if (!pNode) { return; } AbcG::IVisibilityProperty visibilityProperty = getAbcVisibilityProperty(obj); bool isConstant = true; if (visibilityProperty.valid()) { isConstant = visibilityProperty.isConstant(); } if (isConstant) { Animatable *pAnimatable = pNode->SubAnim(0); if (pAnimatable && pAnimatable->ClassID() == ALEMBIC_VISIBILITY_CONTROLLER_CLASSID) { pNode->DeleteSubAnim(0); } alembic_fillvis_options visFillOptions; visFillOptions.pIObj = &obj; visFillOptions.dTicks = 0; visFillOptions.bOldVisibility = true; AlembicImport_FillInVis(visFillOptions); BOOL bVis = visFillOptions.bVisibility ? TRUE : FALSE; float fBool = bVis ? 1.0f : 0.0f; pNode->SetVisibility(0, fBool); } else { // Create the xform modifier AlembicVisibilityController *pControl = static_cast<AlembicVisibilityController *>( GetCOREInterface()->CreateInstance( CTRL_FLOAT_CLASS_ID, ALEMBIC_VISIBILITY_CONTROLLER_CLASSID)); // Set the alembic id TimeValue t = GET_MAX_INTERFACE()->GetTime(); TimeValue zero(0); // Set the alembic id pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "path"), zero, EC_UTF8_to_TCHAR(file.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "identifier"), zero, EC_UTF8_to_TCHAR(identifier.c_str())); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "time"), zero, 0.0f); pControl->GetParamBlockByID(0)->SetValue( GetParamIdByName(pControl, 0, "muted"), zero, FALSE); // Add the modifier to the node pNode->SetVisController(pControl); if (!isConstant) { std::stringstream controllerName; controllerName << GET_MAXSCRIPT_NODE(pNode); controllerName << "mynode2113.visibility.controller.time"; AlembicImport_ConnectTimeControl(controllerName.str().c_str(), options); } } }
void RigidBodyWorld::UpdateViewPorts () { //GetCOREInterface()->RedrawViews(GetCOREInterface()->GetTime()); GetCOREInterface()->ForceCompleteRedraw(); }
HRESULT ExportScene(const TCHAR* name, bool showPrompts, bool exportSelected) { HRESULT hr = S_OK; Interface* ip = GetCOREInterface(); TCHAR* msg = exportSelected? _T("Exporting selected via Microsoft Extensions for Max ...") : _T("Exporting via Microsoft Extensions for Max ..."); ip->ProgressStart(msg, TRUE, ProgressCb, NULL); TCHAR OutPath[512]; if (SUCCEEDED(hr = MassageOutputPath(name, OutPath, sizeof(OutPath)/sizeof(OutPath[0])))) { //TODO: if (!showPrompts || SUCCEEDED(hr = DoExportOptionsDlg())) { CPipelineLock lock; ThePipeline.SceneWriteLock(true, lock); try { ThePipeline.ResetData(); ThePipeline.SyncData(false, exportSelected); DXCCSaveSceneArgs options = { TRUE, //NoAddRefs; FALSE, //NoAnimation; FALSE, //NoFrameNames; FALSE, //NoMeshNames; FALSE, //NoMeshes; FALSE, //NoMeshAdjacencies; FALSE, //NoMeshSkins; FALSE, //NoMeshMaterials; FALSE, //ReplaceEffectPaths; "", //ReplacementEffectPath[MAX_PATH]; FALSE, //ReplaceTexturePaths; "", //ReplacementTexturePath[MAX_PATH]; FALSE, //RelativePaths; "", //RelativeToPath[MAX_PATH]; }; DumpFrameCounts(ThePipeline.AccessRoot()); hr = DXCCSaveScene(OutPath, D3DXF_FILEFORMAT_TEXT, ThePipeline.AccessManager(), ThePipeline.AccessRoot(), NULL, &options); DumpFrameCounts(ThePipeline.AccessRoot()); if (FAILED(hr)) { // print message } } catch (...) { ThePipeline.SceneWriteUnlock(lock); throw; } ThePipeline.SceneWriteUnlock(lock); } } ip->ProgressEnd(); return hr; }
IGeometryChecker::ReturnVal OverlappedUVWFacesChecker::GeometryCheckWithUVMesh(UVWChannel &uvmesh,TimeValue t,INode *nodeToCheck, BitArray &arrayOfFaces) { LARGE_INTEGER ups,startTime; QueryPerformanceFrequency(&ups); QueryPerformanceCounter(&startTime); //used to see if we need to pop up a dialog bool checkTime = GetIGeometryCheckerManager()->GetAutoUpdate();//only check time for the dialog if auto update is active! //get our bounding box Box3 bounds; bounds.Init(); int numVerts = uvmesh.GetNumTVVerts(); int i; for (i = 0; i < numVerts; ++i) { Point3 tv = uvmesh.GetTVVert(i); if(_isnan(tv.x) || !_finite(tv.x)||_isnan(tv.y) || !_finite(tv.y)||_isnan(tv.z) || !_finite(tv.z)) return IGeometryChecker::eFail; //if we have a bad tvert bail out... bounds += uvmesh.GetTVVert(i); } //put a small fudge to keep faces off the edge bounds.EnlargeBy(0.05f); //build our transform float xScale = bounds.pmax.x - bounds.pmin.x; float yScale = bounds.pmax.y - bounds.pmin.y; Point3 offset = bounds.pmin; //create our buffer OverlapMap overlapMap; overlapMap.Init(); Interface *ip = GetCOREInterface(); int numProcsToUse = omp_get_num_procs()-1; if(numProcsToUse<0) numProcsToUse = 1; TCHAR buf[256]; TCHAR tmpBuf[64]; _tcscpy(tmpBuf,GetString(IDS_CHECK_TIME_USED)); _tcscpy(buf,GetString(IDS_RUNNING_GEOMETRY_CHECKER)); ip->PushPrompt(buf); int total = 0; bool compute = true; EscapeChecker::theEscapeChecker.Setup(); for (int i = 0; i < uvmesh.GetNumOfFaces(); ++i) { if(compute==true) { //loop through the faces int deg = uvmesh.GetFaceDegree(i); int index[4]; index[0] = uvmesh.GetFaceTVVert(i,0); Point3 pa = uvmesh.GetTVVert(index[0]); pa.x -= offset.x; pa.x /= xScale; pa.y -= offset.y; pa.y /= yScale; for (int j = 0; j < deg -2; j++) { index[1] = uvmesh.GetFaceTVVert(i,j+1); index[2] = uvmesh.GetFaceTVVert(i,j+2); Point3 pb = uvmesh.GetTVVert(index[1]); Point3 pc = uvmesh.GetTVVert(index[2]); pb.x -= offset.x; pb.x /= xScale; pb.y -= offset.y; pb.y /= yScale; pc.x -= offset.x; pc.x /= xScale; pc.y -= offset.y; pc.y /= yScale; //add face to buffer //select anything that overlaps overlapMap.Map(uvmesh,i,pa,pb,pc,arrayOfFaces); } } total += 1; if(compute==true) { if(EscapeChecker::theEscapeChecker.Check()) { compute = false; _tcscpy(buf,GetString(IDS_EXITING_GEOMETRY_CHECKER)); ip->ReplacePrompt(buf); break; //can now break, no omp } if((total%100)==0) { { float percent = (float)total/(float)uvmesh.GetNumOfFaces()*100.0f; _stprintf(buf,tmpBuf,percent); ip->ReplacePrompt(buf); } } if(checkTime==true) { DialogChecker::Check(checkTime,compute,uvmesh.GetNumOfFaces(),startTime,ups); if(compute==false) break; } } } ip->PopPrompt(); return TypeReturned(); }
void TweakMouseProc::ComputeNewUVW(ViewExp& vpt, IPoint2 m) { if ( ! vpt.IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return; } Ray r; vpt.MapScreenToWorldRay ((float) m.x, (float) m.y, r); TimeValue t = GetCOREInterface()->GetTime(); Matrix3 tm = mod->GetMeshTopoDataNode(mHitLDIndex)->GetObjectTM(t); Matrix3 itm = Inverse(tm); r.p = r.p * itm; r.dir = VectorTransform(r.dir,itm); //intersect our ray with that face and get our new bary coords Point3 n = mHitLD->GetGeomFaceNormal(mHitFace); Point3 p1, p2, p3; p1 = mHitP[0]; p2 = mHitP[1]; p3 = mHitP[2]; Point3 p, bry; float d, rn, a; // See if the ray intersects the plane (backfaced) rn = DotProd(r.dir,n); if (rn > -0.0001) return; // Use a point on the plane to find d Point3 v1 = p1; d = DotProd(v1,n); // Find the point on the ray that intersects the plane a = (d - DotProd(r.p,n)) / rn; // Must be positive... if (a < 0.0f) return ; // The point on the ray and in the plane. p = r.p + a*r.dir; // Compute barycentric coords. bry = BaryCoords(p1,p2,p3,p); // DbgAssert(bry.x + bry.y+ bry.z = 1.0) Point3 uvw = mHitUVW[0] * bry.x + mHitUVW[1] * bry.y + mHitUVW[2] * bry.z; Point3 v = uvw - mSourceUVW; v *= -1.0f; mFinalUVW = mSourceUVW + v; mHitLD->SetTVVert(GetCOREInterface()->GetTime(),mHitTVVert,mFinalUVW,mod); mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE); mod->InvalidateView(); if (mod->ip) mod->ip->RedrawViews(mod->ip->GetTime()); }
void XModifier::NotifyPreCollapse(INode *node, IDerivedObject *derObj, int index) { bModDisabled = true; TimeValue t = GetCOREInterface()->GetTime(); NotifyDependents(Interval(t,t),PART_ALL,REFMSG_CHANGE); }
int TweakMouseProc::proc( HWND hwnd, int msg, int point, int flags, IPoint2 m ) { int res = TRUE; ViewExp& vpt = iObjParams->GetViewExp(hwnd); if ( ! vpt.IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return FALSE; } static IPoint2 cancelPoints[3]; static HWND cancelHWND; switch ( msg ) { case MOUSE_PROPCLICK: //reset start point //kill the command mode SetCursor(LoadCursor(NULL,IDC_ARROW)); GetCOREInterface()->SetStdCommandMode(CID_OBJSELECT); mHitLD = NULL; break; case MOUSE_ABORT: { theHold.Cancel(); if (mHitLD) { mHitLD->SetTVVert(GetCOREInterface()->GetTime(),mHitTVVert,mSourceUVW,mod); mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE); mod->InvalidateView(); if (mod->ip) mod->ip->RedrawViews(mod->ip->GetTime()); } break; } case MOUSE_POINT: { //see if we hit a point if (point == 0) { theHold.Begin(); mod->HoldPoints(); mHitLD = HitTest(vpt, m, mHitVert); if (mHitLD != NULL) { float at = 0; Ray r; vpt.MapScreenToWorldRay ((float) m.x, (float) m.y, r); TimeValue t = GetCOREInterface()->GetTime(); Matrix3 tm = mod->GetMeshTopoDataNode(mHitLDIndex)->GetObjectTM(t); Matrix3 itm = Inverse(tm); r.p = r.p * itm; r.dir = VectorTransform(r.dir,itm); mHitLD->Intersect(r,true,false, at, mBary, mHitFace); if (mHitFace != -1) { int deg = mHitLD->GetFaceDegree(mHitFace); for (int j = 0; j < deg; j++) { if (mHitVert == mHitLD->GetFaceGeomVert(mHitFace,j)) { mHitTVVert = mHitLD->GetFaceTVVert(mHitFace,j); mSourceUVW = mHitLD->GetTVVert(mHitTVVert); int offset1 = j; int offset2 = j+1; if (j == 0) { offset1 = 1; offset2 = 2; } else if (j == deg-1) { offset1 = deg-1; offset2 = deg-2; } mHitP[0] = mHitLD->GetGeomVert(mHitLD->GetFaceGeomVert(mHitFace,0)); mHitP[1] = mHitLD->GetGeomVert(mHitLD->GetFaceGeomVert(mHitFace,offset1)); mHitP[2] = mHitLD->GetGeomVert(mHitLD->GetFaceGeomVert(mHitFace,offset2)); mHitUVW[0] = mHitLD->GetTVVert(mHitLD->GetFaceTVVert(mHitFace,0)); mHitUVW[1] = mHitLD->GetTVVert(mHitLD->GetFaceTVVert(mHitFace,offset1)); mHitUVW[2] = mHitLD->GetTVVert(mHitLD->GetFaceTVVert(mHitFace,offset2)); } } } else { mHitLD->Intersect(r,true,false, at, mBary, mHitFace); mHitLD = NULL; } } } else { //accept the undo if (mHitLD) { if (flags & MOUSE_SHIFT) { AverageUVW(); } else { ComputeNewUVW(vpt, m); } mHitLD = NULL; TSTR mstr = mod->GetMacroStr(_T("modifiers[#unwrap_uvw].unwrap.setVertexPositionByNode")); macroRecorder->FunctionCall(mstr, 4, 0, mr_time,GetCOREInterface()->GetTime(), mr_int,mHitTVVert+1, mr_point3, mFinalUVW, mr_reftarg, mod->GetMeshTopoDataNode(mHitLDIndex) ); } theHold.Accept(GetString (IDS_DS_MOVE2)); } break; } case MOUSE_MOVE: { //if we hit a point get the transform and compute the uv offset if (mHitLD) { if (flags & MOUSE_SHIFT) { AverageUVW(); } else { ComputeNewUVW(vpt, m); } } break; } case MOUSE_FREEMOVE: { //see if hit and set cursor //hit test point int index = -1; float at = 0; Ray r; vpt.MapScreenToWorldRay ((float) m.x, (float) m.y, r); TimeValue t = GetCOREInterface()->GetTime(); BOOL hitFace = FALSE; for (int ldID = 0; ldID < mod->GetMeshTopoDataCount(); ldID++) { Matrix3 tm = mod->GetMeshTopoDataNode(ldID)->GetObjectTM(t); Matrix3 itm = Inverse(tm); r.p = r.p * itm; r.dir = VectorTransform(r.dir,itm); MeshTopoData *ld = mod->GetMeshTopoData(ldID); Point3 bry; int hit = -1; if (ld) { if (ld->Intersect(r,true,false, at, bry, hit)) hitFace = TRUE; } } if ((HitTest(vpt, m, index)!= NULL) && hitFace) SetCursor(GetCOREInterface()->GetSysCursor(SYSCUR_SELECT)); else SetCursor(LoadCursor(NULL,IDC_ARROW)); break; } } return res; }
BOOL plAutoUIBase::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_INITDIALOG) { fhDlg = hDlg; ICreateControls(); PostMessage(fhDlg, WM_SIZE_PANEL, 0, 0); } uint32_t count = fParams.size(); for (uint32_t i = 0; i < count; i++) { if (fParams[i]->IsMyMessage(msg, wParam, lParam, fPBlock)) { if (fParams[i]->GetParamType() == plAutoUIParam::kTypeDropDownList && HIWORD(wParam) == CBN_SELENDOK) { plDropDownListParam* ddl = (plDropDownListParam*)fParams[i]; ParamID id = ddl->GetID(); std::string str = ddl->GetString(fPBlock); int yOffset = 10; // We now have the id and current state of the drop-down list that changed // so now we need to update the visible state of the controls for (uint32_t idx = 0; idx < fParams.size(); idx++) { plAutoUIParam* par = fParams[idx]; if (par->CheckVisibility(id, str)) { par->Show(yOffset); yOffset += par->GetHeight() + 5; } else { par->Hide(); } } IRollupWindow *rollup = GetCOREInterface()->GetCommandPanelRollup(); int index = rollup->GetPanelIndex(fhDlg); if (index >= 0) rollup->SetPageDlgHeight(index, yOffset); InvalidateRect(fhDlg, NULL, TRUE); } return TRUE; } } // During init but after everything else we want to update the visibility if (msg == WM_SIZE_PANEL) { // Ok, this sucks but I don't know of a better way at this point // We need to intialize the visible state of the controls, and the only way to do this // is by looping through and finding all of the drop-down lists for (uint32_t i = 0; i < fParams.size(); i++) { if (fParams[i]->GetParamType() == plAutoUIParam::kTypeDropDownList) { plDropDownListParam* ddl = (plDropDownListParam*)fParams[i]; ParamID id = ddl->GetID(); std::string str = ""; const char* cstr = ddl->GetString(fPBlock); int yOffset = 10; if (cstr) str = cstr; // We now have the id and current state of the drop-down list that changed // so now we need to update the visible state of the controls for (uint32_t idx = 0; idx < fParams.size(); idx++) { if (fParams[idx]->CheckVisibility(id, str)) { fParams[idx]->Show(yOffset); yOffset += fParams[idx]->GetHeight() + 5; } else { fParams[idx]->Hide(); } } IRollupWindow *rollup = GetCOREInterface()->GetCommandPanelRollup(); int index = rollup->GetPanelIndex(fhDlg); if (index >= 0) rollup->SetPageDlgHeight(index, yOffset); InvalidateRect(fhDlg, NULL, TRUE); } } return TRUE; } return FALSE; }
void BlobMesh::fnAddMode() { GetCOREInterface()->DoHitByNameDialog(new DumpHitDialog(this)); }
bool SplineData::AddNode(INode *node) { //see if the node is a shape object if (node != NULL) { TimeValue t = GetCOREInterface()->GetTime(); Interval valid; Matrix3 tm = node->GetObjectTM(t,&valid); ObjectState nos = node->EvalWorldState(t); if (nos.obj->IsShapeObject()) { ShapeObject *pathOb = (ShapeObject*)nos.obj; int numberOfCurves = pathOb->NumberOfCurves(); //get number of splines if (numberOfCurves != 0) { pathOb->MakePolyShape(t, mShapeCache,32,FALSE); mShapeCache.Transform(tm); mSplineElementData.SetCount(numberOfCurves); for (int i = 0; i < numberOfCurves; i++) mSplineElementData[i] = NULL; for (int i = 0; i < numberOfCurves; i++) { Box3 bounds; bounds.Init(); //sample the shape object int numberOfCurves = pathOb->NumberOfPieces(t, i); if (numberOfCurves != 0) { mSplineElementData[i] = new SplineElementData(); mSplineElementData[i]->ResetBoundingBox(); mSplineElementData[i]->SetLineCache(&mShapeCache.lines[i]); mSplineElementData[i]->ComputePlanarUp(mPlanarMapUp); mSplineElementData[i]->SetNumCurves(numberOfCurves); mSplineElementData[i]->SetNumberOfCrossSections(numberOfCurves+1); if (pathOb->CurveClosed(t,i)) mSplineElementData[i]->SetClosed(true); else mSplineElementData[i]->SetClosed(false); float curveLength = pathOb->LengthOfCurve(t,i); float runningLength = 0.0f; Quat q; q.Identity(); mSplineElementData[i]->SetCrossSection(0,Point3(0.0f,0.0f,0.0f),Point2(20.0f,20.0f),q); for (int j = 0; j < numberOfCurves; j++) { float u = runningLength/curveLength; mSplineElementData[i]->SetCrossSection(j,Point3(0.0f,0.0f,u),Point2(20.0f,20.0f),q); Point3 lastPoint = pathOb->InterpPiece3D(t,i,j,0.0f,PARAM_NORMALIZED); bounds += lastPoint; float runningU = 0.0f; float inc = 1.0f/(float)(mSampleRate-1); for (int k = 1; k < mSampleRate; k++) { runningU += inc; Point3 p = pathOb->InterpPiece3D(t,i,j,runningU,PARAM_NORMALIZED); runningLength += Length(p-lastPoint); lastPoint = p; bounds += lastPoint; } } mSplineElementData[i]->SetCrossSection(numberOfCurves,Point3(0.0f,0.0f,1.0f),Point2(20.0f,20.0f),q); mSplineElementData[i]->Select(FALSE); } } if (mActiveSpline >= numberOfCurves) mActiveSpline = 0; mSplineElementData[mActiveSpline]->Select(TRUE); //build our bounding box RecomputeCrossSections(); return true; } } } return false; }
VertexHideRestore::VertexHideRestore (EditMeshData* md, EditMeshMod* mod) { hide = md->mdelta.vhide; meshData = md; this->mod = mod; t = GetCOREInterface()->GetTime(); // LAM - defect 289808 }