示例#1
0
文件: FromRC.cs 项目: lulzzz/Nucleus
        /// <summary>
        /// Convert a Rhino mesh to a Nucleus one
        /// </summary>
        /// <param name="mesh"></param>
        /// <returns></returns>
        public static Mesh Convert(RC.Mesh mesh)
        {
            if (mesh == null)
            {
                return(null);
            }
            Mesh result = new Mesh();

            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                result.AddVertex(Convert(mesh.Vertices[i]));
                // TODO: Vertex colours?
            }
            for (int i = 0; i < mesh.Faces.Count; i++)
            {
                RC.MeshFace mF = mesh.Faces[i];
                if (mF.IsTriangle)
                {
                    result.AddFace(mF.A, mF.B, mF.C);
                }
                else
                {
                    result.AddFace(mF.A, mF.B, mF.C, mF.D);
                }
            }
            return(result);
        }
示例#2
0
        private void BuildTrapezoid(Mesh mesh)
        {
            // ReSharper disable InconsistentNaming
            var ptLL = mesh.AddVertex(0, 0);
            var ptLR = mesh.AddVertex(3, 0);
            var ptUR = mesh.AddVertex(2, 1);
            var ptUL = mesh.AddVertex(1, 1);

            // ReSharper restore InconsistentNaming
            mesh.AddFace(ptLL, ptUL, ptUR, ptLR);
        }
示例#3
0
        private Face BuildCwSquare(Mesh mesh)
        {
            // ReSharper disable InconsistentNaming
            var ptLL = mesh.AddVertex(3, 3);
            var ptLR = mesh.AddVertex(4, 3);
            var ptUL = mesh.AddVertex(3, 4);
            var ptUR = mesh.AddVertex(4, 4);

            // ReSharper restore InconsistentNaming
            return(mesh.AddFace(ptLL, ptUL, ptUR, ptLR));
        }
示例#4
0
        private void BuildParallelogram(Mesh mesh)
        {
            // ReSharper disable InconsistentNaming
            var ptLL = mesh.AddVertex(0, 0);
            var ptLR = mesh.AddVertex(2, 0);
            var ptUR = mesh.AddVertex(3, 1);
            var ptUL = mesh.AddVertex(1, 1);

            // ReSharper restore InconsistentNaming
            mesh.AddFace(ptLL, ptLR, ptUR, ptUL);
        }
示例#5
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //

        #endregion

        private Face BuildCcwSquare(Mesh mesh)
        {
            // ReSharper disable InconsistentNaming
            var ptLL = mesh.AddVertex(0, 0);
            var ptLR = mesh.AddVertex(1, 0);
            var ptUL = mesh.AddVertex(0, 1);
            var ptUR = mesh.AddVertex(1, 1);

            // ReSharper restore InconsistentNaming
            return(mesh.AddFace(ptLL, ptLR, ptUR, ptUL));
        }
示例#6
0
        private void MergeTriangleIntoMesh(Mesh mesh, SMCTriangleNetHashTable hashMap, OriginalTriangle ot)
        {
            int p0x = ot.P0.X;
            int p0y = ot.P0.Y;
            int p0z = ot.P0.Z;
            int p1x = ot.P1.X;
            int p1y = ot.P1.Y;
            int p1z = ot.P1.Z;
            int p2x = ot.P2.X;
            int p2y = ot.P2.Y;
            int p2z = ot.P2.Z;
            int p0i;
            int p1i;
            int p2i;
            int index = 0;

            index = hashMap.GetHashValue(p0x, p0y, p0z);
            if (index == -1)
            {
                p0i = mesh.AddVertex(new Point3d(p0x, p0y, p0z));
                hashMap.SetHashValue(p0x, p0y, p0z, p0i);
            }
            else
            {
                p0i = index;
            }

            index = hashMap.GetHashValue(p1x, p1y, p1z);
            if (index == -1)
            {
                p1i = mesh.AddVertex(new Point3d(p1x, p1y, p1z));
                hashMap.SetHashValue(p1x, p1y, p1z, p1i);
            }
            else
            {
                p1i = index;
            }

            index = hashMap.GetHashValue(p2x, p2y, p2z);
            if (index == -1)
            {
                p2i = mesh.AddVertex(new Point3d(p2x, p2y, p2z));
                hashMap.SetHashValue(p2x, p2y, p2z, p2i);
            }
            else
            {
                p2i = index;
            }

            Triangle t = new Triangle(p0i, p1i, p2i);

            mesh.AddFace(t);
        }
示例#7
0
文件: DXF.cs 项目: possner/IfcTerrain
        public static Result ReadDXFTin(bool is3d, DxfFile dxfFile, string layer, double minDist, string logFilePath, string verbosityLevel)
        {
            double minDistSq = minDist * minDist;
            var    result    = new Result();

            if (!UnitToMeter.TryGetValue(dxfFile.Header.DefaultDrawingUnits, out double scale))
            {
                scale = 1.0;
            }
            var tin = new Mesh(is3d, minDist);

            //Serilog.Log.Logger = new LoggerConfiguration()
            //                   .MinimumLevel.Debug()
            //                   .WriteTo.File(logFilePath)
            //                   .CreateLogger();
            var logger = LogManager.GetCurrentClassLogger();

            foreach (var entity in dxfFile.Entities)
            {
                if (entity.Layer == layer && entity is Dxf3DFace face)
                {
                    var p1 = Point3.Create(face.FirstCorner.X * scale, face.FirstCorner.Y * scale, face.FirstCorner.Z * scale);
                    var p2 = Point3.Create(face.SecondCorner.X * scale, face.SecondCorner.Y * scale, face.SecondCorner.Z * scale);
                    var p3 = Point3.Create(face.ThirdCorner.X * scale, face.ThirdCorner.Y * scale, face.ThirdCorner.Z * scale);
                    var p4 = Point3.Create(face.FourthCorner.X * scale, face.FourthCorner.Y * scale, face.FourthCorner.Z * scale);
                    if (Vector3.Norm2(p4 - p3) < minDistSq)
                    {
                        int i1 = tin.AddPoint(p1);
                        int i2 = tin.AddPoint(p2);
                        int i3 = tin.AddPoint(p3);
                        try
                        {
                            tin.AddFace(new[] { i1, i2, i3 });
                        }
                        catch
                        {
                            logger.Error("Redundant Face in Mesh found! Ignored during processings");
                        }
                    }
                }
            }
            if (!tin.Points.Any() || !tin.FaceEdges.Any())
            {
                result.Error = Properties.Resources.errNoLineData;
                logger.Error("Error. No line data found");
                return(result);
            }
            result.Mesh = tin;
            logger.Info("Reading DXF-data successful");
            logger.Info(tin.Points.Count + " Points, " + tin.FixedEdges.Count + " Lines and " + tin.FaceEdges.Count + " Faces read");
            return(result);
        }
