Exemplo n.º 1
0
 public Instructions(Screen parent, ScreenManager manager)
     : base(parent, manager)
 {
     logo = Resources.instructions_texture_region;
     transition_time = 3;
     background = 1;
 }
Exemplo n.º 2
0
        public Billboard(TextureRegion region)
        {
            this.region = region;
            float max = MathHelper.Max(region.width, region.height);
            this.size = new Vector3(region.width / max, region.height / max, 0);
            this.color = Color.White;

            this.age = 0;
            this.fade = false;
        }
Exemplo n.º 3
0
 // 3d sprite
 public SpriteInfo(TextureRegion region, Color color, float x, float y, float z, float width, float height, float rotation_x, float rotation_y, float rotation_z, int index)
 {
     this.region = region; this.color = color; this.x = x; this.y = y; this.z = z; this.width = width; this.height = height; this.index = index; this.rotation_x = rotation_x; this.rotation_y = rotation_y; this.rotation_z = rotation_z;
 }
Exemplo n.º 4
0
        public void Add(TextureRegion region, Color color, float x, float y, float z, float width, float height, float rotation_x, float rotation_y, float rotation_z)
        {
            SpriteInfo sprite = new SpriteInfo(region, color, x, y, z, width, height, rotation_x, rotation_y, rotation_z, count);

            if (!sprites.ContainsKey(region.texture))
                sprites[region.texture] = new List<SpriteInfo>();
            sprites[region.texture].Add(sprite);

            count++;
        }
Exemplo n.º 5
0
        public static void Load(ContentManager content)
        {
            background_music = content.Load<SoundEffect>("music/background");
            droplet_sound = content.Load<SoundEffect>("music/droplet");

            bubble_texture = content.Load<Texture2D>("textures/bubble_small");
            bubble_reflection_texture = content.Load<Texture2D>("textures/bubble_reflection_small");
            title_texture = content.Load<Texture2D>("textures/title");
            ray_texture = content.Load<Texture2D>("textures/bg-light-0001");
            logo_texture = content.Load<Texture2D>("textures/logo");
            instructions_texture = content.Load<Texture2D>("textures/instructions");

            instructions_texture_region = new TextureRegion(instructions_texture, 0, 0, 813, 360);
            logo_texture_region = new TextureRegion(logo_texture, 0, 0, 340, 270);
            white_texture_region = new TextureRegion(title_texture, 17 * 16 + 8, 8, 1, 1);
            particle_texture_region = new TextureRegion(title_texture, 18 * 16+1, 1, 14, 14);
            bubble_reflection_texture_region = new TextureRegion(bubble_reflection_texture, 0, 0, 128, 128);
            bubble_texture_region = new TextureRegion(bubble_texture, 0, 0, bubble_texture.Width, bubble_texture.Height);
            controls_region = new TextureRegion(title_texture, 0, 96, 512, 320);
            hud_on = new TextureRegion(title_texture, 96, 416, 96, 96);
            hud_off = new TextureRegion(title_texture, 0, 416, 96, 96);

            arial10px_font = FontProcessor.Build(content.Load<Texture2D>("fonts/arial10px"));
            description_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni15px_bold"));
            option_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni28px_bold"));
            title_font = FontProcessor.Build(content.Load<Texture2D>("fonts/aharoni48px_bold"));

            spriterenderer_material = content.Load<Effect>("shaders/spriterenderer/default");
            postprocessor_blur = content.Load<Effect>("shaders/postprocessor/dof_blur");
            postprocessor_dof = content.Load<Effect>("shaders/postprocessor/dof");
            postprocessor_scale = content.Load<Effect>("shaders/postprocessor/dof_scale");
            postprocessor_extract = content.Load<Effect>("shaders/postprocessor/bloom_extract");
            postprocessor_bloom = content.Load<Effect>("shaders/postprocessor/bloom_combine");

            box_model = content.Load<Model>("models/box");
            rock_model = content.Load<Model>("models/rock");
            skybox_model = content.Load<Model>("models/skybox");
            seaurchin_model = content.Load<Model>("models/urchin");
            fish_model = content.Load<Model>("models/nemo");
            octopus_model = content.Load<Model>("models/octopus");
            starfish_model = content.Load<Model>("models/starfish");

            name_to_object_mapping = new Dictionary<string, object>();
            object_to_name_mapping = new Dictionary<object, string>();

            Add("models/box", box_model);
            Add("models/rock", rock_model);
            Add("models/skybox", skybox_model);
            Add("models/urchin", seaurchin_model);
            Add("models/nemo", fish_model);
            Add("models/octopus", octopus_model);
            Add("models/starfish", starfish_model);
            Add("textures/bg-light-0001", ray_texture);
        }
