コード例 #1
0
        // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
        // Constructores
        // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

        /// <summary>
        /// Crea un nuevo objeto de tipo MatrizRotación
        /// </summary>
        /// <param name="tipo">Tipo de rotación (X, Y, Z)</param>
        /// <param name="beta">Ángulo de rotación en radianes</param>
        public MatrizRotación(Ejes tipo, double beta) : base(4)
        {
            if (tipo == Ejes.X)
            {
                this[1, 1] = Math.Cos(beta);
                this[1, 2] = -Math.Sin(beta);
                this[2, 1] = Math.Sin(beta);
                this[2, 2] = Math.Cos(beta);
            }
            else if (tipo == Ejes.Y)
            {
                this[0, 0] = Math.Cos(beta);
                this[0, 2] = Math.Sin(beta);
                this[2, 0] = -Math.Sin(beta);
                this[2, 2] = Math.Cos(beta);
            }
            else if (tipo == Ejes.Z)
            {
                this[0, 0] = Math.Cos(beta);
                this[0, 1] = -Math.Sin(beta);
                this[1, 0] = Math.Sin(beta);
                this[1, 1] = Math.Cos(beta);
            }
            else
            {
                throw new ArgumentException();
            }
        }
コード例 #2
0
        private void glControl3_Load(object sender, EventArgs e)
        {
            logContextInfo(); //Mostramos info de contexto.
            SetupShaders();   //Creamos los shaders y el programa de shader
            matrices      = new List <Matrix4>();
            primeraVez    = 1;
            myCube        = new Cube(0.1f); //Construimos los objetos que voy a dibujar.
            ejes_globales = new Ejes(10.0f);
            ejes_locales  = new Ejes(0.2f);
            mundo         = new escena(sProgram);

            mundo.iniciarEscena();

            myCube.Build(sProgram); //Construyo los buffers OpenGL que voy a usar.
            ejes_globales.Build(sProgram);
            ejes_locales.Build(sProgram);

            myCamera = new SphericalCamera();                            //Creo una camara.

            gl.ClearColor(Color.Black);                                  //Configuro el Color de borrado.
            gl.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); //De cada poligono solo dibujo las lineas de contorno (wireframe).
        }
コード例 #3
0
        private Entity ProcesarSeleccion(uint[] bufferSeleccion, int hits)
        {
            int offsetBuffer = 0;

            List <Component> componentesSeleccionados = new List <Component>();

            Component minComponent = null;
            uint      minZ         = uint.MaxValue;

            for (int i = 0; i < hits; i++)
            {
                uint names = bufferSeleccion[offsetBuffer++];

                uint zMin = bufferSeleccion[offsetBuffer++];
                uint zMax = bufferSeleccion[offsetBuffer++];

                for (uint n = 0; n < names; n++)
                {
                    int name = (int)bufferSeleccion[offsetBuffer++];

                    if (name == -1 || name == -2 || name == -3)
                    {
                        //Es uno de los helpers

                        switch (name)
                        {
                        case -1:     //X
                            ejeMoviendoObjeto = Ejes.EJE_X;
                            break;

                        case -2:     //Y
                            ejeMoviendoObjeto = Ejes.EJE_Y;
                            break;

                        case -3:     //Z
                            ejeMoviendoObjeto = Ejes.EJE_Z;
                            break;
                        }

                        moviendoObjeto          = true;
                        posCursorMoviendoObjeto = MousePosition;

                        return(selectedEntity);
                    }
                    else
                    {
                        foreach (Component comp in Component.AllComponents)
                        {
                            if (comp.Id == name)
                            {
                                componentesSeleccionados.Add(comp);

                                if (minComponent == null || zMin < minZ)
                                {
                                    minZ         = zMin;
                                    minComponent = comp;
                                }

                                break;
                            }
                        }
                    }
                }
            }

            if (componentesSeleccionados.Count > 0)
            {
                return(minComponent.Entity);
            }
            else
            {
                return(null);
            }
        }