示例#8
0
        } //End ReadTIN

        public static Result ConvertReb(bool is3D, RebDaData rebData, int horizon, double minDist, string logFilePath, string verbosityLevel)
        {
            //Serilog.Log.Logger = new LoggerConfiguration()
            //                   .MinimumLevel.Debug()
            //                   .WriteTo.File(logFilePath)
            //                   .CreateLogger();
            var logger = LogManager.GetCurrentClassLogger();

            var mesh   = new Mesh(is3D, minDist);
            var result = new Result();
            var pmap   = new Dictionary <long, int>();

            foreach (var kv in rebData.Points)
            {
                pmap.Add(kv.Key, mesh.AddPoint(kv.Value));
            }
            if (rebData.Lines.TryGetValue(horizon, out var lines))
            {
                foreach (var line in lines)
                {
                    if (pmap.TryGetValue(line.P1, out int v1) &&
                        pmap.TryGetValue(line.P2, out int v2))
                    {
                        mesh.FixEdge(v1, v2);
                    }
                }
            }
            if (rebData.Tris.TryGetValue(horizon, out var tris))
            {
                foreach (var tri in tris)
                {
                    if (pmap.TryGetValue(tri.P1, out int v1) &&
                        pmap.TryGetValue(tri.P2, out int v2) &&
                        pmap.TryGetValue(tri.P3, out int v3))
                    {
                        var pos = mesh.AddFace(new[] { v1, v2, v3 });
                        if (!pos.HasValue)
                        {
                            Console.WriteLine($"Missed {v1} {v2} {v3}");
                        }
                    }
                }
            }
            result.Mesh = mesh;
            logger.Info("Reading RebDa-data successful");
            logger.Info(mesh.Points.Count + " points, " + mesh.FixedEdges.Count + " lines and " + mesh.FaceEdges.Count + " faces read");
            return(result);
        }
示例#9
0
        /// <summary>
        /// Convert a netDXF mesh to a Nucleus mesh
        /// </summary>
        /// <param name="mesh"></param>
        /// <returns></returns>
        public static Mesh Convert(nDE.Mesh mesh)
        {
            var result = new Mesh();

            // Vertices:
            for (int i = 0; i < mesh.Vertexes.Count; i++)
            {
                result.AddVertex(Convert(mesh.Vertexes[i]));
            }
            // Faces:
            for (int i = 0; i < mesh.Faces.Count; i++)
            {
                result.AddFace(mesh.Faces[i]);
            }
            return(result);
        }
示例#10
0
    public void AddTriangle(Point3d p0, Point3d p1, Point3d p2)
    {
        int  p0i;
        int  p1i;
        int  p2i;
        int  index = 0;
        bool hasValue;

        hasValue = hashMap.ContainsKey(p0);
        if (!hasValue)
        {
            p0i = mesh.AddVertex(p0);
            hashMap.Add(p0, p0i);
        }
        else
        {
            index = hashMap[p0];
            p0i   = index;
        }

        hasValue = hashMap.ContainsKey(p1);
        if (!hasValue)
        {
            p1i = mesh.AddVertex(p1);
            hashMap.Add(p1, p1i);
        }
        else
        {
            index = hashMap[p1];
            p1i   = index;
        }

        hasValue = hashMap.ContainsKey(p2);
        if (!hasValue)
        {
            p2i = mesh.AddVertex(p2);
            hashMap.Add(p2, p2i);
        }
        else
        {
            index = hashMap[p2];
            p2i   = index;
        }
        Triangle t = new Triangle(p0i, p1i, p2i);

        mesh.AddFace(t);
    }
示例#11
0
 /// <summary>
 /// Convert a netDXF mesh to a Nucleus mesh
 /// </summary>
 /// <param name="mesh"></param>
 /// <returns></returns>
 public static Mesh Convert(nDE.Mesh mesh)
 {
     var result = new Mesh();
     // Vertices:
     for (int i = 0; i < mesh.Vertexes.Count; i++)
     {
         result.AddVertex(Convert(mesh.Vertexes[i]));
     }
     // Faces:
     for (int i = 0; i < mesh.Faces.Count; i++)
     {
         var indices = mesh.Faces[i];
         indices.AddToAll(-1); // Make zero-indexed
         result.AddFace(indices);
     }
     return result;
 }
示例#12
0
 /// <summary>
 /// Convert a netDXF polyface mesh to a Nucleus mesh
 /// </summary>
 /// <param name="mesh"></param>
 /// <returns></returns>
 public static Mesh Convert(nDE.PolyfaceMesh mesh)
 {
     var result = new Mesh();
     // Vertices:
     for (int i = 0; i < mesh.Vertexes.Count; i++)
     {
         result.AddVertex(Convert(mesh.Vertexes[i].Position));
     }
     // Faces:
     for (int i = 0; i < mesh.Faces.Count; i++)
     {
         var face = mesh.Faces[i];
         var indices = face.VertexIndexes.ToInts();
         indices.AddToAll(-1); // Make zero-indexed
         result.AddFace(indices);
     }
     return result;
 }
示例#13
0
        //private PolyMesh MeshPoints(Point3d[] PointsDown, Point3d[] PointsUp) {
        //    PolyMesh polyMesh = new PolyMesh();
        //    polyMesh.Vertices.AddRange(PointsDown);
        //    polyMesh.Vertices.AddRange(PointsUp);
        //    int length = checked((int)PointsDown.Length - 1);
        //    for (int i = 0; i <= length; i = checked(i + 1)) {
        //        int num = i;
        //        int length1 = (checked(checked(i + 1) + (int)PointsDown.Length)) % (int)PointsDown.Length;
        //        int num1 = checked(i + (int)PointsDown.Length);
        //        int length2 = checked((checked(checked(num1 + 1) + (int)PointsDown.Length)) % (int)PointsDown.Length + (int)PointsDown.Length);
        //        polyMesh.Faces.Add((IEnumerable<int>)(new int[] { num, length1, length2, num1 }));
        //    }
        //    return polyMesh;
        //}

        private Mesh MeshPoints(Point3d[] PointsDown, Point3d[] PointsUp)
        {
            Mesh polyMesh = new Mesh();

            polyMesh.Vertices.AddVertices(PointsDown);
            polyMesh.Vertices.AddVertices(PointsUp);
            int length = checked ((int)PointsDown.Length - 1);

            for (int i = 0; i <= length; i = checked (i + 1))
            {
                int num     = i;
                int length1 = (checked (checked (i + 1) + (int)PointsDown.Length)) % (int)PointsDown.Length;
                int num1    = checked (i + (int)PointsDown.Length);
                int length2 = checked ((checked (checked (num1 + 1) + (int)PointsDown.Length)) % (int)PointsDown.Length + (int)PointsDown.Length);
                polyMesh.AddFace((IEnumerable <int>)(new int[] { num, length1, length2, num1 }));
            }
            return(polyMesh);
        }
        /// <summary>
        /// Retourne un maillage interprétable par mon moteur de rendu
        /// </summary>
        public Mesh MakeMesh()
        {
            Mesh mesh = new Mesh(VertexTypeD11.STANDARD_VERTEX);

            for (int i = 0; i < Vertices.Count; i++)
            {
                mesh.Vertices.Add(new StandardVertex(Vertices[i].Position, new Vector3(0.0f, 0.0f, 1.0f), new Vector2(0.0f, 0.0f)));
            }

            for (int i = 0; i < Faces.Count; i++)
            {
                //if (! IsFaceBorder( Faces[i] ) )
                //{
                List <VertexWE> v = GetFaceVertices(Faces[i]);
                mesh.AddFace(v[0].Id, v[1].Id, v[2].Id);
                //}
            }
            if (mesh.Faces.Count == 0)
            {
                return(null);
            }
            mesh.UpdateMesh();
            return(mesh);
        }
