Example #1
0
        public Player(CompositeModel model, Camera camera, Controller controller)
            : base(model)
        {
            this.damage = 0;

            this.cam = camera;
            this.controller = controller;

            this.wizXZ = Vector2.Zero;
            this.wizXZvel = Vector2.Zero;

            this.wizVel = 0f;
            this.wizFloat = true;

            this.power = 1f;
            this.charging = false;

            this.color = this.model.CustomColor;

            bearing = 0;

            this.model.addCollisionCylinder(6.1f, 1f, Vector3.Up * 3.05f);
            this.model.addBoundingCylinder(6.1f, 1f, Vector3.Up * 3.05f);
        }
Example #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //*/
            renderMaster.changeRenderList("_master");

            Camera[] cams = new Camera[4];

            cams[0] = playerOne.Cam;
            cams[1] = playerTwo.Cam;
            cams[2] = playerThree.Cam;
            cams[3] = playerFour.Cam;

            //some hacky code to change render during runtime, ignores the nice classes for input I made =(

            KeyboardState hackKeyboard = Keyboard.GetState();

            bool hackPP = true;
            int hackTar = 0;

            if (hackKeyboard.IsKeyDown(Keys.NumPad0))
            {
                hackPP = false;
            }
            if (hackKeyboard.IsKeyDown(Keys.NumPad1))
            {
                hackTar = -1; hackPP = false;
            }
            if (hackKeyboard.IsKeyDown(Keys.NumPad2))
            {
                hackTar = 1; hackPP = false;
            }

            renderMaster.render(cams, hackPP, hackTar);

            base.Draw(gameTime);
        }
Example #3
0
        //kinda hacky int input for the target, we'll say negative is depth, positive is normal, and 0 is toon
        public void render(Camera[] cam, bool postProcess, int target)
        {
            //for each screen to render
            for (int i = 0; i < (int)screenSplit; i++)
            {
                //render three times per viewport, for normal, depth, and toon-shading
                DrawModel(cam[i], normalRenderTarget[i], "Normal", Color.Transparent);
                DrawModel(cam[i], depthRenderTarget[i], "Depth", Color.Transparent);
                DrawModel(cam[i], toonRenderTarget[i], "Toon", Color.CornflowerBlue);
            }

            //this draws the sky (null output will render to screen)
            this.graphicsDevice.SetRenderTarget(null);
            this.graphicsDevice.Clear(Color.Cornsilk);

            Vector2 resolution = new Vector2(screenRect[0].Width, screenRect[0].Height);

            sobelEffect.Parameters["ScreenResolution"].SetValue(resolution);
            sobelEffect.CurrentTechnique = sobelEffect.Techniques["EdgeDetect"];

            //this begins the spritebatch(xna thing to batch textured planes for easier 2d rendering)
            if (postProcess)
            {
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
                    SamplerState.LinearClamp, DepthStencilState.Default,
                    RasterizerState.CullNone, sobelEffect);//with the effect
            }
            else
            {
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
                    SamplerState.LinearClamp, DepthStencilState.Default,
                    RasterizerState.CullNone, null);//without
            }

            //draw the target
            for (int i = 0; i < (int)screenSplit; i++)
            {
                sobelEffect.Parameters["NormalTexture"].SetValue(normalRenderTarget[i]);
                sobelEffect.Parameters["DepthTexture"].SetValue(depthRenderTarget[i]);
                sobelEffect.Parameters["SceneTexture"].SetValue(toonRenderTarget[i]);

                // here we cheat to allow the user to control output, the user can specify which render to draw.
                // The post processing can occur over any render if necessary, but will always be the same as it always
                // has the normal and depth textures as its parameters for normal and depth texture
                // although changing this could allow me to pass in a blank texture as a parameter to see the contributions
                // of the normal and depth map. (Every feature I add gives me 10 new ideas)
                if (target < 0)
                {
                    spriteBatch.Draw((Texture2D)depthRenderTarget[i], screenRect[i], Color.White);
                }
                else if (target > 0)
                {
                    spriteBatch.Draw((Texture2D)normalRenderTarget[i], screenRect[i], Color.White);
                }
                else
                {
                    spriteBatch.Draw((Texture2D)toonRenderTarget[i], screenRect[i], Color.White);
                }

            }

            spriteBatch.End();
        }
Example #4
0
        //poor name, this actually draws the list of models, from the perspective of a camera, to a certain render target, with a certain technique
        public void DrawModel(Camera camera, RenderTarget2D renderTarget, String techniqueName, Color bgColor)
        {
            graphicsDevice.SetRenderTarget(renderTarget);
            graphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };

            this.graphicsDevice.Clear(bgColor);

            //This big nasty iteration just goes over each of the models, their meshes and the effects to render them. It's the XNA way!
            foreach (CompositeModel model in currentList)
            {

                foreach (ModelMesh mesh in model.Meshes)
                {
                        foreach (Effect eff in mesh.Effects)
                        {
                            eff.CurrentTechnique = eff.Techniques[techniqueName];

                            Matrix World = model.getWorld();

                            eff.Parameters["World"].SetValue(World);
                            eff.Parameters["View"].SetValue(camera.getView());
                            eff.Parameters["Projection"].SetValue(camera.getProjection());

                            eff.Parameters["WorldInverseTranspose"].SetValueTranspose(Matrix.Invert(World));

                            eff.Parameters["Bounds"].SetValue(bounds);

                            //Oh yes, any transparent texture will take a custom color.
                            eff.Parameters["PlayerColor"].SetValue(model.CustomColor.ToVector4());

                            eff.CurrentTechnique.Passes[0].Apply();

                        }
                   //after all the effects are applied, we draw. I should batch up some geometry and do this less so I can render more.
                   mesh.Draw();
                }
            }
        }