示例#1
0
        //====================================
        // Inicializacion
        //====================================
        public void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            //Configurar MeshFactory customizado
            loader.MeshFactory = new MyCustomMeshFactory();

            //Cargar los mesh:
            scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Meshes\\box\\BoxSeba3-TgcScene.xml");

            mesh          = (MyMesh)scene.Meshes[0];
            mesh.Scale    = new Vector3(0.8f, 0.3f, 0.8f);
            mesh.Position = FuegoPosicion;

            string texturePath  = GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Meshes\\box\\Textures\\FireDistortion.tga";
            string texturePath2 = GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Meshes\\box\\Textures\\FireOpacity.tga";
            string texturePath3 = GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Meshes\\box\\Textures\\FireBase.tga";

            currentTexture  = TgcTexture.createTexture(d3dDevice, texturePath);
            currentTexture2 = TgcTexture.createTexture(d3dDevice, texturePath2);
            currentTexture3 = TgcTexture.createTexture(d3dDevice, texturePath3);


            //Cargar Shader
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Blizarro\\Shaders\\fuego.fx", null, null, ShaderFlags.None, null, out compilationErrors);

            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }

            // le asigno el efecto a la malla
            mesh.effect = effect;


            //Centrar camara rotacional respecto a este mesh
            //GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);

            time = 0;
        }
示例#2
0
        public MyMesh createMeshInstance(string name, Vector3 translation, Vector3 rotation, Vector3 scale)
        {
            if (this.parentInstance != null)
            {
                throw new Exception("No se puede crear una instancia de otra malla instancia. Hay que partir del original.");
            }

            //Crear instancia
            MyMesh instance = new MyMesh(name, this, translation, rotation, scale);

            //instance.effect = effect;

            //BoundingBox
            instance.boundingBox = new TgcBoundingBox(this.boundingBox.PMin, this.boundingBox.PMax);
            instance.updateBoundingBox();

            instance.enabled = true;
            return(instance);
        }