public void SpawnDebris(Sprite sprite, Vector2 Direction, int Quantity = 3, float Gravity = 1.1f, int DisplayFrames = 40) { //Console.WriteLine("Juice launched " + Convert.ToString(Direction)); float Force = Direction.Length(); if (Force == 0) { Force = 25; } for (int i = 0; i < Quantity; i++) { Vector2 ProjectionDirection = new Vector2(); if (Direction == new Vector2(0, 0)) { ProjectionDirection = new Vector2(r.Next(-6, 7), r.Next(-15, 5)); } else { ProjectionDirection = Direction; ProjectionDirection.X += (float)(r.NextDouble() - 0.5d) * Force * 0.7f; ProjectionDirection.Y += (float)(r.NextDouble() - 1d) * Force * 0.6f;; } ProjectionDirection.Normalize(); } }
public override MIPEmulsionTrackInfo ProjectVolumeTrack(Track t, ProjectionDirection direct, int layernumber) { double[] tvec; double[,] prop; MIPEmulsionTrackInfo mipt = new MIPEmulsionTrackInfo(); m_Track = t; SetKalmanFilter(); if (layernumber < 1) { throw new Exception("Layer Number must be greater than 0"); } if (direct == ProjectionDirection.DownStream) { kf.FilterBackward(); prop = new double[4, 4] { { 1, layernumber *m_ProjectionZ, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, layernumber *m_ProjectionZ }, { 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[0].StateVec); mipt.BottomZ = layernumber * m_ProjectionZ + m_Track[0].Info.BottomZ; mipt.TopZ = layernumber * m_ProjectionZ + m_Track[0].Info.TopZ; mipt.Intercept.Z = layernumber * m_ProjectionZ + m_Track[0].Info.Intercept.Z; mipt.AreaSum = m_Track[0].Info.AreaSum; mipt.Sigma = m_Track[0].Info.Sigma; mipt.Count = m_Track[0].Info.Count; mipt.Field = m_Track[0].Info.Field; } else { int n = kf.Length; kf.FilterForward(); prop = new double[4, 4] { { 1, -layernumber * m_ProjectionZ, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, -layernumber * m_ProjectionZ }, { 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[n - 1].StateVec); mipt.BottomZ = -layernumber * m_ProjectionZ + m_Track[n - 1].Info.BottomZ; mipt.TopZ = -layernumber * m_ProjectionZ + m_Track[n - 1].Info.TopZ; mipt.Intercept.Z = -layernumber * m_ProjectionZ + m_Track[n - 1].Info.Intercept.Z; mipt.AreaSum = m_Track[n - 1].Info.AreaSum; mipt.Sigma = m_Track[n - 1].Info.Sigma; mipt.Count = m_Track[n - 1].Info.Count; mipt.Field = m_Track[n - 1].Info.Field; } mipt.Intercept.X = tvec[0]; mipt.Slope.X = tvec[1]; mipt.Intercept.Y = tvec[2]; mipt.Slope.Y = tvec[3]; mipt.Slope.Z = 1; return(mipt); }
public void RenderView() { bool newBool; newBool = EditorGUILayout.Foldout(_isVisible, "Selection Projection Settings"); if (newBool != _isVisible) { UndoEx.RecordForToolAction(this); _isVisible = newBool; } GUIContent content = new GUIContent(); if (_isVisible) { EditorGUILayoutEx.BeginVerticalBox(); Octave3DWorldBuilder.ActiveInstance.ShowGUIHint("The surface projection object must be a terrain object (with a terrain collider) or mesh (no colliders required). " + "If it is a mesh, it must also be a child of Octave3D."); content.text = "Surface object"; content.tooltip = "The object which acts as a projection surface. Must be a terrain (with a mesh collider attached) or mesh object. If it is a mesh object, it must be a child of Octave3D."; GameObject newSurface = EditorGUILayout.ObjectField(content, ProjectionSurface, typeof(GameObject), true) as GameObject; if (newSurface != _projectionSurface) { UndoEx.RecordForToolAction(this); ProjectionSurface = newSurface; } content.text = "Projection direction"; content.tooltip = "The direction in which the objects will be projected on the projection surface."; ProjectionDirection newProjectionDir = (ProjectionDirection)EditorGUILayout.EnumPopup(content, ProjectionDir); if (newProjectionDir != ProjectionDir) { UndoEx.RecordForToolAction(this); ProjectionDir = newProjectionDir; } content.text = "Project selection"; content.tooltip = "Projects the selected objects onto the projection surface (if one was specified)."; if (GUILayout.Button(content, GUILayout.Width(130.0f))) { if (ProjectionSurface == null) { Debug.LogWarning("Projection not possible. No projection surface was specified!"); } else { ObjectSelection.Get().ProjectSelectionOnProjectionSurface(); } } EditorGUILayoutEx.EndVerticalBox(); } }
public override MIPEmulsionTrackInfo ProjectVolumeTrackByGap(Track t, ProjectionDirection direct, double projection_gap) { double[] tvec; double[,] prop; MIPEmulsionTrackInfo mipt = new MIPEmulsionTrackInfo(); m_Track = t; SetKalmanFilter(); if (projection_gap < 0) { throw new Exception("Projection Gap must be greater than 0"); } if (direct == ProjectionDirection.DownStream) { kf.FilterBackward(); prop = new double[6, 6] { { 1, projection_gap, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 0, 1, projection_gap, 0, 0 }, { 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 1, projection_gap }, { 0, 0, 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[0].StateVec); mipt.BottomZ = projection_gap + m_Track[0].Info.BottomZ; mipt.TopZ = projection_gap + m_Track[0].Info.TopZ; mipt.AreaSum = m_Track[0].Info.AreaSum; mipt.Sigma = m_Track[0].Info.Sigma; mipt.Count = m_Track[0].Info.Count; mipt.Field = m_Track[0].Info.Field; } else { int n = kf.Length; kf.FilterForward(); prop = new double[6, 6] { { 1, -projection_gap, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 0, 1, -projection_gap, 0, 0 }, { 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 1, -projection_gap }, { 0, 0, 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[n - 1].StateVec); mipt.BottomZ = -projection_gap + m_Track[n - 1].Info.BottomZ; mipt.TopZ = -projection_gap + m_Track[n - 1].Info.TopZ; mipt.AreaSum = m_Track[n - 1].Info.AreaSum; mipt.Sigma = m_Track[n - 1].Info.Sigma; mipt.Count = m_Track[n - 1].Info.Count; mipt.Field = m_Track[n - 1].Info.Field; } mipt.Intercept.X = tvec[0]; mipt.Slope.X = tvec[1]; mipt.Intercept.Y = tvec[2]; mipt.Slope.Y = tvec[3]; mipt.Intercept.Z = tvec[4]; mipt.Slope.Z = 1; return(mipt); }
public Vector2 ProjectCoordinates(Vector2 positionToConvert, ProjectionDirection direction) { if (direction == ProjectionDirection.SCREENTOWORLD) { return(Vector2.Transform(new Vector2(positionToConvert.X, positionToConvert.Y), Matrix.Invert(GetTransformation()))); } else if (direction == ProjectionDirection.WORLDTOSCREEN) { return(Vector2.Transform(new Vector2(positionToConvert.X, positionToConvert.Y), GetTransformation())); } else { throw new ArgumentException("Projection Direction provided is not valid."); } }
public override MIPEmulsionTrackInfo ProjectVolumeTrackAtZ(ProjectionDirection direct, double projection_Z) { double[] tvec; double[,] prop; double projection_gap; MIPEmulsionTrackInfo mipt = new MIPEmulsionTrackInfo(); if (m_Track == null) { throw new Exception("Track not set!"); } if (direct == ProjectionDirection.DownStream) { kf.FilterBackward(); projection_gap = projection_Z - m_Track[0].Info.Intercept.Z; prop = new double[6, 6] { { 1, projection_gap, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 0, 1, projection_gap, 0, 0 }, { 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 1, projection_gap }, { 0, 0, 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[0].StateVec); mipt.BottomZ = projection_gap + m_Track[0].Info.BottomZ; mipt.TopZ = projection_gap + m_Track[0].Info.TopZ; mipt.AreaSum = m_Track[0].Info.AreaSum; mipt.Sigma = m_Track[0].Info.Sigma; } else { int n = kf.Length; kf.FilterForward(); projection_gap = m_Track[n - 1].Info.Intercept.Z - projection_Z; prop = new double[6, 6] { { 1, -projection_gap, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 0, 1, -projection_gap, 0, 0 }, { 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 1, -projection_gap }, { 0, 0, 0, 0, 0, 1 } }; tvec = Matrices.Product(prop, kf[n - 1].StateVec); mipt.BottomZ = -projection_gap + m_Track[n - 1].Info.BottomZ; mipt.TopZ = -projection_gap + m_Track[n - 1].Info.TopZ; mipt.AreaSum = m_Track[n - 1].Info.AreaSum; mipt.Sigma = m_Track[n - 1].Info.Sigma; } mipt.Intercept.X = tvec[0]; mipt.Slope.X = tvec[1]; mipt.Intercept.Y = tvec[2]; mipt.Slope.Y = tvec[3]; mipt.Intercept.Z = tvec[4]; mipt.Slope.Z = 1; return(mipt); }
public abstract MIPEmulsionTrackInfo ProjectVolumeTrackAtZ(Track t, ProjectionDirection direct, double projection_Z);
public abstract MIPEmulsionTrackInfo ProjectVolumeTrackByGap(Track t, ProjectionDirection direct, double projection_gap);