public InstantExplosionWeapon(string defaultPath, Camera camera)
        {
            if (sound == null)
            {
                sound = new Sound(defaultPath + "Audio/laserfire3.wav");
            }

            this.reloadTime = 1000;
            this.damage     = 10;

            Texture t = new BasicTexture(defaultPath + "Texture/Particle/p.png");

            this.position  = new Vector3f();
            this.direction = new Vector3f();
            pe             = new PointEmitter(position);

            Vector3f maxV = new Vector3f(10.0f, 10.0f, 10.0f);
            Vector3f minV = maxV * -1.0f;
            Vector3f g    = new Vector3f(0.0f, -0.001f, 0.0f);

            Color4f minC = new Color4f(1.0f, 0.7f, 0.7f, 0.0f);
            Color4f maxC = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);

            pf = new BillboardedParticleFactory(t, minV, maxV, g, 0.0f, 1.0f, minC, maxC, 0.2f);
            ps = new ParticleSystem(pe, pf, camera, false, 0.1f, 1000);
            pe.setActive(false);
            ps.reset();
        }
        public void LoadAnimations()
        {
            LoadProjects();
            animations = new List <Animation.Animation>();
            for (int i = 0; i < projects.Count; i++)
            {
                animations.Add(new Animation.Animation());
                int frameCounter = 0;
                while (true)
                {
                    string filename = projects[i] + "/Frame_" + frameCounter + ".png";
                    if (!File.Exists(filename))
                    {
                        break;
                    }
                    Texture2D pngTexture = getTextureFromPng(filename);

                    BasicTexture preview = new BasicTexture(pngTexture,
                                                            new Vector2(GlobalParameters.screenWidth / 2, GlobalParameters.screenHeight / 2),
                                                            new Vector2(300, 300));
                    animations[i].Frames.Add(preview);
                    frameCounter++;
                }
            }
        }
Exemple #3
0
        static void LoadObjects()
        {
            w.setSkyBox(new SkyBox(new CubeMapTexture(c.defaultPath + "CubeMap/sky0", CubeMapType.None)));
            crosshairPosition = new Vector3f(3.0f, 1.0f, 0.0f);

            w.Add(new HUD(c.defaultPath));
            Vector3f va, vb, vc, vd;

            va = new Vector3f(-100.0f, 0.0f, -10.0f);
            vb = new Vector3f(100.0f, 0.0f, -10.0f);
            vc = new Vector3f(100.0f, 0.0f, 50.0f);
            vd = new Vector3f(-100.0f, 0.0f, 50.0f);
            w.Add(new GroundPlane(new BasicTexture(c.defaultPath + "Texture/Tile/chess0.jpg"), 70, 7, new Vector3f(0.0f, 0.0f, -5.0f), 200, 20.0f));

            w.Add(gun);
            w.Add(gun2);

            playerPosition = new Vector3f(0.0f, 1.0f, 0.0f);
            playerVelocity = new Vector3f();
            BasicTexture[] textures = new BasicTexture[8];
            for (int i = 1; i <= 8; i++)
            {
                textures[i - 1] = new BasicTexture(c.defaultPath + "How/Media/Girl/Move" + i + ".png");
            }
            player = new AnimatedQuad(textures, playerPosition, 1.0f, textures[0].Width() / textures[0].Height());
            w.Add(player);
            w.Add(new Quad(new BasicTexture(c.defaultPath + "Texture/Foilage/Vine with alpha.png"), new Vector3f(-100, 0.65f, 5.001f), 10.0f, 20.0f, 1.0f));
            w.Add(new BillboardedQuad(new BasicTexture(c.defaultPath + "Texture/Particle/crosshairs.png"), w.getActiveCamera(), crosshairPosition, new Vector2f(1.0f, 1.0f)));
        }
