Exemplo n.º 1
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            Color4 colorObject = buttonColor.BackColor;

            geometricInfo = new GeometricInfo(new Vector3(float.Parse(textBoxShiftX.Text), float.Parse(textBoxShiftY.Text), float.Parse(textBoxShiftZ.Text)),
                                              new Vector4(colorObject.R, colorObject.G, colorObject.B, trackBarAlpha.Value / 10f),
                                              float.Parse(textBoxSide.Text, System.Globalization.NumberStyles.Float),
                                              int.Parse(textBoxColBreakX.Text), int.Parse(textBoxColBreakY.Text),
                                              int.Parse(textBoxCoeffSX.Text), int.Parse(textBoxCoeffSY.Text),
                                              (int)numericUpDownAngelX.Value, (int)numericUpDownAngelY.Value, (int)numericUpDownAngelZ.Value,
                                              _typeObjectCreate);

            if (_typeObjectCreate == TypeObjectCreate.SolidCube)
            {
                figureVertex = ObjectCreate.CreateSolidCube(geometricInfo);
            }
            if (_typeObjectCreate == TypeObjectCreate.Plane)
            {
                figureVertex = ObjectCreate.CreatePlane(geometricInfo);
            }
            if (_typeObjectCreate == TypeObjectCreate.Sphere)
            {
                figureVertex = ObjectCreate.CreateSphere(geometricInfo);
            }
            colorObject.A = trackBarAlpha.Value / 10f;
            Close();
        }
Exemplo n.º 2
0
        //Задел на будущее
        ObjectCreate()
        {
            Vector3 startPosition = Vector3.Zero;
            Vector4 colorObj      = new Vector4(0, 0, 0, 1);

            geometricInfo = new GeometricInfo(startPosition, colorObj);
            vertices      = CreateSolidCube(geometricInfo.side);
        }
Exemplo n.º 3
0
        public RenderObject(Vertex[] vertices, Vector3 startPosition, Color4 color, Color4 locСolorСhoice, TypeObjectRenderLight typeObject = TypeObjectRenderLight.SimpleObject, bool plane = false, float locSide = 1, TypeObjectCreate locTypeObjectCreate = TypeObjectCreate.SolidCube, int locColBreakX = 1, int locColBreakY = 1, int locCoeffSX = 1, int locCoeffSY = 1, int locAngleX = 0, int locAngleY = 0, int locAngleZ = 0)
        {
            geometricInfo         = new GeometricInfo(startPosition, new Vector4(color.R, color.G, color.B, color.A), locSide, locColBreakX, locColBreakY, locCoeffSX, locCoeffSY, locAngleX, locAngleY, locAngleZ, locTypeObjectCreate);
            trajctoryRenderObject = new TrajctoryRenderObject();
            _VerticeCount         = vertices.Length;
            _VertexArray          = GL.GenVertexArray();
            TypeObject            = typeObject;
            GL.GenBuffers(1, out _Buffer);
            //PolygonMode.Line
            GL.BindVertexArray(_VertexArray);
            GL.BindBuffer(BufferTarget.ArrayBuffer, _Buffer);
            GL.NamedBufferStorage(_Buffer, Vertex.Size * _VerticeCount,          // the size needed by this buffer
                                  vertices,                                      // data to initialize with
                                  BufferStorageFlags.MapWriteBit);               // at this point we will only write to the buffer
                                                                                 // create vertex array and buffer here

            GL.VertexArrayAttribBinding(_VertexArray, 1, 0);
            GL.EnableVertexArrayAttrib(_VertexArray, 1);
            GL.VertexArrayAttribFormat(
                _VertexArray,
                1,                                                               // attribute index, from the shader location = 0
                4,                                                               // size of attribute, vec4
                VertexAttribType.Float,                                          // contains floats
                false,                                                           // does not need to be normalized as it is already, floats ignore this flag anyway
                0);                                                              // relative offset, first item

            GL.VertexArrayAttribBinding(_VertexArray, 2, 0);
            GL.EnableVertexArrayAttrib(_VertexArray, 2);
            GL.VertexArrayAttribFormat(
                _VertexArray,
                2,                                                               // attribute index, from the shader location = 1
                4,                                                               // size of attribute, vec4
                VertexAttribType.Float,                                          // contains floats
                false,                                                           // does not need to be normalized as it is already, floats ignore this flag anyway
                16);                                                             // relative offset after a vec4
            GL.VertexArrayAttribBinding(_VertexArray, 3, 0);
            GL.EnableVertexArrayAttrib(_VertexArray, 3);
            GL.VertexArrayAttribFormat(
                _VertexArray,
                3,                                                               // attribute index, from the shader location = 2
                4,                                                               // size of attribute, vec4
                VertexAttribType.Float,                                          // contains floats
                false,                                                           // does not need to be normalized as it is already, floats ignore this flag anyway
                32);                                                             // relative offset after a vec4 + vec4

            _Initialized = true;
            GL.VertexArrayVertexBuffer(_VertexArray, 0, _Buffer, IntPtr.Zero, Vertex.Size);
            ColorСhoice.X = locСolorСhoice.R;
            ColorСhoice.Y = locСolorСhoice.G;
            ColorСhoice.Z = locСolorСhoice.B;
            ColorСhoice.W = locСolorСhoice.A;
            if (plane)
            {
                bufferProjectionShadow(vertices);
            }
        }
