Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        void LoadContent()
        {
            SafeDispose(ref factory);
            SafeDispose(ref vertexBuffers);
            SafeDispose(ref indexBuffers);

            surfaceShader = Game.Content.Load <Ubershader>("surface");
            factory       = new StateFactory(surfaceShader, typeof(SurfaceFlags), Primitive.TriangleList, VertexInputElement.FromStructure <VertexColorTextureTBN>());


            scene = Game.Content.Load <Scene>(@"Scenes\testScene");

            vertexBuffers = scene.Meshes
                            .Select(mesh => VertexBuffer.Create(Game.GraphicsDevice, mesh.Vertices.Select(v => VertexColorTextureTBN.Convert(v)).ToArray()))
                            .ToArray();

            indexBuffers = scene.Meshes
                           .Select(mesh => IndexBuffer.Create(Game.GraphicsDevice, mesh.GetIndices()))
                           .ToArray();


            surfaceProps = scene.Materials
                           .Select(mtrl => new SurfaceProperties()
            {
                Diffuse   = LoadTexture2D(mtrl.TexturePath, "|srgb", defaultDiffuse),
                Specular  = LoadTexture2D(mtrl.TexturePath, "_spec", defaultSpecular),
                NormalMap = LoadTexture2D(mtrl.TexturePath, "_local", defaultNormalMap),
                Emission  = LoadTexture2D(mtrl.TexturePath, "_glow|srgb", defaultEmission),
            })
                           .ToArray();
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        void LoadContent()
        {
            SafeDispose(ref factory);

            skySphere   = Game.Content.Load <Scene>("skySphere");
            cloudSphere = Game.Content.Load <Scene>("cloudSphere");
            clouds      = Game.Content.Load <Texture2D>("clouds|srgb");
            cirrus      = Game.Content.Load <Texture2D>("cirrus|srgb");
            noise       = Game.Content.Load <Texture2D>("cloudNoise");
            arrows      = Game.Content.Load <Texture2D>("arrowsAll");

            vertexBufferBlur = new VertexBuffer(Game.GraphicsDevice, typeof(VertexColorTextureTBN), 6);
            vertexBuffers    = skySphere.Meshes
                               .Select(mesh => VertexBuffer.Create(Game.GraphicsDevice, mesh.Vertices.Select(v => VertexColorTextureTBN.Convert(v)).ToArray()))
                               .ToArray();

            indexBuffers = skySphere.Meshes
                           .Select(mesh => IndexBuffer.Create(Game.GraphicsDevice, mesh.GetIndices()))
                           .ToArray();

            cloudVertexBuffers = cloudSphere.Meshes
                                 .Select(mesh => VertexBuffer.Create(Game.GraphicsDevice, mesh.Vertices.Select(v => VertexColorTextureTBN.Convert(v)).ToArray()))
                                 .ToArray();

            cloudIndexBuffers = cloudSphere.Meshes
                                .Select(mesh => IndexBuffer.Create(Game.GraphicsDevice, mesh.GetIndices()))
                                .ToArray();

            sky     = Game.Content.Load <Ubershader>("sky");
            factory = new StateFactory(sky, typeof(SkyFlags), (ps, i) => EnumFunc(ps, (SkyFlags)i));
        }