CRhinoCommand::result CCommandVRaptor::RunCommand( const CRhinoCommandContext& context ) { // CCommandVRaptor::RunCommand() is called when the user runs the "VRaptor" // command or the "VRaptor" command is run by a history operation. // TODO: Add command code here. // Rhino command that display a dialog box interface should also support // a command-line, or scriptable interface. ON_wString wStr; wStr.Format( L"The raptor is slumbering.\n", EnglishCommandName() ); RhinoApp().Print( wStr ); wStr.Format( L"another one.\n", EnglishCommandName() ); RhinoApp().Print( wStr ); // TODO: Return one of the following values: // CRhinoCommand::success: The command worked. // CRhinoCommand::failure: The command failed because of invalid input, inability // to compute the desired result, or some other reason // computation reason. // CRhinoCommand::cancel: The user interactively canceled the command // (by pressing ESCAPE, clicking a CANCEL button, etc.) // in a Get operation, dialog, time consuming computation, etc. return CRhinoCommand::success; }
CRhinoCommand::result CCommandExposeSdk::RunCommand( const CRhinoCommandContext& context ) { // CCommandExposeSdk::RunCommand() is called when the user runs the "ExposeSdk" // command or the "ExposeSdk" command is run by a history operation. // TODO: Add command code here. // Rhino command that display a dialog box interface should also support // a command-line, or scriptable interface. ON_wString wStr; wStr.Format( L"The \"%s\" command is under construction.\n", EnglishCommandName() ); if( context.IsInteractive() ) RhinoMessageBox( wStr, PlugIn()->PlugInName(), MB_OK ); else RhinoApp().Print( wStr ); // TODO: Return one of the following values: // CRhinoCommand::success: The command worked. // CRhinoCommand::failure: The command failed because of invalid input, inability // to compute the desired result, or some other reason // computation reason. // CRhinoCommand::cancel: The user interactively canceled the command // (by pressing ESCAPE, clicking a CANCEL button, etc.) // in a Get operation, dialog, time consuming computation, etc. return CRhinoCommand::success; }
CRhinoCommand::result CCommandVRCreateViews::RunCommand( const CRhinoCommandContext& context ) { AFX_MANAGE_STATE( ::RhinoApp().RhinoModuleState() ); // dunno, from example ON_wString wStr; wStr.Format( L"READY SET\n", EnglishCommandName() ); RhinoApp().Print( wStr ); ON_SimpleArray<CRhinoView*> viewList; // don't know what is up with* this* ON_SimpleArray<ON_UUID> viewportIds; CRhinoView* lView = 0; CRhinoView* rView = 0; ON_SimpleArray<CRhinoView*> lrViews; // will contain our vr views int i = 0; // also use this in loops int lr = 0; // use to track 1st and 2nd find // builds a list of (current) viewport IDs context.m_doc.GetViewList( viewList, true, false ); for ( i = 0; i < viewList.Count(); i ++) { CRhinoView* tempView = viewList[i]; // pull view out -> this is redeclared here, in sample, but not in second loop if (tempView) viewportIds.Append( tempView->ActiveViewportID() ); } viewList.Empty(); // empty bc we are going to re-build later when new views context.m_doc.NewView( ON_3dmView() ); context.m_doc.NewView( ON_3dmView() ); // we will build two // find viewport UUID just created context.m_doc.GetViewList( viewList, true, false); for (i = 0; i < viewList.Count(); i++) { CRhinoView* tempView = viewList[i]; if (tempView) { int rc = viewportIds.Search( tempView->ActiveViewportID() ); // returns index of 1st element which satisfies search. returns -1 when no such item found if (rc < 0 ) // if current tempView did not exist prior to this running { if (lr > 0) // and if lr already found 1 { rView = tempView; // right is 2nd view we find break; // so this breaks when we find, and lView is left as the viewList[i] where we found the new viewport, whose ID was not in our list. // and we are left with lView being = viewList[i] at new view } if (lr == 0) { lView = tempView; // left is 1st view lr = 1; } } else tempView = 0; // reset lView to null and re-loop } } lrViews.Append(lView); lrViews.Append(rView); // init points ON_3dPoint locationL = ON_3dPoint(100.0,100.0,100.0); ON_3dPoint locationR = ON_3dPoint(100.0,165.1,100.0); ON_3dPoint targetSetup = ON_3dPoint(0,0,0); if (lView && rView) { for (int i = 0; i < 2; i++) { // RhinoApp().ActiveView()-> ON_3dmView onView = lrViews[i]->ActiveViewport().View(); if(i == 0) onView.m_name = L"lView"; //lrViews[i]->MoveWindow(0,0,VR().resolution.w/2,VR().resolution.h, true); if(i == 1) onView.m_name = L"rView"; //lrViews[i]->MoveWindow(960,0,VR().resolution.w/2,VR().resolution.h, true); lrViews[i]->ActiveViewport().SetView(onView); lrViews[i]->ActiveViewport().m_v.m_vp.ChangeToPerspectiveProjection(50,true,35); lrViews[i]->ActiveViewport().m_v.m_vp.SetCameraLocation(locationL); lrViews[i]->FloatRhinoView(true); lrViews[i]->Redraw(); } } VR().lView = lView; VR().rView = rView; ON_wString SYNC; SYNC.Format(L"SYNCVRBEGIN\n" ); RhinoApp().Print( SYNC ); if (vrConduit.IsEnabled() && ::IsWindow( vrConduit.m_hWnd1 ) && ::IsWindow( vrConduit.m_hWnd2 ) ) // if is already enabled ? { vrConduit.m_pView1 = 0; vrConduit.m_pView2 = 0; vrConduit.Disable(); } else { vrConduit.m_pView1 = lView; vrConduit.m_pView2 = rView; vrConduit.m_hWnd1 = vrConduit.m_pView1->m_hWnd; vrConduit.m_hWnd2 = vrConduit.m_pView2->m_hWnd; SyncVR(lView, rView); // ok it runs once. we should also set them up perspective & looking at 0,0 vrConduit.Bind( *lView ); vrConduit.Bind( *rView ); lView->Redraw(); rView->Redraw(); vrConduit.Enable(); } // but do not update names immediately; have to refresh somehow // now re-name update positions outside of loop: continuously // bring in OVR Tracking and assign to VR Viewports // then, orbit? return CRhinoCommand::success; }