Exemple #4
0
        public override void LoadContent()
        {
            _paintBrush = new BasicTexture("Static\\SettingsScene/image_color-select", new Vector2(100, 40), new Vector2(64, 64));
            _textures.Add(_paintBrush);

            _layerButtons.Add(new BasicTexture("Static\\SettingsScene/button_layer-1", new Vector2(1150, 100), new Vector2(150, 50)));
            _layerButtons.Add(new BasicTexture("Static\\SettingsScene/button_layer-2", new Vector2(1320, 100), new Vector2(150, 50)));
            _layerButtons.Add(new BasicTexture("Static\\SettingsScene/button_layer-3", new Vector2(1490, 100), new Vector2(150, 50)));

            _exportButton = new BasicTexture("Static\\SettingsScene/button_export", new Vector2(GlobalParameters.screenWidth - 100, GlobalParameters.screenHeight - 40), new Vector2(167, 50));

            Texture2D textureBlack  = CreateTexture(GlobalParameters.GlobalGraphics, 30, 30, pixel => Color.Black);
            Texture2D textureRed    = CreateTexture(GlobalParameters.GlobalGraphics, 30, 30, pixel => Color.Red);
            Texture2D textureBlue   = CreateTexture(GlobalParameters.GlobalGraphics, 30, 30, pixel => Color.Blue);
            Texture2D textureGreen  = CreateTexture(GlobalParameters.GlobalGraphics, 30, 30, pixel => Color.Green);
            Texture2D textureYellow = CreateTexture(GlobalParameters.GlobalGraphics, 30, 30, pixel => Color.Yellow);

            Vector2 pointDimensions = new Vector2(30, 30);

            _colors.Add(new BasicTexture(textureBlack, new Vector2(30, 90), pointDimensions));
            _colors.Add(new BasicTexture(textureRed, new Vector2(65, 90), pointDimensions));
            _colors.Add(new BasicTexture(textureBlue, new Vector2(100, 90), pointDimensions));
            _colors.Add(new BasicTexture(textureGreen, new Vector2(135, 90), pointDimensions));
            _colors.Add(new BasicTexture(textureYellow, new Vector2(170, 90), pointDimensions));
            _colors.Add(new BasicTexture("Static\\SettingsScene/Eraser", new Vector2(210, 90), pointDimensions));

            _onion            = new BasicTexture("Static\\SettingsScene/Onion", new Vector2(210, 130), pointDimensions);
            _backArrow        = new BasicTexture("Static\\SettingsScene/Arrow_point-left", new Vector2(100, GlobalParameters.screenHeight - 75), new Vector2(96, 96));
            _toggleSizeButton = new BasicTexture("Static\\SettingsScene/button_change-size", new Vector2(GlobalParameters.screenWidth / 2, GlobalParameters.screenHeight - 30), new Vector2(120, 24));
        }
