Beispiel #1
0
        public void CrearTetera()
        {
            Device d3dDevice = D3DDevice.Instance.Device;

            //Cargar mesh
            this.meshTetera = new TgcSceneLoader().loadSceneFromFile(MediaDir + "ModelosTgc\\Teapot\\Teapot-TgcScene.xml").Meshes[0];
            this.meshTetera.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            this.meshTetera.Position = new Vector3(30, 10, 0);

            // Arreglo las normales
            int[] adj = new int[this.meshTetera.D3dMesh.NumberFaces * 3];
            this.meshTetera.D3dMesh.GenerateAdjacency(0, adj);
            this.meshTetera.D3dMesh.ComputeNormals(adj);

            // inicializo el mapa de normales
            g_pNormals = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth,
                d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            this.effect.SetValue("g_Normals", g_pNormals);

            // Resolucion de pantalla
            this.effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            this.effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            this.meshTetera.Effect = this.effect;
        }
Beispiel #2
0
 public Wheel(TgcMesh mesh, TGCVector3 traslado, TGCVector3 escalado)
 {
     this.mesh          = mesh;
     mesh.AutoTransform = false;
     trasladoInicial    = TGCMatrix.Translation(traslado);
     vectorLimiteIzquierdo.TransformCoordinate(TGCMatrix.RotationY(-FastMath.QUARTER_PI));
     vectorLimiteDerecho.TransformCoordinate(TGCMatrix.RotationY(FastMath.QUARTER_PI));
     scalation = TGCMatrix.Scaling(escalado);
 }
 public static TgcMesh Get()
 {
     if (Shark == null || Shark.D3dMesh == null)
     {
         Shark = new TgcSceneLoader()
                 .loadSceneFromFile(Game.Default.MediaDirectory + "shark-TgcScene.xml").Meshes[0];
     }
     return(Shark);
 }
Beispiel #4
0
        /// <summary>
        /// Obtener la lista de vertices originales del mesh
        /// </summary>
        private List <EditPolyVertex> getMeshOriginalVertexData(TgcMesh origMesh)
        {
            List <EditPolyVertex> origVertices = new List <EditPolyVertex>();

            switch (origMesh.RenderType)
            {
            case TgcMesh.MeshRenderType.VERTEX_COLOR:
                TgcSceneLoader.VertexColorVertex[] verts1 = (TgcSceneLoader.VertexColorVertex[])origMesh.D3dMesh.LockVertexBuffer(
                    typeof(TgcSceneLoader.VertexColorVertex), LockFlags.ReadOnly, origMesh.D3dMesh.NumberVertices);
                for (int i = 0; i < verts1.Length; i++)
                {
                    EditPolyVertex v = new EditPolyVertex();
                    v.position = verts1[i].Position;

                    /*v.normal = verts1[i].Normal;
                     * v.color = verts1[i].Color;*/
                    origVertices.Add(v);
                }
                origMesh.D3dMesh.UnlockVertexBuffer();
                break;

            case TgcMesh.MeshRenderType.DIFFUSE_MAP:
                TgcSceneLoader.DiffuseMapVertex[] verts2 = (TgcSceneLoader.DiffuseMapVertex[])origMesh.D3dMesh.LockVertexBuffer(
                    typeof(TgcSceneLoader.DiffuseMapVertex), LockFlags.ReadOnly, origMesh.D3dMesh.NumberVertices);
                for (int i = 0; i < verts2.Length; i++)
                {
                    EditPolyVertex v = new EditPolyVertex();
                    v.position = verts2[i].Position;

                    /*v.normal = verts2[i].Normal;
                     * v.texCoords = new Vector2(verts2[i].Tu, verts2[i].Tv);
                     * v.color = verts2[i].Color;*/
                    origVertices.Add(v);
                }
                origMesh.D3dMesh.UnlockVertexBuffer();
                break;

            case TgcMesh.MeshRenderType.DIFFUSE_MAP_AND_LIGHTMAP:
                TgcSceneLoader.DiffuseMapAndLightmapVertex[] verts3 = (TgcSceneLoader.DiffuseMapAndLightmapVertex[])origMesh.D3dMesh.LockVertexBuffer(
                    typeof(TgcSceneLoader.DiffuseMapAndLightmapVertex), LockFlags.ReadOnly, origMesh.D3dMesh.NumberVertices);
                for (int i = 0; i < verts3.Length; i++)
                {
                    EditPolyVertex v = new EditPolyVertex();
                    v.position = verts3[i].Position;

                    /*v.normal = verts3[i].Normal;
                     * v.texCoords = new Vector2(verts3[i].Tu0, verts3[i].Tv0);
                     * v.color = verts3[i].Color;
                     * v.texCoords2 = new Vector2(verts3[i].Tu1, verts3[i].Tv1);*/
                    origVertices.Add(v);
                }
                origMesh.D3dMesh.UnlockVertexBuffer();
                break;
            }

            return(origVertices);
        }
