public CModelEditor(string AssetName) { _viewDirection = EViewDirection.VD_FRONT; mAssetName = AssetName; _asset = CGame.AssetManager.GetAsset <CModelAsset>(AssetName); _vectorModel = _asset.mVectorModel; }
public void PrimHandleUpdate(CVectorModel Model, ref SGizmoData Gizmo, int SelectedPrimID) { if (Gizmo.mGizmoHover != EGizmoHandleID.NONE) { return; } float minT = float.MaxValue; Vector3 planeHitPoint = Vector3.zero; int hitPlaneID = -1; bool planeWasHit = false; for (int i = 0; i < Model.mPlanes.Count; ++i) { CModelPlane p = Model.mPlanes[i]; Vector3 hit; float t; if (p.IntersectRay(Gizmo.mStartMouseRay, out hit, out t)) { planeWasHit = true; if (t < minT) { minT = t; planeHitPoint = hit; hitPlaneID = i; } } } if (planeWasHit) { Gizmo.mGizmoHover = EGizmoHandleID.PRIMTIVE; Gizmo.mHoverID = hitPlaneID; } }
public void Init(CVectorModel Model, MeshFilter Filter) { _model = Model; _meshFilter = Filter; Update(); }
public void EdgePaintHandleUpdate(CVectorModel Model, ref SGizmoData Gizmo) { if (Gizmo.mGizmoHover != EGizmoHandleID.NONE) { return; } float minT = float.MaxValue; Vector3 planeHitPoint = Vector3.zero; int hitPlaneID = -1; bool planeWasHit = false; for (int i = 0; i < Model.mPlanes.Count; ++i) { CModelPlane p = Model.mPlanes[i]; Vector3 hit; float t; if (p.IntersectRay(Gizmo.mStartMouseRay, out hit, out t)) { planeWasHit = true; if (t < minT) { minT = t; planeHitPoint = hit; hitPlaneID = i; } } } if (planeWasHit) { CModelPlane p = Model.mPlanes[hitPlaneID]; // Find closest impact point on plane Vector3 projPoint; float d1 = CIntersections.PointVsLine(planeHitPoint, p.c1, p.c2, out projPoint); float d2 = CIntersections.PointVsLine(planeHitPoint, p.c2, p.c3, out projPoint); float d3 = CIntersections.PointVsLine(planeHitPoint, p.c3, p.c4, out projPoint); float d4 = CIntersections.PointVsLine(planeHitPoint, p.c4, p.c1, out projPoint); //CDebug.DrawLine(planeHitPoint, planeHitPoint + new Vector3(0, 0.1f, 0), Color.yellow, false); //CDebug.DrawLine(projPoint, projPoint + new Vector3(0, 0.1f, 0), Color.magenta, false); Gizmo.mGizmoHover = EGizmoHandleID.EDGE; Gizmo.mHoverID = hitPlaneID; if (d4 < d2 && d4 < d3 && d4 < d1) { Gizmo.mCornerID = 3; CDebug.DrawLine(p.c4, p.c1, Color.blue, false); } else if (d2 < d1 && d2 < d3 && d2 < d4) { Gizmo.mCornerID = 1; CDebug.DrawLine(p.c2, p.c3, Color.blue, false); } else if (d3 < d2 && d3 < d1 && d3 < d4) { Gizmo.mCornerID = 2; CDebug.DrawLine(p.c3, p.c4, Color.blue, false); } else { Gizmo.mCornerID = 0; CDebug.DrawLine(p.c1, p.c2, Color.blue, false); } } }
public CModelAsset() { mType = EAssetType.AT_MODEL; mVectorModel = new CVectorModel(); mVectorModel.RebuildEverything(); }