示例#15
0
        protected override void RenderScene()
        {
            if (mCamera.ProjectionMode != eProjectionMode.Orthographic &&
                mViewer.DrawNormalsMode == eDrawNormalsMode.DrawNormals)
            {
                mRenderer.RenderScene(mScene, mCamera, RenderOptions.ShowNormals);
            }
            else
            {
                base.RenderScene();
            }

            if (mActiveEntity == null)
            {
                foreach (Entity lEntity in mScene.Entities)
                {
                    foreach (Mesh lMesh in lEntity.Meshes)
                    {
                        OwnedMesh lOm = lMesh as OwnedMesh;
                        if (lOm != null && lOm.Owner == mViewer.ActiveObject)
                        {
                            mActiveEntity = lEntity;
                            goto breakouter;
                        }
                    }
                }
                breakouter :;
            }

            if (mActiveEntity != null)
            {
                Mesh   lBoundingMesh = new Mesh(PolygonMode.Quads);
                Cuboid lBounds       = mActiveEntity.GetBoundingBox();

                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMax), Color.Red));
                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMin), Color.Red));
                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMin), Color.Red));
                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMax), Color.Red));
                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMax, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMax, lBounds.YMin, lBounds.ZMax), Color.Red));
                lBoundingMesh.AddFace(
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMin), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMin, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMax), Color.Red),
                    new Vertex(new GLTK.Point(lBounds.XMin, lBounds.YMax, lBounds.ZMin), Color.Red));

                lBoundingMesh.RenderMode = RenderMode.Wireframe;

                Entity lBox = new Entity();
                lBox.Transform = mActiveEntity.Transform;
                lBox.Meshes.Add(lBoundingMesh);

                mRenderer.ClearDepthBuffer();
                mRenderer.RenderSingleObject(lBox, RenderOptions.Default);
                mActiveEntity = null;
            }
        }
示例#16
0
        /// <summary>
        /// Liest das erste TIN aus einer LandXML Datei
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="errors"></param>
        /// <returns></returns>
        public static Result ReadTIN(bool is3d, string fileName, double minDist, string logFilePath, string verbosityLevel)
        {
            var result = new Result();

            //Serilog.Log.Logger = new LoggerConfiguration()
            //                   .MinimumLevel.Debug()
            //                   .WriteTo.File(logFilePath)
            //                   .CreateLogger();
            var logger = LogManager.GetCurrentClassLogger();

            try
            {
                using (var reader = XmlReader.Create(fileName))
                {
                    XElement el;
                    double?  scale     = null;
                    var      pntIds    = new Dictionary <string, int>();
                    var      mesh      = new Mesh(is3d, minDist);
                    bool     insideTin = false;
                    reader.MoveToContent();
                    // Parse the file and display each of the nodes.
                    while (!reader.EOF)
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.LocalName)
                            {
                            case "Metric":
                            case "Imperial":
                                el = XElement.ReadFrom(reader) as XElement;
                                if (el != null)
                                {
                                    var att = el.Attribute("linearUnit");
                                    if (att != null && ToMeter.TryGetValue(att.Value.ToLower(), out double tscale))
                                    {
                                        scale = tscale;
                                    }
                                }
                                break;

                            case "Definition":
                                if (reader.MoveToFirstAttribute() &&
                                    reader.LocalName == "surfType" &&
                                    reader.Value.ToUpper() == "TIN")
                                {
                                    insideTin = true;
                                }
                                break;

                            case "P":
                                el = XElement.ReadFrom(reader) as XElement;
                                if (el != null)
                                {
                                    var att = el.Attribute("id");
                                    if (att != null && Point3.Create(
                                            el.Value.Replace(',', '.').Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), out var pt))
                                    {
                                        pntIds.Add(att.Value, mesh.AddPoint(scale.HasValue ? scale.Value * pt : pt));
                                    }
                                }
                                break;

                            case "F":
                                el = XElement.ReadFrom(reader) as XElement;
                                if (el != null)
                                {
                                    string[] pts = el.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (pts.Length == 3 &&
                                        pntIds.TryGetValue(pts[0], out int p1) &&
                                        pntIds.TryGetValue(pts[1], out int p2) &&
                                        pntIds.TryGetValue(pts[2], out int p3))
                                    {
                                        mesh.AddFace(new[] { p1, p2, p3 });
                                    }
                                }
                                break;

                            default:
                                reader.Read();
                                break;
                            }
                        }
                        else if (insideTin && reader.NodeType == XmlNodeType.EndElement && reader.Name == "Definition")
                        {
                            if (!mesh.Points.Any() || !mesh.FaceEdges.Any())
                            {
                                result.Error = string.Format(Properties.Resources.errNoTINData, Path.GetFileName(fileName));
                                logger.Error("No TIN-data found");
                                return(result);
                            }
                            logger.Info("Reading LandXML-Data successful");
                            logger.Info(mesh.Points.Count + " points, " + mesh.FixedEdges.Count + " lines and " + mesh.FaceEdges.Count + " faces read");

                            result.Mesh = mesh;
                            return(result);
                        }
                        else
                        {
                            reader.Read();
                        }
                    }
                }
            }
            catch
            {
                result.Error = string.Format(Properties.Resources.errFileNotReadable, Path.GetFileName(fileName));
                logger.Error("File not readable");
                return(result);
            }
            result.Error = string.Format(Properties.Resources.errNoTIN, Path.GetFileName(fileName));
            logger.Error("No TIN-data found");
            return(result);
        } //End ReadTIN
