void CEasyGenView::OnRButtonDown(UINT nFlags, CPoint point) { CEasyGenDoc *pDoc = GetDocument(); CNmVec3 ray; CNmVec3 p; int tab; BOOL kCTRL = nFlags & MK_CONTROL; BOOL kSHIFT = nFlags & MK_SHIFT; BOOL GotPoint = GetXYZ(point, p); BOOL GotRay = GetRay(point, ray); m_RDP = point; SetCapture(); switch (tab = pDoc->GetActiveTab()) { case (TAB_GRID): break; case (TAB_MODIFIER): break; case (TAB_ALPHAMAP): break; case (TAB_MODELS): // MD3 - Move an Md3Highlighted model if (!kCTRL && kSHIFT && GotRay && m_Md3Highlight) { CNmVec3 pos; float dist; if (g_Grid.GetDistanceTrisRay(m_Eye, ray, pos, dist)) { m_Md3Highlight->m_egvPos = pos; InvalidateRect(NULL, FALSE); } } break; } CView::OnRButtonDown(nFlags, point); }
void CEasyGenView::OnLButtonDblClk(UINT nFlags, CPoint point) { CEasyGenDoc *pDoc = GetDocument(); CNmVec3 ray; CNmVec3 p; BOOL kCTRL = nFlags & MK_CONTROL; BOOL kSHIFT = nFlags & MK_SHIFT; BOOL GotPoint = GetXYZ(point, p); BOOL GotRay = GetRay(point, ray); switch (pDoc->GetActiveTab()) { case (TAB_GRID): // player place if (!kCTRL && kSHIFT && GotPoint && g_Grid.PtInGrid(p.x, p.y)) { pDoc->m_vPlayer.x = p.x; pDoc->m_vPlayer.y = p.y; S_POSINFO inf; if (g_Grid.GetInfo(pDoc->m_vPlayer.x, pDoc->m_vPlayer.y, &inf)) { pDoc->m_vPlayer.z = inf.z; } m_vGenericPos.Set(p.x, p.y, pDoc->m_vPlayer.z); UpdateStatusBar(); InvalidateRect(NULL, FALSE); } break; case (TAB_MODIFIER): // modifier place if (kCTRL && !kSHIFT && GotPoint && g_Grid.PtInGrid(p.x, p.y)) { pDoc->m_modX = p.x; pDoc->m_modY = p.y; g_Mod.PositionSet(p.x, p.y); UpdateStatusBar(); InvalidateRect(NULL, FALSE); pDoc->m_bInvalidateGridPreview = TRUE; } break; case (TAB_ALPHAMAP): break; case (TAB_MODELS): // MD3 - Insert model if (kCTRL && !kSHIFT && GotRay) { CNmVec3 pos; float dist; S_MD3PTR *md3ptr; if (g_Grid.GetDistanceTrisRay(m_Eye, ray, pos, dist)) { md3ptr = g_Md3Man.m_Placed.Append(); // g_Md3Man.m_Placed.Append( pDoc->GetMd3SelectedTabModels() ); if (md3ptr) { md3ptr->pMd3 = pDoc->GetMd3SelectedTabModels(); md3ptr->m_egvPos = pos; InvalidateRect(NULL, FALSE); } } } break; } // CAMERA - camera place [EVERY TAB] if (!kSHIFT && !kCTRL && GotPoint && g_Grid.PtInGrid(p.x, p.y)) { m_Eye.x = p.x; m_Eye.y = p.y; InvalidateRect(NULL, FALSE); } CView::OnLButtonDblClk(nFlags, point); }
void CEasyGenView::OnLButtonDown(UINT nFlags, CPoint point) { CEasyGenDoc *pDoc = GetDocument(); S_POSINFO inf; CTris *t; CNmVec3 p; int tab; m_LDP = point; BOOL kCTRL = nFlags & MK_CONTROL; BOOL kSHIFT = nFlags & MK_SHIFT; BOOL Refresh = FALSE; int mod = pDoc->GetModifier(); switch (tab = pDoc->GetActiveTab()) { case (TAB_GRID): break; case (TAB_MODIFIER): // Get a vertex to drag(CTRL+SHIFT+LeftBut) if (kCTRL && kSHIFT) { if (GetXYZ(point, p)) { if (g_Grid.GetInfo(p.x, p.y, &inf)) { m_VertexGot = g_Grid.GetK(inf.i, inf.j); } } } // Exclude triangle from export | to prevent erroneus exclusion if (!kCTRL && kSHIFT && g_Grid.OptionExcludedTrisGet()) { if (GetXYZ(point, p)) { t = g_Grid.GetTris(g_Grid.GetTris(p.x, p.y)); if (t) { t->SetExcluded(!t->GetExcluded()); pDoc->m_bInvalidateGridColor = TRUE; Refresh = TRUE; } } } break; case (TAB_ALPHAMAP): int curindex; curindex = g_AlphamapMan.GetCurSel(); // paint the alphamap (CTRL+SHIFT+LeftBut) if (kCTRL && kSHIFT && curindex != -1) { if (GetXYZ(point, p)) { if (g_Grid.GetInfo(p.x, p.y, &inf)) { m_VertexGot = g_Grid.GetK(inf.i, inf.j); // g_Grid.SetAlphaIndex(m_VertexGot, curindex ); g_Grid.PaintAlphaIndex(inf.i, inf.j, pDoc->m_dwPaintRadius, curindex); Refresh = TRUE; } } } int indexgot; // copy alphamap index (SHIFT+LeftBut) if (!kCTRL && kSHIFT) { if (GetXYZ(point, p)) { if (g_Grid.GetInfo(p.x, p.y, &inf)) { m_VertexGot = g_Grid.GetK(inf.i, inf.j); indexgot = g_Grid.GetAlphaIndex(m_VertexGot); if (indexgot != g_AlphamapMan.GetCurSel()) { g_AlphamapMan.SetCurSel(indexgot); pDoc->UpdateFormView(TAB_ALPHAMAP); } } } } break; case (TAB_MODELS): // MD3 - Selecting if (!kCTRL && kSHIFT) { CNmVec3 ray, dummy; float md3_dist, hitterra_dist; bool hitterra; S_MD3PTR *oldh = m_Md3Highlight; S_MD3PTR *hit_md3; if (GetRay(point, ray)) { if (g_Md3Man.GetByRay(m_Eye, ray, hit_md3, md3_dist)) { // check if is covered by terrain!!! hitterra = g_Grid.GetDistanceTrisRay(m_Eye, ray, dummy, hitterra_dist); if (!hitterra) { m_Md3Highlight = hit_md3; } else if (hitterra_dist > md3_dist) { m_Md3Highlight = hit_md3; } } } if (m_Md3Highlight != oldh) { Refresh = TRUE; } } break; } // rotate tris (CTRL+LeftBut) if ((tab == TAB_GRID || tab == TAB_MODIFIER || tab == TAB_ALPHAMAP) && mod == MOD_NONE && kCTRL && !kSHIFT) { if (GetXYZ(point, p)) { if (g_Grid.GetInfo(p.x, p.y, &inf)) { int i, j, k; int mt1; S_FACEDATAEX *f; mt1 = g_Grid.GetTris(p.x, p.y); mt1 &= ~1; k = mt1 / 2; i = k % g_Grid.GetCellsX(); j = k / g_Grid.GetCellsX(); f = g_Grid.GetFace(k); if ((f->flags & FACE_FL_TRISINV)) { f->flags &= ~FACE_FL_TRISINV; } else { f->flags |= FACE_FL_TRISINV; } g_Grid.FaceOrientateTris(i, j, f->flags & FACE_FL_TRISINV); Refresh = TRUE; } } } if (Refresh) { InvalidateRect(NULL, FALSE); } // SetCapture(); CView::OnLButtonDown(nFlags, point); }