Exemple #1
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);
        }
Exemple #2
0
        public void init()
        {
            //sonidos
            sound_b = new staticSound();
            sound_c = new staticSound();
            sound_b.init("burbuja.wav");
            sound_c.init("hundido.wav");
            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            loader.MeshFactory = new ShadedMeshFactory();
            //Cargar mesh
            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\Sphere\\Sphere-TgcScene.xml");

            mesh = (ShadedMesh)scene.Meshes[0];
            mesh.loadEffect("Shaders//ball.fx", "Basic");
            mesh.AutoUpdateBoundingBox = false;

            //calcular el radio de la esfera
            Vector3[] vP = mesh.getVertexPositions();
            rad = 0f;
            foreach (Vector3 i in vP)
            {
                Vector3 dist = new Vector3(i.X - mesh.Position.X, i.Y - mesh.Position.Y, i.Z - mesh.Position.Z);
                float   d    = dist.Length();
                rad = Math.Max(d, rad);
            }

            //Correccion de normales
            int[] adj = new int[mesh.D3dMesh.NumberFaces * 3];
            mesh.D3dMesh.GenerateAdjacency(0, adj);
            mesh.D3dMesh.ComputeNormals(adj);
        }
Exemple #3
0
        public static void init()
        {
            TgcSceneLoader loader = new TgcSceneLoader();

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

            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\leaf-TgcScene.xml");

            mesh = (ShadedMesh)scene.Meshes[0];
            mesh.loadEffect("Shaders//hoja.fx", "Basic");

            leaf_tex = mesh.DiffuseMaps[0].D3dTexture;
            mesh.Effect.SetValue("xLeafTex", leaf_tex);
            mesh.AutoUpdateBoundingBox = false;

            mesh.BoundingBox.scaleTranslate(new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 0.9f));

            rand = new Random(DateTime.Now.Millisecond * DateTime.Now.Second * DateTime.Now.Minute);
        }
Exemple #4
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;
        }