Exemplo n.º 4
0
 public GeometricInfo(GeometricInfo geometricInfo)
 {
     side              = geometricInfo.side;
     StartPosition     = geometricInfo.StartPosition;
     colBreakX         = geometricInfo.colBreakX;
     colBreakY         = geometricInfo.colBreakY;
     coeffSX           = geometricInfo.coeffSX;
     coeffSY           = geometricInfo.coeffSX;
     StartAngleX       = geometricInfo.StartAngleX;
     StartAngleY       = geometricInfo.StartAngleY;
     StartAngleZ       = geometricInfo.StartAngleZ;
     typeObjectCreate  = geometricInfo.typeObjectCreate;
     ColorObj          = geometricInfo.ColorObj;
     TranslationMatrix = geometricInfo.TranslationMatrix;
     RotationMatrix    = geometricInfo.RotationMatrix;
 }
Exemplo n.º 5
0
 ObjectCreate(GeometricInfo locGeometricInfo)
 {
     geometricInfo = locGeometricInfo;
     if (locGeometricInfo.typeObjectCreate == TypeObjectCreate.SolidCube)
     {
         vertices = CreateSolidCube(locGeometricInfo);
     }
     if (locGeometricInfo.typeObjectCreate == TypeObjectCreate.Sphere)
     {
         vertices = CreateSphere(locGeometricInfo);
     }
     if (locGeometricInfo.typeObjectCreate == TypeObjectCreate.Plane)
     {
         vertices = CreatePlane(locGeometricInfo);
     }
 }