Beispiel #5
0
 public void CrearBuggy()
 {
     //Cargar modelo estatico
     this.meshBuggy = new TgcSceneLoader().loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Buggy\\Buggy-TgcScene.xml").Meshes[0];
     this.meshBuggy.Scale = new Vector3(0.5f, 0.5f, 0.5f);
     this.meshBuggy.Position = new Vector3(-30, 10, 0);
     this.meshBuggy.Effect = this.effect;
     this.meshBuggy.Technique = "PS3";
 }
Beispiel #6
0
 public void CrearBuggy()
 {
     //Cargar modelo estatico
     this.meshBuggy           = new TgcSceneLoader().loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Buggy\\Buggy-TgcScene.xml").Meshes[0];
     this.meshBuggy.Scale     = new Vector3(0.5f, 0.5f, 0.5f);
     this.meshBuggy.Position  = new Vector3(-30, 10, 0);
     this.meshBuggy.Effect    = this.effect;
     this.meshBuggy.Technique = "PS3";
 }
Beispiel #7
0
        public ObjetoEscena(GameModel env)
        {
            this.env = env;
            loader   = new TgcSceneLoader();

            meshPath = getMeshPath();
            mesh     = loader.loadSceneFromFile(meshPath).Meshes[0];
            mesh.BoundingBox.scaleTranslate(mesh.Position, new Vector3(0.3f, 0.3f, 0.3f));
        }
Beispiel #8
0
 public void Aplicar(TgcMesh mesh)
 {
     mesh.Effect = efectoShader;
     if (tecnica == null)
     {
         tecnica = TgcShaders.Instance.getTgcMeshTechnique(mesh.RenderType);
     }
     mesh.Technique = tecnica;
 }
Beispiel #9
0
 /// <summary>
 ///     Crear un SkyBox vacio
 /// </summary>
 public TgcSkyBox()
 {
     Faces        = new TgcMesh[6];
     FaceTextures = new string[6];
     SkyEpsilon   = 25f;
     color        = Color.White;
     Center       = new Vector3(0, 0, 0);
     Size         = new Vector3(1000, 1000, 1000);
 }
Beispiel #10
0
 public Elemento(float peso, float resistencia, TgcMesh mesh) : this(mesh, resistencia)
 {
     Peso = peso;
     ElementosComposicion   = new List <Elemento>();
     Flexibilidad           = 0;
     vibracion              = 0;
     momentoUltimaVibracion = 0;
     ColorBase              = Color.White;
 }