示例#17
0
        private void TryInitialize()
        {
            this.warpGateAo = Enumerable.FirstOrDefault <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObject.ActorType == ActorType.WarpGate));
            this.Visible    = this.Enabled = this.warpGateAo != null;
            if (!this.Enabled)
            {
                foreach (KeyValuePair <WarpDestinations, WarpPanel> keyValuePair in this.panels)
                {
                    keyValuePair.Value.PanelMask.Dispose();
                    keyValuePair.Value.Layers.Dispose();
                }
                this.panels.Clear();
            }
            else
            {
                if (this.panels.Count == 0)
                {
                    Mesh mesh1 = new Mesh()
                    {
                        Effect      = (BaseEffect) new DefaultEffect.Textured(),
                        DepthWrites = false,
                        Texture     = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/fullwhite"))
                    };
                    mesh1.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
                    Mesh mesh2 = new Mesh()
                    {
                        Effect       = (BaseEffect) new DefaultEffect.Textured(),
                        AlwaysOnTop  = true,
                        DepthWrites  = false,
                        SamplerState = SamplerState.PointClamp
                    };
                    Texture2D texture2D1 = this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/nature/background");
                    mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture)texture2D1;
                    mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture    = (Texture)texture2D1;
                    mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Left * 5f, FaceOrientation.Right, true).Texture    = (Texture)texture2D1;
                    Group group1 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
                    group1.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/WATERFRONT/WATERFRONT_C");
                    group1.Material = new Material()
                    {
                        Opacity = 0.3f,
                        Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.7f)
                    };
                    Group group2 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
                    group2.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/WATERFRONT/WATERFRONT_B");
                    group2.Material = new Material()
                    {
                        Opacity = 0.5f,
                        Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.5f)
                    };
                    Group group3 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
                    group3.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/WATERFRONT/WATERFRONT_A");
                    group3.Material = new Material()
                    {
                        Opacity = 1f,
                        Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.4f)
                    };
                    this.panels.Add(WarpDestinations.First, new WarpPanel()
                    {
                        PanelMask   = mesh1,
                        Layers      = mesh2,
                        Face        = FaceOrientation.Front,
                        Destination = "NATURE_HUB"
                    });
                    Mesh mesh3 = new Mesh()
                    {
                        Effect      = (BaseEffect) new DefaultEffect.Textured(),
                        DepthWrites = false,
                        Texture     = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/fullwhite"))
                    };
                    mesh3.AddFace(new Vector3(3.875f), Vector3.Right * (25.0 / 16.0), FaceOrientation.Right, true);
                    Mesh mesh4 = new Mesh()
                    {
                        Effect       = (BaseEffect) new DefaultEffect.Textured(),
                        AlwaysOnTop  = true,
                        DepthWrites  = false,
                        SamplerState = SamplerState.PointClamp
                    };
                    Texture2D texture2D2 = this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/graveyard/back");
                    Group     group4     = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
                    group4.Texture      = (Texture)texture2D2;
                    group4.SamplerState = SamplerState.PointWrap;
                    mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/GRAVE/GRAVE_CLOUD_C");
                    mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/GRAVE/GRAVE_CLOUD_B");
                    mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/GRAVE/GRAVE_CLOUD_A");
                    Group group5 = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
                    group5.SamplerState = SamplerState.PointWrap;
                    group5.Blending     = new BlendingMode?(BlendingMode.Additive);
                    group5.Texture      = (Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/graveyard/rainoverlay");
                    this.panels.Add(WarpDestinations.Graveyard, new WarpPanel()
                    {
                        PanelMask   = mesh3,
                        Layers      = mesh4,
                        Face        = FaceOrientation.Right,
                        Destination = "GRAVEYARD_GATE"
                    });
                    Mesh mesh5 = new Mesh()
                    {
                        Effect      = (BaseEffect) new DefaultEffect.Textured(),
                        DepthWrites = false,
                        Texture     = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/fullwhite"))
                    };
                    mesh5.AddFace(new Vector3(3.875f), Vector3.Left * (25.0 / 16.0), FaceOrientation.Left, true);
                    Mesh mesh6 = new Mesh()
                    {
                        Effect       = (BaseEffect) new DefaultEffect.Textured(),
                        AlwaysOnTop  = true,
                        DepthWrites  = false,
                        SamplerState = SamplerState.PointClamp
                    };
                    Texture2D texture2D3 = this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/industrial/background");
                    mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture    = (Texture)texture2D3;
                    mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Backward * 5f, FaceOrientation.Back, true).Texture = (Texture)texture2D3;
                    mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture)texture2D3;
                    Group group6 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
                    group6.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_B");
                    group6.Material = new Material()
                    {
                        Opacity = 0.5f
                    };
                    Group group7 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
                    group7.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_F");
                    group7.Material = new Material()
                    {
                        Opacity = 0.325f
                    };
                    this.panels.Add(WarpDestinations.Mechanical, new WarpPanel()
                    {
                        PanelMask   = mesh5,
                        Layers      = mesh6,
                        Face        = FaceOrientation.Left,
                        Destination = "INDUSTRIAL_HUB"
                    });
                    Mesh mesh7 = new Mesh()
                    {
                        Effect      = (BaseEffect) new DefaultEffect.Textured(),
                        DepthWrites = false,
                        Texture     = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/fullwhite"))
                    };
                    mesh7.AddFace(new Vector3(3.875f), Vector3.Forward * (25.0 / 16.0), FaceOrientation.Back, true);
                    Mesh mesh8 = new Mesh()
                    {
                        Effect       = (BaseEffect) new DefaultEffect.Textured(),
                        AlwaysOnTop  = true,
                        DepthWrites  = false,
                        SamplerState = SamplerState.PointClamp
                    };
                    Texture2D texture2D4 = this.CMProvider.Global.Load <Texture2D>("Skies/SEWER/BRICK_BACKGROUND");
                    Group     group8     = mesh8.AddFace(Vector3.One * 16f, Vector3.Backward * 8f, FaceOrientation.Back, true);
                    group8.Texture      = (Texture)texture2D4;
                    group8.SamplerState = SamplerState.PointWrap;
                    Group group9 = mesh8.AddFace(Vector3.One * 16f, Vector3.Right * 8f, FaceOrientation.Left, true);
                    group9.Texture      = (Texture)texture2D4;
                    group9.SamplerState = SamplerState.PointWrap;
                    Group group10 = mesh8.AddFace(Vector3.One * 16f, Vector3.Left * 8f, FaceOrientation.Right, true);
                    group10.Texture      = (Texture)texture2D4;
                    group10.SamplerState = SamplerState.PointWrap;
                    Group group11 = mesh8.AddFace(new Vector3(128f, 8f, 1f), new Vector3(0.0f, 4f, -8f), FaceOrientation.Back, true);
                    group11.Texture      = (Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/sewer/sewage");
                    group11.SamplerState = SamplerState.PointWrap;
                    this.panels.Add(WarpDestinations.Sewers, new WarpPanel()
                    {
                        PanelMask   = mesh7,
                        Layers      = mesh8,
                        Face        = FaceOrientation.Back,
                        Destination = "SEWER_HUB"
                    });
                    Mesh mesh9 = new Mesh()
                    {
                        Effect      = (BaseEffect) new DefaultEffect.Textured(),
                        DepthWrites = false,
                        Texture     = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/fullwhite"))
                    };
                    mesh9.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
                    Mesh mesh10 = new Mesh()
                    {
                        Effect       = (BaseEffect) new DefaultEffect.Textured(),
                        AlwaysOnTop  = true,
                        DepthWrites  = false,
                        SamplerState = SamplerState.PointClamp
                    };
                    Texture2D texture2D5 = this.CMProvider.Global.Load <Texture2D>("Other Textures/warp/zu/back");
                    Group     group12    = mesh10.AddFace(new Vector3(16f, 32f, 16f), Vector3.Zero, FaceOrientation.Front, true);
                    group12.Texture      = (Texture)texture2D5;
                    group12.SamplerState = SamplerState.PointWrap;
                    Group group13 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
                    group13.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/ABOVE/ABOVE_C");
                    group13.Material = new Material()
                    {
                        Opacity = 0.4f,
                        Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.7f)
                    };
                    Group group14 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
                    group14.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/ABOVE/ABOVE_B");
                    group14.Material = new Material()
                    {
                        Opacity = 0.6f,
                        Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.6f)
                    };
                    Group group15 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
                    group15.Texture  = (Texture)this.CMProvider.Global.Load <Texture2D>("Skies/ABOVE/ABOVE_A");
                    group15.Material = new Material()
                    {
                        Opacity = 1f,
                        Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.5f)
                    };
                    this.panels.Add(WarpDestinations.Zu, new WarpPanel()
                    {
                        PanelMask   = mesh9,
                        Layers      = mesh10,
                        Face        = FaceOrientation.Front,
                        Destination = "ZU_CITY_RUINS"
                    });
                }
                if (Fez.LongScreenshot)
                {
                    this.GameState.SaveData.UnlockedWarpDestinations.Add("SEWER_HUB");
                    this.GameState.SaveData.UnlockedWarpDestinations.Add("GRAVEYARD_GATE");
                    this.GameState.SaveData.UnlockedWarpDestinations.Add("INDUSTRIAL_HUB");
                    this.GameState.SaveData.UnlockedWarpDestinations.Add("ZU_CITY_RUINS");
                }
                string str = this.LevelManager.Name.Replace('\\', '/');
                this.CurrentLevelName = str.Substring(str.LastIndexOf('/') + 1);
                if (!this.GameState.SaveData.UnlockedWarpDestinations.Contains(this.CurrentLevelName))
                {
                    this.GameState.SaveData.UnlockedWarpDestinations.Add(this.CurrentLevelName);
                }
                else if (this.GameState.SaveData.UnlockedWarpDestinations.Count > 1)
                {
                    ICollection <Volume> values    = this.LevelManager.Volumes.Values;
                    Func <Volume, bool>  predicate = (Func <Volume, bool>)(x =>
                    {
                        if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
                        {
                            return((double)Vector3.DistanceSquared(FezMath.GetCenter(x.BoundingBox), this.warpGateAo.Position) < 4.0);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                    Volume volume;
                    if ((volume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>)values, predicate)) != null)
                    {
                        volume.ActorSettings.DotDialogue.Clear();
                        volume.ActorSettings.DotDialogue.AddRange((IEnumerable <DotDialogueLine>) new DotDialogueLine[3]
                        {
                            new DotDialogueLine()
                            {
                                ResourceText = "DOT_WARP_A",
                                Grouped      = true
                            },
                            new DotDialogueLine()
                            {
                                ResourceText = "DOT_WARP_B",
                                Grouped      = true
                            },
                            new DotDialogueLine()
                            {
                                ResourceText = "DOT_WARP_UP",
                                Grouped      = true
                            }
                        });
                        bool flag;
                        if (this.GameState.SaveData.OneTimeTutorials.TryGetValue("DOT_WARP_A", out flag) && flag)
                        {
                            volume.ActorSettings.PreventHey = true;
                        }
                    }
                }
                Vector3 zero = Vector3.Zero;
                if (this.warpGateAo.ArtObject.Cubemap.Height == 128)
                {
                    zero -= Vector3.UnitY;
                }
                foreach (WarpPanel warpPanel in this.panels.Values)
                {
                    warpPanel.PanelMask.Position = this.warpGateAo.Position + zero;
                    warpPanel.Layers.Position    = this.warpGateAo.Position + zero;
                    warpPanel.Enabled            = warpPanel.Destination != this.CurrentLevelName && this.GameState.SaveData.UnlockedWarpDestinations.Contains(warpPanel.Destination);
                    if (warpPanel.Destination == "ZU_CITY_RUINS")
                    {
                        switch (this.CurrentLevelName)
                        {
                        case "NATURE_HUB":
                            warpPanel.Face = FaceOrientation.Front;
                            warpPanel.PanelMask.Rotation = Quaternion.Identity;
                            warpPanel.Layers.Rotation    = Quaternion.Identity;
                            continue;

                        case "GRAVEYARD_GATE":
                            warpPanel.Face = FaceOrientation.Right;
                            warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
                            warpPanel.Layers.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
                            continue;

                        case "INDUSTRIAL_HUB":
                            warpPanel.Face = FaceOrientation.Left;
                            warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
                            warpPanel.Layers.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
                            continue;

                        case "SEWER_HUB":
                            warpPanel.Face = FaceOrientation.Back;
                            warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
                            warpPanel.Layers.Rotation    = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
                            continue;

                        default:
                            continue;
                        }
                    }
                }
            }
        }
