示例#1
0
        /// <summary>
        /// Flattens a dimensional model for display
        /// </summary>
        /// <param name="model">the model to flatten</param>
        /// <returns>the flattened view</returns>
        public static string FlattenModel(IDimensionalModelData model)
        {
            switch (model.ModelType)
            {
            case DimensionalModelType.Flat:
                return(FlattenFlatModel(model));
            }

            return(string.Empty);
        }
示例#2
0
        public string[] GetDimensionalData(long id)
        {
            IDimensionalModelData model = TemplateCache.Get <IDimensionalModelData>(id);

            if (model == null)
            {
                return(new string[0]);
            }

            return(model.ModelPlanes.Select(plane => plane.TagName).Distinct().ToArray());
        }
示例#3
0
        public string GetEntityModelView(long modelId)
        {
            IDimensionalModelData model = TemplateCache.Get <IDimensionalModelData>(modelId);

            if (model == null)
            {
                return(string.Empty);
            }

            return(Render.FlattenModelForWeb(model));
        }
示例#4
0
        public ActionResult Edit(long id, AddEditDimensionalModelDataViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IDimensionalModelData obj = TemplateCache.Get <IDimensionalModelData>(id);
            string message;

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Index", new { Message = message }));
            }

            try
            {
                foreach (IDimensionalModelPlane plane in vModel.DataObject.ModelPlanes)
                {
                    foreach (IDimensionalModelNode node in plane.ModelNodes)
                    {
                        node.YAxis = plane.YAxis;
                    }
                }

                if (vModel.DataObject.IsModelValid())
                {
                    obj.Name        = vModel.DataObject.Name;
                    obj.ModelType   = vModel.DataObject.ModelType;
                    obj.ModelPlanes = vModel.DataObject.ModelPlanes;
                    obj.Vacuity     = vModel.DataObject.Vacuity;

                    if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                    {
                        LoggingUtility.LogAdminCommandUsage("*WEB* - EditDimensionalModelData[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                        message = "Edit Successful.";
                    }
                    else
                    {
                        message = "Error; Edit failed.";
                    }
                }
                else
                {
                    message = "Invalid model; Models must contain 21 planes of a tag name followed by 21 rows of 21 nodes.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, false);
                message = "Error; Creation failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
示例#5
0
        public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "")
        {
            string message;

            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IDimensionalModelData obj = TemplateCache.Get <IDimensionalModelData>(removeId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveDimensionalModelData[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
                else
                {
                    message = "Error; Removal failed.";
                }
            }
            else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IDimensionalModelData obj = TemplateCache.Get <IDimensionalModelData>(unapproveId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - UnapproveDimensionalModelData[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Unapproval Successful.";
                }
                else
                {
                    message = "Error; Unapproval failed.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
示例#6
0
        private static string FlattenFlatModel(IDimensionalModelData model)
        {
            var flattenedModel = new StringBuilder();

            //load the plane up with blanks
            List <string[]> flattenedPlane = new List <string[]>();

            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });

            short xI, yI;

            for (yI = 0; yI < 11; yI++)
            {
                for (xI = 0; xI < 11; xI++)
                {
                    var node = model.GetNode(xI, yI, 0);

                    flattenedPlane[yI][xI] = DamageTypeToCharacter(node.Style, xI < 5);
                }
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (var nodes in flattenedPlane)
            {
                flattenedModel.AppendLine(string.Join("", nodes));
            }

            flattenedModel.AppendLine();

            return(flattenedModel.ToString());
        }
示例#7
0
        public ActionResult Edit(long id)
        {
            AddEditDimensionalModelDataViewModel vModel = new AddEditDimensionalModelDataViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            IDimensionalModelData obj = TemplateCache.Get <IDimensionalModelData>(id);

            if (obj == null)
            {
                string message = "That does not exist";
                return(RedirectToAction("Index", new { Message = message }));
            }

            vModel.DataObject = obj;

            return(View("~/Views/GameAdmin/DimensionalModel/Edit.cshtml", vModel));
        }
示例#8
0
        public ActionResult Add(AddEditDimensionalModelDataViewModel vModel, HttpPostedFileBase modelFile)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
            string          message;

            try
            {
                IDimensionalModelData newModel = vModel.DataObject;

                foreach (IDimensionalModelPlane plane in newModel.ModelPlanes)
                {
                    foreach (IDimensionalModelNode node in plane.ModelNodes)
                    {
                        node.YAxis = plane.YAxis;
                    }
                }

                if (newModel.IsModelValid())
                {
                    if (newModel.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                    {
                        message = "Error; Creation failed.";
                    }
                    else
                    {
                        LoggingUtility.LogAdminCommandUsage("*WEB* - AddDimensionalModelData[" + newModel.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                        message = "Creation Successful.";
                    }
                }
                else
                {
                    message = "Invalid model file; Model files must contain 21 planes of a tag name followed by 21 rows of 21 nodes.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, false);
                message = "Error; Creation failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
示例#9
0
        private static string GetNodeString(int x, short y, IDimensionalModelData model, bool forWeb)
        {
            IDimensionalModelNode node = model.GetNode((short)(x + 1), (short)(y + 1));

            string nodeString = string.Empty;

            if (node != null)
            {
                nodeString = DamageTypeToCharacter(node.Style, x < 5);

                if (forWeb)
                {
                    nodeString = string.Format("<a title='{0}'>{1}</a>"
                                               , node.Composition == null ? string.Empty : node.Composition.Name
                                               , nodeString);
                }
            }
            else if (forWeb)
            {
                nodeString = "<a title=''> </a>";
            }

            return(nodeString);
        }
示例#10
0
        /// <summary>
        /// Flattens a dimensional model for display
        /// </summary>
        /// <param name="model">the model to flatten</param>
        /// <param name="pitch">rotation on the z-axis</param>
        /// <param name="yaw">rotation on the Y-axis</param>
        /// <param name="roll">rotation on the x-axis</param>
        /// <returns>the flattened view</returns>
        public static string FlattenModel(IDimensionalModelData model, short pitch, short yaw, short roll)
        {
            switch (model.ModelType)
            {
            case DimensionalModelType.None:
                return(String.Empty);

            case DimensionalModelType.Flat:
                return(FlattenFlatModel(model));

            case DimensionalModelType.ThreeD:
                break;     //let it through
            }

            var flattenedModel = new StringBuilder();

            /*
             * We start by looking at the "front" of the model which starts at Y=11, Z=1, X=11 (the upper most left corner node) and contains all the Z=1 nodes of the entire thing
             *
             * YAW = pivot on X
             * Positive Yaw rotates the object counter-clockwise
             * yaw 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * yaw 11-21 - length = model zAxis 1-11, height = yAxis 11-1, depth = xAxis 1-11
             * yaw 22-32 - length = model xAxis 1-11, height = yAxis 11-1, depth = zAxis 11-1
             * yaw 33-43 - length = model zAxis 11-1, height = yAxis 11-1, depth = xAxis 11-1
             *
             * PITCH = pivot on Z
             * Positive pitch rotates the object forward and back
             * pitch 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * pitch 11-21 - length = model xAxis 11-1, height = zAxis 1-11, depth = yAxis 1-11
             * pitch 22-32 - length = model xAxis 11-1, height = yAxis 1-11, depth = zAxis 11-1
             * pitch 33-43 - length = model xAxis 11-1, height = zAxis 11-1, depth = yAxis 11-1
             *
             * ROLL = pivot on Y
             * Positive roll "spins" the object diagonally
             * roll 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * roll 11-21 - length = model yAxis 1-11, height = xAxis 1-1, depth = zAxis 1-11
             * roll 22-32 - length = model xAxis 1-11, height = yAxis 1-1, depth = zAxis 1-11
             * roll 33-43 - length = model yAxis 11-1, height = xAxis 11-1, depth = zAxis 1-11
             *
             */

            //Figure out the change. We need to "advance" by Length and Height here (where as the "find behind node" function advances Depth only)
            var heightChanges = new short[] { 0, 0, 0 }; // X, Y, Z
            var lengthChanges = new short[] { 0, 0, 0 }; // X, Y, Z

            if (yaw > 0)
            {
                if (yaw <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (yaw <= 21)
                {
                    heightChanges[1]--;
                    lengthChanges[2]++;
                }
                else if (yaw <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]--;
                }
                else
                {
                    heightChanges[1]--;
                    lengthChanges[2]--;
                }
            }

            if (pitch > 0)
            {
                if (pitch <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (pitch <= 21)
                {
                    heightChanges[2]++;
                    lengthChanges[0]--;
                }
                else if (pitch <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]--;
                }
                else
                {
                    heightChanges[2]--;
                    lengthChanges[0]--;
                }
            }

            if (roll > 0)
            {
                if (roll <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (roll <= 21)
                {
                    heightChanges[0]++;
                    lengthChanges[1]++;
                }
                else if (roll <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]++;
                }
                else
                {
                    heightChanges[0]--;
                    lengthChanges[1]--;
                }
            }

            if (roll == 0 && yaw == 0 && pitch == 0)
            {
                heightChanges[1]--;
                lengthChanges[0]--;
            }

            if (heightChanges[0] > 1)
            {
                heightChanges[0] = 1;
            }
            if (heightChanges[0] < -1)
            {
                heightChanges[0] = -1;
            }

            if (heightChanges[1] > 1)
            {
                heightChanges[1] = 1;
            }
            if (heightChanges[1] < -1)
            {
                heightChanges[1] = -1;
            }

            if (heightChanges[2] > 1)
            {
                heightChanges[2] = 1;
            }
            if (heightChanges[2] < -1)
            {
                heightChanges[2] = -1;
            }

            if (lengthChanges[0] > 1)
            {
                lengthChanges[0] = 1;
            }
            if (lengthChanges[0] < -1)
            {
                lengthChanges[0] = -1;
            }

            if (lengthChanges[1] > 1)
            {
                lengthChanges[1] = 1;
            }
            if (lengthChanges[1] < -1)
            {
                lengthChanges[1] = -1;
            }

            if (lengthChanges[2] > 1)
            {
                lengthChanges[2] = 1;
            }
            if (lengthChanges[2] < -1)
            {
                lengthChanges[2] = -1;
            }

            //figure out the starting point which is like the viewer's pov
            var startVertex = FindStartingVertex(yaw, pitch, roll);

            int startXAxis = startVertex.Item1;
            int startYAxis = startVertex.Item2;
            int startZAxis = startVertex.Item3;

            //load the plane up with blanks
            List <string[]> flattenedPlane = new List <string[]>();

            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });

            short xAxis, yAxis, zAxis;
            int   xI, yI;

            for (yI = 0; yI < 11; yI++)
            {
                xAxis = (short)(startXAxis + (heightChanges[0] * yI));
                yAxis = (short)(startYAxis + (heightChanges[1] * yI));
                zAxis = (short)(startZAxis + (heightChanges[2] * yI));

                for (xI = 0; xI < 11; xI++)
                {
                    if (xAxis <= 0)
                    {
                        xAxis = (short)(11 + xAxis);
                    }
                    if (yAxis <= 0)
                    {
                        yAxis = (short)(11 + yAxis);
                    }
                    if (zAxis <= 0)
                    {
                        zAxis = (short)(11 + zAxis);
                    }

                    if (xAxis > 11)
                    {
                        xAxis = (short)(xAxis - 11);
                    }
                    if (yAxis > 11)
                    {
                        yAxis = (short)(yAxis - 11);
                    }
                    if (zAxis > 11)
                    {
                        zAxis = (short)(zAxis - 11);
                    }

                    var node = model.GetNode(xAxis, yAxis, zAxis);

                    while (node != null && String.IsNullOrWhiteSpace(flattenedPlane[yI][xI]))
                    {
                        flattenedPlane[yI][xI] = DamageTypeToCharacter(node.Style, xI < 5);

                        node = model.GetNodeBehindNode(node.XAxis, node.YAxis, node.ZAxis, pitch, yaw, roll);
                    }

                    //reset everything to either the proper length start or height start
                    if (lengthChanges[0] != 0)
                    {
                        xAxis = (short)(xAxis + lengthChanges[0]);
                    }
                    else
                    {
                        xAxis = (short)(startXAxis + (heightChanges[0] * yI));
                    }

                    if (lengthChanges[1] != 0)
                    {
                        yAxis = (short)(yAxis + lengthChanges[1]);
                    }
                    else
                    {
                        yAxis = (short)(startYAxis + (heightChanges[1] * yI));
                    }

                    if (lengthChanges[2] != 0)
                    {
                        zAxis = (short)(zAxis + lengthChanges[2]);
                    }
                    else
                    {
                        zAxis = (short)(startZAxis + (heightChanges[2] * yI));
                    }
                }
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (var nodes in flattenedPlane)
            {
                flattenedModel.AppendLine(string.Join("", nodes));
            }

            flattenedModel.AppendLine();

            return(flattenedModel.ToString());
        }
示例#11
0
        private static string FlattenFlatModel(IDimensionalModelData model, bool forWeb = false)
        {
            StringBuilder flattenedModel = new StringBuilder();

            //load the plane up with blanks
            List <string[]> flattenedPlane = new List <string[]>
            {
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " },
                new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }
            };

            short yI;

            for (yI = 0; yI < 21; yI++)
            {
                short xI = 0;

                flattenedPlane[yI][xI]      = GetNodeString(xI, yI, model, forWeb);
                flattenedPlane[yI][xI + 1]  = GetNodeString(xI + 1, yI, model, forWeb);
                flattenedPlane[yI][xI + 2]  = GetNodeString(xI + 2, yI, model, forWeb);
                flattenedPlane[yI][xI + 3]  = GetNodeString(xI + 3, yI, model, forWeb);
                flattenedPlane[yI][xI + 4]  = GetNodeString(xI + 4, yI, model, forWeb);
                flattenedPlane[yI][xI + 5]  = GetNodeString(xI + 5, yI, model, forWeb);
                flattenedPlane[yI][xI + 6]  = GetNodeString(xI + 6, yI, model, forWeb);
                flattenedPlane[yI][xI + 7]  = GetNodeString(xI + 7, yI, model, forWeb);
                flattenedPlane[yI][xI + 8]  = GetNodeString(xI + 8, yI, model, forWeb);
                flattenedPlane[yI][xI + 9]  = GetNodeString(xI + 9, yI, model, forWeb);
                flattenedPlane[yI][xI + 10] = GetNodeString(xI + 10, yI, model, forWeb);
                flattenedPlane[yI][xI + 11] = GetNodeString(xI + 11, yI, model, forWeb);
                flattenedPlane[yI][xI + 12] = GetNodeString(xI + 12, yI, model, forWeb);
                flattenedPlane[yI][xI + 13] = GetNodeString(xI + 13, yI, model, forWeb);
                flattenedPlane[yI][xI + 14] = GetNodeString(xI + 14, yI, model, forWeb);
                flattenedPlane[yI][xI + 15] = GetNodeString(xI + 15, yI, model, forWeb);
                flattenedPlane[yI][xI + 16] = GetNodeString(xI + 16, yI, model, forWeb);
                flattenedPlane[yI][xI + 17] = GetNodeString(xI + 17, yI, model, forWeb);
                flattenedPlane[yI][xI + 18] = GetNodeString(xI + 18, yI, model, forWeb);
                flattenedPlane[yI][xI + 19] = GetNodeString(xI + 19, yI, model, forWeb);
                flattenedPlane[yI][xI + 20] = GetNodeString(xI + 20, yI, model, forWeb);
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (string[] nodes in flattenedPlane)
            {
                flattenedModel.AppendLine(string.Join("", nodes));
            }

            flattenedModel.AppendLine();

            return(flattenedModel.ToString());
        }
示例#12
0
        private static string FlattenFlatModel(IDimensionalModelData model)
        {
            var flattenedModel = new StringBuilder();

            //load the plane up with blanks
            List<string[]> flattenedPlane = new List<string[]>();
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });

            short xI, yI;
            for (yI = 0; yI < 11; yI++)
            {
                for (xI = 0; xI < 11; xI++)
                {
                    var node = model.GetNode(xI, yI, 0);

                    flattenedPlane[yI][xI] = DamageTypeToCharacter(node.Style, xI < 5);
                }
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (var nodes in flattenedPlane)
                flattenedModel.AppendLine(string.Join("", nodes));

            flattenedModel.AppendLine();

            return flattenedModel.ToString();
        }
示例#13
0
        /// <summary>
        /// Flattens a dimensional model for display
        /// </summary>
        /// <param name="model">the model to flatten</param>
        /// <param name="pitch">rotation on the z-axis</param>
        /// <param name="yaw">rotation on the Y-axis</param>
        /// <param name="roll">rotation on the x-axis</param>
        /// <returns>the flattened view</returns>
        public static string FlattenModel(IDimensionalModelData model, short pitch, short yaw, short roll)
        {
            switch(model.ModelType)
            {
                case DimensionalModelType.None:
                    return String.Empty;
                case DimensionalModelType.Flat:
                    return FlattenFlatModel(model);
                case DimensionalModelType.ThreeD:
                    break; //let it through
            }

            var flattenedModel = new StringBuilder();

            /*
             * We start by looking at the "front" of the model which starts at Y=11, Z=1, X=11 (the upper most left corner node) and contains all the Z=1 nodes of the entire thing
             *
             * YAW = pivot on X
             * Positive Yaw rotates the object counter-clockwise
             * yaw 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * yaw 11-21 - length = model zAxis 1-11, height = yAxis 11-1, depth = xAxis 1-11
             * yaw 22-32 - length = model xAxis 1-11, height = yAxis 11-1, depth = zAxis 11-1
             * yaw 33-43 - length = model zAxis 11-1, height = yAxis 11-1, depth = xAxis 11-1
             *
             * PITCH = pivot on Z
             * Positive pitch rotates the object forward and back
             * pitch 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * pitch 11-21 - length = model xAxis 11-1, height = zAxis 1-11, depth = yAxis 1-11
             * pitch 22-32 - length = model xAxis 11-1, height = yAxis 1-11, depth = zAxis 11-1
             * pitch 33-43 - length = model xAxis 11-1, height = zAxis 11-1, depth = yAxis 11-1
             *
             * ROLL = pivot on Y
             * Positive roll "spins" the object diagonally
             * roll 1-10 - length = model xAxis 11-1, height = yAxis 11-1, depth = zAxis 1-11
             * roll 11-21 - length = model yAxis 1-11, height = xAxis 1-1, depth = zAxis 1-11
             * roll 22-32 - length = model xAxis 1-11, height = yAxis 1-1, depth = zAxis 1-11
             * roll 33-43 - length = model yAxis 11-1, height = xAxis 11-1, depth = zAxis 1-11
             *
             */

            //Figure out the change. We need to "advance" by Length and Height here (where as the "find behind node" function advances Depth only)
            var heightChanges = new short[] { 0, 0, 0 }; // X, Y, Z
            var lengthChanges = new short[] { 0, 0, 0 }; // X, Y, Z

            if (yaw > 0)
            {
                if (yaw <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (yaw <= 21)
                {
                    heightChanges[1]--;
                    lengthChanges[2]++;
                }
                else if (yaw <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]--;
                }
                else
                {
                    heightChanges[1]--;
                    lengthChanges[2]--;
                }
            }

            if (pitch > 0)
            {
                if (pitch <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (pitch <= 21)
                {
                    heightChanges[2]++;
                    lengthChanges[0]--;
                }
                else if (pitch <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]--;
                }
                else
                {
                    heightChanges[2]--;
                    lengthChanges[0]--;
                }
            }

            if (roll > 0)
            {
                if (roll <= 10)
                {
                    heightChanges[1]--;
                    lengthChanges[0]--;
                }
                else if (roll <= 21)
                {
                    heightChanges[0]++;
                    lengthChanges[1]++;
                }
                else if (roll <= 32)
                {
                    heightChanges[1]++;
                    lengthChanges[0]++;
                }
                else
                {
                    heightChanges[0]--;
                    lengthChanges[1]--;
                }
            }

            if (roll == 0 && yaw == 0 && pitch == 0)
            {
                heightChanges[1]--;
                lengthChanges[0]--;
            }

            if (heightChanges[0] > 1)
                heightChanges[0] = 1;
            if (heightChanges[0] < -1)
                heightChanges[0] = -1;

            if (heightChanges[1] > 1)
                heightChanges[1] = 1;
            if (heightChanges[1] < -1)
                heightChanges[1] = -1;

            if (heightChanges[2] > 1)
                heightChanges[2] = 1;
            if (heightChanges[2] < -1)
                heightChanges[2] = -1;

            if (lengthChanges[0] > 1)
                lengthChanges[0] = 1;
            if (lengthChanges[0] < -1)
                lengthChanges[0] = -1;

            if (lengthChanges[1] > 1)
                lengthChanges[1] = 1;
            if (lengthChanges[1] < -1)
                lengthChanges[1] = -1;

            if (lengthChanges[2] > 1)
                lengthChanges[2] = 1;
            if (lengthChanges[2] < -1)
                lengthChanges[2] = -1;

            //figure out the starting point which is like the viewer's pov
            var startVertex = FindStartingVertex(yaw, pitch, roll);

            int startXAxis = startVertex.Item1;
            int startYAxis = startVertex.Item2;
            int startZAxis = startVertex.Item3;

            //load the plane up with blanks
            List<string[]> flattenedPlane = new List<string[]>();
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });

            short xAxis, yAxis, zAxis;
            int xI, yI;
            for (yI = 0; yI < 11; yI++)
            {
                xAxis = (short)(startXAxis + (heightChanges[0] * yI));
                yAxis = (short)(startYAxis + (heightChanges[1] * yI));
                zAxis = (short)(startZAxis + (heightChanges[2] * yI));

                for (xI = 0; xI < 11; xI++)
                {
                    if (xAxis <= 0)
                        xAxis = (short)(11 + xAxis);
                    if (yAxis <= 0)
                        yAxis = (short)(11 + yAxis);
                    if (zAxis <= 0)
                        zAxis = (short)(11 + zAxis);

                    if (xAxis > 11)
                        xAxis = (short)(xAxis - 11);
                    if (yAxis > 11)
                        yAxis = (short)(yAxis - 11);
                    if (zAxis > 11)
                        zAxis = (short)(zAxis - 11);

                    var node = model.GetNode(xAxis, yAxis, zAxis);

                    while (node != null && String.IsNullOrWhiteSpace(flattenedPlane[yI][xI]))
                    {
                        flattenedPlane[yI][xI] = DamageTypeToCharacter(node.Style, xI < 5);

                        node = model.GetNodeBehindNode(node.XAxis, node.YAxis, node.ZAxis, pitch, yaw, roll);
                    }

                    //reset everything to either the proper length start or height start
                    if (lengthChanges[0] != 0)
                        xAxis = (short)(xAxis + lengthChanges[0]);
                    else
                        xAxis = (short)(startXAxis + (heightChanges[0] * yI));

                    if (lengthChanges[1] != 0)
                        yAxis = (short)(yAxis + lengthChanges[1]);
                    else
                        yAxis = (short)(startYAxis + (heightChanges[1] * yI));

                    if (lengthChanges[2] != 0)
                        zAxis = (short)(zAxis + lengthChanges[2]);
                    else
                        zAxis = (short)(startZAxis + (heightChanges[2] * yI));
                }
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (var nodes in flattenedPlane)
                flattenedModel.AppendLine(string.Join("", nodes));

            flattenedModel.AppendLine();

            return flattenedModel.ToString();
        }
示例#14
0
        private static string FlattenFlatModel(IDimensionalModelData model, bool forWeb = false)
        {
            var flattenedModel = new StringBuilder();

            //load the plane up with blanks
            List<string[]> flattenedPlane = new List<string[]>();
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });
            flattenedPlane.Add(new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " " });

            short xI, yI;
            for (yI = 0; yI < 11; yI++)
            {
                for (xI = 0; xI < 11; xI++)
                {
                    short xIs = (short)(xI + 1);
                    short yIs = (short)(yI + 1);

                    var node = model.GetNode(xIs, yIs);

                    var nodeString = DamageTypeToCharacter(node.Style, xI < 5);

                    if (forWeb)
                        nodeString = String.Format("<a title='{0}'>{1}</a>"
                            , node.Composition == null ? String.Empty : node.Composition.Name
                            , nodeString);

                    flattenedPlane[yI][xI] = nodeString;
                }
            }

            flattenedModel.AppendLine();

            //Write out the flattened view to the string builder with line terminators
            foreach (var nodes in flattenedPlane)
                flattenedModel.AppendLine(string.Join("", nodes));

            flattenedModel.AppendLine();

            return flattenedModel.ToString();
        }
示例#15
0
        /// <summary>
        /// Flattens a dimensional model for display on the web (with material tooltips)
        /// </summary>
        /// <param name="model">the model to flatten</param>
        /// <returns>the flattened view</returns>
        public static string FlattenModelForWeb(IDimensionalModelData model)
        {
            switch(model.ModelType)
            {
                case DimensionalModelType.Flat:
                    return FlattenFlatModel(model, true);
            }

            return String.Empty;
        }