Esempio n. 1
0
        /// <summary>
        /// Creates a new shadowmap resolver
        /// </summary>
        /// <param name="graphicsDevice">The Graphics Device used by the XNA game</param>
        /// <param name="quadRender"></param>
        /// <param name="baseSize">The size of the light regions </param>
        public ShadowmapResolver(GraphicsDevice graphicsDevice, QuadRenderComponent quadRender, ShadowmapSize maxShadowmapSize, ShadowmapSize maxDepthBufferSize)
        {
            this.graphicsDevice = graphicsDevice;
            this.quadRender     = quadRender;

            reductionChainCount = (int)maxShadowmapSize;
            baseSize            = 2 << reductionChainCount;
            depthBufferSize     = 2 << (int)maxDepthBufferSize;
        }
        /// <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
            quadRenderer = new QuadRenderComponent(graphicsDevice);

            Color[] whitePixel = { Color.White };
            nullTexture = new Texture2D(graphicsDevice, 1, 1);
            nullTexture.SetData <Color>(whitePixel);
        }
Esempio n. 3
0
        public override void Initialize(GraphicsDevice graphdev, Game game, params object[] param)
        {
            base.Initialize(graphdev, game);

            this.SQuadRender = new QuadRenderComponent(CoreGame);
            this.BloomRender = new BloomRenderComponent(CoreGame);

            var lvl = (LevelNames)param[0];

            LevelManager.Instance.Initialize();
            LevelManager.Instance.LoadLevel(lvl);

            this.WCore = new World(CoreGame, GraphDev.Viewport.Height, GraphDev.Viewport.Width, GraphDev.Viewport);
            this.WCore.Initialize();
        }
        /// <summary>
        /// Base renderer where custom RenderTasks derive from, with their
        /// own set of Scenes and render targets for inputs and outputs.
        /// </summary>

        public BaseShader(RenderProfile profile, ContentManager content)
        {
            hasSceneInput = true;
            this.content  = content;

            graphicsDevice = profile.graphicsDevice;

            renderStopWatch = new Stopwatch();
            renderInputs    = new Dictionary <string, RenderInput>();

            // Setup rendering components
            quadRenderer  = new QuadRenderComponent(graphicsDevice);
            sceneRenderer = new SceneRenderer(graphicsDevice, content);
            sceneCuller   = new SceneCuller();

            LoadContent();
        }
Esempio n. 5
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");
        }
Esempio n. 6
0
        public override void LoadContent()
        {
            // We add to the GameServices objects that we want to be able to use accross different classes
            // without having to pass them explicitly every time.
            GraphicsDevice = GameServices.GetService<GraphicsDevice>();
            Content = GameServices.GetService<ContentManager>();
            graphics = GameServices.GetService<GraphicsDeviceManager>();
            soundManager = GameServices.GetService<SoundManager>();

            ScreenManager.AddScreen(RankScreen, null, false);
            ScreenManager.AddScreen(PauseScreen, null, false);

            world = new World(new Vector2(0, 0));
            GameServices.AddService<World>(world);

            this.world.ContactManager.PostSolve += new PostSolveDelegate(PostSolve);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create a new track
            randomRaceTrack = RandomTrack.createTrack();

            randomRaceTrack.polygonList = polygonsList;

            int[] crucialPoints = { 300, 600, 1000 };
            Logic = new GameLogic(crucialPoints, randomRaceTrack.curvePointsMiddle.Count);

            randomRaceTrack.gameLogic = Logic;
            Logic.DidFinishLap += randomRaceTrack.ResetStickyNotes;

            mySneezesManager.randomTrack = randomRaceTrack;

            LoadPaperEffect();

            screenRenderer = new ScreenRenderer();
            GameServices.AddService<ScreenRenderer>(screenRenderer);
            Logic.DidEliminateCar += screenRenderer.setSadToPlayer;
            Logic.DidFinishLap += screenRenderer.setLap;

            for (int i = 0; i < 4; i++)
            {
                Car aCar = new Car(world, Content.Load<Texture2D>("Images/small_car"), Color.White, randomRaceTrack, i, playerIndexes[i]);
                Cars.Add(aCar);
            }

            assetCreator = new AssetCreator(graphics.GraphicsDevice);
            assetCreator.LoadContent(this.Content);

            defaultViewport = GraphicsDevice.Viewport;

            isFullHd=(ScreenManager.preferredHeight!=720);

            // Single screen mode only
            cameraFollowing = new Camera(defaultViewport, Vector2.Zero, new Vector2(defaultViewport.Width / 2, defaultViewport.Height / 2), 0.0f, Cars.Count, isFullHd);
            //ZOOM:

            //low res:
            //0.95 for 2 players
            //0.93 for 3 players
            //0.91 for 4 players

            //high res:
            //0.95 for 4 players

            GameServices.AddService<Camera>(cameraFollowing);

            mySneezesManager.camera = cameraFollowing;

            //generate starting positions and angles
            int startingPoint = 0;
               // positionCars(startingPoint);

            _debugView = new DebugViewXNA(world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactNormals);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Controllers);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            basicVert = new VertexPositionColorTexture[maxNumberOfTriangles];
            for (int i = 0; i < maxNumberOfTriangles; i++) basicVert[i].TextureCoordinate = new Vector2(-1);

            verticesBorders = new VertexPositionColorTexture[randomRaceTrack.curvePointsInternal.Count];

            fluid = new Fluid();
            fluid.Init();

            currentPoses = new Vector2[4];
            prevPoses = new Vector2[4];

            currentMousePos = new Vector2(100);
            prevMousePos = new Vector2(0);

            quad = new QuadRenderComponent(ScreenManager.Game, cameraFollowing, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            ScreenManager.Game.Components.Add(quad);

            fluidUpdateThread = new Thread(this.UpdateFluid);
            fluidUpdateThread.Start();

            mySneezesManager.fluid = fluid;

            fluidEffect = Content.Load<Effect>("Shaders/FluidEffect");
            fluidEffect.Parameters["random"].SetValue(randomTex);

            texInk = new Texture2D(graphics.GraphicsDevice,
                fluid.m_w, fluid.m_h, true,
                SurfaceFormat.Color);
            buffer = new RenderTarget2D(GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, true,
                SurfaceFormat.Color, GraphicsDevice.PresentationParameters.DepthStencilFormat);

            //gaussian = new GaussianBlur(ScreenManager.Game);
        }