示例#18
0
        //private PolyMesh MeshConnector(List<Circle> Circles, List<int> Values, ref List<Point3d> LargeCircleDivision, ref List<Point3d> MiddleCircleDivision, ref List<Point3d> SmallCircleDivision) {
        //    Circle item;
        //    int num = 0;
        //    do {
        //        Circle circle = Circles[num];
        //        circle.Reverse();
        //        Circles[num] = circle;
        //        num = checked(num + 1);
        //    }
        //    while (num <= 1);
        //    PolyMesh polyMesh = new PolyMesh();
        //    PolyMesh polyMesh1 = new PolyMesh();
        //    List<Point3d> point3ds = new List<Point3d>();
        //    List<Point3d> point3ds1 = new List<Point3d>();
        //    List<Point3d> point3ds2 = new List<Point3d>();
        //    int item1 = Values[0];
        //    for (int i = 0; i <= item1; i = checked(i + 1)) {
        //        PolyVertexList vertices = polyMesh.Vertices;
        //        item = Circles[0];
        //        vertices.Add(item.PointAt((double)i / (double)Values[0] * 3.14159265358979 * 2));
        //        if (i < Values[0]) {
        //            item = Circles[0];
        //            point3ds2.Add(item.PointAt((double)i / (double)Values[0] * 3.14159265358979 * 2));
        //        }
        //    }
        //    int num1 = Values[0];
        //    for (int j = 0; j <= num1; j = checked(j + 1)) {
        //        PolyVertexList polyVertexList = polyMesh.Vertices;
        //        item = Circles[2];
        //        polyVertexList.Add(item.PointAt((double)j / (double)Values[0] * 3.14159265358979));
        //    }
        //    int item2 = checked(Values[0] - 1);
        //    for (int k = 0; k <= item2; k = checked(k + 1)) {
        //        polyMesh.Faces.Add((IEnumerable<int>)(new int[] { k, checked(checked(k + Values[0]) + 1), checked(checked(k + Values[0]) + 2), checked(k + 1) }));
        //    }
        //    int num2 = Values[1];
        //    for (int l = 0; l <= num2; l = checked(l + 1)) {
        //        PolyVertexList vertices1 = polyMesh1.Vertices;
        //        item = Circles[1];
        //        vertices1.Add(item.PointAt((double)l / (double)Values[1] * 3.14159265358979 * 2));
        //        if (l < Values[1]) {
        //            item = Circles[1];
        //            point3ds1.Add(item.PointAt((double)l / (double)Values[1] * 3.14159265358979 * 2));
        //        }
        //    }
        //    int item3 = Values[1];
        //    for (int m = 0; m <= item3; m = checked(m + 1)) {
        //        PolyVertexList polyVertexList1 = polyMesh1.Vertices;
        //        item = Circles[2];
        //        polyVertexList1.Add(item.PointAt((double)m / (double)Values[1] * 3.14159265358979 + 3.14159265358979));
        //    }
        //    int num3 = checked(Values[0] - 1);
        //    for (int n = 0; n <= num3; n = checked(n + 1)) {
        //        item = Circles[2];
        //        point3ds.Add(item.PointAt((double)n / (double)Values[0] * 3.14159265358979));
        //    }
        //    int item4 = checked(Values[1] - 1);
        //    for (int o = 0; o <= item4; o = checked(o + 1)) {
        //        item = Circles[2];
        //        point3ds.Add(item.PointAt((double)o / (double)Values[1] * 3.14159265358979 + 3.14159265358979));
        //    }
        //    int num4 = checked(Values[1] - 1);
        //    for (int p = 0; p <= num4; p = checked(p + 1)) {
        //        polyMesh1.Faces.Add((IEnumerable<int>)(new int[] { p, checked(checked(p + Values[1]) + 1), checked(checked(p + Values[1]) + 2), checked(p + 1) }));
        //    }
        //    polyMesh.Append(polyMesh1);
        //    LargeCircleDivision = point3ds;
        //    MiddleCircleDivision = point3ds1;
        //    SmallCircleDivision = point3ds2;
        //    return polyMesh;
        //}

        private Mesh MeshConnector(List <Circle> Circles, List <int> Values, ref List <Point3d> LargeCircleDivision, ref List <Point3d> MiddleCircleDivision, ref List <Point3d> SmallCircleDivision)
        {
            Circle item;
            int    num = 0;

            do
            {
                Circle circle = Circles[num];
                circle.Reverse();
                Circles[num] = circle;
                num          = checked (num + 1);
            }while (num <= 1);
            Mesh           polyMesh  = new Mesh();
            Mesh           polyMesh1 = new Mesh();
            List <Point3d> point3ds  = new List <Point3d>();
            List <Point3d> point3ds1 = new List <Point3d>();
            List <Point3d> point3ds2 = new List <Point3d>();
            int            item1     = Values[0];

            for (int i = 0; i <= item1; i = checked (i + 1))
            {
                Rhino.Geometry.Collections.MeshVertexList vertices = polyMesh.Vertices;
                item = Circles[0];
                vertices.Add(item.PointAt((double)i / (double)Values[0] * 3.14159265358979 * 2));
                if (i < Values[0])
                {
                    item = Circles[0];
                    point3ds2.Add(item.PointAt((double)i / (double)Values[0] * 3.14159265358979 * 2));
                }
            }
            int num1 = Values[0];

            for (int j = 0; j <= num1; j = checked (j + 1))
            {
                Rhino.Geometry.Collections.MeshVertexList polyVertexList = polyMesh.Vertices;
                item = Circles[2];
                polyVertexList.Add(item.PointAt((double)j / (double)Values[0] * 3.14159265358979));
            }
            int item2 = checked (Values[0] - 1);

            for (int k = 0; k <= item2; k = checked (k + 1))
            {
                polyMesh.AddFace((IEnumerable <int>)(new int[] { k, checked (checked (k + Values[0]) + 1), checked (checked (k + Values[0]) + 2), checked (k + 1) }));
            }
            int num2 = Values[1];

            for (int l = 0; l <= num2; l = checked (l + 1))
            {
                Rhino.Geometry.Collections.MeshVertexList vertices1 = polyMesh1.Vertices;
                item = Circles[1];
                vertices1.Add(item.PointAt((double)l / (double)Values[1] * 3.14159265358979 * 2));
                if (l < Values[1])
                {
                    item = Circles[1];
                    point3ds1.Add(item.PointAt((double)l / (double)Values[1] * 3.14159265358979 * 2));
                }
            }
            int item3 = Values[1];

            for (int m = 0; m <= item3; m = checked (m + 1))
            {
                Rhino.Geometry.Collections.MeshVertexList polyVertexList1 = polyMesh1.Vertices;
                item = Circles[2];
                polyVertexList1.Add(item.PointAt((double)m / (double)Values[1] * 3.14159265358979 + 3.14159265358979));
            }
            int num3 = checked (Values[0] - 1);

            for (int n = 0; n <= num3; n = checked (n + 1))
            {
                item = Circles[2];
                point3ds.Add(item.PointAt((double)n / (double)Values[0] * 3.14159265358979));
            }
            int item4 = checked (Values[1] - 1);

            for (int o = 0; o <= item4; o = checked (o + 1))
            {
                item = Circles[2];
                point3ds.Add(item.PointAt((double)o / (double)Values[1] * 3.14159265358979 + 3.14159265358979));
            }
            int num4 = checked (Values[1] - 1);

            for (int p = 0; p <= num4; p = checked (p + 1))
            {
                polyMesh1.AddFace((IEnumerable <int>)(new int[] { p, checked (checked (p + Values[1]) + 1), checked (checked (p + Values[1]) + 2), checked (p + 1) }));
            }
            polyMesh.Append(polyMesh1);
            LargeCircleDivision  = point3ds;
            MiddleCircleDivision = point3ds1;
            SmallCircleDivision  = point3ds2;
            return(polyMesh);
        }
