Beispiel #1
0
        public override TgcMesh createMeshToExport()
        {
            TgcMesh m = mesh.toMesh(this.Name);

            m.UserProperties = this.UserProperties;
            m.Layer          = this.Layer;
            return(m);
        }
Beispiel #2
0
        public void init(string text)
        {
            TgcBox box = new TgcBox();

            box.setExtremes(new Vector3(0, 0, 0), new Vector3(400, 2, 1000));
            box.Color = Color.Blue;
            box.updateValues();
            TgcMesh temp = box.toMesh("water");

            TgcSceneLoader loader = new TgcSceneLoader();

            //Configurar MeshFactory customizado
            loader.MeshFactory = new ShadedMeshFactory();
            mesh             = (ShadedMesh)loader.MeshFactory.createNewMesh(temp.D3dMesh, "water", TgcMesh.MeshRenderType.VERTEX_COLOR);
            mesh.BoundingBox = box.BoundingBox;
            mesh.loadEffect("Shaders//water.fx", "Basic");
            mesh.AutoUpdateBoundingBox = false;

            TgcTexture t_temp = TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\waterbump.dds");//"perlin_noise.jpg");//"waterbump.dds");

            noise       = t_temp.D3dTexture;
            t_temp      = TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\" + text);
            riverBottom = t_temp.D3dTexture;

            mesh.Effect.SetValue("xNoiseTex", noise);
            mesh.Effect.SetValue("xRiverBottom", riverBottom);

            Surface renderTarget = GuiController.Instance.D3dDevice.GetRenderTarget(0);

            riverReflex = new Texture(GuiController.Instance.D3dDevice, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, renderTarget.Description.Format, Pool.Default);
        }
        /// <summary>
        /// Cargar una nueva malla
        /// </summary>
        private void changeMesh(string meshName)
        {
            if (selectedMesh == null || selectedMesh != meshName)
            {
                if (mesh != null)
                {
                    mesh.dispose();
                    mesh = null;
                }

                selectedMesh = meshName;

                //Cargar mesh y animaciones
                TgcSkeletalLoader loader = new TgcSkeletalLoader();
                mesh = loader.loadMeshAndAnimationsFromFile(mediaPath + selectedMesh + "-TgcSkeletalMesh.xml", mediaPath, animationsPath);

                //Crear esqueleto a modo Debug
                mesh.buildSkletonMesh();

                //Elegir animacion inicial
                mesh.playAnimation(selectedAnim, true);

                //Crear caja como modelo de Attachment del hueos "Bip01 L Hand"
                attachment = new TgcSkeletalBoneAttach();
                TgcBox attachmentBox = TgcBox.fromSize(new Vector3(2, 40, 2), Color.Red);
                attachment.Mesh   = attachmentBox.toMesh("attachment");
                attachment.Bone   = mesh.getBoneByName("Bip01 L Hand");
                attachment.Offset = Matrix.Translation(3, -15, 0);
                attachment.updateValues();


                //Configurar camara
                GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
            }
        }
Beispiel #4
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear suelo
            TgcTexture pisoTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\rock_floor1.jpg");

            suelo = TgcBox.fromSize(new Vector3(500, 0, 500), new Vector3(2000, 0, 2000), pisoTexture);


            //Cargar malla original
            TgcSkeletalLoader loader    = new TgcSkeletalLoader();
            string            pathMesh  = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";
            string            mediaPath = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);

            //Agregar animación a original
            loader.loadAnimationFromFile(original, mediaPath + "Patear-TgcSkeletalAnim.xml");

            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment = new TgcSkeletalBoneAttach();
            TgcBox attachmentBox             = TgcBox.fromSize(new Vector3(3, 60, 3), Color.Green);

            attachment.Mesh   = attachmentBox.toMesh("attachment");
            attachment.Bone   = original.getBoneByName("Bip01 L Hand");
            attachment.Offset = Matrix.Translation(10, -40, 0);
            attachment.updateValues();
            original.Attachments.Add(attachment);


            //Crear 9 instancias mas de este modelo, pero sin volver a cargar el modelo entero cada vez
            float offset         = 200;
            int   cantInstancias = 4;

            instances = new List <TgcSkeletalMesh>();
            for (int i = 0; i < cantInstancias; i++)
            {
                TgcSkeletalMesh instance = original.createMeshInstance(original.Name + i);

                instance.move(i * offset, 0, 0);
                instances.Add(instance);
            }


            //Especificar la animación actual para todos los modelos
            original.playAnimation("Patear");
            foreach (TgcSkeletalMesh instance in instances)
            {
                instance.playAnimation("Patear");
            }


            //Camara en primera persona
            GuiController.Instance.FpsCamera.Enable        = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400;
            GuiController.Instance.FpsCamera.JumpSpeed     = 400;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(293.201f, 291.0797f, -604.6647f), new Vector3(299.1028f, -63.9185f, 330.1836f));
        }
