コード例 #1
0
        /// <summary>
        /// Invoked after either control has created its graphics device.
        /// </summary>
        private void OnGraphicsControlLoadContent(object sender, GraphicsDeviceEventArgs e)
        {
            _basicEffect = new BasicEffect(e.GraphicsDevice)
            {
                View  = Matrix.LookAtRH(new Vector3(0, 0, 3), new Vector3(0, 0, 0), Vector3.UnitY),
                World = Matrix.Identity,
                PreferPerPixelLighting = true
            };
            _basicEffect.EnableDefaultLighting();

            _geometricPrimitives = new[]
            {
                GeometricPrimitive.Cube.New(e.GraphicsDevice),
                GeometricPrimitive.Cylinder.New(e.GraphicsDevice),
                GeometricPrimitive.GeoSphere.New(e.GraphicsDevice),
                GeometricPrimitive.Teapot.New(e.GraphicsDevice),
                GeometricPrimitive.Torus.New(e.GraphicsDevice)
            };
            _primitiveIndex = 0;

            _texture                    = Texture2D.Load(e.GraphicsDevice, "Modules/SharpDXSceneViewer/Resources/tile_aqua.png");
            _basicEffect.Texture        = _texture;
            _basicEffect.TextureEnabled = true;

            _yaw   = 0.5f;
            _pitch = 0.3f;
        }
コード例 #2
0
        /// <summary>
        /// Loads an <see cref="EffectData"/> from the specified file.
        /// </summary>
        /// <param name="device">The graphics device</param>
        /// <param name="fileName">The filename.</param>
        /// <returns>An <see cref="EffectData"/> </returns>
        public static SpriteFont Load(GraphicsDevice device, string fileName)
        {
            var fileDirectory = Path.GetDirectoryName(fileName);

            using (var stream = new NativeFileStream(fileName, NativeFileMode.Open, NativeFileAccess.Read))
                return(Load(device, stream, bitmapName => Texture2D.Load(device, Path.Combine(fileDirectory, bitmapName))));
        }
コード例 #3
0
        /// <summary>
        /// Invoked after either control has created its graphics device.
        /// </summary>
        private void OnGraphicsControlLoadContent(object sender, GraphicsDeviceEventArgs e)
        {
            _effect = new BasicEffect(e.GraphicsDevice)
            {
                View  = Matrix.LookAtRH(new Vector3(0, 0, 3), new Vector3(0, 0, 0), Vector3.UnitY),
                World = Matrix.Identity,
                PreferPerPixelLighting = true,
                FogEnabled             = true,
                FogStart = 1,
                FogEnd   = 100,
            };

            _effect.EnableDefaultLighting();


            _texture               = Texture2D.Load(e.GraphicsDevice, "Modules/Scene/Resources/aima_1.png");
            _effect.Texture        = _texture;
            _effect.TextureEnabled = true;

            //var content = new SharpDX.Toolkit.Content.ContentManager(IoC.Get<IServiceProvider>());
            //content.Resolvers.Add(new FileSystemContentResolver("C:\\Users\\boris\\Documents\\stealthshifter\\Assets\\Models\\"));

            //var path = "C:\\Users\\boris\\Documents\\stealthshifter\\Assets\\Models\\assets.fbx";
            //var path = "Z:\\Общие Проекты\\monkey.x";
            //_model = content.Load<Model>("Z:\\Общие Проекты\\monkey.x");
            //_model = content.Load<Model>("assets.fbx");

            //_model = SharpDX.Toolkit.Graphics.Model.Load(e.GraphicsDevice, File.Open(path, FileMode.Open), name => _texture);

            _geometricPrimitives = new[]
            {
                GeometricPrimitive.Cube.New(e.GraphicsDevice),
                GeometricPrimitive.Cylinder.New(e.GraphicsDevice),
                GeometricPrimitive.GeoSphere.New(e.GraphicsDevice),
                GeometricPrimitive.Teapot.New(e.GraphicsDevice),
                GeometricPrimitive.Torus.New(e.GraphicsDevice),
                GeometricPrimitive.Plane.New(e.GraphicsDevice, 10f, 10f)
            };
            _primitiveIndex = 0;

            _yaw   = 0.5f;
            _pitch = 0.3f;
        }