Beispiel #11
0
        public void addCandles()
        {
            candleMesh = GetMeshFromScene("Vela-TgcScene.xml");
            //candleMesh.Effect = shader;
            //candleMesh.Technique = "DIFFUSE_MAP";
            for (int i = 0; i < g.cameraSprites.candlesInMap; i++)
            {
                int j, k;
                do
                {
                    j = Random.Next(1, Chunks.chunksPerDim - 1);
                    k = Random.Next(1, Chunks.chunksPerDim - 1);

                    var pos = genPosInChunk(j, k);
                    pos.Y += 200f;

                    if (checkColission(pos, 700f))
                    {
                        continue;
                    }

                    var candleMeshc = new Meshc();
                    //un poco excesivo que sea un meshc, lo eficiente seria que vela sea un tipo propio con una colision
                    //por radio. Pero hacer eso hace agregar un nuevo tipo de meshc, lo que podria hacer el codigo mas lento
                    //si sigo el camino de no usar polimorfismo. Igual ni ganas de agregar otro tipo. Que sea un meshc tiene
                    //los beneficios de que se va a poder deformar, y estas colisiones van a evitar que las velas se superpongan
                    //aunque agregar codigo para que se haga eso tampoco es una locura

                    candleMeshc.mesh         = candleMesh;
                    candleMeshc.originalMesh = TGCMatrix.Scaling(new TGCVector3(10, 15, 10)) * TGCMatrix.Translation(pos);

                    var box  = candleMeshc.mesh.BoundingBox;
                    var size = box.calculateSize();
                    var posb = box.calculateBoxCenter();

                    size.X *= 2.5f;
                    size.Y *= 10f;
                    size.Z *= 2.5f; //estaria bueno que tgc tenga multiplicacion miembro a miembro

                    candleMeshc.paralleliped = Parallelepiped.fromSizePosition(
                        size,
                        posb
                        );

                    //no uso  transformColission porque hace caer 4 vertices, lo que tiene potencial de registrar la
                    //vela en mas de un chunk
                    candleMeshc.paralleliped.transform(candleMeshc.originalMesh);
                    Chunk c = g.chunks.fromCoordinates(candleMeshc.paralleliped.transformedVertex[0]);
                    if (c != null)
                    {
                        c.meshes.Add(candleMeshc);
                    }

                    break;
                } while (true);
            }
        }
        public TgcMesh CrearRueda(float escala)
        {
            //TgcMesh rueda = Loader.loadSceneFromFile(MediaDir + "ModelosX\\rueda.x").Meshes[0];
            TgcMesh rueda = Loader.loadSceneFromFile(MediaDir + "Rueda\\Rueda-TgcScene.xml").Meshes[0];

            rueda.Scale = new Vector3(escala, escala, escala);
            //rueda.AutoTransformEnable = false;
            return(rueda);
        }
Beispiel #13
0
 public Fish(TgcMesh model, RigidBody rigidBody) : base(model, rigidBody)
 {
     EscapeMov = new EscapeFromPosition(new TGCVector3(1f, 0f, 0f), 0.1f, 30f);
     RandomMov = new RandomMovement(new TGCVector3(1f, 0f, 0f), 0.3f, 10f);
     //Mesh.Technique = "RenderScene";
     //Mesh.Effect = movement;
     Mesh.Effect    = FishEffect;
     Mesh.Technique = "Fish";
 }
Beispiel #14
0
 public void cargarDecorativo(TgcMesh unDecorativo, TgcScene unaEscena, TGCVector3 posicion, TGCVector3 escala, float rotacion)
 {
     unDecorativo          = unaEscena.Meshes[0];
     unDecorativo.Position = posicion;
     unDecorativo.Scale    = escala;
     unDecorativo.RotateY(rotacion);
     decorativos.Add(unDecorativo);
     aabbDeDecorativos.Add(unDecorativo.BoundingBox);
 }
Beispiel #15
0
        public bool estaCerca(TgcMesh item)
        {
            Vector3 posicionPersonaje = this.Posicion;
            Vector3 posicionObjeto    = item.Position;

            float distanciaCuadrada = Vector3.LengthSq(posicionObjeto - posicionPersonaje);

            return(distanciaCuadrada < 2500 * 20000);
        }
Beispiel #16
0
 /// <summary>
 ///     Crear un SkyBox vacio
 /// </summary>
 public TgcSkyBox()
 {
     Faces        = new TgcMesh[6];
     FaceTextures = new string[6];
     SkyEpsilon   = 25f;
     Color        = Color.White;
     Center       = TGCVector3.Empty;
     Size         = new TGCVector3(1000, 1000, 1000);
 }
Beispiel #17
0
 public Canoa(TgcMesh mesh, string rutaImagen, string MediaDir)
 {
     this.mesh        = mesh;
     this.rutaImagen  = rutaImagen;
     this.descripcion = "Canoa";
     piezaAsociada    = new Pieza(3, "Pieza 3", MediaDir + "\\2D\\windows\\windows_3.png", null);
     pistaAsociada    = new Pista(null, MediaDir + "\\2D\\pista_canoa.png", null);
     mapa             = new Mapa(null, MediaDir + "\\2D\\MapaHud.png");
 }
