Beispiel #1
0
        /// <summary>
        /// create a mesh resource and copy vmesh data to the mesh!
        /// </summary>
        /// <param name="vmesh"></param>
        CGMeshResource writeVMeshToMesh(ref CGVMesh vmesh)
        {
            CGMeshResource res;
            Mesh           mesh;

            bool wantNormals  = (AddNormals != CGYesNoAuto.No);
            bool wantTangents = (AddTangents != CGYesNoAuto.No);

            res = getNewMesh();
        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                res.Filter.gameObject.isStatic = false;
            }
        #endif
            mesh = res.Prepare();
            res.gameObject.layer = Layer;
            vmesh.ToMesh(ref mesh);
            VertexCount += vmesh.Count;
            if (AddUV2 && !vmesh.HasUV2)
            {
                mesh.uv2 = CGUtility.CalculateUV2(vmesh.UV);
            }
            if (wantNormals && !vmesh.HasNormals)
            {
                mesh.RecalculateNormals();
            }
            if (wantTangents && !vmesh.HasTangents)
            {
                res.Filter.CalculateTangents();
            }


            // Reset Transform
            res.Filter.transform.localPosition = Vector3.zero;
            res.Filter.transform.localRotation = Quaternion.identity;
            res.Filter.transform.localScale    = Vector3.one;
        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                res.Filter.gameObject.isStatic = MakeStatic;
            }
        #endif
            res.Renderer.sharedMaterials = vmesh.GetMaterials();


            return(res);
        }
Beispiel #2
0
        /// <summary>
        /// create a mesh resource and copy vmesh data to the mesh!
        /// </summary>
        /// <param name="vmesh"></param>
        CGMeshResource writeVMeshToMesh(ref CGVMesh vmesh)
        {
            CGMeshResource res;
            Mesh mesh;

            bool wantNormals = (AddNormals != CGYesNoAuto.No);
            bool wantTangents = (AddTangents != CGYesNoAuto.No);
            res = getNewMesh();
#if UNITY_EDITOR
            if (!Application.isPlaying)
                res.Filter.gameObject.isStatic = false;
#endif
            mesh = res.Prepare();
            res.gameObject.layer = Layer;
            vmesh.ToMesh(ref mesh);
            VertexCount += vmesh.Count;
            if (AddUV2 && !vmesh.HasUV2)
                mesh.uv2 = CGUtility.CalculateUV2(vmesh.UV);
            if (wantNormals && !vmesh.HasNormals)
                mesh.RecalculateNormals();
            if (wantTangents && !vmesh.HasTangents)
                res.Filter.CalculateTangents();


            // Reset Transform
            res.Filter.transform.localPosition = Vector3.zero;
            res.Filter.transform.localRotation = Quaternion.identity;
            res.Filter.transform.localScale = Vector3.one;
#if UNITY_EDITOR
            if (!Application.isPlaying)
                res.Filter.gameObject.isStatic = MakeStatic;
#endif
            res.Renderer.sharedMaterials = vmesh.GetMaterials();


            return res;
        }