Exemple #5
0
        /**
         * Helper method to determine if two textures collide. Returns true if they collide, otherwise false.
         */
        public static bool CheckTexturesCollision(BasicTexture texture1, BasicTexture texture2)
        {
            Rectangle rect1 = new Rectangle((int)texture1.position.X, (int)texture1.position.Y, (int)texture1.dimensions.X, (int)texture1.dimensions.Y);
            Rectangle rect2 = new Rectangle((int)texture2.position.X, (int)texture2.position.Y, (int)texture2.dimensions.X, (int)texture2.dimensions.Y);

            if (rect1.Intersects(rect2))
            {
                Rectangle intersection = Rectangle.Intersect(rect1, rect2);

                for (int x = intersection.X; x < intersection.X + intersection.Width; x++)
                {
                    for (int y = intersection.Y; y < intersection.Y + intersection.Height; y++)
                    {
                        int pixel1 = texture1.colorData[x - (int)texture1.position.X, y - (int)texture1.position.Y].A;
                        int pixel2 = texture2.colorData[x - (int)texture2.position.X, y - (int)texture2.position.Y].A;

                        if (pixel1 != 0 && pixel2 != 0)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #6
0
        public override void LoadContent()
        {
            Vector2 projectsButtonLocation = new Vector2(GlobalParameters.screenWidth / 2 - 300, GlobalParameters.screenHeight / 2);
            Vector2 drawButtonLocation     = new Vector2(GlobalParameters.screenWidth / 2 + 15, GlobalParameters.screenHeight / 2);

            _uiElements.Add(new RedirectButton("Projects Scene", "Static\\MenuScene/button_view-animations", projectsButtonLocation, new Vector2(280, 54)));
            _uiElements.Add(new RedirectButton("Drawing Scene", "Static\\MenuScene/button_new-animation", drawButtonLocation, new Vector2(285, 54)));
            _logo = new BasicTexture("Static\\MenuScene/logo", new Vector2(0, 0), new Vector2(400, 400));
        }
Exemple #7
0
        public Frame()
        {
            width  = 1165;
            height = 850;

            Texture2D texture = DrawingService.CreateTexture(GlobalParameters.GlobalGraphics, width, height, pixel => new Color(), Shapes.RECTANGLE);

            _layer1 = new BasicTexture(texture, new Vector2(width / 2, height / 2), new Vector2(width, height));
            _layer2 = new BasicTexture(texture, new Vector2(width / 2, height / 2), new Vector2(width, height));
            _layer3 = new BasicTexture(texture, new Vector2(width / 2, height / 2), new Vector2(width, height));
        }
        public override void LoadContent()
        {
            Texture2D borderTexture = CreateTexture(GlobalParameters.GlobalGraphics, GlobalParameters.screenWidth, 300, pixel => Color.Orange);

            _textures.Add(new BasicTexture(borderTexture, new Vector2(0, 0), new Vector2(GlobalParameters.screenWidth * 2, 300)));
            _textures.Add(new BasicTexture(borderTexture, new Vector2(0, GlobalParameters.screenHeight), new Vector2(GlobalParameters.screenWidth * 2, 300)));
            BasicTexture arrowRight = new BasicTexture("Static\\ProjectsScene/button_arrow", new Vector2(GlobalParameters.screenWidth / 2 + 200, GlobalParameters.screenHeight / 2), new Vector2(45, 45));

            arrowRight.rotation = 1.571f;
            BasicTexture arrowLeft = new BasicTexture("Static\\ProjectsScene/button_arrow", new Vector2(GlobalParameters.screenWidth / 2 - 200, GlobalParameters.screenHeight / 2), new Vector2(45, 45));

            arrowLeft.rotation = -1.571f;
            _textures.Add(arrowRight);
            _textures.Add(arrowLeft);
            _textures.Add(new BasicTexture("Static\\ProjectsScene/button_view-project-directory", new Vector2(GlobalParameters.screenWidth - 200, GlobalParameters.screenHeight - 30), new Vector2(372, 50)));
            LoadAnimations();
        }
Exemple #9
0
        protected override void LoadContent()
        {
            GlobalParameters.GlobalContent     = this.Content;
            GlobalParameters.GlobalSpriteBatch = new SpriteBatch(GraphicsDevice);
            GlobalParameters.GlobalGraphics    = graphics.GraphicsDevice;
            GlobalParameters.GlobalKeyboard    = new KeyboardController();
            GlobalParameters.GlobalMouse       = new MouseController();

            GlobalParameters.CurrentColor = Color.Black;
            GlobalParameters.font         = Content.Load <SpriteFont>("Static\\Roboto");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            cursor = new BasicTexture("Static\\pencil-cursor", new Vector2(0, 0), new Vector2(28, 28));

            foreach (KeyValuePair <string, BaseScene> scene in GlobalParameters.Scenes)
            {
                scene.Value.LoadContent();
            }
        }
Exemple #10
0
        public static bool CheckMouseCollision(BasicTexture texture1)
        {
            Rectangle rect1     = new Rectangle((int)texture1.position.X, (int)texture1.position.Y, (int)texture1.dimensions.X, (int)texture1.dimensions.Y);
            Rectangle mouseRect = new Rectangle((int)GlobalParameters.GlobalMouse.newMousePos.X, (int)GlobalParameters.GlobalMouse.newMousePos.Y, 1, 1);

            if (rect1.Intersects(mouseRect))
            {
                Rectangle intersection = Rectangle.Intersect(rect1, mouseRect);
                for (int x = intersection.X; x < intersection.X + intersection.Width; x++)
                {
                    for (int y = intersection.Y; y < intersection.Y + intersection.Height; y++)
                    {
                        int pixel1 = texture1.colorData[x - (int)texture1.position.X, y - (int)texture1.position.Y].A;

                        if (pixel1 != 0)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #11
0
        private void GetMaterial(StreamReader reader, string name, Dictionary<string, Material> dict, string fileName, Dictionary<string, Texture> textureList)
        {
            Material material = new Material();
            float[] ambient = new float[4];
            float[] diffuse = new float[4];
            float[] specular = new float[4];
            float alpha = ambient[3] = diffuse[3] = specular[3] = 1.0f;
            float shininess = 0.2f;
            Material.IllumType illumType = Material.IllumType.SPECULAR;
            Texture texture = null;
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine().Trim();
                string[] words = regex.Split(line);
                string firstWord = words[0].ToLower();
                if(firstWord.Equals("newmtl"))
                {
                    GetMaterial(reader, words[1].Trim(), dict, fileName, textureList);
                }
                else if (firstWord.Equals("ka"))
                {
                    for(int i = 0; i < 3; i++)
                        ambient[i] = (ToFloat(words[i+1]));
                }
                else if (firstWord.Equals("kd"))
                {
                    for (int i = 0; i < 3; i++)
                        diffuse[i] = (ToFloat(words[i + 1]));
                }
                else if (firstWord.Equals("ks"))
                {
                    for (int i = 0; i < 3; i++)
                        specular[i] = (ToFloat(words[i + 1]));
                }
                else if (firstWord.Equals("d") || firstWord.Equals("tr"))
                {
                    alpha = ambient[3] = diffuse[3] = specular[3] = ToFloat(words[1]);
                }
                else if (firstWord.Equals("ns"))
                {
                    shininess = ToFloat(words[1]);
                }
                else if (firstWord.Equals("illum"))
                {
                    if (words[1].Equals("1"))
                        illumType = Material.IllumType.FLAT;
                    else if (words[1].Equals("2"))
                        illumType = Material.IllumType.SPECULAR;

                }
                else if (firstWord.Equals("map_kd") || firstWord.Equals("map_ks"))
                {
                    int lastS = fileName.LastIndexOf('/');
                    string filePath = fileName.Substring(0, lastS+1);
                    if (words.Length > 1)
                    {
                        if (!textureList.ContainsKey(words[1]))
                        {
                            texture = new BasicTexture(new Pixmap(filePath + words[1]));
                            //texture = Texture.CreateFromFile(filePath + words[1]);
                            textureList.Add(words[1], texture);
                        }
                        else
                        {
                            texture = textureList[words[1]];
                        }
                    }
                }
            }
            material.SetAmbient(ambient);
            material.SetDiffuse(diffuse);
            material.SetSpecular(specular);
            material.SetAlpha(alpha);
            material.SetShininess(shininess);
            material.SetIllumType(illumType);
            material.SetTexture(texture);
            dict.Add(name, material);
        }
Exemple #12
0
        private void GetMaterial(StreamReader reader, string name, Dictionary <string, Material> dict, string fileName, Dictionary <string, Texture> textureList)
        {
            Material material = new Material();

            float[] ambient   = new float[4];
            float[] diffuse   = new float[4];
            float[] specular  = new float[4];
            float   alpha     = ambient[3] = diffuse[3] = specular[3] = 1.0f;
            float   shininess = 0.2f;

            Material.IllumType illumType = Material.IllumType.SPECULAR;
            Texture            texture   = null;

            while (!reader.EndOfStream)
            {
                string   line      = reader.ReadLine().Trim();
                string[] words     = regex.Split(line);
                string   firstWord = words[0].ToLower();
                if (firstWord.Equals("newmtl"))
                {
                    GetMaterial(reader, words[1].Trim(), dict, fileName, textureList);
                }
                else if (firstWord.Equals("ka"))
                {
                    for (int i = 0; i < 3; i++)
                    {
                        ambient[i] = (ToFloat(words[i + 1]));
                    }
                }
                else if (firstWord.Equals("kd"))
                {
                    for (int i = 0; i < 3; i++)
                    {
                        diffuse[i] = (ToFloat(words[i + 1]));
                    }
                }
                else if (firstWord.Equals("ks"))
                {
                    for (int i = 0; i < 3; i++)
                    {
                        specular[i] = (ToFloat(words[i + 1]));
                    }
                }
                else if (firstWord.Equals("d") || firstWord.Equals("tr"))
                {
                    alpha = ambient[3] = diffuse[3] = specular[3] = ToFloat(words[1]);
                }
                else if (firstWord.Equals("ns"))
                {
                    shininess = ToFloat(words[1]);
                }
                else if (firstWord.Equals("illum"))
                {
                    if (words[1].Equals("1"))
                    {
                        illumType = Material.IllumType.FLAT;
                    }
                    else if (words[1].Equals("2"))
                    {
                        illumType = Material.IllumType.SPECULAR;
                    }
                }
                else if (firstWord.Equals("map_kd") || firstWord.Equals("map_ks"))
                {
                    int    lastS    = fileName.LastIndexOf('/');
                    string filePath = fileName.Substring(0, lastS + 1);
                    if (words.Length > 1)
                    {
                        if (!textureList.ContainsKey(words[1]))
                        {
                            texture = new BasicTexture(new Pixmap(filePath + words[1]));
                            //texture = Texture.CreateFromFile(filePath + words[1]);
                            textureList.Add(words[1], texture);
                        }
                        else
                        {
                            texture = textureList[words[1]];
                        }
                    }
                }
            }
            material.SetAmbient(ambient);
            material.SetDiffuse(diffuse);
            material.SetSpecular(specular);
            material.SetAlpha(alpha);
            material.SetShininess(shininess);
            material.SetIllumType(illumType);
            material.SetTexture(texture);
            dict.Add(name, material);
        }