コード例 #1
0
        void OnEnable()
        {
            Debug.Log("[GameResources] OnEnable");

            chunkSimplifier = GameObject.Find("/Managers/ChunkSimplifier").GetComponent <ChunkSimplifier>();
            colorTexture    = GameObject.Find("/Managers/ColorTexture").GetComponent <ColorTexture>();

            LoadTextureColor();
        }
コード例 #2
0
        public void Init(int chunkSize)
        {
            meshFilter   = GetComponent <MeshFilter>();
            meshCollider = GetComponent <MeshCollider>();
            meshRenderer = GetComponent <MeshRenderer>();
            colorTexture = GameManager.Instance.GetColorTexture();
//			voxelMeshBuilder = GameManager.Instance.GetVoxelMeshBuilder();
            chunkSimplifier = GameObject.Find("/Managers/ChunkSimplifier").GetComponent <ChunkSimplifier>();

            meshRenderer.sharedMaterial.mainTexture = colorTexture.Texture;

            chunk = new Chunk(chunkSize, chunkSize, chunkSize);
        }
コード例 #3
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);
        }
コード例 #4
0
        void Start()
        {
            Debug.Log("[VoxelModel] Start");

            gameResources   = GameObject.Find("/Managers/GameResources").GetComponent <GameResources>();
            chunkSimplifier = GameObject.Find("/Managers/ChunkSimplifier").GetComponent <ChunkSimplifier>();
            colorTexture    = GameObject.Find("/Managers/ColorTexture").GetComponent <ColorTexture>();

            meshFilter   = GetComponent <MeshFilter>();
            meshCollider = GetComponent <MeshCollider>();
            meshRenderer = GetComponent <MeshRenderer>();

            LoadModel();

            isStarted = true;
        }