Exemplo n.º 6
0
        private static TextureRegion[] CreateRegionsFromTexture(Texture2D texture, Color[] data)
        {
            List<TextureRegion> regions_list = new List<TextureRegion>();
            TextureRegion region;
            Color curr_color, prev_color;
            bool begin, end, curr_clear, prev_clear;
            int height, offset_y, offset_x;
            int texture_width, texture_height;
            int curr_region;
            int sprites_per_row = 0;

            texture_width = texture.Width;
            texture_height = texture.Height;

            height = GetFirstSpriteHeight(texture, data);

            offset_x = offset_y = 0; prev_clear = true; prev_color = clip_color;
            for (int j = 0; j < texture_height; j++)
            {
                curr_clear = true;
                for (int i = 0; i < texture_width; i++)
                {
                    curr_color = data[i + j * texture_width];

                    begin = (curr_color != clip_color && prev_color == clip_color);
                    end = (curr_color == clip_color && prev_color != clip_color);
                    curr_clear = (curr_clear && curr_color == clip_color);

                    if (begin && prev_clear)
                    {
                        if (offset_y == 0 && prev_clear)
                            sprites_per_row++;

                        region = new TextureRegion();
                        region.texture = texture;
                        region.height = height;
                        region.u = i;
                        if (prev_clear)
                            region.v = j;

                        regions_list.Add(region);
                    }
                    if (end && prev_clear)
                    {
                        curr_region = offset_x + offset_y * sprites_per_row;
                        region = regions_list[curr_region];
                        region.width = i - region.u;
                        regions_list[curr_region] = region;

                        offset_x++;
                    }

                    prev_color = curr_color;

                }

                offset_x = 0;
                if ((!prev_clear) && curr_clear)
                    offset_y++;

                prev_clear = curr_clear;
            }

            return regions_list.ToArray();
        }
Exemplo n.º 7
0
        private static TextureRegion[] CreateRegionsFromTexture(Texture2D texture, Color[] data)
        {
            List <TextureRegion> regions_list = new List <TextureRegion>();
            TextureRegion        region;
            Color curr_color, prev_color;
            bool  begin, end, curr_clear, prev_clear;
            int   height, offset_y, offset_x;
            int   texture_width, texture_height;
            int   curr_region;
            int   sprites_per_row = 0;

            texture_width  = texture.Width;
            texture_height = texture.Height;

            height = GetFirstSpriteHeight(texture, data);

            offset_x = offset_y = 0; prev_clear = true; prev_color = clip_color;
            for (int j = 0; j < texture_height; j++)
            {
                curr_clear = true;
                for (int i = 0; i < texture_width; i++)
                {
                    curr_color = data[i + j * texture_width];

                    begin      = (curr_color != clip_color && prev_color == clip_color);
                    end        = (curr_color == clip_color && prev_color != clip_color);
                    curr_clear = (curr_clear && curr_color == clip_color);

                    if (begin && prev_clear)
                    {
                        if (offset_y == 0 && prev_clear)
                        {
                            sprites_per_row++;
                        }

                        region         = new TextureRegion();
                        region.texture = texture;
                        region.height  = height;
                        region.u       = i;
                        if (prev_clear)
                        {
                            region.v = j;
                        }

                        regions_list.Add(region);
                    }
                    if (end && prev_clear)
                    {
                        curr_region  = offset_x + offset_y * sprites_per_row;
                        region       = regions_list[curr_region];
                        region.width = i - region.u;
                        regions_list[curr_region] = region;

                        offset_x++;
                    }

                    prev_color = curr_color;
                }

                offset_x = 0;
                if ((!prev_clear) && curr_clear)
                {
                    offset_y++;
                }

                prev_clear = curr_clear;
            }

            return(regions_list.ToArray());
        }
Exemplo n.º 8
0
 // 3d sprite
 public SpriteInfo(TextureRegion region, Color color, float x, float y, float z, float width, float height, float rotation_x, float rotation_y, float rotation_z, int index)
 {
     this.region = region; this.color = color; this.x = x; this.y = y; this.z = z; this.width = width; this.height = height; this.index = index; this.rotation_x = rotation_x; this.rotation_y = rotation_y; this.rotation_z = rotation_z;
 }
