예제 #1
0
        protected override void ExtraOnGUI()
        {
            base.ExtraOnGUI();
            int size = (int)getValue("size");

            for (int i = 4; i < 12; i++)
            {
                int prev = (int)Mathf.Pow(2, i - 1);
                int next = (int)Mathf.Pow(2, i);
                if (size >= prev && size < next)
                {
                    size = prev;
                }
            }
            setValue("size", size);
            MaterialPreviewEditor.setParameters(getValue("parallax"), getValue("shininess"), getColor("matcolor"), getColor("shinecolor"), getValue("direction"), getValue("threshold"), getValue("tiling"));
            int tiling = (int)getValue("tiling");

            setValue("tiling", tiling);

            if (CNodeManager.status == CNodeManager.STATUS_NONE)
            {
                if (size != C2DMap.sizeX)
                {
                    CNodeManager.status = CNodeManager.STATUS_TASK4;
                }
            }
            window.height += LStyle.FontSize * 3;
        }
예제 #2
0
        // First run
        void StartInitialize()
        {
            if (settings == null)
            {
                return;
            }
            size         = 256;
            C2DMap.sizeX = size;
            C2DMap.sizeY = size;
            if (settings.currentFile == "")
            {
                New();
            }
            else
            {
                LoadDirect(settings.currentFile);
            }

            MaterialPreviewEditor.Create(LStyle.MaterialName);

            startInitialize = true;
            ForceRepaint    = true;
            ResetState();
            maintainTextures();
        }
예제 #3
0
 public override void Create()
 {
     output.CalculateTextures();
     MaterialPreviewEditor.forceRepaint();
     Repaint();
     status = STATUS_NONE;
 }
예제 #4
0
        public void CalculateTextures()
        {
            CTextureNode Heightmap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            if (NormalMap == null || ColorMap == null || Heightmap == null)
            {
                return;
            }
            Heightmap.GenerateTexture();
            ColorMap.GenerateTexture();
            NormalMap.GenerateTexture();

            MaterialPreviewEditor.SetTextures(NormalMap.texture, Heightmap.texture, ColorMap.texture, MaterialPreviewEditor.currentMaterial);
            MaterialPreviewEditor.forceRepaint();
            CNodeManager.Progress();
        }
예제 #5
0
        public void Export(string file)
        {
//			CTextureNode ShininessMap = (CTextureNode)getNode (Inputs, 0);
            CTextureNode HeightMap = (CTextureNode)getNode(Inputs, 0);
            CTextureNode ColorMap  = (CTextureNode)getNode(Inputs, 1);
            CTextureNode NormalMap = (CTextureNode)getNode(Inputs, 2);

            string FileNormalMap = file + "_Normal";
            string FileColorMap  = file + "_Color";
            string FileHeightMap = file + "_Height";

            MaterialPreviewEditor.forceRepaint();

            if (NormalMap != null)
            {
                Util.SaveTextureFile(NormalMap.texture, "", FileNormalMap);
            }

            if (ColorMap != null)
            {
                Util.SaveTextureFile(ColorMap.texture, "", FileColorMap);
            }

            if (HeightMap != null)
            {
                Util.SaveTextureFile(HeightMap.texture, "", FileHeightMap);
            }

            AssetDatabase.Refresh();
            try {
                Material mat = new Material(file);                                                 //MaterialPreviewEditor.currentMaterial;
                AssetDatabase.CreateAsset(mat, file + ".mat");
                mat.shader = MaterialPreviewEditor.currentMaterial.shader;

                Texture2D T_hm = (Texture2D)AssetDatabase.LoadAssetAtPath(FileHeightMap + ".png", typeof(Texture2D));
                Texture2D T_c  = (Texture2D)AssetDatabase.LoadAssetAtPath(FileColorMap + ".png", typeof(Texture2D));
//			Texture2D T_ex = (Texture2D)AssetDatabase.LoadAssetAtPath(FileExtraMap + ".png", typeof(Texture2D));
                Texture2D T_nr = (Texture2D)AssetDatabase.LoadAssetAtPath(FileNormalMap + ".png", typeof(Texture2D));
                MaterialPreviewEditor.SetTextures(T_nr, T_hm, T_c, mat);
                MaterialPreviewEditor.SetProperties(mat);
            } catch (System.Exception e) {
                Debug.Log(e.Message);
            }
        }
예제 #6
0
        private void renderMenuButtons()
        {
            float dy = Screen.height / 15f;                                    ///34;
            float hy = Screen.height / 15 - 4;
            float y  = hy / 2;
            float i  = 0;

            int bsx  = 200;
            int dbsx = (int)(bsx * 1.15f);

            GUI.color = LStyle.Colors [4];
            GUI.DrawTexture(new Rect(Screen.width - dbsx, 0, Screen.width, Screen.height), background2);
            GUI.color           = LStyle.Colors [4];
            GUI.backgroundColor = LStyle.Colors [4];
            int db = dbsx - bsx;

            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "View material"))
            {
                MaterialPreviewEditor.Create(LStyle.MaterialName);
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "New"))
            {
                New();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Load"))
            {
                Load();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Save"))
            {
                Save();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Save as"))
            {
                SaveAs();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "About"))
            {
                About();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Export"))
            {
                Export();
            }
            i++;
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Abort"))
            {
                KillThread();
            }
            if (GUI.Button(new Rect(Screen.width - bsx, y + dy * i++, bsx - db, hy), "Force calculate"))
            {
                output.changed = true;
                mouseUp        = true;
                maintainTextures();
            }

/*						if (GUI.Button (new Rect (Screen.width - bsx, y + dy * i++, bsx - db, hy), "Refresh nodes"))
 *                                                              RefreshNodesNew ();
 */

            y += hy;
        }