Пример #1
0
    public void UpdateCollider()
    {
        if (data.generateCollider != BuildrData.ColliderGenerationModes.None)
        {
            if (data.floorHeight == 0)
            {
                return;
            }
            if (colliderMesh == null)
            {
                colliderMesh = new DynamicMeshGenericMultiMaterialMesh();
            }

            colliderMesh.Clear();
            colliderMesh.subMeshCount = 1;
            BuildrBuildingCollider.Build(colliderMesh, data);
            colliderMesh.Build(false);

            int numberOfStairMeshes = colliderMesh.meshCount;
            for (int i = 0; i < numberOfStairMeshes; i++)
            {
                string meshName = "collider";
                if (numberOfStairMeshes > 1)
                {
                    meshName += " mesh " + (i + 1);
                }
                GameObject newMeshHolder = new GameObject(meshName);
                newMeshHolder.transform.parent = transform;
                meshFilt      = newMeshHolder.AddComponent <MeshFilter>();
                meshRend      = newMeshHolder.AddComponent <MeshRenderer>();
                meshFilt.mesh = colliderMesh[i].mesh;
                colliderHolders.Add(newMeshHolder);
            }
        }
    }
Пример #2
0
    private static void ExportCollider(BuildrData data)
    {
        DynamicMeshGenericMultiMaterialMesh COL_MESH = new DynamicMeshGenericMultiMaterialMesh();

        COL_MESH.subMeshCount = data.textures.Count;
        BuildrBuildingCollider.Build(COL_MESH, data);
//        COL_MESH.CollapseSubmeshes();
        COL_MESH.Build(false);

        ExportMaterial[] exportTextures = new ExportMaterial[1];
        ExportMaterial   newTexture     = new ExportMaterial();

        newTexture.name      = "blank";
        newTexture.filepath  = "";
        newTexture.generated = true;
        exportTextures[0]    = newTexture;

        int numberOfColliderMeshes = COL_MESH.meshCount;

        for (int i = 0; i < numberOfColliderMeshes; i++)
        {
            MeshUtility.Optimize(COL_MESH[i].mesh);
            string ColliderSuffixIndex = ((numberOfColliderMeshes > 1) ? "_" + i : "");
            string ColliderFileName    = data.exportFilename + COLLIDER_SUFFIX + ColliderSuffixIndex;
            string ColliderFolder      = ROOT_FOLDER + data.exportFilename + "/";
            Export(ColliderFileName, ColliderFolder, data, COL_MESH[i].mesh, exportTextures);
        }
    }