コード例 #1
0
        public FlappyBirdGame()
        {
            mediaLoader = new MediaLoader();
            mediaLoader.RegisterMediaAssembly <FlappyBirdGame>();

            spriteSheet = new SpriteSheet("Media/Graphics/atlas.png", "Media/Data/atlas.txt");
        }
コード例 #2
0
        public ShaderComponent(string path, XmlElement el, MediaLoader ml)
        {
            name   = Xml.GetAttributeString(el, "id");
            target = Xml.GetAttributeString(el, "target");

            XmlElement sh = el["shader"];

            shader = new Shader(path + ": " + name, sh);

            foreach (XmlElement bind in el["binds"])
            {
                updates.Add(new UpdateFloat(bind, shader));
            }

            foreach (XmlElement upd in el["update"])
            {
                string updname = upd.Name;
                if (updname == "texture")
                {
                    updates.Add(new ApplyTexture(upd, ml));
                }
                else if (updname == "buffer")
                {
                    updates.Add(new ApplyBuffer(upd, ml));
                }
            }
        }
コード例 #3
0
        private static IContainer LoadMetadataFromFFprobe(this IContainer resource)
        {
            var mediaLoader = new MediaLoader(resource);

            if (mediaLoader.HasAudio)
            {
                resource.Streams.AddRange(mediaLoader.BaseData.Streams
                                          .OfType <AudioStreamMetadata>()
                                          .Select(audioMetadata => AudioStream.Create(MetadataInfo.Create(audioMetadata))));
            }

            if (mediaLoader.HasVideo)
            {
                resource.Streams.AddRange(mediaLoader.BaseData.Streams
                                          .OfType <VideoStreamMetadata>()
                                          .Select(videoMetadata => VideoStream.Create(MetadataInfo.Create(videoMetadata))));
            }

            if (mediaLoader.HasData)
            {
                resource.Streams.AddRange(mediaLoader.BaseData.Streams
                                          .OfType <DataStreamMetadata>()
                                          .Select(dataMetadata => DataStream.Create(MetadataInfo.Create(dataMetadata))));
            }

            return(resource);
        }
コード例 #4
0
        private void newMesh(FileSystem fs)
        {
            MediaLoader ml = new MediaLoader(fs);

            def.compile(ml);
            mesh = def.Compiled;
            forceRedraw();
        }
コード例 #5
0
        public ApplyTexture(XmlElement el, MediaLoader ml)
        {
            string file = Xml.GetAttributeString(el, "file");

            location = Xml.GetAttribute <int>(el, "location", int.Parse, -1);

            text = ml.fetch <Texture>(file);
        }
コード例 #6
0
        public async Task MediaLoaderLoadsFullPathTexture()
        {
            var ml = new MediaLoader();

            ml.RegisterMediaAssembly <FlappyBirdGame>();

            using (var image = await ml.LoadTextureAsync(FullPathAtlasPng))
            {
                Assert.NotNull(image);
            }
        }
コード例 #7
0
        public void MediaLoaderLoadsStream()
        {
            var ml = new MediaLoader();

            ml.RegisterMediaAssembly <FlappyBirdGame>();

            using (var stream = ml.LoadStream(AtlasPng))
            {
                Assert.NotNull(stream);
            }
        }
コード例 #8
0
        public static Pipeline Create(string path, MediaLoader ml, int width, int height)
        {
            Linker linker = new Linker();
            string t      = linker.read(path, ml, width, height);

            linker.link();
            Pipeline pp   = linker.getPipeline(linker.getTarget(t));
            Binder   bind = new Binder(ml.FS);

            pp.bind(bind);
            bind.createBuffers();
            return(pp);
        }
コード例 #9
0
        internal string read(string path, MediaLoader ml, int width, int height)
        {
            XmlElement root = Xml.Open(Xml.FromStream(ml.FS.open(path)), "pipeline");
            string     t    = Xml.GetAttributeString(root, "target");

            foreach (XmlElement targetElement in Xml.Elements(root["targets"]))
            {
                Target target = Targets.Targets.Create(targetElement, width, height);
                target.Id = Xml.GetAttributeString(targetElement, "id");
                addTarget(target);
            }
            foreach (XmlElement providerElement in Xml.Elements(root["providers"]))
            {
                Provider provider = Providers.Providers.Create(providerElement);
                provider.Id = Xml.GetAttributeString(providerElement, "id");
                addProvider(provider);
            }

            return(t);
        }
