static void Main(string[] args)
        {
            var configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText("appsettings.json"));

            var plantInfosPath = args[0];

            var totalPlantInfos = GetTotalPlantInfos(JsonConvert.DeserializeObject <List <PlantInfo> >(File.ReadAllText(plantInfosPath)));

            _labelMaker    = new LabelMaker(configuration);
            _toolPathMaker = new ToolPathMaker(configuration);

            var splitPlantInfos = totalPlantInfos.Partition <PlantInfo>(6);

            var i = 0;

            foreach (var plantInfos in splitPlantInfos)
            {
                var carbideDoc = new Document();
                carbideDoc.DocumentValues.Thickness = configuration.LabelZ;

                AddObjects(carbideDoc, plantInfos);
                carbideDoc = AddToolPaths(configuration, carbideDoc);

                var labelString = JsonConvert.SerializeObject(carbideDoc);

                File.WriteAllText($"plantLabels_{i}.c2d", labelString);
                i++;
            }
        }
    void CreateTextureQuad(TextureFormat format, Vector3 pos)
    {
        if ((int)format >= 0)
        {
            GameObject   go  = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            Transform    t   = go.GetComponent <Transform> ();
            MeshRenderer mr  = go.GetComponent <MeshRenderer> ();
            Material     mat = new Material(_shader);

            Texture3D tex = null;
            if (SystemInfo.SupportsTextureFormat(format))
            {
                if (setPixelSupport.Contains(format))
                {
                    if (debugMode)
                    {
                        Debug.Log("Texture supported " + format.ToString());
                    }
                    tex = new Texture3D(widthheight, widthheight, widthheight, format, false);
                    tex.SetPixels(refTexture.GetPixels());

                    LabelMaker.MakeLabel(format.ToString(), Color.green, t);
                }
                else
                {
                    if (debugMode)
                    {
                        Debug.LogWarning("Texture not supported with SetPixels " + format.ToString());
                    }
                    LabelMaker.MakeLabel(format.ToString(), Color.yellow, t);
                    //tex = warningTexture;
                }
            }
            else
            {
                if (debugMode)
                {
                    Debug.LogWarning("Texture not supported on platform " + format.ToString());
                }
                LabelMaker.MakeLabel(format.ToString(), Color.red, t);
                //tex = errorTexture;
            }

            if (tex != null)
            {
                tex.filterMode = FilterMode.Point;
                mat.SetTexture("_texture", tex);
                mat.name     = format.ToString();
                go.name      = format.ToString();
                mr.material  = mat;
                tex.wrapMode = TextureWrapMode.Repeat;
                tex.Apply();
            }

            t.SetParent(transform);
            t.position = pos;
        }
    }
Exemple #3
0
    void CreateSphere(Cubemap _texture, Vector3 pos)
    {
        GameObject go   = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        GameObject temp = new GameObject(_texture.ToString());

        spheres.Add(go.transform);
        go.transform.SetParent(temp.transform);
        Transform t = temp.GetComponent <Transform> ();

        t.localScale = Vector3.one * scale;
        MeshRenderer mr  = go.GetComponent <MeshRenderer> ();
        Material     mat = new Material(_shader);

        Cubemap tex = null;

        tex = new Cubemap(_texture.width, TextureFormat.ARGB32, false);
        Color[][] pixels = new Color[6][];
        if (!getPixel)
        {
            for (int i = 0; i < 6; i++)
            {
                pixels [i] = new Color[_texture.width * _texture.width];
                pixels [i] = _texture.GetPixels(cubemapFaces [i]);
                tex.SetPixels(pixels [i], cubemapFaces [i]);
            }
        }
        else
        {
            for (int ii = 0; ii < 6; ii++)
            {
                pixels [ii] = new Color[_texture.width * _texture.width];
                int i = 0;
                for (int y = 0; y < _texture.width; y++)
                {
                    for (int x = 0; x < _texture.width; x++)
                    {
                        pixels [ii] [i] = _texture.GetPixel(cubemapFaces [ii], x, y);
                        i++;
                    }
                }
                tex.SetPixels(pixels [ii], cubemapFaces [ii]);
            }
        }
        //tex.SetPixels (pixels);
        tex.Apply();
        LabelMaker.MakeLabel(_texture.name.ToString().Remove(0, 5), Color.white, t);
        tex.filterMode  = FilterMode.Point;
        mat.mainTexture = tex;
        mat.name        = _texture.name;
        go.name         = _texture.name;
        mr.material     = mat;
        tex.wrapMode    = TextureWrapMode.Clamp;
        tex.Apply();
        t.SetParent(transform);
        t.position = pos;
    }
    void CreateTextureQuad(RenderTextureFormat format, Vector3 pos)
    {
        if ((int)format >= 0)
        {
            GameObject   go  = GameObject.CreatePrimitive(PrimitiveType.Quad);
            Transform    t   = go.GetComponent <Transform> ();
            MeshRenderer mr  = go.GetComponent <MeshRenderer> ();
            Material     mat = new Material(_shader);

            TextureFormat tf       = TextureFormat.Alpha8;
            bool          isFormat = false;
            string        s        = format.ToString();
            try {
                tf       = (TextureFormat)Enum.Parse(typeof(TextureFormat), s);
                isFormat = true;
            } catch (ArgumentException e) {
                isFormat = false;
            }
            Texture2D tex = null;
            if (SystemInfo.SupportsRenderTextureFormat(format) && isFormat)
            {
                Debug.Log("Texture supported " + format.ToString());
                tex = new Texture2D(widthheight, widthheight, tf, false);
                Graphics.CopyTexture(refTexture, tex);
                LabelMaker.MakeLabel(format.ToString(), Color.green, t);
            }
            else
            {
                Debug.LogWarning("Texture not supported on platform of CopyTexture " + format.ToString());
                tex = errorTexture;
                LabelMaker.MakeLabel(format.ToString(), Color.red, t);
            }
            tex.filterMode  = FilterMode.Point;
            mat.mainTexture = tex;
            mat.name        = format.ToString();
            mr.material     = mat;
            tex.wrapMode    = TextureWrapMode.Repeat;
            go.name         = format.ToString();
            t.SetParent(transform);
            t.position = pos;
        }
    }
