コード例 #1
0
        //=================================================================================
        // carga armamento en alguna de las manos del personaje
        //=================================================================================
        public void AgarrarArmamento()
        {
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene  = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Escudo\\Escudo-TgcScene.xml");

            TgcSceneLoader loader2 = new TgcSceneLoader();
            TgcScene       scene2  = loader2.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Armas\\Hacha\\Hacha-TgcScene.xml");

            C_ArmamentoManoDerecha = scene.Meshes[0];//.Meshes[0];
            //C_ArmamentoManoDerecha.AutoTransformEnable = true;
            C_ArmamentoManoDerecha.Scale = new Vector3(10, 10, 10);
            C_ArmamentoManoIzquierda     = scene2.Meshes[0];//.Meshes[0];

            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment  = new TgcSkeletalBoneAttach();
            TgcSkeletalBoneAttach attachment2 = new TgcSkeletalBoneAttach();

            attachment.Mesh   = C_ArmamentoManoDerecha;
            attachment.Bone   = mesh.getBoneByName("Bip01 R Hand");
            attachment.Offset = Matrix.Transformation2D(new Vector2(0, 10), 0, new Vector2(1.5f, 1.5f), new Vector2(0, 0), 60, new Vector2(2, 5));

            attachment2.Mesh   = C_ArmamentoManoIzquierda;
            attachment2.Bone   = mesh.getBoneByName("Bip01 L Hand");
            attachment2.Offset = Matrix.Transformation2D(new Vector2(0, 10), 0, new Vector2(2, 2), new Vector2(0, 0), 60, new Vector2(2, 5));

            attachment.updateValues();
            attachment2.updateValues();
            mesh.Attachments.Add(attachment);
            mesh.Attachments.Add(attachment2);
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
ファイル: Personaje.cs プロジェクト: ftobares/tp-tgc
        public void addWeapon(TgcSkeletalMesh personaje, Weapon aWeapon)
        {
            List <TgcMesh> listMesh = aWeapon.getListMesh();

            foreach (TgcMesh m in listMesh)
            {
                TgcSkeletalBoneAttach attachment = new TgcSkeletalBoneAttach();
                attachment.Mesh = m;
                attachment.Bone = personaje.getBoneByName("Bip01 R Hand");
                //attachment.Offset = Matrix.Translation(0, -10, -15);

                Matrix resultMatrix = Matrix.Translation(-5, -10, -15);
                resultMatrix = Matrix.Multiply(resultMatrix, Matrix.Scaling(0.5f, 0.5f, 0.5f));
                resultMatrix = Matrix.Multiply(resultMatrix, Matrix.RotationY(Geometry.RadianToDegree(90)));
                //resultMatrix = Matrix.Multiply(resultMatrix, Matrix.Translation(0, 10, 0));
                resultMatrix = Matrix.Multiply(resultMatrix, Matrix.Translation(5, 0, 0));
                //resultMatrix = Matrix.Multiply(resultMatrix, Matrix.RotationZ(Geometry.DegreeToRadian(30)));
                //resultMatrix = Matrix.Multiply(resultMatrix, Matrix.RotationX(Geometry.RadianToDegree(20)));
                attachment.Offset = resultMatrix;
                //attachment.Offset = Matrix.Multiply(Matrix.Multiply(
                //                                        Matrix.Translation(0, -10, -15),
                //                                        Matrix.Scaling(0.5f, 0.5f, 0.5f)),
                //                                    Matrix.RotationY(Geometry.RadianToDegree(90)));
                attachment.updateValues();
                personaje.Attachments.Add(attachment);
            }
        }
コード例 #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));
        }
コード例 #5
0
        public override void Init()
        {
            //Crear suelo
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                       MediaDir + "Texturas\\Quake\\TexturePack2\\rock_floor1.jpg");

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

            //Cargar malla original
            var loader    = new TgcSkeletalLoader();
            var pathMesh  = MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";
            var mediaPath = MediaDir + "SkeletalAnimations\\Robot\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);

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

            //Agregar attachment a original
            var attachment    = new TgcSkeletalBoneAttach();
            var 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;
            var   cantInstancias = 4;

            instances = new List <TgcSkeletalMesh>();
            for (var i = 0; i < cantInstancias; i++)
            {
                var 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 (var instance in instances)
            {
                instance.playAnimation("Patear");
            }

            //Camara en primera persona
            Camara = new TgcFpsCamera(new Vector3(293.201f, 291.0797f, -604.6647f));
        }
コード例 #6
0
ファイル: Police.cs プロジェクト: ftobares/tp-tgc
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public override void Init()
        {
            //Paths para archivo XML de la malla
            var pathMesh = MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";

            //Path para carpeta de texturas de la malla
            var mediaPath = MediaDir + "SkeletalAnimations\\Robot\\";

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

            //Crear rutas con cada animacion
            var animationsPath = new string[animationList.Length];

            for (var i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcSkeletalAnim.xml";
            }

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

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

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

            //Agregar combo para elegir animacion
            selectedAnim      = animationList[0];
            animationModifier = AddInterval("animation", animationList, 0);

            //Modifier para especificar si la animacion se anima con loop
            var animateWithLoop = true;

            loopModifier = AddBoolean("loop", "Loop anim:", animateWithLoop);

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

            renderSkeletonModifier = AddBoolean("renderSkeleton", "Show skeleton:", renderSkeleton);

            //Modifier para FrameRate
            frameRateModifier = AddFloat("frameRate", 0, 100, 30);

            //Modifier para color
            currentColor  = Color.White;
            colorModifier = AddColor("Color", currentColor);

            //Modifier para BoundingBox
            boundingBoxModifier = AddBoolean("BoundingBox", "BoundingBox:", false);

            //Modifier para habilitar attachment
            showAttachment     = false;
            attachmentModifier = AddBoolean("Attachment", "Attachment:", showAttachment);

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

            //Crear caja como modelo de Attachment del hueso "Bip01 L Hand"
            attachment = new TgcSkeletalBoneAttach();
            var attachmentBox = TGCBox.fromSize(new TGCVector3(5, 100, 5), Color.Blue);

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

            //Configurar camara
            Camera = new TgcRotationalCamera(new TGCVector3(0, 70, 0), 200, Input);
        }
コード例 #9
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));
        }