Beispiel #1
0
        /// <summary>
        /// overrides the <see cref="Entity.OnForegroundDraw(OpenGlDevice)"/> method.
        /// </summary>
        /// <param name="Device"></param>
        public override void OnForegroundDraw(OpenGlDevice Device)
        {
            Matrix P = Device.ProjectionMatrix;

            Device.ProjectionMatrix = ForegroundMatrix();
            float pw = Device.PenWidth;

            Device.PenWidth = PenWidth;
            Color C = Device.Emission;

            Device.Emission = Color;

            Device.drawLine(new xyz(A.x, A.Y, Device.ViewPort.Width / 2),
                            new xyz(A.x, B.Y, Device.ViewPort.Width / 2));
            Device.drawLine(new xyz(A.x, B.Y, Device.ViewPort.Width / 2),
                            new xyz(B.x, B.Y, Device.ViewPort.Width / 2));
            Device.drawLine(new xyz(B.x, B.Y, Device.ViewPort.Width / 2),
                            new xyz(B.x, A.Y, Device.ViewPort.Width / 2));

            Device.drawLine(new xyz(B.x, A.Y, Device.ViewPort.Width / 2),
                            new xyz(A.x, A.Y, Device.ViewPort.Width / 2));
            Device.PenWidth = pw;
            Device.Emission = C;

            Device.ProjectionMatrix = P;
        }
Beispiel #2
0
        /// <summary>
        /// overrides the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/>method.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            Device.PushMatrix();
            Device.MulMatrix(_Transformation);
            if (Device.RenderKind != RenderKind.SnapBuffer)
            {
                Material SaveE = Device.Material;
                Device.Material = ShaftMaterial;

                Arc K = new Arc(new xy(0, 0), Radius);
                K.ClockWise = false;
                Device.drawCurve(K);
                Device.drawCylinder(Radius, Size - TopHeight);
                Device.PushMatrix();

                Device.MulMatrix(Matrix.Translation(0, 0, Size - TopHeight));
                Device.Material = TopMaterial;
                Device.drawConePointed(TopRadius, TopHeight);
                K           = new Arc(new xy(0, 0), TopRadius);
                K.ClockWise = false;
                Device.drawCurve(K);
                Device.PopMatrix();
                Device.Material = SaveE;
            }
            else
            {
                Device.PushTag(0);
                Device.drawLine(new xyz(0, 0, 0), new xyz(0, 0, Size));
                Device.PopTag();
                Device.PushTag(1);
                Device.drawPoint(new xyz(0, 0, 0), 0.3);
                Device.PopTag();
                Device.PushTag(2);
                Device.drawPoint(new xyz(0, 0, Size), 0.3);
                Device.PopTag();
            }
            Device.PopMatrix();
            base.OnDraw(Device);
        }