示例#19
0
        /// <summary>
        ///  Liest das erste TIN aus einer LandXML Datei
        /// </summary>
        /// <param name="fileName">  </param>
        /// <returns>  </returns>
        public static Result ReadTIN(bool is3d, string fileName, double minDist)
        {
            Serilog.Log.Logger = new LoggerConfiguration()
                                 .MinimumLevel.Debug()
                                 //.WriteTo.File(@"D:\\Daten\\myapp.txt", rollingInterval: RollingInterval.Day)
                                 .WriteTo.File(System.Configuration.ConfigurationManager.AppSettings["LogFilePath"])
                                 .CreateLogger();

            var result = new Result();

            try
            {
                using (var reader = XmlReader.Create(fileName))
                {
                    bool isRelief = false;
                    reader.MoveToContent();
                    while (!reader.EOF && (reader.NodeType != XmlNodeType.Element || !(isRelief = reader.LocalName == "ReliefFeature")))
                    {
                        reader.Read();
                    }
                    if (isRelief)
                    {
                        string id        = reader.MoveToFirstAttribute() && reader.LocalName == "id" ? reader.Value : null;
                        bool   insideTin = false;
                        while (!reader.EOF && (reader.NodeType != XmlNodeType.Element || !(insideTin = reader.LocalName == "tin")))
                        {
                            reader.Read();
                        }
                        if (insideTin)
                        {
                            bool insideTri = false;
                            while (!reader.EOF && (reader.NodeType != XmlNodeType.Element || !(insideTri = reader.LocalName == "trianglePatches")))
                            {
                                reader.Read();
                            }
                            if (insideTri)
                            {
                                while (!reader.EOF && (reader.NodeType != XmlNodeType.Element || !(insideTri = reader.LocalName == "Triangle")))
                                {
                                    reader.Read();
                                }
                                if (insideTri)
                                {
                                    var tin = new Mesh(is3d, minDist);
                                    while (reader.NodeType == XmlNodeType.Element && reader.LocalName == "Triangle" &&
                                           XElement.ReadFrom(reader) is XElement el)
                                    {
                                        var      posList = el.Descendants().Where(d => d.Name.LocalName == "posList" && !d.IsEmpty);
                                        string[] pl;
                                        if (posList.Any() &&
                                            (pl = posList.First().Value.Split(new[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries)).Length == 12 &&
                                            pl[0] == pl[9] && pl[1] == pl[10] && pl[2] == pl[11] &&
                                            Point3.Create(pl, out var pt1) &&
                                            Point3.Create(pl, out var pt2, 3) &&
                                            Point3.Create(pl, out var pt3, 6))
                                        {
                                            tin.AddFace(new[] { pt1, pt2, pt3 });
                                        }
                                        reader.Read();
                                    }
                                    if (!tin.Points.Any() || !tin.FaceEdges.Any())
                                    {
                                        result.Error = string.Format(Properties.Resources.errNoTINData, Path.GetFileName(fileName));
                                        Log.Error("No TIN-data found");
                                        return(result);
                                    }
                                    result.Mesh = tin;
                                    Log.Information("Reading GML-data successful");
                                    Log.Information(tin.Points.Count + " points, " + tin.FixedEdges.Count + " lines and " + tin.FaceEdges.Count + " faces read");
                                    return(result);
                                }
                            }
                        }
                    }
                    result.Error = string.Format(Properties.Resources.errNoTIN, Path.GetFileName(fileName));
                    Log.Error("No TIN-data found");
                    return(result);
                }
            }
            catch
            {
                result.Error = string.Format(Properties.Resources.errFileNotReadable, Path.GetFileName(fileName));
                Log.Error("File not readable");
                return(result);
            }
        } //End ReadTIN
示例#20
0
 private void BuildMesh()
 {
   Vector3 a = (this.Volume.To - this.Volume.From) / 2f;
   float num1 = a.Y * 2f;
   Mesh mesh1 = new Mesh();
   Mesh mesh2 = new Mesh();
   FaceOrientation[] faceOrientationArray = new FaceOrientation[4]
   {
     FaceOrientation.Front,
     FaceOrientation.Right,
     FaceOrientation.Back,
     FaceOrientation.Left
   };
   foreach (FaceOrientation faceOrientation in faceOrientationArray)
   {
     Vector3 vector3_1 = FezMath.AsVector(FezMath.IsSide(FezMath.GetTangent(faceOrientation)) ? FezMath.GetTangent(faceOrientation) : FezMath.GetBitangent(faceOrientation));
     Vector3 origin = this.Center + FezMath.AsVector(faceOrientation) * a;
     float num2 = Math.Abs(FezMath.Dot(a, vector3_1)) * 2f;
     Vector3 vector3_2 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
     Vector3 vector3_3 = origin + (a - new Vector3(0.5f)) * (-vector3_1 + Vector3.UnitY);
     for (int index = 0; (double) index < (double) num2; ++index)
     {
       Vector3 p = vector3_2 + (float) index * vector3_1;
       if (!Enumerable.Any<Group>((IEnumerable<Group>) mesh1.Groups, (Func<Group, bool>) (g => FezMath.AlmostEqual(g.Position, p))))
         mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
       p = vector3_3 + (float) index * vector3_1;
       if (!Enumerable.Any<Group>((IEnumerable<Group>) mesh1.Groups, (Func<Group, bool>) (g => FezMath.AlmostEqual(g.Position, p))))
         mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
     }
     Vector3 vector3_4 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
     Vector3 vector3_5 = origin + (a - new Vector3(0.5f)) * (vector3_1 - Vector3.UnitY);
     for (int index = 0; (double) index < (double) num1; ++index)
     {
       Vector3 p = vector3_4 + (float) index * Vector3.UnitY;
       if (!Enumerable.Any<Group>((IEnumerable<Group>) mesh1.Groups, (Func<Group, bool>) (g => FezMath.AlmostEqual(g.Position, p))))
         mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
       p = vector3_5 + (float) index * Vector3.UnitY;
       if (!Enumerable.Any<Group>((IEnumerable<Group>) mesh1.Groups, (Func<Group, bool>) (g => FezMath.AlmostEqual(g.Position, p))))
         mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
     }
     mesh2.AddFace(num2 * FezMath.Abs(vector3_1) + num1 * Vector3.UnitY, origin, faceOrientation, Color.White, true);
   }
   foreach (Group group in mesh1.Groups)
     group.TextureMatrix = (Dirtyable<Matrix?>) new Matrix?(new Matrix(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f));
   mesh2.Collapse<VertexPositionNormalColor>();
   IndexedUserPrimitives<VertexPositionNormalColor> indexedUserPrimitives1 = mesh2.FirstGroup.Geometry as IndexedUserPrimitives<VertexPositionNormalColor>;
   mesh1.CollapseWithNormalTexture<FezVertexPositionNormalTexture>();
   IndexedUserPrimitives<FezVertexPositionNormalTexture> indexedUserPrimitives2 = mesh1.FirstGroup.Geometry as IndexedUserPrimitives<FezVertexPositionNormalTexture>;
   this.instanceIndex = this.Host.HolesBodyMesh.Groups.Count;
   this.Host.HolesBodyMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionInstance>(Enumerable.ToArray<VertexPositionInstance>(Enumerable.Select<VertexPositionNormalColor, VertexPositionInstance>((IEnumerable<VertexPositionNormalColor>) indexedUserPrimitives1.Vertices, (Func<VertexPositionNormalColor, VertexPositionInstance>) (x => new VertexPositionInstance(x.Position)
   {
     InstanceIndex = (float) this.instanceIndex
   }))), indexedUserPrimitives1.Indices, PrimitiveType.TriangleList);
   this.Host.HolesFringeMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionTextureInstance>(Enumerable.ToArray<VertexPositionTextureInstance>(Enumerable.Select<FezVertexPositionNormalTexture, VertexPositionTextureInstance>((IEnumerable<FezVertexPositionNormalTexture>) indexedUserPrimitives2.Vertices, (Func<FezVertexPositionNormalTexture, VertexPositionTextureInstance>) (x => new VertexPositionTextureInstance(x.Position, x.TextureCoordinate)
   {
     InstanceIndex = (float) this.instanceIndex
   }))), indexedUserPrimitives2.Indices, PrimitiveType.TriangleList);
 }
示例#21
0
 private void TryInitialize()
 {
   this.warpGateAo = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.WarpGate));
   this.Visible = this.Enabled = this.warpGateAo != null;
   if (!this.Enabled)
   {
     foreach (KeyValuePair<WarpDestinations, WarpPanel> keyValuePair in this.panels)
     {
       keyValuePair.Value.PanelMask.Dispose();
       keyValuePair.Value.Layers.Dispose();
     }
     this.panels.Clear();
   }
   else
   {
     if (this.panels.Count == 0)
     {
       Mesh mesh1 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh1.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
       Mesh mesh2 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/nature/background");
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture) texture2D1;
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture = (Texture) texture2D1;
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Left * 5f, FaceOrientation.Right, true).Texture = (Texture) texture2D1;
       Group group1 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group1.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_C");
       group1.Material = new Material()
       {
         Opacity = 0.3f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.7f)
       };
       Group group2 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group2.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_B");
       group2.Material = new Material()
       {
         Opacity = 0.5f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.5f)
       };
       Group group3 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group3.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_A");
       group3.Material = new Material()
       {
         Opacity = 1f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.4f)
       };
       this.panels.Add(WarpDestinations.First, new WarpPanel()
       {
         PanelMask = mesh1,
         Layers = mesh2,
         Face = FaceOrientation.Front,
         Destination = "NATURE_HUB"
       });
       Mesh mesh3 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh3.AddFace(new Vector3(3.875f), Vector3.Right * (25.0 / 16.0), FaceOrientation.Right, true);
       Mesh mesh4 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/graveyard/back");
       Group group4 = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
       group4.Texture = (Texture) texture2D2;
       group4.SamplerState = SamplerState.PointWrap;
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_C");
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_B");
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_A");
       Group group5 = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
       group5.SamplerState = SamplerState.PointWrap;
       group5.Blending = new BlendingMode?(BlendingMode.Additive);
       group5.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/graveyard/rainoverlay");
       this.panels.Add(WarpDestinations.Graveyard, new WarpPanel()
       {
         PanelMask = mesh3,
         Layers = mesh4,
         Face = FaceOrientation.Right,
         Destination = "GRAVEYARD_GATE"
       });
       Mesh mesh5 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh5.AddFace(new Vector3(3.875f), Vector3.Left * (25.0 / 16.0), FaceOrientation.Left, true);
       Mesh mesh6 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D3 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/background");
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture = (Texture) texture2D3;
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Backward * 5f, FaceOrientation.Back, true).Texture = (Texture) texture2D3;
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture) texture2D3;
       Group group6 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
       group6.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_B");
       group6.Material = new Material()
       {
         Opacity = 0.5f
       };
       Group group7 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
       group7.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_F");
       group7.Material = new Material()
       {
         Opacity = 0.325f
       };
       this.panels.Add(WarpDestinations.Mechanical, new WarpPanel()
       {
         PanelMask = mesh5,
         Layers = mesh6,
         Face = FaceOrientation.Left,
         Destination = "INDUSTRIAL_HUB"
       });
       Mesh mesh7 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh7.AddFace(new Vector3(3.875f), Vector3.Forward * (25.0 / 16.0), FaceOrientation.Back, true);
       Mesh mesh8 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D4 = this.CMProvider.Global.Load<Texture2D>("Skies/SEWER/BRICK_BACKGROUND");
       Group group8 = mesh8.AddFace(Vector3.One * 16f, Vector3.Backward * 8f, FaceOrientation.Back, true);
       group8.Texture = (Texture) texture2D4;
       group8.SamplerState = SamplerState.PointWrap;
       Group group9 = mesh8.AddFace(Vector3.One * 16f, Vector3.Right * 8f, FaceOrientation.Left, true);
       group9.Texture = (Texture) texture2D4;
       group9.SamplerState = SamplerState.PointWrap;
       Group group10 = mesh8.AddFace(Vector3.One * 16f, Vector3.Left * 8f, FaceOrientation.Right, true);
       group10.Texture = (Texture) texture2D4;
       group10.SamplerState = SamplerState.PointWrap;
       Group group11 = mesh8.AddFace(new Vector3(128f, 8f, 1f), new Vector3(0.0f, 4f, -8f), FaceOrientation.Back, true);
       group11.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/sewer/sewage");
       group11.SamplerState = SamplerState.PointWrap;
       this.panels.Add(WarpDestinations.Sewers, new WarpPanel()
       {
         PanelMask = mesh7,
         Layers = mesh8,
         Face = FaceOrientation.Back,
         Destination = "SEWER_HUB"
       });
       Mesh mesh9 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh9.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
       Mesh mesh10 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D5 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/zu/back");
       Group group12 = mesh10.AddFace(new Vector3(16f, 32f, 16f), Vector3.Zero, FaceOrientation.Front, true);
       group12.Texture = (Texture) texture2D5;
       group12.SamplerState = SamplerState.PointWrap;
       Group group13 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group13.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_C");
       group13.Material = new Material()
       {
         Opacity = 0.4f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.7f)
       };
       Group group14 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group14.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_B");
       group14.Material = new Material()
       {
         Opacity = 0.6f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.6f)
       };
       Group group15 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group15.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_A");
       group15.Material = new Material()
       {
         Opacity = 1f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.5f)
       };
       this.panels.Add(WarpDestinations.Zu, new WarpPanel()
       {
         PanelMask = mesh9,
         Layers = mesh10,
         Face = FaceOrientation.Front,
         Destination = "ZU_CITY_RUINS"
       });
     }
     if (Fez.LongScreenshot)
     {
       this.GameState.SaveData.UnlockedWarpDestinations.Add("SEWER_HUB");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("GRAVEYARD_GATE");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("INDUSTRIAL_HUB");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("ZU_CITY_RUINS");
     }
     string str = this.LevelManager.Name.Replace('\\', '/');
     this.CurrentLevelName = str.Substring(str.LastIndexOf('/') + 1);
     if (!this.GameState.SaveData.UnlockedWarpDestinations.Contains(this.CurrentLevelName))
       this.GameState.SaveData.UnlockedWarpDestinations.Add(this.CurrentLevelName);
     else if (this.GameState.SaveData.UnlockedWarpDestinations.Count > 1)
     {
       ICollection<Volume> values = this.LevelManager.Volumes.Values;
       Func<Volume, bool> predicate = (Func<Volume, bool>) (x =>
       {
         if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
           return (double) Vector3.DistanceSquared(FezMath.GetCenter(x.BoundingBox), this.warpGateAo.Position) < 4.0;
         else
           return false;
       });
       Volume volume;
       if ((volume = Enumerable.FirstOrDefault<Volume>((IEnumerable<Volume>) values, predicate)) != null)
       {
         volume.ActorSettings.DotDialogue.Clear();
         volume.ActorSettings.DotDialogue.AddRange((IEnumerable<DotDialogueLine>) new DotDialogueLine[3]
         {
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_A",
             Grouped = true
           },
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_B",
             Grouped = true
           },
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_UP",
             Grouped = true
           }
         });
         bool flag;
         if (this.GameState.SaveData.OneTimeTutorials.TryGetValue("DOT_WARP_A", out flag) && flag)
           volume.ActorSettings.PreventHey = true;
       }
     }
     Vector3 zero = Vector3.Zero;
     if (this.warpGateAo.ArtObject.Cubemap.Height == 128)
       zero -= Vector3.UnitY;
     foreach (WarpPanel warpPanel in this.panels.Values)
     {
       warpPanel.PanelMask.Position = this.warpGateAo.Position + zero;
       warpPanel.Layers.Position = this.warpGateAo.Position + zero;
       warpPanel.Enabled = warpPanel.Destination != this.CurrentLevelName && this.GameState.SaveData.UnlockedWarpDestinations.Contains(warpPanel.Destination);
       if (warpPanel.Destination == "ZU_CITY_RUINS")
       {
         switch (this.CurrentLevelName)
         {
           case "NATURE_HUB":
             warpPanel.Face = FaceOrientation.Front;
             warpPanel.PanelMask.Rotation = Quaternion.Identity;
             warpPanel.Layers.Rotation = Quaternion.Identity;
             continue;
           case "GRAVEYARD_GATE":
             warpPanel.Face = FaceOrientation.Right;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
             continue;
           case "INDUSTRIAL_HUB":
             warpPanel.Face = FaceOrientation.Left;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
             continue;
           case "SEWER_HUB":
             warpPanel.Face = FaceOrientation.Back;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
             continue;
           default:
             continue;
         }
       }
     }
   }
 }