Beispiel #5
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;
        }
Beispiel #6
0
        // Constructor
        public ObstaculoRigido(float _x, float _z, float _y, float ancho, float alto, float largo, string textura)
        {
            TgcBox box = TgcBox.fromSize(
                new Vector3(_x, _z, _y),           //posicion
                new Vector3(ancho, alto, largo),   //tamaño
                TgcTexture.createTexture(textura));

            //Computar OBB a partir del AABB del mesh. Inicialmente genera el mismo volumen que el AABB, pero luego te permite rotarlo (cosa que el AABB no puede)
            this.obb  = TgcObb.computeFromAABB(box.BoundingBox);
            this.mesh = box.toMesh("caja");
        }
        /// <summary>
        /// Utilidad para crear cajones
        /// </summary>
        private GestureLocker crearCajon(Vector3 pos, Vector3 size)
        {
            TgcBox cajonMesh = TgcBox.fromSize(size, Color.Green);

            cajonMesh.Position = pos;

            GestureLocker locker = new GestureLocker();

            locker.HandleSphere = new TgcBoundingSphere(cajonMesh.Position + new Vector3(0, 0, cajonMesh.Size.Z / 2), 1f);
            locker.HandleMaxZ   = locker.HandleSphere.Center.Z + cajonMesh.Size.Z;
            locker.Mesh         = cajonMesh.toMesh("cajon");
            locker.init();

            cajonMesh.dispose();
            return(locker);
        }
Beispiel #8
0
        private void addWeapon()
        {
            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment = new TgcSkeletalBoneAttach();
            TgcBox attachmentBox             = TgcBox.fromSize(new Vector3(1, 10, 1), Color.Black);

            attachment.Mesh = attachmentBox.toMesh("attachment");
            attachment.Bone = original.getBoneByName("Bip01 L Hand");

            Matrix offsetMatrix = Matrix.RotationY(Geometry.DegreeToRadian(190));

            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.RotationZ(Geometry.DegreeToRadian(80)));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.Translation(10, 0, 0));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.RotationX(Geometry.DegreeToRadian(300)));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.Translation(-2.5f, -1.5f, 0));

            attachment.Offset = offsetMatrix;
            attachment.updateValues();
            original.Attachments.Add(attachment);
        }
