public InstancedModelDrawer(Game game) : base(game) { #if WINDOWS var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.WindowsPhysicsResources.ResourceManager); #elif XBOX360 var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.Xbox360PhysicsResources.ResourceManager); #else ResourceContentManager resourceContentManager = null; #endif instancingEffect = resourceContentManager.Load <Effect>("InstancedEffect"); worldTransformsParameter = instancingEffect.Parameters["WorldTransforms"]; textureIndicesParameter = instancingEffect.Parameters["TextureIndices"]; viewParameter = instancingEffect.Parameters["View"]; projectionParameter = instancingEffect.Parameters["Projection"]; instancingEffect.Parameters["LightDirection1"].SetValue(Vector3.Normalize(new Vector3(.8f, -1.5f, -1.2f))); instancingEffect.Parameters["DiffuseColor1"].SetValue(new Vector3(.66f, .66f, .66f)); instancingEffect.Parameters["LightDirection2"].SetValue(Vector3.Normalize(new Vector3(-.8f, 1.5f, 1.2f))); instancingEffect.Parameters["DiffuseColor2"].SetValue(new Vector3(.3f, .3f, .5f)); instancingEffect.Parameters["AmbientAmount"].SetValue(.5f); instancingEffect.Parameters["Texture0"].SetValue(textures[0]); instancingEffect.Parameters["Texture1"].SetValue(textures[1]); instancingEffect.Parameters["Texture2"].SetValue(textures[2]); instancingEffect.Parameters["Texture3"].SetValue(textures[3]); instancingEffect.Parameters["Texture4"].SetValue(textures[4]); instancingEffect.Parameters["Texture5"].SetValue(textures[5]); instancingEffect.Parameters["Texture6"].SetValue(textures[6]); instancingEffect.Parameters["Texture7"].SetValue(textures[7]); //This vertex declaration could be compressed or made more efficient, but such optimizations weren't critical. instancingVertexDeclaration = new VertexDeclaration(new[] { new VertexElement(0, VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1) }); }
public ModelMD5(Game game, MD5Mesh meshFile) { ResourceContentManager rm = new ResourceContentManager(game.Services, XNAQ3Lib.MD5.Resources.MD5Resources.ResourceManager); mesh = meshFile; graphicsDevice = game.GraphicsDevice; animationController = new MD5AnimationController(mesh.Hierarchy); UseMaximumBounds = true; modelEffect = rm.Load <Effect>("SkinnedModelEffect"); boundingBoxEffect = rm.Load <Effect>("BoundingBoxEffect"); vertices = new MD5VertexFormat[mesh.Submeshes.Length][]; indices = new short[mesh.Submeshes.Length][]; MD5Logger logger = new MD5Logger(game.Content.RootDirectory + "\\" + meshFile.Filename + ".txt"); for (int i = 0; i < mesh.Submeshes.Length; i++) { vertices[i] = new MD5VertexFormat[mesh.Submeshes[i].Vertices.Length]; if (System.IO.File.Exists(game.Content.RootDirectory + @"\" + mesh.Submeshes[i].Shader + ".xnb")) { mesh.Submeshes[i].Texture = game.Content.Load <Texture2D>(mesh.Submeshes[i].Shader); } else { logger.WriteLine("Missing texture: " + mesh.Submeshes[i].Shader); } } SetIndices(); SetVertices(); SetBoundingBoxVerticesAndIndices(graphicsDevice); }
private void InitializeGFX(IGraphicsDeviceService graphics) { services = new GameServiceContainer(); services.AddService <IGraphicsDeviceService>(graphics); this.graphics = graphics.GraphicsDevice; Content = new ContentManager(services, "Content"); spriteBatch = new SpriteBatch(graphics.GraphicsDevice); Pixel = new Texture2D(graphics.GraphicsDevice, 1, 1); Pixel.SetData(new[] { Color.White }); Format = new System.Globalization.NumberFormatInfo(); Format.CurrencyDecimalSeparator = "."; Cam = new Camera2D(); Cam.Position = new Vector2( graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); #if DX InternContent = new ResourceContentManager(services, DX.Properties.Resources.ResourceManager); GetRenderTargetManager = new RenderTargetManager(this); AntialisingRenderTarget = GetRenderTargetManager.CreateNewRenderTarget2D("MSAA", true); RenderTargetTimer = new Timer(); RenderTargetTimer.Interval = 500; RenderTargetTimer.Elapsed += (sender, e) => OnRenderTargetTimeOutEnd(); #elif GL InternContent = new ResourceContentManager(services, GL.Properties.Resources.ResourceManager); #endif Font = InternContent.Load <SpriteFont>("Font"); FontHeight = Font.MeasureString("A").Y; FrameworkDispatcher.Update(); }
/// <summary>Initializes a new gui visualizer from a skin stored as a resource</summary> /// <param name="serviceProvider"> /// Game service provider containing the graphics device service /// </param> /// <param name="resourceManager"> /// Resource manager containing the resources used in the skin /// </param> /// <param name="skinResource"> /// Name of the resource containing the skin description /// </param> public static FlatGuiVisualizer FromResource( IServiceProvider serviceProvider, ResourceManager resourceManager, string skinResource ) { byte[] resourceData = (byte[])resourceManager.GetObject(skinResource); if (resourceData == null) { throw new ArgumentException( "Resource '" + skinResource + "' not found", "skinResource" ); } // This sucks! I cannot use ResourceManager.GetStream() on a resource that's // stored as a byte array! using ( MemoryStream skinStream = new MemoryStream(resourceData, false) ) { ResourceContentManager contentManager = new ResourceContentManager( serviceProvider, resourceManager ); try { return(new FlatGuiVisualizer(contentManager, skinStream)); } catch (Exception) { contentManager.Dispose(); throw; } } }
public InstancedModelDrawer(Game game) : base(game) { var resourceContentManager = new ResourceContentManager(game.Services, DrawerResource.ResourceManager); #if WINDOWS instancingEffect = resourceContentManager.Load <Effect>("InstancedEffect"); #else instancingEffect = resourceContentManager.Load <Effect>("InstancedEffectXbox"); #endif //instancingEffect = game.Content.Load<Effect>("InstancedEffect"); worldTransformsParameter = instancingEffect.Parameters["WorldTransforms"]; textureIndicesParameter = instancingEffect.Parameters["TextureIndices"]; viewParameter = instancingEffect.Parameters["View"]; projectionParameter = instancingEffect.Parameters["Projection"]; instancingEffect.Parameters["LightDirection1"].SetValue(Vector3.Normalize(new Vector3(.8f, -1.5f, -1.2f))); instancingEffect.Parameters["DiffuseColor1"].SetValue(new Vector3(.66f, .66f, .66f)); instancingEffect.Parameters["LightDirection2"].SetValue(Vector3.Normalize(new Vector3(-.8f, 1.5f, 1.2f))); instancingEffect.Parameters["DiffuseColor2"].SetValue(new Vector3(.3f, .3f, .5f)); instancingEffect.Parameters["AmbientAmount"].SetValue(.5f); instancingEffect.Parameters["Colors"].SetValue(colors); }
/// <summary>Creates a new solid color screen mask</summary> /// <param name="graphicsDevice"> /// Graphics device the screen mask will be draw with /// </param> /// <param name="createDelegate"> /// Factory method that will be used to instantiate the mask /// </param> /// <returns>The newly created solid color screen mask</returns> internal static ColorScreenMask Create( GraphicsDevice graphicsDevice, CreateDelegate createDelegate ) { // Fake up a service provider with a graphics device service so we can // create a content manager without the huge rat-tail of references IServiceProvider serviceProvider; serviceProvider = GraphicsDeviceServiceHelper.MakePrivateServiceProvider( GraphicsDeviceServiceHelper.MakeDummyGraphicsDeviceService(graphicsDevice) ); // Create a resource content manager to load the default effect and hand // everything to the new screen mask instance, which will then be responsible // for freeing those resources again. ResourceContentManager contentManager = new ResourceContentManager( serviceProvider, Resources.ScreenMaskResources.ResourceManager ); try { Effect effect = contentManager.Load <Effect>("ScreenMaskEffect"); try { return(createDelegate(graphicsDevice, contentManager, effect)); } catch (Exception) { effect.Dispose(); throw; } } catch (Exception) { contentManager.Dispose(); throw; } }
/// <summary> /// Initializes the services. /// </summary> private void InitializeServices(GameServiceContainer services) { AlmiranteEngine.ResourceContents = new ResourceContentManager(services, "Content"); services.AddService(typeof(ResourceContentManager), AlmiranteEngine.ResourceContents); AlmiranteEngine.Time = new TimeManager(); services.AddService(typeof(TimeManager), AlmiranteEngine.Time); AlmiranteEngine.Camera = new CameraManager(); services.AddService(typeof(CameraManager), AlmiranteEngine.Camera); AlmiranteEngine.Audio = new AudioManager(); services.AddService(typeof(AudioManager), AlmiranteEngine.Audio); if (!windows) { AlmiranteEngine.DeviceManager = new GraphicsDeviceManager(Application); services.AddService(typeof(GraphicsDeviceManager), AlmiranteEngine.DeviceManager); } AlmiranteEngine.Settings = new Settings(); services.AddService(typeof(Settings), AlmiranteEngine.Settings); AlmiranteEngine.Resources = new ResourceManager(AlmiranteEngine.ResourceContents); services.AddService(typeof(ResourceManager), AlmiranteEngine.Resources); AlmiranteEngine.Input = new InputManager(); services.AddService(typeof(InputManager), AlmiranteEngine.Input); AlmiranteEngine.Scenes = new SceneManager(); services.AddService(typeof(SceneManager), AlmiranteEngine.Scenes); this.InitializeExports(); }
public static void Initialise(IServiceProvider services) { #if WINDOWS manager = new ResourceContentManager(services, x86Resources.ResourceManager); #else manager = new ResourceContentManager(services, XboxResources.ResourceManager); #endif }
internal static void Init() { myResourceManager = new ResourceContentManager(MonuxServices, Resources.ResourceManager); PrimitiveEffect = myResourceManager.Load <Effect> ("WINDX_PrimitiveEffect"); DebugFont = myResourceManager.Load <SpriteFont>("WINDX_FONT_Debug"); DefaultFont = myResourceManager.Load <SpriteFont>("WINDX_FONT_Default"); DefaultCursor = myResourceManager.Load <Texture2D> ("WINDX_TEX_DefaultCursor"); }
public GammaCorrectionPostProcessor() { _brightness = 0.2f; #if WINDOWS var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, WindowsPostProcessResources.ResourceManager); #else var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, Xbox360PostProcessResources.ResourceManager); #endif _gammaCorrectEffect = shaderResources.Load <Effect>("GammaCorrect"); }
public DeltaGame(Rectangle screenArea) : base() { #if DEBUG IsMouseVisible = true; Window.AllowUserResizing = true; #endif _embedded = new ResourceContentManager(Services, EmbeddedContent.ResourceManager); base.Content.RootDirectory = "Content"; G.Setup(this, screenArea); }
public ColorCorrectionProcessor() { _viewport = SunBurnCoreSystem.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport; #if WINDOWS var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, WindowsPostProcessResources.ResourceManager); #else var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, Xbox360PostProcessResources.ResourceManager); #endif _colorCorrectEffect = shaderResources.Load <Effect>("PostColorCorrect"); }
protected override void LoadContent() { _batch = new SpriteBatch(GraphicsDevice); #if WINDOWS var resourceContentManager = new ResourceContentManager(Services, Resources.WindowsCoreResources.ResourceManager); #elif XBOX var resourceContentManager = new ResourceContentManager(Services, Resources.Xbox360CoreResources.ResourceManager); #endif _font = resourceContentManager.Load <SpriteFont>("DebugFont"); }
protected override void LoadContent() { Content = new ResourceContentManager(Services, Properties.Resources.ResourceManager); base.LoadContent(); State = new State(GraphicsDevice, path + "\\"); Effect = new BasicEffect(GraphicsDevice); var block = State.Blocks.Records[0].Archive; var models = State.Models; Font = Content.Load <SpriteFont>("UIFont"); Batch = new SpriteBatch(GraphicsDevice); manager.IsFullScreen = StartFullScreen; }
protected override void Initialize() { debugObjects = new Dictionary <string, object>(); debugValues = new Dictionary <string, float>(); debugStrings = new List <string>(); ContentManager content = new ResourceContentManager(services, Resource.ResourceManager); DebugFont = content.Load <SpriteFont>("DebugFont"); DebugPos = new Vector2(15, 15); DebugColor = Color.Yellow; FPSCounter = new FPSCounter(DebugPos, DebugFont, DebugColor); }
public override void ChangePrimitive(Primitive primitive) { // Load sphere and apply effect to sphere. ResourceContentManager resourceContentManager = new ResourceContentManager(_serviceProvider, Resources.ResourceManager); Model model = resourceContentManager.Load <Model>(primitive.ToString()); foreach (ModelMesh mesh in model.Meshes) { foreach (ModelMeshPart meshPart in mesh.MeshParts) { meshPart.Effect = _effect; } } Model = model; }
public PrimitiveBatch(GraphicsDevice graphicsDevice, IServiceProvider services, Viewport viewport, int bufferSize) { if (graphicsDevice == null) { throw new ArgumentNullException("graphicsDevice"); } _graphicsDevice = graphicsDevice; ResourceContentManager content = new ResourceContentManager(services, Resources.ResourceManager); LoadEffect(content.Load <Effect>("PrimitiveEffect")); CreateRasterizerState(); }
/// <summary> /// Constructor without a default scene /// </summary> public Core(IServiceProvider services) : base(services) { content = new ContentManager(services, "MeteorEngine.Content"); resxContent = new ResourceContentManager(services, MeteorContentResource.ResourceManager); renderStats = new RenderStats(); currentRenderProfile = null; renderProfiles = new List <RenderProfile>(); debugString = new StringBuilder(64, 64); // Setup rendering components cameras = new List <Camera>(); scenes = new List <Scene>(); }
protected override void Initialize() { Content = new ContentManager(this.Services, "Content"); DefaultResourceContent = new ResourceContentManager(Services, DefaultResources.ResourceManager); base.Initialize(); Defaults.Initialize(); Input.Input.Initialize(); DebugDraw.Initialize(Graphics.GraphicsDevice); FlatEarth.Window.Initialize(Window); Resolution.Set(1280, 1024, false); Resolution.SetVirtual(800, 800); Renderer = new Renderer(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ResourceContentManager Content = new ResourceContentManager(this.Services, Resource1.ResourceManager); //Font1 = content1.Load<SpriteFont>("Arial"); Font1 = Content.Load <SpriteFont>("Arial"); // TODO: use this.Content to load your game content here FontPos = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); }
public LightRenderer( ) { _game = ObjectFactory.GetInstance <IGame>( ); var content = new ResourceContentManager(((Game)_game).Services, Resource1.ResourceManager); var effect = content.Load <Effect>(@"KryptonEffect"); _krypton = new KryptonEngine((Game)_game, effect); _krypton.Initialize( ); IoC.Model.ItemsAddedOrRemoved += (s, e) => rebuild( ); IoC.Model.ItemChanged += (s, e) => rebuild( ); IoC.Model.NewModelLoaded += (s, e) => rebuild( ); }
public void TestVectorFontReading() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { using ( ResourceContentManager contentManager = new ResourceContentManager( GraphicsDeviceServiceHelper.MakePrivateServiceProvider(service), Resources.UnitTestResources.ResourceManager ) ) { VectorFont font = contentManager.Load <VectorFont>("UnitTestVectorFont"); Assert.IsNotNull(font); } } }
public override void Initialize(IServiceProvider serviceProvider, GraphicsDevice graphicsDevice) { ResourceContentManager contentManager = new ResourceContentManager(serviceProvider, Resources.ResourceManager); BasicEffect basicEffect = new BasicEffect(graphicsDevice); basicEffect.VertexColorEnabled = false; basicEffect.LightingEnabled = false; basicEffect.TextureEnabled = true; basicEffect.Texture = contentManager.Load <Texture2D>("CubeTexture"); basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(1, 1, 1, 10); basicEffect.View = Matrix.CreateLookAt(Vector3.Backward * 2, Vector3.Zero, Vector3.Up); _effect = basicEffect; CreateCube(graphicsDevice, 1); }
public GameConsole(Game game, SpriteBatch spriteBatch, IEnumerable <IConsoleCommand> commands, GameConsoleOptions options) { var content = new ResourceContentManager(game.Services, Resource1.ResourceManager); if (options.Font == null) { options.Font = content.Load <SpriteFont>("ConsoleFont"); } options.RoundedCorner = content.Load <Texture2D>("roundedCorner"); GameConsoleOptions.Options = options; GameConsoleOptions.Commands = commands.ToList(); Enabled = true; console = new GameConsoleComponent(this, game, spriteBatch); game.Services.AddService(typeof(GameConsole), this); game.Components.Add(console); }
/// <summary> /// Loads a SpriteFont from an embedded resource. /// </summary> /// <returns></returns> public static SpriteFont LoadFont(ResourceManager manager, string fontName) { // Grab the current content manager. var oldManager = GameBase.Game.Content; // Set the new content manager. var resxContent = new ResourceContentManager(GameBase.Game.Services, manager); GameBase.Game.Content = resxContent; // Load up the font. var font = GameBase.Game.Content.Load <SpriteFont>(fontName); // Reset the content manager back to what it was. GameBase.Game.Content = oldManager; return(font); }
/// <summary> /// Constructor without a default scene /// </summary> public Core(GameServiceContainer services) : base(services) { #if XNA content = new ResourceContentManager(services, MeteorContentResource.ResourceManager); #elif MONOGAME content = new ContentManager(services, "MeteorEngine.Content"); #endif renderStats = new RenderStats(); currentRenderProfile = null; renderProfiles = new List <RenderProfile>(); debugString = new StringBuilder(64, 64); // Setup rendering components cameras = new List <Camera>(); scenes = new Dictionary <String, Scene>(); }
public Game1() { graphics = new GraphicsDeviceManager(this); //Content.RootDirectory = "Content"; Content = new ResourceContentManager(this.Services, MyResources.ResourceManager); graphics.PreferredBackBufferWidth = STAGE_WIDTH; graphics.PreferredBackBufferHeight = STAGE_HEIGHT; int x = 0; int y = 0; // this is for our bit map font char[] charArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', ' ', '©', '□', ':', '/', '@', '#', '*', '!', '$', '^', '(', ')' }; FONT_FRAMES = new Dictionary <char, Rectangle>(50); for (int i = 0; i < 5; i++) { for (int j = 0; j < 10; j++) { FONT_FRAMES.Add(charArr[i * 10 + j], new Rectangle(x, y, ActionScene.UNIT, ActionScene.UNIT)); x += ActionScene.UNIT; } x = 0; y += ActionScene.UNIT; } //graphics.IsFullScreen = true; }
// Dof Focus /// <summary> /// Creates a BaseRenderTargetPostProcessor instance. /// </summary> public DepthOfFieldPostProcessor() { FarClip = 140f; FocalWidth = 50f; FocalDistance = 60f; Attenuation = 0.5f; BlurRadius = 2; BlurAmount = 0.5f; _viewport = SunBurnCoreSystem.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport; #if WINDOWS var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, WindowsPostProcessResources.ResourceManager); #else var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, Xbox360PostProcessResources.ResourceManager); #endif _blurEffect = shaderResources.Load <Effect>("GaussianBlur"); _dofEffect = shaderResources.Load <Effect>("DepthOfField"); ComputeKernel(_blurRadius, _blurAmount); ComputeOffsets(_viewport.Width, _viewport.Height); }
protected override TreeProfile Read(ContentReader input, TreeProfile existingInstance) { // brace yourself for the simple and intuitive way of retrieving the graphics device IGraphicsDeviceService deviceService = input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService; GraphicsDevice device = deviceService.GraphicsDevice; cnt = new ResourceContentManager(input.ContentManager.ServiceProvider, Resource1.ResourceManager); if (existingInstance == null) { existingInstance = new TreeProfile(device); } ContentManager content = input.ContentManager; existingInstance.Generator = ReadGenerator(input); existingInstance.TrunkTexture = content.Load <Texture2D>(input.ReadString()); existingInstance.LeafTexture = content.Load <Texture2D>(input.ReadString()); string trunkEffect = input.ReadString(); string leafEffect = input.ReadString(); if (trunkEffect == "") { trunkEffect = DefaultTreeShaderAssetName; } if (leafEffect == "") { leafEffect = DefaultLeafShaderAssetName; } existingInstance.TrunkEffect = cnt.Load <Effect>(trunkEffect); existingInstance.LeafEffect = cnt.Load <Effect>(leafEffect); return(existingInstance); }
public BloomPostProcessor() { BlurRadius = 7; BlurAmount = 1f; BloomThreshold = 0.5f; BloomIntensity = 1.5f; BaseIntensity = 1; BloomSaturation = 2.5f; BaseSaturation = 1; _viewport = SunBurnCoreSystem.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport; #if WINDOWS var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, WindowsPostProcessResources.ResourceManager); #else var shaderResources = new ResourceContentManager(SunBurnCoreSystem.Instance.Services, Xbox360PostProcessResources.ResourceManager); #endif _gaussianBlurEffect = shaderResources.Load <Effect>("GaussianBlur"); _bloomExtractEffect = shaderResources.Load <Effect>("BloomExtract"); _bloomCombineEffect = shaderResources.Load <Effect>("BloomCombine"); ComputeKernel(_blurRadius, _blurAmount); ComputeOffsets(_viewport.Width, _viewport.Height); }
/// <summary> /// Initializes the services. /// </summary> private void InitializeServices(GameServiceContainer services) { ResourceContents = new ResourceContentManager(services, "Content"); services.AddService(typeof (ResourceContentManager), ResourceContents); Time = new TimeManager(); services.AddService(typeof (TimeManager), Time); Camera = new CameraManager(); services.AddService(typeof (CameraManager), Camera); Audio = new AudioManager(); services.AddService(typeof (AudioManager), Audio); if (!windows) { DeviceManager = new GraphicsDeviceManager(Application); services.AddService(typeof (GraphicsDeviceManager), DeviceManager); } Settings = new Settings(); services.AddService(typeof (Settings), Settings); Resources = new ResourceManager(ResourceContents); services.AddService(typeof (ResourceManager), Resources); Input = new InputManager(); services.AddService(typeof (InputManager), Input); Scenes = new SceneManager(); services.AddService(typeof (SceneManager), Scenes); InitializeExports(); }