Beispiel #18
0
 public Arma(float potenciaGolpe, float alcance, Matrix translacion, TgcMesh mesh, Efecto efecto, Color colorBase)
 {
     this.potenciaGolpe = potenciaGolpe;
     this.alcance       = alcance;
     this.translacion   = translacion;
     this.mesh          = mesh;
     SetEfecto(efecto);
     this.colorBase = colorBase;
 }
Beispiel #19
0
        //private bool first = true;

        /// <summary>
        ///     Ejecuta el shader original de formato propio de Quake 3 convertido a una version similar de HLSL en DirectX.
        ///     Estado experimental. Desabilitado por el momento.
        /// </summary>
        private void renderShaderMesh(TgcMesh mesh, QShaderData shader)
        {
            // if ((shader.Stages[0].HasBlendFunc) ^ (pass == 1))
            // {
            //tiene es opaco se tiene que renderizar en la primer pasada
            //tiene alpha blending se tiene que renderizar en la segunda pasada
            //    return;
            //}

            var fx = shader.Fx;

            fx.Technique = "tec0";
            fx.SetValue("g_mWorld", TGCMatrix.Identity);
            fx.SetValue("g_mViewProj", mViewProj);
            fx.SetValue("g_time", time);

            TgcTexture originalTexture = null;

            if (mesh.DiffuseMaps != null)
            {
                originalTexture = mesh.DiffuseMaps[0];
            }

            fx.Begin(FX.None);

            for (var j = 0; j < shader.Stages.Count; j++)
            {
                fx.BeginPass(j);
                if (shader.Stages[j].Textures.Count > 0)
                {
                    mesh.DiffuseMaps[0] = shader.Stages[j].Textures[0];
                }

                //mesh.render();
                D3DDevice.Instance.Device.SetTexture(0, mesh.DiffuseMaps[0].D3dTexture);
                if (mesh.LightMap != null)
                {
                    D3DDevice.Instance.Device.SetTexture(1, mesh.LightMap.D3dTexture);
                }
                else
                {
                    D3DDevice.Instance.Device.SetTexture(1, null);
                }

                mesh.D3dMesh.DrawSubset(0);

                fx.EndPass();
            }

            fx.End();

            if (mesh.DiffuseMaps != null)
            {
                mesh.DiffuseMaps[0] = originalTexture;
            }
        }
Beispiel #20
0
        public void Init(string MediaDir)
        {
            #region Configuracion Basica de World

            //Creamos el mundo fisico por defecto.
            collisionConfiguration = new DefaultCollisionConfiguration();
            dispatcher             = new CollisionDispatcher(collisionConfiguration);
            GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher);
            constraintSolver      = new SequentialImpulseConstraintSolver();
            overlappingPairCache  = new DbvtBroadphase(); //AxisSweep3(new BsVector3(-5000f, -5000f, -5000f), new BsVector3(5000f, 5000f, 5000f), 8192);
            dynamicsWorld         = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collisionConfiguration);
            dynamicsWorld.Gravity = new TGCVector3(0, -100f, 0).ToBulletVector3();

            #endregion Configuracion Basica de World

            foreach (var mesh in meshes)
            {
                var buildingbody = BulletRigidBodyFactory.Instance.CreateRigidBodyFromTgcMesh(mesh);
                dynamicsWorld.AddRigidBody(buildingbody);
            }

            //Se crea un plano ya que esta escena tiene problemas
            //con la definición de triangulos para el suelo
            var floorShape = new StaticPlaneShape(TGCVector3.Up.ToBulletVector3(), 10);
            floorShape.LocalScaling = new TGCVector3().ToBulletVector3();
            var floorMotionState = new DefaultMotionState();
            var floorInfo        = new RigidBodyConstructionInfo(0, floorMotionState, floorShape);
            floorBody                 = new RigidBody(floorInfo);
            floorBody.Friction        = 1;
            floorBody.RollingFriction = 1;
            floorBody.Restitution     = 1f;
            floorBody.UserObject      = "floorBody";
            dynamicsWorld.AddRigidBody(floorBody);

            var loader = new TgcSceneLoader();
            ///Se crea una caja para que haga las veces del Hummer dentro del modelo físico
            TgcTexture texture  = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box4.jpg");
            TGCBox     boxMesh1 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);
            boxMesh1.Position = new TGCVector3(0, 10, 0);
            hummer            = boxMesh1.ToMesh("box");
            boxMesh1.Dispose();

            //Se crea el cuerpo rígido de la caja, en la definicio de CreateBox el ultimo parametro representa si se quiere o no
            //calcular el momento de inercia del cuerpo. No calcularlo lo que va a hacer es que la caja que representa el Hummer
            //no rote cuando colicione contra el mundo.
            hummerBody             = BulletRigidBodyFactory.Instance.CreateBox(new TGCVector3(55, 20, 80), 10, hummer.Position, 0, 0, 0, 0.55f, false);
            hummerBody.Restitution = 0;
            hummerBody.Gravity     = new TGCVector3(0, -100, 0).ToBulletVector3();
            dynamicsWorld.AddRigidBody(hummerBody);

            //Se carga el modelo del Hummer
            hummer = loader.loadSceneFromFile(MediaDir + @"MeshCreator\\Meshes\\Vehiculos\\Hummer\\Hummer-TgcScene.xml").Meshes[0];

            leftright  = new TGCVector3(1, 0, 0);
            fowardback = new TGCVector3(0, 0, 1);
        }
 public Entity(TgcMesh mesh, TGCVector3 defaultLookDir)
 {
     if (!necesitaArmaParaInteractuar)
     {
         agarrarEfecto = new TgcStaticSound();
         agarrarEfecto.loadSound(SoundsManager.Instance().mediaDir + "Sounds\\grab.wav", SoundsManager.Instance().sound);
     }
     this.mesh           = mesh;
     this.defaultLookDir = defaultLookDir;
 }
