示例#1
0
 protected virtual void WriteMesh()
 {
     MeshUtility.InverseTransformMesh(tsMesh, this.transform);
     if (_doubleSided)
     {
         MeshUtility.MakeDoublesided(tsMesh);
     }
     else if (_flipFaces)
     {
         MeshUtility.FlipFaces(tsMesh);
     }
     if (_tangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
     tsMesh.WriteMesh(ref mesh);
     if (_normalMethod == 0)
     {
         mesh.RecalculateNormals();
     }
     if (filter != null)
     {
         filter.sharedMesh = mesh;
     }
     updateCollider = true;
 }
 protected virtual void WriteMesh()
 {
     MeshUtility.InverseTransformMesh(tsMesh, transform);
     if (_doubleSided)
     {
         MeshUtility.MakeDoublesidedHalf(tsMesh);
     }
     else if (_flipFaces)
     {
         MeshUtility.FlipFaces(tsMesh);
     }
     if (_tangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
     if (tsMesh.vertexCount > 64000)
     {
         Debug.LogError("WARNING: The generated mesh for " + name + " has " + tsMesh.vertexCount + " vertices. The maximum vertex count for meshes in Unity is 64000. The mesh will not be updated.");
     }
     tsMesh.WriteMesh(ref mesh);
     if (_normalMethod == 0)
     {
         mesh.RecalculateNormals();
     }
     if (filter != null)
     {
         filter.sharedMesh = mesh;
     }
     updateCollider = true;
 }
示例#3
0
 private void ApplyMesh()
 {
     if (!(filter == null))
     {
         MeshUtility.InverseTransformMesh(editMesh, transform.transform);
         MeshUtility.CalculateTangents(editMesh);
         if (destinationMesh == null)
         {
             destinationMesh      = new Mesh();
             destinationMesh.name = originalMesh.name;
         }
         editMesh.WriteMesh(ref destinationMesh);
         destinationMesh.RecalculateBounds();
         filter.sharedMesh = destinationMesh;
     }
 }
示例#4
0
 protected override void BuildMesh()
 {
     if (computer.pointCount == 0)
     {
         return;
     }
     base.BuildMesh();
     Generate();
     if (doubleSided)
     {
         MeshUtility.MakeDoublesided(tsMesh);
     }
     if (calculateTangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
 }
示例#5
0
            private void ApplyMesh()
            {
                if (filter == null)
                {
                    return;
                }
                MeshUtility.CalculateTangents(editMesh);
                if (destinationMesh == null)
                {
                    destinationMesh      = new Mesh();
                    destinationMesh.name = originalMesh.name;
                }

                editMesh.WriteMesh(ref destinationMesh);
                destinationMesh.RecalculateBounds();
                filter.sharedMesh = destinationMesh;
            }
示例#6
0
 protected override void BuildMesh()
 {
     if (_sides <= 2)
     {
         return;
     }
     base.BuildMesh();
     GenerateVertices();
     GenerateTriangles();
     if (doubleSided)
     {
         MeshUtility.MakeDoublesided(tsMesh);
     }
     if (calculateTangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
 }
示例#7
0
 protected override void BuildMesh()
 {
     if (clippedSamples.Length == 0)
     {
         return;
     }
     base.BuildMesh();
     GenerateVertices();
     tsMesh.triangles = MeshUtility.GeneratePlaneTriangles(_slices, clippedSamples.Length, false);
     if (doubleSided)
     {
         MeshUtility.MakeDoublesided(tsMesh);
     }
     if (calculateTangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
 }
示例#8
0
 void Generate()
 {
     if (_symmetry)
     {
         GenerateSymmetrical();
     }
     else
     {
         GenerateDefault();
     }
     if (doubleSided)
     {
         MeshUtility.MakeDoublesided(tsMesh);
     }
     if (calculateTangents)
     {
         MeshUtility.CalculateTangents(tsMesh);
     }
 }
示例#9
0
 private void ApplyCollider()
 {
     if (collider == null)
     {
         return;
     }
     if (originalColliderMesh == originalMesh)
     {
         collider.sharedMesh = filter.sharedMesh;
         return;
     }
     MeshUtility.InverseTransformMesh(editColliderMesh, transform.transform);
     MeshUtility.CalculateTangents(editColliderMesh);
     if (destinationColliderMesh == null)
     {
         destinationColliderMesh      = new Mesh();
         destinationColliderMesh.name = originalColliderMesh.name;
     }
     editColliderMesh.WriteMesh(ref destinationColliderMesh);
     destinationColliderMesh.RecalculateBounds();
     collider.sharedMesh = destinationColliderMesh;
 }
示例#10
0
 private void ApplyCollider()
 {
     if (collider == null)
     {
         return;
     }
     if (originalColliderMesh == originalMesh)
     {
         collider.sharedMesh = filter.sharedMesh;                                       //if the collider has the same mesh as the filter - just copy it
     }
     else
     {
         MeshUtility.CalculateTangents(editColliderMesh);
         if (destinationColliderMesh == null)
         {
             destinationColliderMesh      = new Mesh();
             destinationColliderMesh.name = originalColliderMesh.name;
         }
         editColliderMesh.WriteMesh(ref destinationColliderMesh);
         destinationColliderMesh.RecalculateBounds();
         collider.sharedMesh = destinationColliderMesh;
     }
 }
示例#11
0
        protected override void BuildMesh()
        {
            if (_sides <= 2)
            {
                return;
            }
            base.BuildMesh();
            bodyVertexCount = (_sides + 1) * clippedSamples.Length;
            CapMethod _capModeFinal = _capMode;

            if (!useCap)
            {
                _capModeFinal = CapMethod.None;
            }
            switch (_capModeFinal)
            {
            case CapMethod.Flat: capVertexCount = _sides + 1; break;

            case CapMethod.Round: capVertexCount = _roundCapLatitude * (sides + 1); break;

            default: capVertexCount = 0; break;
            }
            int vertexCount = bodyVertexCount + capVertexCount * 2;

            if (tsMesh.vertexCount != vertexCount)
            {
                tsMesh.vertices = new Vector3[vertexCount];
                tsMesh.normals  = new Vector3[vertexCount];
                tsMesh.colors   = new Color[vertexCount];
                tsMesh.uv       = new Vector2[vertexCount];
                bodyTrisCount   = _sides * (clippedSamples.Length - 1) * 2 * 3;
                switch (_capModeFinal)
                {
                case CapMethod.Flat: capTrisCount = (_sides - 1) * 3 * 2; break;

                case CapMethod.Round: capTrisCount = _sides * _roundCapLatitude * 6; break;

                default: capTrisCount = 0; break;
                }
                if (tsMesh.triangles.Length != bodyTrisCount + capTrisCount * 2)
                {
                    tsMesh.triangles = new int[bodyTrisCount + capTrisCount * 2];
                }
            }
            Generate();
            switch (_capModeFinal)
            {
            case CapMethod.Flat: GenerateFlatCaps(); break;

            case CapMethod.Round: GenerateRoundCaps(); break;
            }

            if (doubleSided)
            {
                MeshUtility.MakeDoublesided(tsMesh);
            }
            if (calculateTangents)
            {
                MeshUtility.CalculateTangents(tsMesh);
            }
        }