Beispiel #9
0
        public void init(int x, int y, int z)
        {
            TgcBox box = new TgcBox();

            box.setExtremes(new Vector3(0, 0, 0), new Vector3(x, y, z));
            box.Color = Color.Brown;
            box.updateValues();
            TgcMesh temp = box.toMesh("earth");

            TgcSceneLoader loader = new TgcSceneLoader();

            //Configurar MeshFactory customizado
            loader.MeshFactory = new ShadedMeshFactory();
            mesh             = (ShadedMesh)loader.MeshFactory.createNewMesh(temp.D3dMesh, "earth", TgcMesh.MeshRenderType.VERTEX_COLOR);
            mesh.BoundingBox = box.BoundingBox;
            mesh.loadEffect("Shaders//hoja.fx", "Basic");

            TgcTexture tex_temp = TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\sand.jpg");

            earthTex = tex_temp.D3dTexture;
            mesh.Effect.SetValue("xLeafTex", earthTex);
            mesh.AutoUpdateBoundingBox = false;
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Paths para archivo XML de la malla
            string pathMesh = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";

            //Path para carpeta de texturas de la malla
            string mediaPath = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\";

            //Lista de animaciones disponibles
            string[] animationList = new string[] {
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar",
            };

            //Crear rutas con cada animacion
            string[] animationsPath = new string[animationList.Length];
            for (int i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcSkeletalAnim.xml";
            }

            //Cargar mesh y animaciones
            TgcSkeletalLoader loader = new TgcSkeletalLoader();

            mesh = loader.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);

            //Crear esqueleto a modo Debug
            mesh.buildSkletonMesh();

            //Agregar combo para elegir animacion
            GuiController.Instance.Modifiers.addInterval("animation", animationList, 0);
            selectedAnim = animationList[0];

            //Modifier para especificar si la animación se anima con loop
            bool animateWithLoop = true;

            GuiController.Instance.Modifiers.addBoolean("loop", "Loop anim:", animateWithLoop);

            //Modifier para renderizar el esqueleto
            bool renderSkeleton = false;

            GuiController.Instance.Modifiers.addBoolean("renderSkeleton", "Show skeleton:", renderSkeleton);

            //Modifier para FrameRate
            GuiController.Instance.Modifiers.addFloat("frameRate", 0, 100, 30);

            //Modifier para color
            currentColor = Color.White;
            GuiController.Instance.Modifiers.addColor("Color", currentColor);

            //Modifier para BoundingBox
            GuiController.Instance.Modifiers.addBoolean("BoundingBox", "BoundingBox:", false);

            //Elegir animacion Caminando
            mesh.playAnimation(selectedAnim, true);

            //Crear caja como modelo de Attachment del hueos "Bip01 L Hand"
            attachment = new TgcSkeletalBoneAttach();
            TgcBox attachmentBox = TgcBox.fromSize(new Vector3(5, 100, 5), Color.Blue);

            attachment.Mesh   = attachmentBox.toMesh("attachment");
            attachment.Bone   = mesh.getBoneByName("Bip01 L Hand");
            attachment.Offset = Matrix.Translation(10, -40, 0);
            attachment.updateValues();

            //Modifier para habilitar attachment
            showAttachment = false;
            GuiController.Instance.Modifiers.addBoolean("Attachment", "Attachment:", showAttachment);

            //Configurar camara
            GuiController.Instance.RotCamera.setCamera(new Vector3(0, 70, 0), 200);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;


            //Cargar textura de CubeMap para Environment Map
            cubeMap = TextureLoader.FromCubeFile(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Shaders\\CubeMap.dds");


            //Crear 3 paredes y un piso con textura comun y textura de normalMap
            TgcTexture diffuseMap = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping_DiffuseMap.jpg");
            TgcTexture normalMap  = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping_NormalMap.jpg");

            TgcTexture[] normalMapArray = new TgcTexture[] { normalMap };

            TgcBox paredSur   = TgcBox.fromExtremes(new Vector3(-200, 0, -210), new Vector3(200, 100, -200), diffuseMap);
            TgcBox paredOeste = TgcBox.fromExtremes(new Vector3(-210, 0, -200), new Vector3(-200, 100, 200), diffuseMap);
            TgcBox paredEste  = TgcBox.fromExtremes(new Vector3(200, 0, -200), new Vector3(210, 100, 200), diffuseMap);
            TgcBox piso       = TgcBox.fromExtremes(new Vector3(-200, -1, -200), new Vector3(200, 0, 200), diffuseMap);

            //Convertir TgcBox a TgcMesh
            TgcMesh m1 = paredSur.toMesh("paredSur");
            TgcMesh m2 = paredOeste.toMesh("paredOeste");
            TgcMesh m3 = paredEste.toMesh("paredEste");
            TgcMesh m4 = piso.toMesh("piso");

            //Convertir TgcMesh a TgcMeshBumpMapping (se usa solo por conveniencia, pero el NormalMap de TgcMeshBumpMapping es innecesario para este ejemplo)
            meshes = new List <TgcMeshBumpMapping>();
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m1, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m2, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m3, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m4, normalMapArray));


            //Borrar TgcMesh y TgcBox, ya no se usan
            paredSur.dispose();
            paredOeste.dispose();
            paredEste.dispose();
            piso.dispose();
            m1.dispose();
            m2.dispose();
            m3.dispose();
            m4.dispose();



            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(0, 50, 100), new Vector3(0, 50, -1));

            //Cargar Shader de DynamicLights
            effect           = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\EnvironmentMap.fx");
            effect.Technique = "SimpleEnvironmentMapTechnique";

            //Cargar shader en meshes
            foreach (TgcMeshBumpMapping m in meshes)
            {
                m.Effect    = effect;
                m.Technique = "SimpleEnvironmentMapTechnique";
            }

            //Mesh para la luz
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);
            GuiController.Instance.Modifiers.addFloat("reflection", 0, 1, 0.35f);
            GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-200, 0, -200), new Vector3(200, 100, 200), new Vector3(0, 80, 0));
            GuiController.Instance.Modifiers.addColor("lightColor", Color.White);
            GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 150, 20);
            GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            GuiController.Instance.Modifiers.addFloat("specularEx", 0, 20, 9f);


            GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
            GuiController.Instance.Modifiers.addColor("mAmbient", Color.White);
            GuiController.Instance.Modifiers.addColor("mDiffuse", Color.White);
            GuiController.Instance.Modifiers.addColor("mSpecular", Color.White);
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;


            //DEBUG: para probar codigo que genera un NormalMap automaticamente. Queda bastante peor que el NormalMap que ya viene hecho
            //createNormalMap(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping_DiffuseMap.jpg", GuiController.Instance.ExamplesMediaDir + "Shaders\\NormalMap_Prueba.jpg");
            //TgcTexture normalMap = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "Shaders\\NormalMap_Prueba2.jpg");



            //Crear 3 paredes y un piso con textura comun y textura de normalMap
            TgcTexture diffuseMap = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping_DiffuseMap.jpg");
            TgcTexture normalMap  = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping_NormalMap.jpg");

            TgcTexture[] normalMapArray = new TgcTexture[] { normalMap };

            TgcBox paredSur   = TgcBox.fromExtremes(new Vector3(-200, 0, -210), new Vector3(200, 100, -200), diffuseMap);
            TgcBox paredOeste = TgcBox.fromExtremes(new Vector3(-210, 0, -200), new Vector3(-200, 100, 200), diffuseMap);
            TgcBox paredEste  = TgcBox.fromExtremes(new Vector3(200, 0, -200), new Vector3(210, 100, 200), diffuseMap);
            TgcBox piso       = TgcBox.fromExtremes(new Vector3(-200, -1, -200), new Vector3(200, 0, 200), diffuseMap);

            //Convertir TgcBox a TgcMesh
            TgcMesh m1 = paredSur.toMesh("paredSur");
            TgcMesh m2 = paredOeste.toMesh("paredOeste");
            TgcMesh m3 = paredEste.toMesh("paredEste");
            TgcMesh m4 = piso.toMesh("piso");

            //Convertir TgcMesh a TgcMeshBumpMapping
            meshes = new List <TgcMeshBumpMapping>();
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m1, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m2, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m3, normalMapArray));
            meshes.Add(TgcMeshBumpMapping.fromTgcMesh(m4, normalMapArray));


            //Borrar TgcMesh y TgcBox, ya no se usan
            paredSur.dispose();
            paredOeste.dispose();
            paredEste.dispose();
            piso.dispose();
            m1.dispose();
            m2.dispose();
            m3.dispose();
            m4.dispose();


            //Crear flechas de debug
            tangents  = new List <TgcArrow>();
            normals   = new List <TgcArrow>();
            binormals = new List <TgcArrow>();
            foreach (TgcMeshBumpMapping mesh in meshes)
            {
                loadDebugArrows(mesh);
            }



            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(0, 50, 100), new Vector3(0, 50, -1));

            //Cargar Shader de personalizado de BumpMapping. Solo soporta meshes de tipo DiffuseMap
            effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\BumpMapping.fx");

            //Cargar shader en meshes
            foreach (TgcMeshBumpMapping m in meshes)
            {
                m.Effect    = effect;
                m.Technique = "BumpMappingTechnique";
            }

            //Mesh para la luz
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);
            GuiController.Instance.Modifiers.addFloat("bumpiness", 0, 1, 1f);
            GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-200, 0, -200), new Vector3(200, 100, 200), new Vector3(0, 80, 0));
            GuiController.Instance.Modifiers.addColor("lightColor", Color.White);
            GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 150, 20);
            GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            GuiController.Instance.Modifiers.addFloat("specularEx", 0, 20, 9f);
            GuiController.Instance.Modifiers.addBoolean("showNormals", "showNormals", false);
            GuiController.Instance.Modifiers.addBoolean("showTangents", "showTangents", false);
            GuiController.Instance.Modifiers.addBoolean("showBinormals", "showBinormals", false);


            GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
            GuiController.Instance.Modifiers.addColor("mAmbient", Color.White);
            GuiController.Instance.Modifiers.addColor("mDiffuse", Color.White);
            GuiController.Instance.Modifiers.addColor("mSpecular", Color.White);
        }