Exemple #5
0
    void CreateTextureQuad(Texture2D _texture, Vector3 pos)
    {
        GameObject   go  = GameObject.CreatePrimitive(PrimitiveType.Quad);
        Transform    t   = go.GetComponent <Transform> ();
        MeshRenderer mr  = go.GetComponent <MeshRenderer> ();
        Material     mat = new Material(_shader);

        Texture2D tex = null;

        tex = new Texture2D(widthheight, widthheight, TextureFormat.ARGB32, false);
        Color[] pixels = new Color[widthheight * widthheight];
        if (!getPixel)
        {
            pixels = _texture.GetPixels();
        }
        else
        {
            int i = 0;
            for (int y = 0; y < widthheight; y++)
            {
                for (int x = 0; x < widthheight; x++)
                {
                    pixels [i] = _texture.GetPixel(x, y);
                    i++;
                }
            }
        }
        tex.SetPixels(pixels);
        tex.Apply();
        LabelMaker.MakeLabel(_texture.name.ToString().Remove(0, 12), Color.white, t);
        tex.filterMode  = FilterMode.Point;
        mat.mainTexture = tex;
        mat.name        = _texture.name;
        go.name         = _texture.name;
        mr.material     = mat;
        tex.wrapMode    = TextureWrapMode.Repeat;
        tex.Apply();
        t.SetParent(transform);
        t.position = pos;
    }
Exemple #6
0
        private System.ComponentModel.Container components = null;                      //Required designer variable
        #endregion

        //Interface
        public winLabel(LabelTemplateNode node, LabelMaker labelMaker)
        {
            //Constructor
            //Required for Windows Form Designer support
            InitializeComponent();
            #region Menu identities (used for onclick handlers)
            this.ctxRefresh.Text = MNU_REFRESH;
            this.ctxCut.Text     = MNU_CUT;
            this.ctxCopy.Text    = MNU_COPY;
            this.ctxPaste.Text   = MNU_PASTE;
            #endregion
            #region Window docking
            this.splitterH.MinExtra = this.splitterH.MinSize = 48;
            this.splitterH.Dock     = this.pnlBottom.Dock = DockStyle.Bottom;
            this.pnlTop.Dock        = DockStyle.Fill;
            this.Controls.AddRange(new Control[] { this.pnlTop, this.splitterH, this.pnlBottom });
            #endregion

            //Bind to template and register for template events
            this.mLabelTemplateNode = node;
            this.mLabelTemplateNode.LabelTemplate.TemplateChanged += new EventHandler(this.OnTemplateChanged);
            this.mLabelMaker = labelMaker;
            this.mLabelMaker.LabelValuesChanged += new EventHandler(OnLabelValuesChanged);
        }