Пример #1
0
    override protected Mesh CreateProduct(Mesh reuse = null)
    {
        Mesh mesh = reuse != null ? reuse : new Mesh();

        if (Input == null)
        {
            mesh.Clear();
            // Debug.Log("Source is null for " + this);
            return(mesh);
        }

        NPVoxModel model = GetVoxModel();

        if (model)
        {
            mesh.Clear();
            if (!model.IsValid)
            {
                Debug.LogWarning("Source Model is not valid");
                return(mesh);
            }
            NPVoxMeshGenerator.CreateMesh(model, mesh, VoxelSize, NormalVariance, NormalVarianceSeed, Optimization, NormalMode, BloodColorIndex, Loop, Cutout, Include, MinVertexGroups, NormalModePerVoxelGroup, NormalProcessors);
            mesh.name = "zzz Mesh";
            return(mesh);
        }
        else
        {
            // Debug.Log("Source Product is null for " + this);
            mesh.Clear();
            return(mesh);
        }
    }
Пример #2
0
    public NPVoxMeshData[] GetVoxMeshData()
    {
        if (m_voxMeshData == null)
        {
            m_voxMeshData = NPVoxMeshGenerator.GenerateVoxMeshData(GetVoxModel(), VoxelSize, Optimization, BloodColorIndex, Loop, Cutout, Include);
        }

        return(m_voxMeshData);
    }
Пример #3
0
    public override void Import()
    {
        base.Import();

        if (NormalProcessors == null)
        {
            NormalProcessors = ScriptableObject.CreateInstance <NPVoxNormalProcessorList>();
        }

        // Normal processor migration code
        if (NormalProcessors && NormalProcessors.RequiresMigration)
        {
            if (UnityEditor.AssetDatabase.GetAssetPath(NormalProcessors).Length == 0)
            {
                NormalProcessors.hideFlags = HideFlags.HideInHierarchy;

                if (NormalModePerVoxelGroup != null && NormalModePerVoxelGroup.Length > 0)
                {
                    for (int i = 0; i < NormalModePerVoxelGroup.Length; i++)
                    {
                        NPVoxNormalProcessor_Voxel processorVoxel = NormalProcessors.AddProcessor <NPVoxNormalProcessor_Voxel>();
                        processorVoxel.NormalMode = NormalModePerVoxelGroup[i];
                        processorVoxel.AddVoxelGroupFilter(i);
                    }
                }
                else
                {
                    NPVoxNormalProcessor_Voxel processorVoxel = NormalProcessors.AddProcessor <NPVoxNormalProcessor_Voxel>();
                    processorVoxel.NormalMode = NormalMode;
                }

                NPVoxNormalProcessor_Variance processorVariance = NormalProcessors.AddProcessor <NPVoxNormalProcessor_Variance>();
                processorVariance.NormalVarianceSeed = NormalVarianceSeed;
                processorVariance.NormalVariance     = NormalVariance;

                NormalProcessors.AddToAsset(UnityEditor.AssetDatabase.GetAssetPath(this));

                UnityEditor.EditorUtility.SetDirty(NormalProcessors);

                NormalProcessors.RequiresMigration = false;
            }

            NormalProcessors.RequiresMigration = false;
        }

        m_voxMeshData = NPVoxMeshGenerator.GenerateVoxMeshData(GetVoxModel(), VoxelSize, Optimization, BloodColorIndex, Loop, Cutout, Include);

        if (NormalProcessors != null)
        {
            NormalProcessors.OnImport();
        }
    }