Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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");
        }
Exemplo n.º 4
0
        /// <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;
            }
        }
Exemplo n.º 5
0
        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) });
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        protected override void LoadContent()
        {
            // Load debug font
            font = resxContent.Load <SpriteFont>("defaultFont");

            // Miscellaneous stuff
            spriteBatch = new SpriteBatch(graphicsDevice);

            targetWidth  = graphicsDevice.Viewport.Width;
            targetHeight = graphicsDevice.Viewport.Height;

            // Load up all available render profiles
            sceneRenderer = new SceneRenderComponent(graphicsDevice, resxContent);
            quadRenderer  = new QuadRenderComponent(graphicsDevice);

            nullTexture = resxContent.Load <Texture2D>("null_color");
        }
Exemplo n.º 9
0
        public static T Load <T>(string resource)
        {
            if (manager == null)
            {
                throw new Exception("Myre.Graphics.Content.Initialise() must be called before Myre.Graphics can load its' resources.");
            }

            return(manager.Load <T>(resource));
        }
Exemplo n.º 10
0
        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");
        }
        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");
        }
Exemplo n.º 12
0
        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");
        }
Exemplo n.º 13
0
        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;
        }
Exemplo n.º 14
0
        // 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);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Load debug resources used by the high-level renderer
        /// </summary>

        protected override void LoadContent()
        {
            // Load debug resources
            font        = content.Load <SpriteFont>("defaultFont");
            spriteBatch = new SpriteBatch(graphicsDevice);

            // Load up all resource renderers
            sceneRenderer = new SceneRenderer(graphicsDevice, content);
            quadRenderer  = new QuadRenderComponent(graphicsDevice);

            Color[] whitePixel = { Color.White };
            nullTexture = new Texture2D(graphicsDevice, 1, 1);
            nullTexture.SetData <Color>(whitePixel);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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();
        }
Exemplo n.º 18
0
        /// <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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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;
        }
        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);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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( );
        }
Exemplo n.º 24
0
        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);
                }
            }
        }
Exemplo n.º 25
0
 protected override void LoadContent()
 {
     Content = new ResourceContentManager(Services, Resources.ResourceManager);
     base.LoadContent();
     m_font = Content.Load <SpriteFont>("SansSerifBold");
 }
Exemplo n.º 26
0
        public override void Initialize()
        {
            StreamingManager.StopSpectating(false);

            content = new ResourceContentManager(GameBase.Instance.Services, ResourcesStore.ResourceManager);

            spriteManager = new SpriteManager();

            BanchoClient.OnConnect      += BanchoClient_OnConnect;
            KeyboardHandler.OnKeyRepeat += KeyboardHandler_OnKeyRepeat;

            pText headerText =
                new pText("Multiplayer Lobby", 30, new Vector2(0, 0), 0.955F, true, new Color(255, 255, 255, 255));

            spriteManager.Add(headerText);

            pText headerText2 = new pText("Let's play together!", 16, new Vector2(4, 26), 0.955F, true,
                                          new Color(255, 255, 255, 255));

            spriteManager.Add(headerText2);

            pSprite bgf =
                new pSprite(content.Load <Texture2D>("lobby-background"), FieldTypes.Window, OriginTypes.TopLeft,
                            ClockTypes.Game, Vector2.Zero, 0, true, Color.White);

            spriteManager.Add(bgf);

            pAnimation back =
                new pAnimation(SkinManager.LoadAll("menu-back"), FieldTypes.Window,
                               OriginTypes.TopLeft,
                               ClockTypes.Game,
                               new Vector2(0, 480), 0.8F, true, new Color(255, 255, 255, (byte)(255 * 0.6)));

            back.SetFramerateFromSkin();
            back.OriginPosition = new Vector2(0, 146);
            back.OnClick       += back_OnClick;
            back.IsClickable    = true;
            back.HoverEffect    = new Transformation(TransformationType.Fade, 0.6F, 1, 0, 300);
            spriteManager.Add(back);

            pButton pbut = new pButton("New Game", new Vector2(270, 285), new Vector2(350, 30), 0.92f, new Color(99, 139, 228), OnCreateGame);

            spriteManager.Add(pbut.SpriteCollection);

            //pbut = new pButton("Join Game", new Vector2(270, 285), new Vector2(140, 30), 0.92f, new Color(99, 139, 228), OnCreateGame);
            //spriteManager.Add(pbut.SpriteCollection);

            pbut = new pButton("Back to Menu", new Vector2(10, 285), new Vector2(250, 30), 0.92f, new Color(235, 160, 62), back_OnClick);
            spriteManager.Add(pbut.SpriteCollection);

            lobbyUserList =
                new pText("", 12, new Vector2(560, 65), 1, true, Color.White);
            lobbyUserList.TextBold = true;
            spriteManager.Add(lobbyUserList);

            noMatches               = new pText("There are no matches available.\nClick 'New Game' to start a new game!", 20, new Vector2(280, 115), new Vector2(400, 0), 1, true, Color.White, false);
            noMatches.TextBold      = true;
            noMatches.CurrentColour = Color.TransparentWhite;
            noMatches.TextAlignment = Alignment.Centre;
            noMatches.OriginType    = OriginTypes.Centre;
            gameList.spriteManager.Add(noMatches);

            base.Initialize();

            JoinLobby();

            LobbyUpdatePending = true;

            GameBase.LoadComplete();

            if (!ChatEngine.IsVisible)
            {
                if (ChatEngine.IsFullVisible)
                {
                    ChatEngine.ToggleFull();
                }
                ChatEngine.Toggle();
            }
        }