Beispiel #13
0
        public override void init()
        {
            camara    = new TgcThirdPersonCamera();
            personaje = new Personaje(camara, new Explosion());

            this.camara.Enable = true;
            this.personaje.getPersonaje().Position = new Vector3(100, 0, 100);
            this.camara.setCamera(this.personaje.getPersonaje().Position, 50, -100);
            this.personaje.init();

            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear suelo
            TgcTexture pisoTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\rock_floor1.jpg");

            suelo = TgcBox.fromSize(new Vector3(500, 0, 500), new Vector3(4000, 0, 4000), pisoTexture);
            box1  = TgcBox.fromSize(new Vector3(500, 0, 500), new Vector3(550, 550, 550), pisoTexture);
            box2  = TgcBox.fromSize(new Vector3(100, 0, 100), new Vector3(550, 550, 550), pisoTexture);
            box3  = TgcBox.fromSize(new Vector3(1400, 0, 900), new Vector3(550, 550, 550), pisoTexture);

            //Cargar malla original
            TgcSkeletalLoader loader    = new TgcSkeletalLoader();
            string            pathMesh  = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\BasicHuman\\" + "CS_Gign-TgcSkeletalMesh.xml";
            string            mediaPath = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\BasicHuman\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);

            string posicionStr = "Disparar";

            //Agregar animación a original
            loader.loadAnimationFromFile(original, GuiController.Instance.AlumnoEjemplosMediaDir + "Kamikaze3D\\Animations\\" + posicionStr + "-TgcSkeletalAnim.xml");
            //loader.loadAnimationFromFile(original, mediaPath + "Animations\\" + posicionStr + "-TgcSkeletalAnim.xml");

            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment = new TgcSkeletalBoneAttach();
            TgcBox attachmentBox             = TgcBox.fromSize(new Vector3(1, 10, 1), Color.Black);

            Matrix offsetMatrix = Matrix.RotationY(Geometry.DegreeToRadian(190));

            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.RotationZ(Geometry.DegreeToRadian(80)));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.Translation(10, 0, 0));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.RotationX(Geometry.DegreeToRadian(300)));
            offsetMatrix = Matrix.Multiply(offsetMatrix, Matrix.Translation(-2.5f, -1.5f, 0));

            attachment.Mesh   = attachmentBox.toMesh("attachment");
            attachment.Bone   = original.getBoneByName("Bip01 L Hand");
            attachment.Offset = offsetMatrix;
            attachment.updateValues();
            original.Scale = new Vector3(0.7f, 0.7f, 0.7f);
            original.Attachments.Add(attachment);


            //Crear 9 instancias mas de este modelo, pero sin volver a cargar el modelo entero cada vez
            float offset         = 200;
            int   cantInstancias = 150;

            instances = new List <TgcSkeletalMesh>();
            for (int i = 0; i < cantInstancias; i++)
            {
                TgcSkeletalMesh instance = original.createMeshInstance(original.Name + i);
                instance.move((i % 20) * offset, 0, (i / 20) * offset);
                instance.Scale = original.Scale;
                instances.Add(instance);
            }


            //Especificar la animación actual para todos los modelos
            original.playAnimation(posicionStr);
            foreach (TgcSkeletalMesh instance in instances)
            {
                instance.playAnimation(posicionStr);
            }

            //Crear quadtree
            quadtree = new Quadtree();
            //como el bounding box del suelo no tiene altura se la agrego
            Vector3 Pmax = suelo.BoundingBox.PMax;

            Pmax.Y = Pmax.Y + 500;
            TgcBoundingBox bb = new TgcBoundingBox(suelo.BoundingBox.PMin, Pmax);

            quadtree.create(instances, bb);
            quadtree.createDebugQuadtreeMeshes();

            return;

            //Camara en primera persona
            GuiController.Instance.FpsCamera.Enable        = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400;
            GuiController.Instance.FpsCamera.JumpSpeed     = 400;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(293.201f, 291.0797f, -604.6647f), new Vector3(299.1028f, -63.9185f, 330.1836f));
        }