Exemplo n.º 6
0
        public DlgAddEditAnFigure(GeometricInfo geometricInfo, bool NewFigure = true)
        {
            Text = "Изменение аналитической фигуры";
            InitializeComponent();
            InitComboBox();
            _typeObjectCreate = geometricInfo.typeObjectCreate;
            comboBoxTypeFigure.SelectedItem = ((List <ComboboxDataSourceTypeFigure>)comboBoxTypeFigure.DataSource).Where(x => x.TypeFigure == _typeObjectCreate).FirstOrDefault();
            comboBoxTypeFigure.Enabled      = !NewFigure;
            trackBarAlpha.Value             = (int)(geometricInfo.ColorObj.W * 10); //Округляем как можем
            textBoxSide.Text = geometricInfo.side.ToString();
            Vector3 translation = geometricInfo.TranslationMatrix.ExtractTranslation();

            textBoxShiftX.Text    = translation.X.ToString();
            textBoxShiftY.Text    = translation.Y.ToString();
            textBoxShiftZ.Text    = translation.Z.ToString();
            textBoxColBreakX.Text = geometricInfo.colBreakX.ToString();
            textBoxColBreakY.Text = geometricInfo.colBreakY.ToString();
            textBoxCoeffSX.Text   = geometricInfo.coeffSX.ToString();
            textBoxCoeffSY.Text   = geometricInfo.coeffSY.ToString();
            var anlgeQauternion = geometricInfo.RotationMatrix.ExtractRotation();
            var tau             = Math.Acos(anlgeQauternion.W);
            var ax = 0;
            var ay = 0;
            var az = 0;

            if (Math.Abs(tau) > 0)
            {
                ax = Convert.ToInt32(Math.Round(anlgeQauternion.X / Math.Sin(tau) * tau / MathHelper.PiOver2 * 180, MidpointRounding.AwayFromZero));
                ay = Convert.ToInt32(Math.Round(anlgeQauternion.Y / Math.Sin(tau) * tau / MathHelper.PiOver2 * 180, MidpointRounding.AwayFromZero));
                az = Convert.ToInt32(Math.Round(anlgeQauternion.Z / Math.Sin(tau) * tau / MathHelper.PiOver2 * 180, MidpointRounding.AwayFromZero));
            }
            numericUpDownAngelX.Value = ax;
            numericUpDownAngelY.Value = ay;
            numericUpDownAngelZ.Value = az;
            if (_typeObjectCreate == TypeObjectCreate.SolidCube)
            {
                labelAngelX.Enabled         = false;
                labelAngelY.Enabled         = false;
                labelAngelZ.Enabled         = false;
                numericUpDownAngelX.Enabled = true;
                numericUpDownAngelY.Enabled = true;
                numericUpDownAngelZ.Enabled = true;
                labelColBreakX.Enabled      = false;
                labelColBreakY.Enabled      = false;
                labelCoeffSX.Enabled        = false;
                labelCoeffSY.Enabled        = false;
                textBoxColBreakX.Enabled    = false;
                textBoxColBreakY.Enabled    = false;
                textBoxCoeffSX.Enabled      = false;
                textBoxCoeffSY.Enabled      = false;
            }
            if (_typeObjectCreate == TypeObjectCreate.Plane)
            {
                labelAngelX.Enabled         = true;
                labelAngelY.Enabled         = true;
                labelAngelZ.Enabled         = true;
                numericUpDownAngelX.Enabled = true;
                numericUpDownAngelY.Enabled = true;
                numericUpDownAngelZ.Enabled = true;
                labelColBreakX.Enabled      = false;
                labelColBreakY.Enabled      = false;
                labelCoeffSX.Enabled        = false;
                labelCoeffSY.Enabled        = false;
                textBoxColBreakX.Enabled    = false;
                textBoxColBreakY.Enabled    = false;
                textBoxCoeffSX.Enabled      = false;
                textBoxCoeffSY.Enabled      = false;
            }
            if (_typeObjectCreate == TypeObjectCreate.Sphere)
            {
                labelAngelX.Enabled         = false;
                labelAngelY.Enabled         = false;
                labelAngelZ.Enabled         = false;
                numericUpDownAngelX.Enabled = true;
                numericUpDownAngelY.Enabled = true;
                numericUpDownAngelZ.Enabled = true;
                labelColBreakX.Enabled      = true;
                labelColBreakY.Enabled      = true;
                labelCoeffSX.Enabled        = true;
                labelCoeffSY.Enabled        = true;
                textBoxColBreakX.Enabled    = true;
                textBoxColBreakY.Enabled    = true;
                textBoxCoeffSX.Enabled      = true;
                textBoxCoeffSY.Enabled      = true;
            }
        }
Exemplo n.º 7
0
 public static Vertex[] CreateSphere(GeometricInfo geometricInfo)//размер куба, смещение y/-y, смещение x/-x, смещение z/-z цвет
 {
     return(CreateSphere(geometricInfo.side, geometricInfo.colBreakX, geometricInfo.colBreakY, geometricInfo.coeffSX, geometricInfo.coeffSY));
 }
Exemplo n.º 8
0
 public static Vertex[] CreatePlane(GeometricInfo geometricInfo)//размер куба, смещение y/-y, смещение x/-x, смещение z/-z цвет
 {
     return(CreatePlane(geometricInfo.side));
 }
Exemplo n.º 9
0
 ObjectCreate(GeometricInfo locGeometricInfo, Vertex[] locVertices)
 {
     geometricInfo = locGeometricInfo;
     vertices      = locVertices;
 }