コード例 #1
0
        public override void Draw(Camera camera)
        {
            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = CustomEffect;

                    part.Effect.Parameters["World"].SetValue(BoneTransforms[mesh.ParentBone.Index] * World);
                    part.Effect.Parameters["View"].SetValue(camera.View);
                    part.Effect.Parameters["Projection"].SetValue(camera.Projection);

                    part.Effect.Parameters["Color"].SetValue(Color.ToVector3());
                }
                mesh.Draw();
            }
        }
コード例 #2
0
        public void Draw(Camera _camera)
        {
            if (_camera != null)
            {
                effect.View = _camera.View;
                effect.Projection = _camera.Projection;

                int vertexCount = 0;
                foreach (var shape in activeShapes)
                    vertexCount += shape.LineCount * 2;

                if (vertexCount > 0)
                {
                    if (verts.Length < vertexCount)
                    {
                        verts = new VertexPositionColor[vertexCount * 2];
                    }

                    int lineCount = 0;
                    int vertIndex = 0;
                    foreach (DebugShape shape in activeShapes)
                    {
                        lineCount += shape.LineCount;
                        int shapeVerts = shape.LineCount * 2;
                        for (int i = 0; i < shapeVerts; i++)
                            verts[vertIndex++] = shape.Vertices[i];
                    }

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

                    int vertexOffset = 0;
                    while (lineCount > 0)
                    {
                        int linesToDraw = Math.Min(lineCount, 65535);

                        GameUtilities.GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;

                        GameUtilities.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, verts, vertexOffset, linesToDraw);

                        vertexOffset += linesToDraw * 2;

                        lineCount -= linesToDraw;
                    }
                }
            }
        }
コード例 #3
0
        public override void Draw(Camera camera)
        {
            if (CustomEffect != null)
            {
                SetModelEffect(CustomEffect, true);

                foreach (ModelMesh mesh in Model.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        SetEffectParameter(part.Effect, "World", BoneTransforms[mesh.ParentBone.Index] * World);
                        SetEffectParameter(part.Effect, "View", camera.View);
                        SetEffectParameter(part.Effect, "Projection", camera.Projection);

                        if (Material != null)
                        {
                            Material.SetEffectParameters(part.Effect);
                        }
                    }
                    mesh.Draw();
                }
            }
        }
コード例 #4
0
        protected override void Initialize()
        {
            occQuery = new OcclusionQuery(GraphicsDevice);
            GameUtilities.Content = Content;
            GameUtilities.GraphicsDevice = GraphicsDevice;
            debug.Initialize();
            shapeDrawer.Initialize();

            mainCamera = new Camera("cam", new Vector3(0, 5, 10), new Vector3(0, 0, -1));
            mainCamera.Initialize();

            base.Initialize();
        }
コード例 #5
0
ファイル: Scene.cs プロジェクト: TomCrypto/Insight
 /// <summary> Creates the camera. </summary>
 private void CreateCamera(Size resolution)
 {
     camera = new Camera(Settings.initialCameraPosition, Settings.initialCameraRotation, 75, (float)resolution.Width / resolution.Height);
 }