Beispiel #22
0
        public override TgcMesh createMeshToExport()
        {
            mesh.Name           = this.Name;
            mesh.Layer          = this.Layer;
            mesh.UserProperties = this.UserProperties;

            TgcMesh cloneMesh = mesh.clone(mesh.Name);

            return(cloneMesh);
        }
Beispiel #23
0
 public Animal(float peso, float resistencia, TgcMesh mesh, Efecto efecto)
     : base(peso, resistencia, mesh, efecto)
 {
     tiempoEnActividad = 7;
     tiempoInactivo    = 3;
     tiempo            = 0;
     velocidadCaminar  = 30f;
     velocidadRotar    = 10F;
     movimientoActual  = "Caminar";
 }
Beispiel #24
0
        protected void cargarMesh()
        {
            //Cargar modelo estatico Box
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(
                GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml",
                GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Box\\");

            bala = scene.Meshes[0];
        }
Beispiel #25
0
        public Vida(TgcMesh vidaModel, TGCVector3 newPosition)
        {
            tgcBotHead          = vidaModel.clone("vida");
            tgcBotHead.Position = newPosition;
            tgcBotHead.Scale    = new TGCVector3(0.15f, 0.15f, 0.15f);
            tgcBotHead.UpdateMeshTransform();

            liveQuantity = 0;
            LiveTaked    = false;
        }
Beispiel #26
0
        public Recarga(String alumnoMediaFolder, Vector3 posicion)
        {
            cargador = new TgcSceneLoader();
            TgcScene nueva = cargador.loadSceneFromFile(alumnoMediaFolder + "GODMODE\\Media\\battery-TgcScene.xml",
                                                        alumnoMediaFolder + "GODMODE\\Media\\");

            mesh          = nueva.Meshes[0];
            mesh.Scale    = new Vector3(0.07f, 0.07f, 0.07f);
            mesh.Position = posicion;
        }
Beispiel #27
0
 private void AgarrarLibros(TgcMesh mesh)
 {
     if (mesh.Name == "Box_1" && !librosAgarrados.Contains(mesh))
     {
         librosAgarrados.Add(mesh);
         cantidadLibrosAdquiridos++;
         mesh.BoundingBox = new Core.BoundingVolumes.TgcBoundingAxisAlignBox();
         mesh.Dispose();
     }
 }
Beispiel #28
0
        /// <summary>
        ///     Convierte el box en un TgcMesh
        /// </summary>
        /// <param name="meshName">Nombre de la malla que se va a crear</param>
        public TgcMesh ToMesh(string meshName)
        {
            //Obtener matriz para transformar vertices
            if (AutoTransformEnable)
            {
                Transform = TGCMatrix.RotationYawPitchRoll(rotation.Y, rotation.X, rotation.Z) * TGCMatrix.Translation(translation);
            }

            return(TgcMesh.FromTGCBox(meshName, this.Texture, this.vertices, this.Transform, this.AlphaBlendEnable));
        }
Beispiel #29
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcBox box = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            boxMesh = box.toMesh("box");
            box.dispose();
            time = 0;
        }
        public void ExecuteCollision(TgcMesh item, TgcMesh bandicoot, Core.Camara.TgcCamera camara, Core.Mathematica.TGCVector3 movimiento)
        {
            var anguloCamara = bandicoot.Position;

            bandicoot.Move(-movimiento);
            bandicoot.Transform = TGC.Core.Mathematica.TGCMatrix.Translation(-movimiento);

            //Bandicoot.Move(0, direccionSalto * MOVEMENT_SPEED * ElapsedTime, 0);
            camara.SetCamera((camara.Position - movimiento), anguloCamara);
        }
        public override void Init()
        {
            //Objetos en movimiento.
            colliderCylinder = new TgcBoundingCylinder(new Vector3(0, 0, 0), 2, 4);
            colliderCylinder.setRenderColor(Color.LimeGreen);
            colliderCylinderFixedY = new TgcBoundingCylinderFixedY(new Vector3(0, 0, 0), 2, 4);
            colliderCylinderFixedY.setRenderColor(Color.LimeGreen);
            //Cargar personaje con animaciones
            var skeletalLoader = new TgcSkeletalLoader();

            personaje =
                skeletalLoader.loadMeshAndAnimationsFromFile(
                    MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml",
                    MediaDir + "SkeletalAnimations\\Robot\\",
                    new[]
            {
                MediaDir + "SkeletalAnimations\\Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml"
            });
            //Configurar animacion inicial
            personaje.playAnimation("Parado", true);
            //Escalarlo porque es muy grande
            personaje.Scale = new Vector3(0.04f, 0.04f, 0.04f);

            //El personaje esta en el 0,0,0 hay que bajarlo
            var size = personaje.BoundingBox.PMax.Y - personaje.BoundingBox.PMin.Y;

            personaje.Position = new Vector3(0, -3f, 0);
            //Rotarlo 180° porque esta mirando para el otro lado
            personaje.rotateY(FastMath.PI);

            //Objetos estaticos, pueden ser mesh o objetos simplificados.
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Patrullero\\Patrullero-TgcScene.xml");

            collisionableMeshAABB          = scene.Meshes[0];
            collisionableMeshAABB.Scale    = new Vector3(0.1f, 0.1f, 0.1f);
            collisionableMeshAABB.Position = new Vector3(6, 0, -2);
            collisionableCylinder          = new TgcBoundingCylinderFixedY(new Vector3(-6, 0, 0), 2, 2);
            collisionableSphere            = new TgcBoundingSphere(new Vector3(-3, 0, 10), 3);

            Modifiers.addBoolean("fixedY", "use fixed Y", true);
            //Modifier para ver BoundingBox del personaje
            Modifiers.addBoolean("showBoundingBox", "Personaje Bouding Box", false);
            Modifiers.addVertex2f("size", new Vector2(1, 1), new Vector2(5, 10), new Vector2(2, 5));
            var angle = FastMath.TWO_PI;

            Modifiers.addVertex3f("rotation", new Vector3(-angle, -angle, -angle), new Vector3(angle, angle, angle),
                                  new Vector3(FastMath.TWO_PI / 8, 0, FastMath.TWO_PI / 8));


            //Configurar camara en Tercer Persona
            camaraInterna = new TgcThirdPersonCamera(personaje.Position, 25, -45);
            Camara        = camaraInterna;
        }
        /// <summary>
        ///     Se llama una sola vez, al principio cuando se ejecuta el ejemplo.
        ///     Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo
        ///     procesamiento que podemos pre calcular para nuestro juego.
        ///     Borrar el codigo ejemplo no utilizado.
        /// </summary>
        public override void Init()
        {
            //Device de DirectX para crear primitivas.
            d3dDevice = D3DDevice.Instance.Device;

            //Instancio el loader del framework
            loader = new TgcSceneLoader();

            //creo usuario
            Player1           = new Player();
            Player1.gameModel = this;

            //inicializo mesh para hacha
            Axe = loader.loadSceneFromFile(MediaDir + "Meshes\\Hacha\\Hacha-TgcScene.xml").Meshes[0];

            //Inicializo cámara
            MyCamera = new TgcFpsCamera(Player1, Axe, Input, (MapLength / 2), -(MapLength / 2), (MapLength / 2), -(MapLength / 2));
            Camara   = MyCamera;

            Frustum.updateVolume(D3DDevice.Instance.Device.Transform.View, D3DDevice.Instance.Device.Transform.Projection);

            //genero el mundo
            MyWorld = new World(MediaDir, d3dDevice, loader, Camara, Frustum, MapLength, true);
            MyWorld.RenderDistance = RenderDistance;
            //inicializo efectos
            effectsManager = new EffectsManager(ShadersDir, this, MyWorld, ElapsedTime);

            effectsManager.applyEffect(Axe);

            //emisor de partículas
            emitter                    = new ParticleEmitter(MediaDir + "Textures\\smokeParticle.png", 10);
            emitter.Position           = new Vector3(0, 0, 0);
            emitter.MinSizeParticle    = 2f;
            emitter.MaxSizeParticle    = 5f;
            emitter.ParticleTimeToLive = 1f;
            emitter.CreationFrecuency  = 1f;
            emitter.Dispersion         = 25;
            emitter.Speed              = new Vector3(5f, 5f, 5f);

            //colisiones
            pickingRay = new TgcPickingRay(Input);
            //sonidos
            soundPlayer = new SoundPlayer(DirectSound, MediaDir);
            soundPlayer.startAmbient();
            //gui
            MenuInterface = new GUI(MediaDir, D3DDevice.Instance, Player1, this);

            TopRightText       = GameUtils.createText("", 0, 0, 20, true);
            TopRightText.Color = Color.LightGray;
            TopRightText.Align = TgcText2D.TextAlign.RIGHT;

            CenterText       = GameUtils.createText("", 0, (D3DDevice.Instance.Height * 0.85f), 25, true);
            CenterText.Color = Color.DodgerBlue;
            CenterText.Align = TgcText2D.TextAlign.CENTER;
        }
        public override void Init()
        {
            //Cargar jugador y pelota
            this.pelota = this.CrearPelota(MediaDir);
            this.jugador = this.CrearJugador(MediaDir);

            //Camara en 1ra persona
            //GuiController.Instance.FpsCamera.Enable = true;
            //GuiController.Instance.FpsCamera.MovementSpeed = 400f;
            //GuiController.Instance.FpsCamera.JumpSpeed = 300f;
            //GuiController.Instance.FpsCamera.setCamera(new Vector3(0, 150, 200), new Vector3(0, 80, 0));

            //Cargar Shader personalizado de MultiDiffuseLights
            /*
             * Cargar Shader personalizado de MultiDiffuseLights
             * Este Shader solo soporta TgcMesh con RenderType DIFFUSE_MAP (que son las unicas utilizadas en este ejemplo)
             * El shader toma 4 luces a la vez para iluminar un mesh.
             * Pero como hacer 4 veces los calculos en el shader es costoso, de cada luz solo calcula el componente Diffuse.
             */
            this.meshMultiDiffuseLights = TgcShaders.loadEffect(ShadersDir + "Shaders\\MeshMultiplePointLight.fx");

            this.skeletalMeshPointLight = TgcShaders.loadEffect(ShadersDir + "Shaders\\SkeletalMeshMultiplePointLight.fx");

            this.luces = new List<Luz>();
            //Crear 4 mesh para representar las 4 para la luces. Las ubicamos en distintas posiciones del escenario, cada una con un color distinto.
            luces.Add(new Luz(TgcBox.fromSize(new Vector3(40, 150, 100), new Vector3(10, 10, 10), Color.BlueViolet), Color.HotPink, new Vector3(-40, 40, 400)));
            luces.Add(new Luz(TgcBox.fromSize(new Vector3(-40, 150, 100), new Vector3(10, 10, 10), Color.LightSteelBlue), Color.Blue, new Vector3(-40, 60, 400)));
            luces.Add(new Luz(TgcBox.fromSize(new Vector3(40, 150, -100), new Vector3(10, 10, 10), Color.Green), Color.Green, new Vector3(-40, 80, 400)));
            luces.Add(new Luz(TgcBox.fromSize(new Vector3(-40, 150, -100), new Vector3(10, 10, 10), Color.Orange), Color.Orange, new Vector3(-40, 100, 400)));

            this.piso = TgcBox.fromSize(new Vector3(0, 0, 0), new Vector3(400, 0, 400), TgcTexture.createTexture(MediaDir + Settings.Default.textureMenuField));

            //Modifiers
            //GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 150, 38);
            //GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.15f);

            //Color de fondo
            //GuiController.Instance.BackgroundColor = Color.Black;

            //test carteles
            this.cartel1 = new TgcSceneLoader().loadSceneFromFile(MediaDir + "Cartel\\Cartel-TgcScene.xml").Meshes[0];

            this.cartelEffect = TgcShaders.loadEffect(ShadersDir + "Shaders\\CartelShader.fx");
        }