Beispiel #3
0
        /// <summary>
        /// overriders the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/> method.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            if (Device.RenderKind != RenderKind.Render)
            {
                return;
            }
            Device.PushMatrix();
            Device.ModelMatrix = Matrix.identity;
            _Base = new Base(true);


            if (Device.SnappItems.Count > 0)
            {
                if ((Device.SnappItems[0].Crossed) && (CrossStyle != Cross.None))
                {
                    Base Base = new Base(true);
                    Base.BaseO = Device.SnappItems[0].Point;

                    Color C = Device.Ambient;
                    Device.Ambient = ColoroFtheCrossSymbol;
                    double r = Device.PixelToWorld(Device.SnappItems[0].Point, CrossSize);
                    if (CrossStyle == Cross.Sphere)
                    {
                        Device.drawSphere(Device.SnappItems[0].Point, r / 2f);
                    }
                    if (CrossStyle == Cross.Cube)
                    {
                        Base B = Device.SnappItems[0].GetBase();

                        Matrix M = B.ToMatrix();
                        Device.PushMatrix();
                        Device.ModelMatrix = M;
                        Device.drawBox(new xyz(-r / 2, -r / 2, -r / 2), new xyz(r, r, r));
                        Device.PopMatrix();
                    }
                    if ((_Base.BaseO.X == 2) && (_Base.BaseO.y == 2) && (_Base.BaseO.Z == 2))
                    {
                    }
                    Device.Ambient = C;
                    return;
                }

                else
                {
                    _Base.BaseO = Device.SnappItems[0].Point;
                    if (_Base.BaseO.dist(Device.Currentxyz) > 0.1)
                    {
                    }
                    if (!AxisFix)
                    {
                        {
                            _Base = Device.SnappItems[0].GetBase();
                        }
                    }
                }
            }
            else
            {
                _Base       = Base.UnitBase;
                _Base.BaseO = Device.Currentxyz;
            }

            float PenW = Device.PenWidth;

            Device.PenWidth = PenWidth;
            Color SaveEmission = Device.Emission;
            bool  Save         = Device.LightEnabled;

            Device.LightEnabled = true;

            Device.Emission = xAxisColor;
            Device.drawLine(Base.BaseO - Base.BaseX * Device.PixelToWorld(Base.BaseO, Size), Base.BaseO + Base.BaseX * Device.PixelToWorld(Base.BaseO, Size));
            double d = Device.PixelToWorld(Base.BaseO, Size);

            Device.Emission = yAxisColor;
            Device.drawLine(Base.BaseO - Base.BaseY * Device.PixelToWorld(Base.BaseO, Size), Base.BaseO + Base.BaseY * Device.PixelToWorld(Base.BaseO, Size));
            Device.Emission = zAxisColor;
            Device.drawLine(Base.BaseO - Base.BaseZ * Device.PixelToWorld(Base.BaseO, Size), Base.BaseO + Base.BaseZ * Device.PixelToWorld(Base.BaseO, Size));
            Device.LightEnabled = Save;
            Device.Emission     = SaveEmission;
            Device.PenWidth     = PenW;
            Device.PopMatrix();

            BaseZ = Base.BaseZ;

            base.OnDraw(Device);
        }
