Example #1
0
        public override void OnInspectorGUI()
        {
            // Grabbing the object this inspector is editing.
            ColorTexture colorTexture = (ColorTexture)target;

            base.OnInspectorGUI();

            if (GUILayout.Button("Save Texture"))
            {
                colorTexture.SaveTextureToFile();
            }

            if (GUILayout.Button("Preview"))
            {
                var texture = colorTexture.Texture;

                if (texture != null)
                {
                    previewTexture = ScaleTexture(texture, 16);
                    hasPreview     = true;
                }
            }

            if (hasPreview)
            {
                GUILayout.Label(previewTexture);
            }
        }
Example #2
0
        void OnEnable()
        {
            Debug.Log("[GameResources] OnEnable");

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

            LoadTextureColor();
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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;
        }
 void InitGame()
 {
     voxelMeshBuilder = GameObject.Find("/Managers/VoxelMeshBuilder").GetComponent <VoxelMeshBuilder>();
     colorTexture     = GameObject.Find("/Managers/ColorTexture").GetComponent <ColorTexture>();
 }
 void Start()
 {
     colorTexture = GameObject.Find("/Managers/ColorTexture").GetComponent <ColorTexture>();
 }
Example #8
0
 void Start()
 {
     colorTexture = GameManager.Instance.GetColorTexture();
 }