Ejemplo n.º 1
0
void MagicView::OnModifyUVMap() 
{
   Selection*  seln  = GetDocument()->GetSelection();

   view_mode = VIEW_UV_MAP;
   SetupModelViews();

   if (seln && uvmap_view) {
      auto p = seln->GetPolys().begin();

      if (p) {
         uvmap_view->UseMaterial(p->material);
         uvmap_view->UsePolys(seln->GetPolys());
      }
   }
}
Ejemplo n.º 2
0
void MagicView::OnTextureMap() 
{
   TextureMapDialog dlg(this);
   if (dlg.DoModal() == IDOK) {
      MagicDoc*   doc      = GetDocument();
      Solid*      solid    = doc->GetSolid();
      Selection*  seln     = doc->GetSelection();
      Selector*   selector = doc->GetSelector();
      Editor*     editor   = doc->GetEditor();
      Material*   mtl      = 0;

      if (dlg.mMaterialIndex >= 0) {
         mtl = &solid->GetModel()->GetMaterials()[dlg.mMaterialIndex];
      }

      editor->UseModel(solid->GetModel());
      editor->ApplyMaterial(mtl, seln->GetPolys(),
                      dlg.mMapType, 2-dlg.mAxis, (float) dlg.mScaleU, (float) dlg.mScaleV,
                      dlg.mFlip, dlg.mMirror, dlg.mRotate);

      selector->Reselect();

      Invalidate();
      doc->SetModifiedFlag(TRUE);
      doc->UpdateAllViews(this);
   }
}
Ejemplo n.º 3
0
void MagicView::OnUpdateTextureMap(CCmdUI* pCmdUI) 
{
   Solid*      solid = GetDocument()->GetSolid();
   Selection*  seln  = GetDocument()->GetSelection();

   pCmdUI->Enable(solid && solid->GetModel() && seln && seln->GetPolys().size() > 0);
}
Ejemplo n.º 4
0
void MagicView::OnMouseMove(UINT nFlags, CPoint point) 
{
   if (drag_right) {
      CPoint offset = point - drag_start;

      if (view_focus == VIEW_PERSPECTIVE) {
         ModelView* view = GetModelViewByIndex(view_focus);
         view->SpinBy(offset.x * 0.5 * DEGREES, 
                      offset.y * 0.5 * DEGREES);
      }

      else if (IsUVEdit()) {
         uvmap_view->MoveBy(offset.x, offset.y);
      }

      else {
         ModelView* view = GetModelViewByIndex(view_focus);
         view->MoveBy(offset.x, offset.y);
      }

      drag_start = point;
      Invalidate();
   }

   else if (drag_left) {
      CPoint      offset      = point - drag_start;
      MagicDoc*   pDoc        = GetDocument();
      Selector*   selector    = pDoc->GetSelector();

      if (IsUVEdit()) {
         if (uvmap_view->IsActive()) {
            uvmap_view->AddMark(point);
         }
         else {
            uvmap_view->DragBy(offset.x, offset.y);
            drag_start = point;
         }
      }

      else if (selector && selector->IsActive()) {
         selector->AddMark(point);
      }
   }

   // xy status message:
   if (view_focus != VIEW_PERSPECTIVE) {
      char        xy[80];
      CPoint      mouse    = LPtoWP(point);
      Selection*  seln     = GetDocument()->GetSelection();

      int nv = seln ? seln->GetVerts().size() : 0;
      int np = seln ? seln->GetPolys().size() : 0;

      if (np || nv)
         sprintf_s(xy, "(%05d,%05d)  Verts:%d Polys:%d", mouse.x, mouse.y, nv, np);
      else
         sprintf_s(xy, "(%05d,%05d)", mouse.x, mouse.y);
      MainFrame::StatusXY(xy);
   }

	CView::OnMouseMove(nFlags, point);
}