Exemplo n.º 9
0
        public void End()
        {
            if (!has_begun)
            {
                throw new InvalidOperationException("Begin must be called before End can be called.");
            }

            if (primitivebatch == null || material == null)
            {
                Warm(device);
            }

            material.Parameters["TextureEnabled"].SetValue(true);
            material.Parameters["World"].SetValue(Matrix.Identity);

            if (is_ortho)
            {
                material.Parameters["View"].SetValue(view);
                material.Parameters["Projection"].SetValue(proj);
            }
            else
            {
                material.Parameters["View"].SetValue(camera.view);
                material.Parameters["Projection"].SetValue(camera.projection);
            }

            Matrix matrix;
            float  a, b, c, d, e, f;

            foreach (Texture2D texture in sprites.Keys)
            {
                List <SpriteInfo> list = sprites[texture];

                if (list.Count <= 0)
                {
                    continue;
                }

                material.Parameters["Texture"].SetValue(texture);
                material.CurrentTechnique.Passes[0].Apply();

                primitivebatch.Begin(Primitive.Quad);
                float texture_pixel_width  = 1.0f / texture.Width;
                float texture_pixel_height = 1.0f / texture.Height;

                for (int i = 0; i < list.Count; i++)
                {
                    SpriteInfo    sprite = list[i];
                    TextureRegion region = sprite.region;

                    float index = 0;
                    if (is_ortho)
                    {
                        index  = 1 - (((float)(sprite.index)) / count);
                        index *= -0.09f;
                    }

                    matrix = Matrix.Identity;
                    if (sprite.rotation_z != 0 || sprite.rotation_x != 0 || sprite.rotation_y != 0)
                    {
                        a = (float)Math.Cos(sprite.rotation_x);
                        b = (float)Math.Sin(sprite.rotation_x);

                        c = (float)Math.Cos(sprite.rotation_y);
                        d = (float)Math.Sin(sprite.rotation_y);

                        e = (float)Math.Cos(sprite.rotation_z);
                        f = (float)Math.Sin(sprite.rotation_z);

                        matrix.M11 = (c * e);
                        matrix.M12 = (c * f);
                        matrix.M13 = -d;
                        matrix.M21 = (e * b * d - a * f);
                        matrix.M22 = ((e * a) + (f * b * d));
                        matrix.M23 = (b * c);
                        matrix.M31 = (e * a * d + b * f);
                        matrix.M33 = (a * c);
                        matrix.M32 = -(b * e - f * a * d);
                    }

                    matrix.M41 = sprite.x;
                    matrix.M42 = sprite.y;
                    matrix.M43 = sprite.z + index;

                    primitivebatch.SetTransform(ref matrix);
                    primitivebatch.SetColor(sprite.color);
                    primitivebatch.SetTextureCoords(region.u * texture_pixel_width, region.v * texture_pixel_height);

                    if (is_ortho)                     //in ortho the view is upside down
                    {
                        primitivebatch.AddVertex(0, 0, 0, 0, 0);
                        primitivebatch.AddVertex(0, 0 + sprite.height, 0, 0, 0 + region.height * texture_pixel_height);
                        primitivebatch.AddVertex(0 + sprite.width, 0 + sprite.height, 0, 0 + region.width * texture_pixel_width, 0 + region.height * texture_pixel_height);
                        primitivebatch.AddVertex(0 + sprite.width, 0, 0, 0 + region.width * texture_pixel_width, 0);
                    }
                    else
                    {
                        primitivebatch.AddVertex(0, 0 + sprite.height, 0, 0, 0);
                        primitivebatch.AddVertex(0, 0, 0, 0, 0 + region.height * texture_pixel_height);
                        primitivebatch.AddVertex(0 + sprite.width, 0, 0, 0 + region.width * texture_pixel_width, 0 + region.height * texture_pixel_height);
                        primitivebatch.AddVertex(0 + sprite.width, 0 + sprite.height, 0, 0 + region.width * texture_pixel_width, 0);
                    }
                }

                primitivebatch.End();

                list.Clear();
            }

            has_begun = false;
        }
Exemplo n.º 10
0
 public Title(Screen parent, ScreenManager manager)
     : base(parent, manager)
 {
     logo = Resources.logo_texture_region;
     transition_time = 3;
     background = 1;
 }