Esempio n. 1
0
    public GameObject RenderGcode()
    {
        Destroy();

        float lineWidth = GcodeParser.GetInstance().GetLayerHeight() * 5;

        GcodeDrawLineManager.GetInstance().SetGcodeRenderBeans(GcodeParser.GetInstance().GetGcodeRenderPointList());
        GcodeDrawLineManager.GetInstance().SetLineWidth(lineWidth);

        gcodeRenderGameObject      = GameObject.CreatePrimitive(PrimitiveType.Cube);
        gcodeRenderGameObject.name = "gcodeRenderGameObject";
        gcodeRenderGameObject.GetComponent <Renderer>().enabled = false;

        foreach (VectorLine vectorLine in GcodeDrawLineManager.GetInstance().GetVectorLineList_types())
        {
            vectorLine.drawTransform = gcodeRenderGameObject.transform;
            vectorLine.active        = true;
        }

        foreach (VectorLine vectorLine in GcodeDrawLineManager.GetInstance().GetVectorLine_topLayer())
        {
            vectorLine.drawTransform = gcodeRenderGameObject.transform;
            vectorLine.active        = true;
        }

        _struct.isRendered = true;

        initColorScheme();
        UpdatGcodePreviewColors();

        SetActive_Top_Layer(true);
        GcodeDrawLineManager.GetInstance().SetColor_topLayer(GcodeTypeColor.Top_Layer);

        return(gcodeRenderGameObject);
    }
Esempio n. 2
0
    public void Destroy()
    {
        _struct.isParsing     = false;
        _struct.parseProgress = 0;
        _struct.isRendered    = false;

        GcodeDrawLineManager.GetInstance().Destroy();

        if (gcodeRenderGameObject != null)
        {
            UnityEngine.Object.Destroy(gcodeRenderGameObject);
        }
    }
Esempio n. 3
0
    public void SetActive_Top_Layer(bool active)
    {
        _showDic_topLayer[GcodeType.Top_Layer] = active;
        if (active)
        {
            _colorsDic_topLayer[GcodeType.Top_Layer] = GcodeTypeColor.Top_Layer;
        }
        else
        {
            _colorsDic_topLayer[GcodeType.Top_Layer] = GcodeTypeColor.Transparent;
        }

        GcodeDrawLineManager.GetInstance().SetActive_topLayer(active);
        GcodeDrawLineManager.GetInstance().SetColor_topLayer(_colorsDic_topLayer[GcodeType.Top_Layer]);
    }
Esempio n. 4
0
    public void AutoSetLineWidth(float distance)
    {
        /**
         * 应该采集一些数据,做函数拟合,来计算线宽。参数如下:
         * 1.模型的transform.z
         * 2.Gcode parse result : layerHeight
         **/

        //		float width = GcodeParser.GetInstance ().GetLayerHeight () * 1000 / distance ;
        //float width = 12 / Mathf.Sqrt(distance);
        float width = 700 / distance;

        if (Mathf.Abs(width - GcodeDrawLineManager.GetInstance().GetLineWidth()) > 0.05f)
        {
            GcodeDrawLineManager.GetInstance().SetLineWidth(width);
        }
    }
Esempio n. 5
0
 void onClick_btn1()
 {
     GcodeDrawLineManager.GetInstance().SetColor_types(null);
 }
Esempio n. 6
0
 public void ShowLayerLessThanZ(float z)
 {
     GcodeDrawLineManager.GetInstance().SetVisiableLayerLessThanZ(z);
 }
Esempio n. 7
0
 public void ShowFirstLayers(int count)
 {
     GcodeDrawLineManager.GetInstance().SetVisiableLayerCount(count);
 }
Esempio n. 8
0
    private void UpdatGcodePreviewColors()
    {
        //1.if active==false ---> color_Transparent
        if (!_showDic_types[GcodeType.WALL_INNER])
        {
            _colorsDic_types[GcodeType.WALL_INNER] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.WALL_OUTER])
        {
            _colorsDic_types[GcodeType.WALL_OUTER] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.SKIN])
        {
            _colorsDic_types[GcodeType.SKIN] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.SKIRT])
        {
            _colorsDic_types[GcodeType.SKIRT] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.SUPPORT])
        {
            _colorsDic_types[GcodeType.SUPPORT] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.FILL])
        {
            _colorsDic_types[GcodeType.FILL] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.UNKNOWN])
        {
            _colorsDic_types[GcodeType.UNKNOWN] = GcodeTypeColor.Transparent;
        }
        if (!_showDic_types[GcodeType.Travel])
        {
            _colorsDic_types[GcodeType.Travel] = GcodeTypeColor.Transparent;
        }

        //2.
        if (_showDic_types[GcodeType.WALL_INNER])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.WALL_INNER] = GcodeTypeColor.WALL_INNER;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.WALL_INNER] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.WALL_OUTER])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.WALL_OUTER] = GcodeTypeColor.WALL_OUTER;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.WALL_OUTER] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.SKIN])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.SKIN] = GcodeTypeColor.SKIN;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.SKIN] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.SKIRT])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.SKIRT] = GcodeTypeColor.SKIRT;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.SKIRT] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.SUPPORT])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.SUPPORT] = GcodeTypeColor.SUPPORT;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.SUPPORT] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.FILL])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.FILL] = GcodeTypeColor.FILL;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.FILL] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.UNKNOWN])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.UNKNOWN] = GcodeTypeColor.UNKNOWN;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.UNKNOWN] = GcodeTypeColor.Material_Color;
            }
        }
        if (_showDic_types[GcodeType.Travel])
        {
            if (_curColorScheme == ColorScheme.Line_Type)
            {
                _colorsDic_types[GcodeType.Travel] = GcodeTypeColor.Travel;
            }
            else if (_curColorScheme == ColorScheme.Material)
            {
                _colorsDic_types[GcodeType.Travel] = GcodeTypeColor.Material_Color;
            }
        }

        GcodeDrawLineManager.GetInstance().SetColor_types(_colorsDic_types);
    }
Esempio n. 9
0
 public void SetActive_gcodeRender(bool value)
 {
     GcodeDrawLineManager.GetInstance().SetActive_types(value);
     GcodeDrawLineManager.GetInstance().SetActive_topLayer(value);
 }
Esempio n. 10
0
 //must call this method in LateUpdate every frame
 public void DrawLayers()
 {
     GcodeDrawLineManager.GetInstance().Draw();
 }