Ejemplo n.º 1
0
            private void DrawLineMesh(UnityEngine.Mesh mesh,
                                      int vertex_count,
                                      UnityEngine.Color colour,
                                      GLLines.Style style)
            {
                mesh.vertices = VertexBuffer.vertices;
                int index_count = style == GLLines.Style.Dashed ? vertex_count & ~1
                                                    : vertex_count;
                var indices = new int[index_count];

                for (int i = 0; i < index_count; ++i)
                {
                    indices[i] = i;
                }
                var colours = new UnityEngine.Color[VertexBuffer.size];

                if (style == GLLines.Style.Faded)
                {
                    for (int i = 0; i < vertex_count; ++i)
                    {
                        var faded_colour = colour;
                        // Fade from the opacity of |colour| (when i = 0) down to 20% of that
                        // opacity.
                        faded_colour.a *= 1 - 0.8f * (i / (float)vertex_count);
                        colours[i]      = faded_colour;
                    }
                }
                else
                {
                    for (int i = 0; i < vertex_count; ++i)
                    {
                        colours[i] = colour;
                    }
                }
                mesh.colors = colours;
                mesh.SetIndices(
                    indices,
                    style == GLLines.Style.Dashed ? UnityEngine.MeshTopology.Lines
                                      : UnityEngine.MeshTopology.LineStrip,
                    submesh: 0);
                mesh.RecalculateBounds();
                // If the lines are drawn in layer 31 (Vectors), which sounds more
                // appropriate, they vanish when zoomed out.  Layer 9 works; pay no
                // attention to its name.
                UnityEngine.Graphics.DrawMesh(
                    mesh,
                    UnityEngine.Vector3.zero,
                    UnityEngine.Quaternion.identity,
                    GLLines.line_material,
                    (int)PrincipiaPluginAdapter.UnityLayers.Atmosphere,
                    PlanetariumCamera.Camera);
            }
Ejemplo n.º 2
0
        public UnityEngine.Mesh ToMesh()
        {
            return(ab);

            var mesh = new UnityEngine.Mesh();

            //   mesh.uv=uv.ToArray();
            //  mesh.triangles = Faces.ToArray();
            for (int i = 0; i < Vertices.Count; i++)
            {
                var v = Vertices[i];
                v.x        -= 30;
                Vertices[i] = v;
                //  Vertices[i]=new UnityEngine.Vector3();
            }
            mesh.vertices = (Vertices).ToArray();
            UnityEngine.Debug.Log("count" + uv.Count);
            var wr = Faces.ToArray();

            Array.Resize(ref wr, Vertices.Count);
            mesh.SetIndices(wr, UnityEngine.MeshTopology.Triangles, 0);


            var tw = uv.ToArray();

            Array.Resize(ref tw, Vertices.Count);


            // uv.ToArray();
            //var sz=    new UnityEngine.Vector3[] { normal };
            //    Array.Resize(ref sz, Vertices.Count);
            //    mesh.normals = sz;

            mesh.SetUVs(0, tw.ToList());
            //   mesh.normals = new UnityEngine.Vector3[] { normal };
            return(mesh);
        }
Ejemplo n.º 3
0
 private void ApplyIndices()
 {
     unityMesh.SetIndices(GetIndices(), GetUnityMeshTopology(), 0);
 }
Ejemplo n.º 4
0
        public UnityEngine.Mesh ToUnity(Utils.Progress progress = null)
        {
            if (unityMesh == null)
            {
                unityMesh = new UnityEngine.Mesh();

                if (name != null)
                {
                    unityMesh.name = name;
                }
                if (vertices != null)
                {
                    unityMesh.vertices = vertices;
                }
                if (normals != null)
                {
                    unityMesh.normals = normals;
                }
                if (tangents != null)
                {
                    unityMesh.tangents = tangents;
                }
                if (uv1 != null)
                {
                    unityMesh.uv = uv1;
                }
                if (uv2 != null)
                {
                    unityMesh.uv2 = uv2;
                }
                if (colors != null)
                {
                    unityMesh.colors = colors;
                }
                if (submeshes != null)
                {
                    int nb_submeshes = submeshes.Length;

                    unityMesh.subMeshCount = nb_submeshes;

                    for (int i = 0; i < nb_submeshes; i++)
                    {
                        SubMesh submesh = submeshes[i];

                        unityMesh.SetIndices(submesh.triangles, submesh.topology, i);
                    }
                }

                unityMesh.RecalculateBounds();

#if !UNITY_5_5_OR_NEWER
                unityMesh.Optimize();
#endif

                if (progress != null)
                {
                    progress.Update(1);
                }
            }

            return(unityMesh);
        }