コード例 #10
0
        public CompositeComponent(string path, XmlElement effect, MediaLoader ml)
        {
            foreach (XmlElement el in Xml.Elements(effect))
            {
                string name = el.Name;

                if (name == "shader")
                {
                    add(new ShaderComponent(path, el, ml));
                }
                else if (name == "composite")
                {
                    add(new CompositeComponent(path, el, ml));
                }
                else
                {
                    throw new Exception("Unknown fse component " + name);
                }
            }
        }
コード例 #11
0
ファイル: UIBuilder.cs プロジェクト: Avatarchik/ViewUIBuilder
    // Use this for initialization
    public void Init(GameObject views)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(ConfigXML));

        using (Stream reader = new FileStream(Application.dataPath + "/../" + configPath, FileMode.Open))
        {
            // Call the Deserialize method to restore the object's state.
            config = (ConfigXML)serializer.Deserialize(reader);
        }
        if (config == null)
        {
            Application.Quit();
        }

        // Load image
        MediaLoader mediaLoader = new MediaLoader(config.mediaPath);

        // TEST LOAD FONT

        /*WWW fontwww = new WWW(Application.dataPath + "../../resources/NewJune-Bold.otf");
         * //Font font = fontwww.bytes as Font;
         * Font font = new Font();
         *
         * string[] fonts = Font.GetOSInstalledFontNames();
         * foreach (string fontName in fonts)
         * {
         *  Debug.Log("fonts = " + fontName);
         * }*/

        // Create Canvas
        createCanvas(config, views);

        init();

        BroadcastMessage("UiFinishedLoading", SendMessageOptions.DontRequireReceiver);
    }
コード例 #12
0
        public Effect(string file, MediaLoader ml)
        {
            XmlElement effect = Xml.Open(Xml.FromStream(ml.FS.open(file)), "effect");

            comp = new CompositeComponent(file, effect, ml);
        }
コード例 #13
0
    public MediaLoader(string mediaPath)
    {
        this.mediaPath = mediaPath;

        if (MediaLoader.instance == null)
        {
            MediaLoader.instance = this;
        }

        XmlSerializer serializer = new XmlSerializer(typeof(MediaXML));

        string path = mediaPath + "Media.xml";

        using (Stream reader = new FileStream(path, FileMode.Open))
        {
            // Call the Deserialize method to restore the object's state.
            mediaXml = (MediaXML)serializer.Deserialize(reader);
        }
        if (mediaXml == null)
        {
            Application.Quit();
        }
        mediaModel = new MediaModel[mediaXml.Images.Length];
        for (int i = 0; i < mediaXml.Images.Length; i++)
        {
            MediasMedia media = mediaXml.Images[i];
            if (media.url.Contains("."))
            {
                Sprite newImg = null;
                if (media.url.Contains(".png"))
                {
                    newImg = loadMedia(mediaPath + media.url);
                }
                MediaModel tempMediaModel = new MediaModel(media.id, new Sprite[] { newImg }, media.reference, media.width, media.height, media.url);
                Log.Instance.Info("tempMediaModel = " + tempMediaModel.id + " - " + tempMediaModel.image + " - " + tempMediaModel.url);
                mediaModel[i] = tempMediaModel;
            }
            else
            {
                string[] files       = Directory.GetFiles(mediaPath + media.url);
                Sprite[] spriteArray = new Sprite[files.Length];
                int      a           = 0;
                foreach (string file in files)
                {
                    Log.Instance.Info("file = " + file);
                    Sprite newImg = loadMedia(file);
                    spriteArray[a] = newImg;
                    a += 1;
                }
                MediaModel tempMediaModel = new MediaModel(media.id, spriteArray, media.reference, media.width, media.height, media.url);
                mediaModel[i] = tempMediaModel;
            }
        }
        Log.Instance.Info("text xml lenght = " + mediaXml.Texts.Length);
        textModel = new TextModel[mediaXml.Texts.Length];
        for (int i = 0; i < mediaXml.Texts.Length; i++)
        {
            MediasText media         = mediaXml.Texts[i];
            TextModel  tempMediaText = new TextModel(media.id, media.reference, media.autoSize, media.font, media.Value, media.fontSize, media.fontColor);
            Log.Instance.Info("tempMediaText = " + tempMediaText.id + " - " + tempMediaText.reference + " - " + tempMediaText.autoSize + " - " + tempMediaText.text);
            textModel[i] = tempMediaText;
        }
    }