示例#22
0
            private void BuildMesh()
            {
                Vector3 a     = (this.Volume.To - this.Volume.From) / 2f;
                float   num1  = a.Y * 2f;
                Mesh    mesh1 = new Mesh();
                Mesh    mesh2 = new Mesh();

                FaceOrientation[] faceOrientationArray = new FaceOrientation[4]
                {
                    FaceOrientation.Front,
                    FaceOrientation.Right,
                    FaceOrientation.Back,
                    FaceOrientation.Left
                };
                foreach (FaceOrientation faceOrientation in faceOrientationArray)
                {
                    Vector3 vector3_1 = FezMath.AsVector(FezMath.IsSide(FezMath.GetTangent(faceOrientation)) ? FezMath.GetTangent(faceOrientation) : FezMath.GetBitangent(faceOrientation));
                    Vector3 origin    = this.Center + FezMath.AsVector(faceOrientation) * a;
                    float   num2      = Math.Abs(FezMath.Dot(a, vector3_1)) * 2f;
                    Vector3 vector3_2 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
                    Vector3 vector3_3 = origin + (a - new Vector3(0.5f)) * (-vector3_1 + Vector3.UnitY);
                    for (int index = 0; (double)index < (double)num2; ++index)
                    {
                        Vector3 p = vector3_2 + (float)index * vector3_1;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                        p = vector3_3 + (float)index * vector3_1;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                    }
                    Vector3 vector3_4 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
                    Vector3 vector3_5 = origin + (a - new Vector3(0.5f)) * (vector3_1 - Vector3.UnitY);
                    for (int index = 0; (double)index < (double)num1; ++index)
                    {
                        Vector3 p = vector3_4 + (float)index * Vector3.UnitY;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                        p = vector3_5 + (float)index * Vector3.UnitY;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                    }
                    mesh2.AddFace(num2 * FezMath.Abs(vector3_1) + num1 * Vector3.UnitY, origin, faceOrientation, Color.White, true);
                }
                foreach (Group group in mesh1.Groups)
                {
                    group.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f));
                }
                mesh2.Collapse <VertexPositionNormalColor>();
                IndexedUserPrimitives <VertexPositionNormalColor> indexedUserPrimitives1 = mesh2.FirstGroup.Geometry as IndexedUserPrimitives <VertexPositionNormalColor>;

                mesh1.CollapseWithNormalTexture <FezVertexPositionNormalTexture>();
                IndexedUserPrimitives <FezVertexPositionNormalTexture> indexedUserPrimitives2 = mesh1.FirstGroup.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>;

                this.instanceIndex = this.Host.HolesBodyMesh.Groups.Count;
                this.Host.HolesBodyMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionInstance>(Enumerable.ToArray <VertexPositionInstance>(Enumerable.Select <VertexPositionNormalColor, VertexPositionInstance>((IEnumerable <VertexPositionNormalColor>)indexedUserPrimitives1.Vertices, (Func <VertexPositionNormalColor, VertexPositionInstance>)(x => new VertexPositionInstance(x.Position)
                {
                    InstanceIndex = (float)this.instanceIndex
                }))), indexedUserPrimitives1.Indices, PrimitiveType.TriangleList);
                this.Host.HolesFringeMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTextureInstance>(Enumerable.ToArray <VertexPositionTextureInstance>(Enumerable.Select <FezVertexPositionNormalTexture, VertexPositionTextureInstance>((IEnumerable <FezVertexPositionNormalTexture>)indexedUserPrimitives2.Vertices, (Func <FezVertexPositionNormalTexture, VertexPositionTextureInstance>)(x => new VertexPositionTextureInstance(x.Position, x.TextureCoordinate)
                {
                    InstanceIndex = (float)this.instanceIndex
                }))), indexedUserPrimitives2.Indices, PrimitiveType.TriangleList);
            }