Exemplo n.º 1
0
        private static Material LoadCustomMaterial(BinaryReader reader)
        {
            var shaderFlags     = (ShaderFlags)reader.ReadInt32();
            var customImageType = reader.ReadByte();
            var pixelSize       = customImageType > 0
                                ? new Size(reader.ReadSingle(), reader.ReadSingle()) : Size.Zero;
            var imageOrAnimationName = customImageType > 0 ? "" : reader.ReadString();
            var customImage          = customImageType == 1
                                ? ContentLoader.Create <Image>(new ImageCreationData(pixelSize)) : null;
            var color = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(),
                                  reader.ReadByte());
            var duration = reader.ReadSingle();
            var material = customImageType > 0
                                ? new Material(ContentLoader.Create <Shader>(new ShaderCreationData(shaderFlags)),
                                               customImage) : new Material(shaderFlags, imageOrAnimationName);

            material.DefaultColor = color;
            material.Duration     = duration;
            return(material);
        }
Exemplo n.º 2
0
        protected override void PlayNativeVideo(float volume)
        {
            video.Rewind();
            for (int index = 0; index < NumberOfBuffers; index++)
            {
                if (!Stream(buffers[index]))
                {
                    break;
                }
            }
            video.Play();
            openAL.Play(channelHandle);
            openAL.SetVolume(channelHandle, volume);
            elapsedSeconds = 0.0f;
            Size size = new Size(video.Width, video.Height);

            if (image == null)
            {
                image = ContentLoader.Create <Image>(new ImageCreationData(size));
            }
            Shader shader = ContentLoader.Create <Shader>(new ShaderCreationData(ShaderFlags.Position2DTextured));

            surface = new Sprite(new Material(shader, image), ScreenSpace.Current.Viewport);
        }
Exemplo n.º 3
0
 private static Shader CreateShader2D()
 {
     return
         (ContentLoader.Create <Shader>(new ShaderCreationData(ShaderFlags.Position2DColoredTextured)));
 }
        private static MeshAnimation CreateAnimationWith75Frames(float framesPerSecond)
        {
            var animationData = new MeshAnimationCreationData(NumberOfAnimationFrames, framesPerSecond);

            return(ContentLoader.Create <MeshAnimation>(animationData));
        }
Exemplo n.º 5
0
        private static MockGeometry CreateMockGeometry()
        {
            var creationData = new GeometryCreationData(VertexFormat.Position3DColor, 3, 3);

            return(ContentLoader.Create <MockGeometry>(creationData));
        }
Exemplo n.º 6
0
 protected Sprite(Image image)
 {
     Material = new Material(ContentLoader.Create <Shader>(
                                 new ShaderCreationData(ShaderFlags.Position2DColoredTextured)), image);
     OnDraw <DrawSprite>();
 }