Пример #1
0
        /// <summary>
        /// Creo la pelota en el centro de la cancha
        /// </summary>
        /// <param name="pathRecursos"> De donde saco la textura</param>
        /// <returns> Una pelota</returns>
        private Pelota CrearPelota(string pathRecursos, Cancha cancha)
        {
            //int radio = 10; Original
            int radio = 6;
            //Crear esfera
            TgcSphere sphere = new TgcSphere();
            //TODO cambiar por matrices
            sphere.AutoTransformEnable = true;
            //sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall));
            sphere.Radius = radio;
            sphere.Position = new Vector3(cancha.Position.X, cancha.Position.Y + radio, cancha.Position.Z);
            sphere.updateValues();

            Pelota pelota = new Pelota(sphere);
            pelota.ShadowEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshPlanarShadows.fx");
            pelota.LightEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshMultiplePointLight.fx");
            return pelota;
        }
Пример #2
0
        /// <summary>
        /// Creo un arco
        /// </summary>
        /// <param name="posicion">Donde va a estar ubicado el Arco</param>
        /// <param name="pathRecursos">De donde sacar el mesh</param>
        /// <returns> Un arco</returns>
        private Arco CrearArco(string pathRecursos, Cancha cancha, int direccion)
        {
            Vector3 posicion = new Vector3(direccion * (cancha.Position.X + cancha.Size.X / 2 - 100), cancha.Position.Y, cancha.Position.Z);

            List<Palo> palos = new List<Palo>();
            TgcMesh palo1 = new TgcSceneLoader().loadSceneFromFile(pathRecursos + Settings.Default.meshFileGoal).Meshes[0];
            //TODO cambiar por matrices
            palo1.AutoTransformEnable = true;
            palo1.Position = posicion;
            palo1.Scale = new Vector3(0.8f, 0.8f, 0.8f);

            TgcMesh palo2 = new TgcSceneLoader().loadSceneFromFile(pathRecursos + Settings.Default.meshFileGoal).Meshes[1];
            //TODO cambiar por matrices
            palo2.AutoTransformEnable = true;
            palo2.Position = posicion;
            palo2.Scale = new Vector3(0.8f, 0.8f, 0.8f);

            TgcMesh palo3 = new TgcSceneLoader().loadSceneFromFile(pathRecursos + Settings.Default.meshFileGoal).Meshes[2];
            //TODO cambiar por matrices
            palo3.AutoTransformEnable = true;
            palo3.Position = posicion;
            palo3.Scale = new Vector3(0.8f, 0.8f, 0.8f);

            palos.Add(new Palo(palo1));
            palos.Add(new Palo(palo2));
            palos.Add(new Palo(palo3));

            Vector3 posicionRed = new Vector3(posicion.X, posicion.Y + palo3.BoundingBox.PMin.Y / 2, posicion.Z);
            Vector3 tamanoRed = new Vector3(0, palo3.BoundingBox.PMin.Y, palo3.BoundingBox.PMax.Z * 2 - 14);

            TgcMesh red = new TgcSceneLoader().loadSceneFromFile(pathRecursos + "Arco\\Red-TgcScene.xml").Meshes[0];
            //TODO cambiar por matrices
            red.AutoTransformEnable = true;
            red.Position = posicionRed + new Vector3(direccion * 65, 0, 0);
            //TODO esto significa que los arcos no son correctos... porque no escalo igual
            red.Scale = new Vector3(3f, 3f, 2f);
            red.AlphaBlendEnable = true;

            //Roto uno de los 2 ya que uso el mismo mesh
            if (direccion == -1)
            {
                red.rotateY(FastMath.PI);
            }

            return new Arco(palos, new Red(TgcBox.fromSize(posicionRed, tamanoRed), red));
        }