Exemplo n.º 1
0
        public void drawSquarre(VertexPositionNormalTexture[] vertexData, int[] indexData, Camera came, BasicEffect effect, GraphicsDevice graphicsDevice)
        {
            Texture2D texture = Tools.Quick.groundTexture[BiomeType.SubtropicalDesert];
            effect.Projection = projectionMatrix;
            effect.Texture = texture;
            effect.TextureEnabled = true; ;

            graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
            graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

            //   effect.DiffuseColor = Color.Red.ToVector3();
            effect.CurrentTechnique.Passes[0].Apply();

            effect.View = came.getview();
            effect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);

            /*  // Draw wireframe box
              graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;    // draw in wireframe
              graphicsDevice.BlendState = BlendState.Opaque;                  // no alpha this time

              effect.TextureEnabled = false;
             // effect.DiffuseColor = Color.Black.ToVector3();
              effect.CurrentTechnique.Passes[0].Apply();

              graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
                 */
        }
Exemplo n.º 2
0
        public void drawBigbuffer(DrawabeElement element, int[] index, Camera came, GraphicsDevice graphicsDevice, bool trans)
        {
            WIREFRAME_RASTERIZER_STATE = new RasterizerState() { CullMode = CullMode.CullClockwiseFace, FillMode = FillMode.Solid };

            graphicsDevice.RasterizerState = WIREFRAME_RASTERIZER_STATE;

            // draw in wireframe

            if (trans)
            {
                graphicsDevice.BlendState = BlendState.AlphaBlend;

            }
            else
            {
                graphicsDevice.BlendState = BlendState.Opaque;
            }

            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            //   effect.DiffuseColor = Color.Red.ToVector3();
            element.effect.View = came.getview();
            element.effect.CurrentTechnique.Passes[0].Apply();
            // vb.GetData<VertexPositionNormalTexture>(vertexData);

            graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, element.vpc, 0, element.vpc.Count() / 3);
            // graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, vertexData.Count(), index, 0, index.Count() / 3);
        }
Exemplo n.º 3
0
        public void drawMesh(Model myModel, Vector3 modelPosition, float modelRotation, Camera camera)
        {
            float aspectRatio = (float)Tools.Quick.graphics.GraphicsDevice.Viewport.Width /
               (float)Tools.Quick.graphics.GraphicsDevice.Viewport.Height;
            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[myModel.Bones.Count];
            myModel.CopyAbsoluteBoneTransformsTo(transforms);
            Tools.Quick.device.RasterizerState = RasterizerState.CullNone;  // vertex order doesn't matter
            Tools.Quick.device.BlendState = BlendState.Opaque;    // use alpha blending
            Tools.Quick.device.DepthStencilState = DepthStencilState.Default;  // don't bother with the depth/stencil buffer

            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in myModel.Meshes)
            {
                // This is where the mesh orientation is set, as well as our camera and projection.
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation) * Matrix.CreateTranslation(modelPosition); //modelPosition
                    effect.View = camera.getview();
                    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),

                        aspectRatio, 1.0f, 1000000.0f);

                }
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            }
        }
Exemplo n.º 4
0
 public ActionMouse(Game1 game , Camera came)
 {
     this.came = came;
     oldms = Mouse.GetState();
     ms = Mouse.GetState();
     this.game = game;
 }
Exemplo n.º 5
0
        public void DrawClippedSky(GraphicsDevice device, Effect effect, Camera camera)
        {
            DepthStencilState s = new DepthStencilState();
            s.DepthBufferWriteEnable = false;
            DepthStencilState bak = device.DepthStencilState;
            device.DepthStencilState = s;
            device.RasterizerState = new RasterizerState() { CullMode = CullMode.None, FillMode = FillMode.Solid };

            Matrix wMatrix = Matrix.CreateScale(scale) * Matrix.CreateTranslation(camera.position);

            effect.CurrentTechnique = effect.Techniques["SkyBox"];
            effect.Parameters["xView"].SetValue(camera.getview());
            effect.Parameters["xProjection"].SetValue(camera.GetProjection());
            effect.Parameters["xWorld"].SetValue(wMatrix);
            effect.Parameters["xCamPos"].SetValue(camera.position);
            effect.Parameters["xSkyBoxTexture"].SetValue(cloudMap);
            effect.Parameters["xEnableLighting"].SetValue(false);
            //currentEffect.Parameters["xClipping"].SetValue(true);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.SetVertexBuffer(vertexBuffer);
                device.Indices = indexBuffer;
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indexBuffer.IndexCount, 0, indexBuffer.IndexCount / 3);
            }

            device.DepthStencilState = bak;
        }
Exemplo n.º 6
0
        public void onGround(Vector3 cameraposition,Camera came)
        {
            int y = searchPosY(cameraposition);

            Vector3 newpos = new Vector3(came.position.X,y+tailleAvat, came.position.Z);
            if (activate) { came.modiposition(newpos, true); }
        }