コード例 #6
0
 public virtual void Draw(Camera camera)
 {
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: TomCrypto/Embree.NET
        /// <summary>
        /// Creates a new renderer.
        /// </summary>
        public Renderer()
        {
            // Create an Embree.NET scene using our Model type

            scene = new Scene<Model>(SceneFlags.Static | SceneFlags.Coherent | SceneFlags.Incoherent | SceneFlags.Robust,
                                     TraversalFlags.Single | TraversalFlags.Packet4);

            // Load all required meshes here

            meshes.Add("buddha", ObjLoader.LoadMesh("Models/buddha.obj"));
            meshes.Add("lucy", ObjLoader.LoadMesh("Models/lucy.obj"));
            meshes.Add("ground", ObjLoader.LoadMesh("Models/ground.obj"));

            // Create a few Model instances with a given modelworld matrix which we will populate later

            var buddhaModel = new Model(Matrix.Combine(Matrix.Scaling(8),
                                                       Matrix.Rotation(-(float)Math.PI / 2, 0, 0.5f),
                                                       Matrix.Translation(new Vector(-2.5f, -1.8f, -4.5f))));

            var lucyModel = new Model(Matrix.Combine(Matrix.Scaling(1.0f / 175),
                                                     Matrix.Rotation(0, (float)Math.PI / 2 + 2.1f, 0),
                                                     Matrix.Translation(new Vector(-11, -1.56f, -5))));

            var lucyModel2 = new Model(Matrix.Combine(Matrix.Scaling(1.0f / 600),
                                                      Matrix.Rotation(0, (float)Math.PI / 2 - 1.8f, 0),
                                                      Matrix.Translation(new Vector(-2.5f, -3.98f, -8))));

            var groundModel = new Model(Matrix.Combine(Matrix.Scaling(100),
                                                       Matrix.Translation(new Vector(0, -5, 0))));

            // Now place these meshes into the world with a given material

            buddhaModel.AddMesh(meshes["buddha"], new Phong(new Vector(0.55f, 0.25f, 0.40f), 0.65f, 48));
            lucyModel.AddMesh(meshes["lucy"], new Phong(new Vector(0.35f, 0.65f, 0.15f), 0.85f, 256));
            groundModel.AddMesh(meshes["ground"], new Phong(new Vector(0.25f, 0.25f, 0.95f), 0.45f, 1024));
            lucyModel2.AddMesh(meshes["lucy"], new Diffuse(new Vector(0.95f, 0.85f, 0.05f) * 0.318f)); // instancing example

            // And finally add them to the scene (into the world)

            scene.Add(buddhaModel);
            scene.Add(lucyModel);
            scene.Add(lucyModel2);
            scene.Add(groundModel);

            // Don't forget to commit when we're done messing with the geometry

            scene.Commit();

            // Place a light source somewhere

            lightPosition = new Point(-11.85f, 11, -13);
            lightIntensity = 900;

            // Get a good shot of the world

            camera = new Camera((float)Math.PI / 5, 1,    // unknown aspect ratio for now
                                new Point(-2.5f, -0.45f, -12), // good position for the camera
                                new Vector(0, 0, 1), 0);  // view direction + no roll (upright)
        }
コード例 #8
0
        public void DrawBoundingBox(BoundingBox box, Camera camera)
        {
            DebugShape shape = GetShapeForLines(12, 0);

            box.GetCorners(corners);

            Color color = Color.Red;

            shape.Vertices[0] = new VertexPositionColor(corners[0], color);
            shape.Vertices[1] = new VertexPositionColor(corners[1], color);
            shape.Vertices[2] = new VertexPositionColor(corners[1], color);
            shape.Vertices[3] = new VertexPositionColor(corners[2], color);
            shape.Vertices[4] = new VertexPositionColor(corners[2], color);
            shape.Vertices[5] = new VertexPositionColor(corners[3], color);
            shape.Vertices[6] = new VertexPositionColor(corners[3], color);
            shape.Vertices[7] = new VertexPositionColor(corners[0], color);

            shape.Vertices[8] = new VertexPositionColor(corners[4], color);
            shape.Vertices[9] = new VertexPositionColor(corners[5], color);
            shape.Vertices[10] = new VertexPositionColor(corners[5], color);
            shape.Vertices[11] = new VertexPositionColor(corners[6], color);
            shape.Vertices[12] = new VertexPositionColor(corners[6], color);
            shape.Vertices[13] = new VertexPositionColor(corners[7], color);
            shape.Vertices[14] = new VertexPositionColor(corners[7], color);
            shape.Vertices[15] = new VertexPositionColor(corners[4], color);

            shape.Vertices[16] = new VertexPositionColor(corners[0], color);
            shape.Vertices[17] = new VertexPositionColor(corners[4], color);
            shape.Vertices[18] = new VertexPositionColor(corners[1], color);
            shape.Vertices[19] = new VertexPositionColor(corners[5], color);
            shape.Vertices[20] = new VertexPositionColor(corners[2], color);
            shape.Vertices[21] = new VertexPositionColor(corners[6], color);
            shape.Vertices[22] = new VertexPositionColor(corners[3], color);
            shape.Vertices[23] = new VertexPositionColor(corners[7], color);

            Draw(camera);
            Clear();
        }
コード例 #9
0
        public void DrawBoundingSphere(BoundingSphere sphere, Camera camera)
        {
            DebugShape shape = GetShapeForLines(sphereLineCount, 0);

            for (int i = 0; i < unitSphere.Length; i++)
            {
                Vector3 vertPos = unitSphere[i] * sphere.Radius + sphere.Center;

                shape.Vertices[i] = new VertexPositionColor(vertPos, Color.Red);
            }

            Draw(camera);
            Clear();
        }