Beispiel #4
0
        /// <summary>
        /// overrides the draw nethod and paints the axis.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            if (FullSize)
            {
                xy WE = Device.WorldExtensions;
                if (WE.dist(Size.toXY()) > 0.2)
                {
                    SetInvalid(true);
                }
                Size = new xyz(WE.x, WE.y, WE.x);
            }
            if (Font == null)
            {
                Font = new Drawing3d.Font(FontName);
            }
            SaveFontSize  = Font.FontSize;
            Font.FontSize = TextHeight;
            base.OnDraw(Device);
            Device.PushMatrix();
            Device.MulMatrix(AxesBase.ToMatrix());
            bool SaveLighting = Device.LightEnabled;

            Device.LightEnabled = false;
            Color Save = Device.Emission;

            Device.Emission = Color;

            if (LeftAndRight)
            {
                Device.drawLine(new xyz(-Size.x, 0, 0), new xyz(Size.x, 0, 0));
                Device.drawLine(new xyz(0, -Size.y, 0), new xyz(0, Size.y, 0));
                if (Dim3d)
                {
                    Device.drawLine(new xyz(0, 0, -Size.z), new xyz(0, 0, Size.z));
                }
            }

            {
                Device.drawLine(new xyz(0, 0, 0), new xyz(Size.x, 0, 0));
                Device.drawLine(new xyz(0, 0, 0), new xyz(0, Size.y, 0));
                if (Dim3d)
                {
                    Device.drawLine(new xyz(0, 0, 0), new xyz(0, 0, Size.z));
                }
            }

            xyz n1   = new xyz(0, DeviderLineLength, 0);
            int from = (int)(-Size.x / Devider.x);

            if (!LeftAndRight)
            {
                from = 0;
            }

            if (Device.RenderKind == RenderKind.Render)
            {
                for (int i = from; i <= Size.x / Devider.x; i++)
                {
                    if (ShowDevider)
                    {
                        Device.drawLine(new xyz(Devider.x * i, 0, 0) - n1, new xyz(Devider.x * i, 0, 0) + n1);
                    }
                    if (ShowText)
                    {
                        double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).x / 2f);

                        Device.drawText(Font, Matrix.Translation(new xyz(Pos, DeviderLineLength, 0)), i.ToString(), 0);
                    }
                }


                from = (int)(-Size.y / Devider.y);
                if (!LeftAndRight)
                {
                    from = 0;
                }
                n1 = new xyz(DeviderLineLength, 0, 0);
                for (int i = from; i <= Size.y / Devider.y; i++)
                {
                    if (i != 0)
                    {
                        if (ShowDevider)
                        {
                            Device.drawLine(new xyz(0, Devider.y * i, 0) - n1, new xyz(0, Devider.y * i, 0) + n1);
                        }
                        if (ShowText)
                        {
                            double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                            Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, Pos, 0)), i.ToString(), 0);
                        }
                    }
                }
                if (Dim3d)
                {
                    for (int i = from; i <= Size.z / Devider.z; i++)
                    {
                        if (i != 0)
                        {
                            if (ShowDevider)
                            {
                                Device.drawLine(new xyz(0, 0, Devider.z * i) - n1, new xyz(0, 0, Devider.z * i) + n1);
                            }
                            if (ShowText)
                            {
                                double Pos = Devider.z * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                                Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, 0, Pos)), i.ToString(), 0);
                            }
                        }
                    }
                }
            }
            if (Device.RenderKind == RenderKind.SnapBuffer)
            {
                if (LeftAndRight)
                {
                    Device.drawLine(new xyz(-Size.x, 0, 0), new xyz(Size.x, 0, 0));
                    Device.drawLine(new xyz(0, -Size.y, 0), new xyz(0, Size.y, 0));
                    if (Dim3d)
                    {
                        Device.drawLine(new xyz(0, 0, -Size.z), new xyz(0, 0, Size.z));
                    }
                }
                else
                if (LeftAndRight)
                {
                    Device.drawLine(new xyz(0, 0, 0), new xyz(Size.x, 0, 0));
                    Device.drawLine(new xyz(0, 0, 0), new xyz(0, Size.y, 0));
                    if (Dim3d)
                    {
                        Device.drawLine(new xyz(0, 0, 0), new xyz(0, 0, Size.z));
                    }
                }
                for (int i = from; i <= Size.x / Devider.x; i++)
                {
                    Device.drawPoint(new xyz(Devider.x * i, 0, 0), Devider.x / 4);
                    if (ShowText)
                    {
                        double        Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).x / 2f);
                        MeshContainer M   = MeshCreator.MeshListCurrent;
                        Device.drawText(Font, Matrix.Translation(new xyz(Pos, DeviderLineLength, 0)), i.ToString(), 0);
                        M = MeshCreator.MeshListCurrent;
                    }
                }


                from = (int)(-Size.y / Devider.y);
                if (!LeftAndRight)
                {
                    from = 0;
                }
                n1 = new xyz(DeviderLineLength, 0, 0);
                for (int i = from; i <= Size.y / Devider.y; i++)
                {
                    if (i != 0)
                    {
                        Device.drawPoint(new xyz(0, Devider.y * i, 0), Devider.x / 4);
                        if (ShowText)
                        {
                            double Pos = Devider.x * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                            Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, Pos, 0)), i.ToString(), 0);
                        }
                    }
                }
                if (Dim3d)
                {
                    for (int i = from; i <= Size.z / Devider.z; i++)
                    {
                        if (i != 0)
                        {
                            Device.drawPoint(new xyz(0, 0, Devider.z * i), Devider.x / 4);

                            if (ShowText)
                            {
                                double Pos = Devider.z * i - ((float)Device.getEnvText(Font, i.ToString()).y / 2f);

                                Device.drawText(Font, Matrix.Translation(new xyz(DeviderLineLength, 0, Pos)), i.ToString(), 0);
                            }
                        }
                    }
                }
            }

            Device.Emission     = Save;
            Device.LightEnabled = SaveLighting;
            Font.FontSize       = SaveFontSize;
            Device.PopMatrix();
        }