Example #1
0
        private Pontos[] GerarPoligono()
        {
            int j, tl = 0;
            No  face;

            Pontos[] p;
            Pontos[] pol = new Pontos[qtdePontos];

            for (int i = 0; i < lFace.Count; i++)
            {
                face = ((No)(lFace[i]));
                p    = new Pontos[face.getCount()];

                j = 0;
                while (face != null)
                {
                    p[j] = (Pontos)lVertAtual[face.getPos()];
                    j++;
                    face = face.getProx();
                }
                p[j] = p[0];

                if (cbBackFaceCulling.Checked)
                {
                    if (((Vetor)lVetorNormal[i]).getZ() > 0)
                    {
                        for (int k = 0; k < j; k++)
                        {
                            pol[tl++] = p[k];
                        }
                    }
                }
                else
                {
                    for (int k = 0; k < j; k++)
                    {
                        pol[tl++] = p[k];
                    }
                }
            }
            return(pol);
        }
Example #2
0
        private double[] MultiplicarPontos(double[][] mat, Pontos p)
        {
            int i, j;

            double[] vet   = { p.getX(), p.getY(), p.getZ(), 1 };
            double[] resul = new double[4];

            for (i = 0; i < 4; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    resul[i] += vet[j] * mat[j][i];
                }
            }

            for (i = 0; i < 4; i++)
            {
                resul[i] = Math.Round(resul[i]);
            }
            return(resul);
        }
Example #3
0
 public Vetor(Pontos ab, Pontos ac)
 {
     this.x = (ab.getY() * ac.getZ()) - (ac.getY() * ab.getZ());
     this.y = (ab.getZ() * ac.getX()) - (ac.getZ() * ab.getX());
     this.z = (ab.getX() * ac.getY()) - (ab.getY() * ac.getX());
 }
Example #4
0
        private void ProjecaoObliqua(double[][] mat)
        {
            int j;

            double[] p1, p2;
            No       face;

            Pontos[] p;

            ret = imgBmp;

            Reta.IniciarMatriz();
            for (int i = 0; i < lFace.Count; i++)
            {
                face = ((No)(lFace[i]));
                p    = new Pontos[face.getCount()];

                j = 0;
                while (face != null)
                {
                    p[j] = (Pontos)lVertAtual[face.getPos()];
                    j++;
                    face = face.getProx();
                }
                p[j] = p[0];

                Pontos vertAB = new Pontos(p[1].getX() - p[0].getX(), p[1].getY() - p[0].getY(), p[1].getZ() - p[0].getZ());
                Pontos vertAC = new Pontos(p[2].getX() - p[0].getX(), p[2].getY() - p[0].getY(), p[2].getZ() - p[0].getZ());

                if (lVetorNormal.Count <= i)
                {
                    lVetorNormal.Add(new Vetor(vertAB, vertAC));
                }
                else
                {
                    lVetorNormal[i] = new Vetor(vertAB, vertAC);
                }

                if (cbBackFaceCulling.Checked)
                {
                    if (((Vetor)lVetorNormal[i]).getZ() > 0)
                    {
                        for (int k = 0; k < j; k++)
                        {
                            p1 = MultiplicarPontos(mat, p[k]);
                            p2 = MultiplicarPontos(mat, p[k + 1]);

                            Reta.Bresenham((int)p1[0], (int)p1[1], (int)p2[0], (int)p2[1]);
                        }
                    }
                }
                else
                {
                    for (int k = 0; k < j; k++)
                    {
                        p1 = MultiplicarPontos(mat, p[k]);
                        p2 = MultiplicarPontos(mat, p[k + 1]);

                        Reta.Bresenham((int)p1[0], (int)p1[1], (int)p2[0], (int)p2[1]);
                    }
                }
            }

            Reta.AlocarBitmap(ret);
            Reta.Desenhar();
            if (btnColorir.Text.Equals("Colorir"))
            {
                // ScanLine.Scanline(Reta.getImgDta());
            }
            Reta.DesalocarBitmap(ret);

            pictureBox.Image = ret;
            imgBmp           = ret;
        }
Example #5
0
        private void OrtograficaLateral()
        {
            int j;
            No  face;

            Pontos[] p;

            ret = imgBmp;

            Reta.IniciarMatriz();

            for (int i = 0; i < lFace.Count; i++)
            {
                face = ((No)(lFace[i]));
                p    = new Pontos[face.getCount()];

                j = 0;
                while (face != null)
                {
                    p[j] = (Pontos)lVertAtual[face.getPos()];
                    j++;
                    face = face.getProx();
                }
                p[j] = p[0];

                Pontos vertAB = new Pontos(p[1].getX() - p[0].getX(), p[1].getY() - p[0].getY(), p[1].getZ() - p[0].getZ());
                Pontos vertAC = new Pontos(p[2].getX() - p[0].getX(), p[2].getY() - p[0].getY(), p[2].getZ() - p[0].getZ());

                if (lVetorNormal.Count <= i)
                {
                    lVetorNormal.Add(new Vetor(vertAB, vertAC));
                }
                else
                {
                    lVetorNormal[i] = new Vetor(vertAB, vertAC);
                }

                if (cbBackFaceCulling.Checked)
                {
                    if (((Vetor)lVetorNormal[i]).getX() > 0)
                    {
                        for (int k = 0; k < j; k++)
                        {
                            Reta.Bresenham(p[k].getY() + 100, p[k].getZ() + 425, p[k + 1].getY() + 100, p[k + 1].getZ() + 425);//pintanto
                        }
                    }
                }
                else
                {
                    for (int k = 0; k < j; k++)
                    {
                        Reta.Bresenham(p[k].getY() + 100, p[k].getZ() + 425, p[k + 1].getY() + 100, p[k + 1].getZ() + 425);//pintanto
                    }
                }
            }

            Reta.AlocarBitmap(ret);
            Reta.Desenhar();
            if (btnColorir.Text.Equals("Colorir"))
            {
                //ScanLine.Scanline(Reta.getImgDta());
            }
            Reta.DesalocarBitmap(ret);

            pictureBox.Image = ret;
            imgBmp           = ret;
        }