Exemplo n.º 7
0
 public void SetCamera(Camera cam)
 {
     camera = cam;
 }
Exemplo n.º 8
0
        public void DrawReflectionMap(Camera c, SkyBox d)
        {
            reflectionCamera.position = c.position;
            reflectionCamera.position.Y = -c.position.Y + waterHeight * 2;
            reflectionCamera.lookat = c.lookat;
            reflectionCamera.lookat.Y = -c.lookat.Y + waterHeight * 2;

            reflectionViewMatrix = reflectionCamera.getview();

            Plane reflectionPlane = CreatePlane(waterHeight, new Vector3(0, -1, 0), viewMatrix, reflectionViewMatrix, true);
            effect.CurrentTechnique = effect.Techniques["Textured"];
            effect.Parameters["xClipPlane0"].SetValue(new Vector4(reflectionPlane.Normal, reflectionPlane.D));
            effect.Parameters["xClipping"].SetValue(true);

            device.SetRenderTarget(reflectionRenderTarget);

            device.DepthStencilState = new DepthStencilState();
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 5.0f, 0);

            d.DrawClippedSky(device, effect, reflectionCamera);
            ground.DrawClippedGround(device, effect, reflectionCamera);

            effect.Parameters["xClipping"].SetValue(false);

            device.SetRenderTarget(null);

            reflectionMap = (Texture2D)reflectionRenderTarget;
        }
Exemplo n.º 9
0
        public void DrawRefractionMap(Camera c)
        {
            viewMatrix = c.getview();
            projectionMatrix = c.GetProjection();
            cameraPosition = c.position;

            Plane refractionPlane = CreatePlane(waterHeight + 50f, new Vector3(0, -1, 0), viewMatrix, projectionMatrix, false);
            effect.CurrentTechnique = effect.Techniques["Textured"];
            effect.Parameters["xClipPlane0"].SetValue(new Vector4(refractionPlane.Normal, refractionPlane.D));
            effect.Parameters["xClipping"].SetValue(true);

            device.SetRenderTarget(refractionRenderTarget);

            device.DepthStencilState = new DepthStencilState();
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 5.0f, 0);

            ground.DrawClippedGround(device, effect, c);

            effect.Parameters["xClipping"].SetValue(false);

            device.SetRenderTarget(null);

            refractionMap = (Texture2D)refractionRenderTarget;
        }
Exemplo n.º 10
0
 public void SetCamera(Camera camera)
 {
     this.camera = camera;
 }
Exemplo n.º 11
0
        public void DrawClippedGround(GraphicsDevice device, Effect effect, Camera camera)
        {
            effect.CurrentTechnique = effect.Techniques["MultiTextured"];
            effect.Parameters["xTexturesMap"].SetValue(biomeTexture);
            effect.Parameters["xView"].SetValue(camera.getview());
            effect.Parameters["xProjection"].SetValue(camera.GetProjection());
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);

            device.RasterizerState = new RasterizerState() { CullMode = CullMode.CullClockwiseFace, FillMode = FillMode.Solid };
            device.BlendState = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;

            //effect.Parameters["xTexture"].SetValue(Tools.Quick.groundTexture[gt]);
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.SetVertexBuffer(GroundVertices);
                device.Indices = GroundIndices;
                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GroundIndices.IndexCount, 0, GroundIndices.IndexCount / 3);
            }
        }
Exemplo n.º 12
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            loadedTextureData = new List<TextureData>();
            size8Font = Content.Load<SpriteFont>("BookmanOldStyleSize8");
            size6Font = Content.Load<SpriteFont>("BookmanOldStyleSize6");

            currentGameCamera = new Camera(new Vector2(0, 0), new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));

            screenManager.LoadContent();
        }
Exemplo n.º 13
0
        public void DrawGround(Vector3 lookat, Vector3 cameraPosition, DrawThings display, Camera camera)
        {
            foreach (GroundCell cell in cells)
            {
                cell.DrawGround(lookat, cameraPosition, display, camera);
            }

            /*GraphicsDevice graphicsDevice = Tools.Quick.device;
            graphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.CullClockwiseFace, FillMode = FillMode.Solid };
            graphicsDevice.BlendState = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            effect.CurrentTechnique = effect.Techniques["MultiTextured"];
            //effect.CurrentTechnique = effect.Techniques["Textured"];

            effect.Parameters["xView"].SetValue(camera.getview());
            effect.Parameters["xProjection"].SetValue(camera.GetProjection());
            effect.Parameters["xWorld"].SetValue(Matrix.Identity);
            //effect.Parameters["xEnableLighting"].SetValue(false);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.SetVertexBuffer(GroundVertices);
                graphicsDevice.Indices = GroundIndices;
                graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GroundIndices.IndexCount, 0, GroundIndices.IndexCount / 3);
            }//*/
        }