Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            DrawValue(e);

            // Draw axes
            vb = ViewingPipeline(x_axis.vb);
            x_axis.Draw(e.Graphics, vb);

            vb = ViewingPipeline(y_axis.vb);
            y_axis.Draw(e.Graphics, vb);

            vb = ViewingPipeline(z_axis.vb);
            z_axis.Draw(e.Graphics, vb);

            // Add all features to mTotal matrix
            Matrix mS = Matrix.ScaleMatrix(scale);
            Matrix mX = Matrix.RotateMatrixAxisX(rotateX);
            Matrix mY = Matrix.RotateMatrixAxisY(rotateY);
            Matrix mZ = Matrix.RotateMatrixAxisZ(rotateZ);
            Matrix mT = Matrix.TranslateMatrix(vector);

            Matrix mTotal = mT * mX * mY * mZ * mS;

            // Draw cube
            vb = ViewingPipeline(GetNewVectors(mTotal, cube));
            cube.Draw(e.Graphics, vb);
        }
Ejemplo n.º 2
0
 private void DrawAxes(PaintEventArgs e)
 {
     // Draw axes
     x_axis.Draw(e.Graphics, ViewingPipeline(x_axis.vb).ToList());
     y_axis.Draw(e.Graphics, ViewingPipeline(y_axis.vb).ToList());
     z_axis.Draw(e.Graphics, ViewingPipeline(z_axis.vb).ToList());
 }
Ejemplo n.º 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            List <Vector> vb;

            base.OnPaint(e);

            // Draw axes
            vb = ViewingPipeline(x_axis.vb, d, r, theta, phi);
            x_axis.Draw(e.Graphics, vb);
            vb = ViewingPipeline(y_axis.vb, d, r, theta, phi);
            y_axis.Draw(e.Graphics, vb);
            vb = ViewingPipeline(z_axis.vb, d, r, theta, phi);
            z_axis.Draw(e.Graphics, vb);

            // Draw cube
            S = Matrix.ScaleMatrix(scale);
            R = Matrix.RotateXMatrix(degreesX) * Matrix.RotateYMatrix(degreesY) * Matrix.RotateZMatrix(degreesZ);
            T = Matrix.TranslateMatrix(new Vector(xValue, yValue, zValue));
            Matrix total = S * R * T;

            vb.Clear();

            foreach (Vector v in cube.vertexbuffer)
            {
                vb.Add(total * v);
            }

            vb = ViewingPipeline(vb, d, r, theta, phi);
            cube.Draw(e.Graphics, vb);

            // Show info
            ShowInfo(e.Graphics);
        }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Draw axes
            x_axis.Draw(e.Graphics,
                        ViewportTransformation(
                            ProjectionTransformation(d,
                                                     ViewTransformation(r, phi, theta, x_axis.vb))));
            y_axis.Draw(e.Graphics,
                        ViewportTransformation(
                            ProjectionTransformation(d,
                                                     ViewTransformation(r, phi, theta, y_axis.vb))));
            z_axis.Draw(e.Graphics,
                        ViewportTransformation(
                            ProjectionTransformation(d,
                                                     ViewTransformation(r, phi, theta, z_axis.vb))));

            // Redefine matrices
            scaleMatrix       = Matrix.ScaleMatrix(scale);
            rotationMatrix    = Matrix.RotateMatrixX(xRotation) * Matrix.RotateMatrixY(yRotation) * Matrix.RotateMatrixZ(zRotation);
            translationMatrix = Matrix.TranslateMatrix(new Vector(xTranslation, yTranslation, zTranslation));

            // Combine the matrices
            transformationMatrix = scaleMatrix * rotationMatrix * translationMatrix;

            switch (modelType)
            {
            case 2:
                // Draw piramid
                piramid.Draw(e.Graphics,
                             ViewportTransformation(
                                 ProjectionTransformation(d,
                                                          ViewTransformation(r, phi, theta,
                                                                             Transformation(transformationMatrix, piramid.vertexbuffer)))));
                break;

            case 1:
            default:
                // Draw cube
                cube.Draw(e.Graphics,
                          ViewportTransformation(
                              ProjectionTransformation(d,
                                                       ViewTransformation(r, phi, theta,
                                                                          Transformation(transformationMatrix, cube.vertexbuffer)))));
                break;
            }

            ShowInfo(e.Graphics);
        }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            List <Vector> vb;

            base.OnPaint(e);

            vb = new List <Vector>();
            vb = ViewingPipeline(x_axis.vb);
            x_axis.Draw(e.Graphics, vb);

            vb = new List <Vector>();
            vb = ViewingPipeline(y_axis.vb);
            y_axis.Draw(e.Graphics, vb);

            vb = new List <Vector>();
            vb = ViewingPipeline(z_axis.vb);
            z_axis.Draw(e.Graphics, vb);

            Matrix S = Matrix.Scale(s);
            Matrix T = Matrix.Translate(new Vector(tx, ty, tz));
            Matrix R = Matrix.RotateX(rx) * Matrix.RotateY(ry) * Matrix.RotateZ(rz);

            Matrix Total = T * R * S;

            vb = new List <Vector>();
            List <Vector> result = new List <Vector>();

            foreach (Vector v in cube.vertexbuffer)
            {
                Vector vd = Total * v;
                vb.Add(vd);
            }

            result = ViewingPipeline(vb);
            cube.Draw(e.Graphics, result);
        }