Beispiel #34
0
 public Palo(TgcMesh mesh)
 {
     this.mesh = mesh;
 }
Beispiel #35
0
 public Red(TgcBox box, TgcMesh red)
 {
     this.box = box;
     this.red = red;
 }
Beispiel #36
0
 private void CrearTanque()
 {
     this.mesh = new TgcSceneLoader().loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml").Meshes[0];
     this.mesh.Position = new Vector3(10, 20, -10);
     this.mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);
     this.mesh.Effect = this.effect;
     this.mesh.Technique = "VS3";
 }
Beispiel #37
0
        /// <summary>
        ///     Se llama una sola vez, al principio cuando se ejecuta el ejemplo.
        ///     Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo
        ///     procesamiento que podemos pre calcular para nuestro juego.
        ///     Borrar el codigo ejemplo no utilizado.
        /// </summary>
        public override void Init()
        {
            //Device de DirectX para crear primitivas.
            var d3dDevice = D3DDevice.Instance.Device;

            //Textura de la carperta Media. Game.Default es un archivo de configuracion (Game.settings) util para poner cosas.
            //Pueden abrir el Game.settings que se ubica dentro de nuestro proyecto para configurar.
            var pathTexturaCaja = MediaDir + Game.Default.TexturaCaja;

            //Cargamos una textura, tener en cuenta que cargar una textura significa crear una copia en memoria.
            //Es importante cargar texturas en Init, si se hace en el render loop podemos tener grandes problemas si instanciamos muchas.
            var texture = TgcTexture.createTexture(pathTexturaCaja);

            //Creamos una caja 3D ubicada de dimensiones (5, 10, 5) y la textura como color.
            var size = new Vector3(5, 10, 5);
            //Construimos una caja según los parámetros, por defecto la misma se crea con centro en el origen y se recomienda así para facilitar las transformaciones.
            Box = TgcBox.fromSize(size, texture);
            //Posición donde quiero que este la caja, es común que se utilicen estructuras internas para las transformaciones.
            //Entonces actualizamos la posición lógica, luego podemos utilizar esto en render para posicionar donde corresponda con transformaciones.
            Box.Position = new Vector3(-25, 0, 0);

            //Cargo el unico mesh que tiene la escena.
            Mesh = new TgcSceneLoader().loadSceneFromFile(MediaDir + "LogoTGC-TgcScene.xml").Meshes[0];
            //Defino una escala en el modelo logico del mesh que es muy grande.
            Mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);

            //Suelen utilizarse objetos que manejan el comportamiento de la camara.
            //Lo que en realidad necesitamos gráficamente es una matriz de View.
            //El framework maneja una cámara estática, pero debe ser inicializada.
            //Posición de la camara.
            var cameraPosition = new Vector3(0, 0, 125);
            //Quiero que la camara mire hacia el origen (0,0,0).
            var lookAt = Vector3.Empty;
            //Configuro donde esta la posicion de la camara y hacia donde mira.
            Camara.SetCamera(cameraPosition, lookAt);
            //Internamente el framework construye la matriz de view con estos dos vectores.
            //Luego en nuestro juego tendremos que crear una cámara que cambie la matriz de view con variables como movimientos o animaciones de escenas.
        }