Esempio n. 7
0
        static public void LoadContent()
        {
            //DEVICE STATES
            Content      = currentGame.Content;
            graphics     = currentGame.graphics;
            device       = graphics.GraphicsDevice;
            spriteBatch  = new SpriteBatch(device);
            windowWidth  = defaultWindowWidth;
            windowHeight = defaultWindowHeight;

            //ASSETS
            #region ASSETS
            //2D
            Consolas18  = Content.Load <SpriteFont>(@"GUI\Consolas18");
            Verdana8    = Content.Load <SpriteFont>(@"GUI\Verdana8");
            cursorImage = Content.Load <Texture2D>(@"GUI\cursor");
            placeholder = Content.Load <Texture2D>(@"GUI\nick");
            crosshairs  = Content.Load <Texture2D>(@"GUI\crosshairs");

            //3D
            quadRenderer     = new QuadRenderComponent(device);
            effect           = Content.Load <Effect>(@"World\Effects\effects");
            nullDiffuse      = Content.Load <Texture2D>(@"World\Models\null_c");
            nullNormal       = Content.Load <Texture2D>(@"World\Models\null_n");
            nullSpecular     = Content.Load <Texture2D>(@"World\Models\null_s");
            skyboxModel      = Content.Load <Model>(@"World\Models\skybox");
            zombieModel      = Content.Load <Model>(@"World\Models\zombie");
            zombieSceneModel = Content.Load <Model>(@"World\Models\zombieScene");
            zombieDiffuse    = Content.Load <Texture2D>(@"World\Models\zombie_c");
            zombieNormal     = Content.Load <Texture2D>(@"World\Models\zombie_n");
            groundDiffuse    = Content.Load <Texture2D>(@"World\Models\ground_c");
            groundNormal     = Content.Load <Texture2D>(@"World\Models\ground_n");
            groundSpecular   = Content.Load <Texture2D>(@"World\Models\ground_s");
            ship1Model       = Content.Load <Model>(@"World\Models\ship1");
            ship1Diffuse     = Content.Load <Texture2D>(@"World\Models\ship1_c");
            ship1Normal      = Content.Load <Texture2D>(@"World\Models\ship1_n");
            ship1Specular    = Content.Load <Texture2D>(@"World\Models\ship1_s");
            ship2Model       = Content.Load <Model>(@"World\Models\ship2");
            ship2Diffuse     = Content.Load <Texture2D>(@"World\Models\ship2_c");
            ship2Normal      = Content.Load <Texture2D>(@"World\Models\ship2_n");
            ship2Specular    = Content.Load <Texture2D>(@"World\Models\ship2_s");
            sphereModel      = Content.Load <Model>(@"World\Models\sphere");
            arrowHead        = Content.Load <Model>(@"World\Models\arrowHead");
            arrowShaft       = Content.Load <Model>(@"World\Models\arrowShaft");

            cameraModel = Content.Load <Model>(@"World\Models\camera");
            #endregion

            //EFFECTS
            #region EFFECTS
            blackImage = new Texture2D(device, screenWidth, screenHeight, false, SurfaceFormat.Color);
            halfPixel  = new Vector2
            {
                X = 0.5f / (float)device.PresentationParameters.BackBufferWidth,
                Y = 0.5f / (float)device.PresentationParameters.BackBufferHeight
            };
            //INPUT
            World              = effect.Parameters["xWorld"];
            ViewProjection     = effect.Parameters["xViewProjection"];
            InvViewProjection  = effect.Parameters["xInvViewProjection"];
            CameraPosition     = effect.Parameters["xCameraPosition"];
            ColorMap           = effect.Parameters["xColorMap"];
            NormalMap          = effect.Parameters["xNormalMap"];
            DepthMap           = effect.Parameters["xDepthMap"];
            SpecularMap        = effect.Parameters["xSpecularMap"];
            ShadowMap          = effect.Parameters["xShadowMap"];
            LightMap           = effect.Parameters["xLightMap"];
            PreviousLightMap   = effect.Parameters["xPreviousLightMap"];
            ReflectMap         = effect.Parameters["xReflectMap"];
            PreviousReflectMap = effect.Parameters["xPreviousReflectMap"];
            HalfPixel          = effect.Parameters["xHalfPixel"];
            HalfPixel.SetValue(halfPixel);
            //LIGHT
            LightColor                = effect.Parameters["xLightColor"];
            LightIntensity            = effect.Parameters["xLightIntensity"];
            LightSpecFactor           = effect.Parameters["xLightSpecFactor"];
            LightSpecPower            = effect.Parameters["xLightSpecPower"];
            LightPosition             = effect.Parameters["xLightPosition"];
            LightDirection            = effect.Parameters["xLightDirection"];
            LightAngle                = effect.Parameters["xLightAngle"];
            LightDecay                = effect.Parameters["xLightDecay"];
            LightRadius               = effect.Parameters["xLightRadius"];
            LightViewProjection       = effect.Parameters["xLightViewProjection"];
            LightAttenuationConstant  = effect.Parameters["xLightAttC"];
            LightAttenuationLinear    = effect.Parameters["xLightAttL"];
            LightAttenuationQuadratic = effect.Parameters["xLightAttQ"];
            //MATERIAL
            MaterialAmbient   = effect.Parameters["xMaterialAmbient"];
            MaterialColor     = effect.Parameters["xMaterialColor"];
            MaterialDiffuse   = effect.Parameters["xMaterialDiffuse"];
            MaterialShininess = effect.Parameters["xMaterialShininess"];
            MaterialMatte     = effect.Parameters["xMaterialMatte"];
            //TECHNIQUES
            Texture      = effect.Techniques["Texture"];
            Scene        = effect.Techniques["Scene"];
            Ambient      = effect.Techniques["Ambient"];
            Directional  = effect.Techniques["Directional"];
            Point        = effect.Techniques["Point"];
            Spot         = effect.Techniques["Spot"];
            Spot2        = effect.Techniques["Spot2"];
            Shadow       = effect.Techniques["Shadow"];
            Final        = effect.Techniques["Final"];
            NoTexture    = effect.Techniques["NoTexture"];
            Basic        = effect.Techniques["BasicNoTexture"];
            TextureBlend = effect.Techniques["TextureBlend"];
            Black        = effect.Techniques["Black"];
            //RENDER TARGETS
            colorTarget       = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            normalTarget      = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            specularTarget    = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            depthTarget       = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Single, DepthFormat.Depth24);
            shadowTarget      = new RenderTarget2D(device, windowWidth * 2, windowHeight * 2, false, SurfaceFormat.Single, DepthFormat.Depth24);
            lightTarget       = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            prevLightTarget   = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            reflectTarget     = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            prevReflectTarget = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            debugTarget       = new RenderTarget2D(device, windowWidth, windowHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            #endregion
        }