コード例 #14
0
 public ApplyBuffer(XmlElement el, MediaLoader ml)
 {
     buffer   = Xml.GetAttributeString(el, "buffer");
     location = Xml.GetAttribute <int>(el, "location", int.Parse, -1);
 }
コード例 #15
0
        public void EmptyMediaLoaderThrows()
        {
            var ml = new MediaLoader();

            Assert.Throws <ArgumentException>(() => ml.LoadStream(AtlasPng));
        }
コード例 #16
0
        public static void Main()
        {
            using (RenderFrame frame = RenderFrame.Create("", 640, 480, 32, false))
            {
                Counter timer = new Counter();
                Setup.basicOpenGL();

                FileSystem fs = new FileSystem();
                fs.addDefaultRoots("pretty good", "simple test");
                MediaLoader loader = new MediaLoader(fs);
                //Texture sample = loader.fetch<Texture>("sample.bmp");

                bool  running = true;
                World world   = World.Load(loader, "level01.lvl");
                //world.add(new MeshInstance(loader.fetch<Mesh>("basicroad.obj")));
                Camera cam = new Camera();
                //Gl.glLoadIdentity();
                float delta = 0;

                Key  rightleft = new PlusMinus(new Hold(new Ckey(Keys.D)), new Hold(new Ckey(Keys.A)));
                Key  forback   = new PlusMinus(new Hold(new Ckey(Keys.W)), new Hold(new Ckey(Keys.S)));
                Key  updown    = new PlusMinus(new Hold(new Ckey(Keys.Space)), new Hold(new Ckey(Keys.ControlKey)));
                Hold sprint    = new Hold(new Ckey(Keys.ShiftKey));

                frame.setCursorPos(frame.Center);

                vec2 mousesmooth = new vec2(0, 0);
                vec3 movement    = new vec3(0, 0, 0);

                float sensitivity    = 0.1f;
                float mousesmoothing = 6;

                Pipeline pipe = Pipeline.Create("pipeline.xml", loader, frame.Width, frame.Height);

                while (running)
                {
                    timer.Start();
                    Application.DoEvents();

                    /*fbo.updateTexture(delegate()
                     * {
                     *  world.render(frame.Width, frame.Height, cam);
                     * });*/

                    frame.begin();
                    pipe.render(new RenderArgs(world, cam, frame.Width, frame.Height));

                    /*Shader.Bind(shader);
                     * FullscreenQuad.render(fbo, frame.Width, frame.Height);
                     * Shader.Unbind();*/
                    frame.swap();

                    /*frame.begin();
                     * world.render(frame.Width, frame.Height, cam);
                     * frame.swap();*/

                    System.Drawing.Point p      = frame.getCursorPos();
                    System.Drawing.Point center = frame.Center;
                    frame.setCursorPos(center);

                    mousesmooth = vec2.Curve(new vec2(p.X - center.X, p.Y - center.Y), mousesmooth, mousesmoothing);
                    movement    = vec3.Curve(Key.Combine(rightleft, updown, forback).Normalized *(3 + sprint.Value * 3), movement, 5);

                    // math::Quaternion(math::op::vec3::yAxisPositive, -x) * math::Quaternion(mRotation.getRight(), y) * mRotation;

                    quat final = quat.FpsQuat(cam.rotation, mousesmooth.x * sensitivity, mousesmooth.y * sensitivity);
                    cam.location += cam.rotation.getRUI(movement) * delta;
                    cam.rotate(final);

                    foreach (RenderFrame.Event e in frame.Events)
                    {
                        System.Diagnostics.Debug.WriteLine(e);
                        if (e.button.equals(new Ckey(Keys.Escape)))
                        {
                            running = false;
                        }
                        else
                        {
                            Key.Run(e.button, e.down, rightleft, forback, updown, sprint);
                        }
                    }
                    timer.Stop();
                    delta = timer.Duration;
                }
            }
        }