Ejemplo n.º 1
0
        void Refresh()
        {
//			MeshData meshData = voxelMeshBuilder.BuildMesh(chunk);
//			voxelMeshBuilder.RenderMesh(meshData, meshFilter, meshCollider);

            MeshData meshData = chunkSimplifier.BuildMesh(chunk);

            chunkSimplifier.RenderMesh(meshData, meshFilter, meshCollider);
        }
Ejemplo n.º 2
0
        void Start()
        {
            meshFilter   = GetComponent <MeshFilter>();
            meshCollider = GetComponent <MeshCollider>();
            meshRenderer = GetComponent <MeshRenderer>();
            colorTexture = GameManager.Instance.GetColorTexture();
//			voxelMeshBuilder = GameManager.Instance.GetVoxelMeshBuilder();
            chunkSimplifier = GameObject.Find("/Managers/ChunkSimplifier").GetComponent <ChunkSimplifier>();

            QBTFile qbtFile = LoadQubicleFile();

            QBTFile.VoxelData[,,] qbtData = qbtFile.VoxelsData;

            colorTexture.AddColors(qbtFile.Colors.ToArray());

            sizeX = qbtData.GetLength(0);
            sizeY = qbtData.GetLength(1);
            sizeZ = qbtData.GetLength(2);

            chunk = new Chunk(sizeX, sizeY, sizeZ);
            for (int x = 0; x < sizeX; x++)
            {
                for (int y = 0; y < sizeY; y++)
                {
                    for (int z = 0; z < sizeZ; z++)
                    {
                        if (qbtData[x, y, z].m != 0)
                        {
                            // The z axis is reversed in qubicle
                            chunk.SetVoxel(
                                x, y, sizeZ - 1 - z,
                                Voxel.Type.Solid,
                                qbtData[x, y, z].Color
                                );
                        }
                    }
                }
            }

            meshRenderer.sharedMaterial.mainTexture = colorTexture.Texture;

//			MeshData meshData = voxelMeshBuilder.BuildMesh(chunk);
//			voxelMeshBuilder.RenderMesh(meshData, meshFilter, meshCollider);

            MeshData meshData = chunkSimplifier.BuildMesh(chunk);

            chunkSimplifier.RenderMesh(meshData, meshFilter, meshCollider);
        }
Ejemplo n.º 3
0
        void LoadModel()
        {
            Debug.Log("[VoxelModel] LoadModel");

            if (string.IsNullOrEmpty(modelName))
            {
                return;
            }

            chunk = gameResources.GetChunk(modelName);
            meshRenderer.sharedMaterial.mainTexture = colorTexture.Texture;

            meshFilter.sharedMesh = new Mesh();

            MeshData meshData = chunkSimplifier.BuildMesh(chunk);

            chunkSimplifier.RenderMesh(meshData, meshFilter, meshCollider);
        }
Ejemplo n.º 4
0
        public void GenerateModels()
        {
            Debug.Log("[GameResources] GeneratePrefab");

            LoadQbtModels();

            // Generate meshes
            foreach (var item in models)
            {
                string modelName = item.Key;
                Chunk  chunk     = item.Value;
                string destPath  = "Assets/Core/VoxelModels/Meshes/" + modelName + ".asset";

                Debug.Log("[GameResources] Loading " + modelName);

                MeshData meshData = chunkSimplifier.BuildMesh(chunk);
                Mesh     mesh     = chunkSimplifier.CreateMesh(meshData);

                CreateOrReplaceAsset(mesh, destPath);
                AssetDatabase.SaveAssets();
            }
        }