private void RenderSpriteList(List <_3DSprite> sprites, BasicEffect effect, EffectTechnique technique)
        {
            ApplyCamera(effect);
            effect.TextureEnabled = true;

            var byTexture = sprites.GroupBy(x => x.Texture);

            foreach (var group in byTexture)
            {
                effect.Texture = group.Key;
                effect.CommitChanges();

                effect.Begin();
                foreach (var pass in technique.Passes)
                {
                    pass.Begin();
                    foreach (var geom in group)
                    {
                        effect.World = geom.World;
                        effect.CommitChanges();

                        geom.Geometry.DrawGeometry(this.Device);
                    }
                    pass.End();
                }
                effect.End();
            }
        }
Example #2
0
        /// <summary>
        /// Renders a bounding sphere using different colors for each axis.
        /// </summary>
        /// <param name="sphere">The sphere to render.</param>
        /// <param name="graphicsDevice">The graphics device to use when rendering.</param>
        /// <param name="view">The current view matrix.</param>
        /// <param name="projection">The current projection matrix.</param>
        /// <param name="xyColor">The color for the XY circle.</param>
        /// <param name="xzColor">The color for the XZ circle.</param>
        /// <param name="yzColor">The color for the YZ circle.</param>
        public static void Render(
            BoundingSphere sphere,
            GraphicsDevice graphicsDevice,
            Matrix view,
            Matrix projection,
            Color xyColor,
            Color xzColor,
            Color yzColor)
        {
            if (vertBuffer == null)
            {
                InitializeGraphics(graphicsDevice, 30);
            }

            graphicsDevice.VertexDeclaration = vertDecl;
            graphicsDevice.Vertices[0].SetSource(
                vertBuffer,
                0,
                VertexPositionColor.SizeInBytes);

            effect.World =
                Matrix.CreateScale(sphere.Radius) *
                Matrix.CreateTranslation(sphere.Center);
            effect.View         = view;
            effect.Projection   = projection;
            effect.DiffuseColor = xyColor.ToVector3();

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                //render each circle individually
                graphicsDevice.DrawPrimitives(
                    PrimitiveType.LineStrip,
                    0,
                    sphereResolution);

                effect.DiffuseColor = xzColor.ToVector3();
                effect.CommitChanges();
                graphicsDevice.DrawPrimitives(
                    PrimitiveType.LineStrip,
                    sphereResolution + 1,
                    sphereResolution);

                effect.DiffuseColor = yzColor.ToVector3();
                effect.CommitChanges();
                graphicsDevice.DrawPrimitives(
                    PrimitiveType.LineStrip,
                    (sphereResolution + 1) * 2,
                    sphereResolution);

                pass.End();
            }
            effect.End();
        }
Example #3
0
        public void Draw(Matrix view, Matrix projection)
        {
            Editor.graphics.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace;

            if (Editor.bUseFog)
            {
                Editor.graphics.GraphicsDevice.RenderState.FogEnable = true;
            }

            effect.Begin();

            effect.World      = world;
            effect.View       = view;
            effect.Projection = projection;

            effect.CommitChanges();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                Editor.graphics.GraphicsDevice.Indices           = indexBuffer;
                Editor.graphics.GraphicsDevice.VertexDeclaration = vertexDeclaration;
                Editor.graphics.GraphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, VertexPositionColor.SizeInBytes);
                Editor.graphics.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, vertices.Length, 0, vertices.Length / 2);

                pass.End();
            }

            effect.End();
        }
Example #4
0
        public override void Draw()
        {
            GraphicsDevice device = GameContainer.Graphics.GraphicsDevice;

            effect.LightingEnabled    = false;
            effect.VertexColorEnabled = false;
            effect.TextureEnabled     = true;
            effect.Alpha = 1;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                device.VertexDeclaration = vertexDecl;
                device.Indices           = ib;
                device.Vertices[0].SetSource(vb, 0, VertexPositionColorTexture.SizeInBytes);

                effect.World      = transform.World;
                effect.View       = camera.View;
                effect.Projection = camera.Projection;

                effect.Texture = advert;

                effect.CommitChanges();

                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);

                pass.End();
            }
            effect.End();
        }
Example #5
0
        /// <summary>
        /// Initializes this Avatar instance.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            Effect = new BasicEffect(Device, null);
            Effect.TextureEnabled = true;
            Effect.CommitChanges();
        }
Example #6
0
        private void DrawBones(Skelenton skel)
        {
            var device = GraphicsDevice;

            device.RenderState.PointSize = 10.0f;
            device.VertexDeclaration     = new VertexDeclaration(GraphicsDevice, VertexPositionColor.VertexElements);
            device.RenderState.CullMode  = CullMode.None;

            var effect = new BasicEffect(GraphicsDevice, null);


            //effect.Texture = TextureUtils.TextureFromColor(device, color);
            //effect.TextureEnabled = true;

            effect.World              = World;
            effect.View               = View;
            effect.Projection         = Projection;
            effect.VertexColorEnabled = true;
            effect.EnableDefaultLighting();

            effect.CommitChanges();
            effect.Begin();
            foreach (var pass in effect.Techniques[0].Passes)
            {
                pass.Begin();

                foreach (var bone in skel.Bones)
                {
                    var color = Color.Green;

                    if (bone.Name == "ROOT")
                    {
                        color = Color.Red;
                    }
                    else if (bone.Name == "HEAD")
                    {
                        color = Color.Yellow;
                    }

                    var vertex     = new VertexPositionColor(bone.AbsolutePosition, color);
                    var vertexList = new VertexPositionColor[1] {
                        vertex
                    };
                    device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);
                }
                pass.End();
            }
            effect.End();
        }
Example #7
0
        /// <summary>
        /// Draw the Terrain using a Basic Effect. Method called from Draw();
        /// </summary>
        private void BasicEffectDraw(GraphicsDevice graphicsDevice, Matrix view, Matrix projection)
        {
            Ray   pickRay = Editor.camera.GetPickRay();
            float?rayLength;

            basicEffect.Begin();

            for (int y = 0; y < cell.GetLength(1); y++)
            {
                for (int x = 0; x < cell.GetLength(0); x++)
                {
                    float distance = Vector3.Distance(Editor.camera.position, cell[x, y].center);
                    if (distance < Editor.camera.viewDistance)
                    {
                        if (Editor.camera.boundingFrustrum.Contains(cell[x, y].boundingBox) != ContainmentType.Disjoint)
                        {
                            basicEffect.World      = cell[x, y].world;
                            basicEffect.View       = view;
                            basicEffect.Projection = projection;

                            basicEffect.CommitChanges();

                            //------- PickRay Test -------
                            cell[x, y].boundingBox.Intersects(ref pickRay, out rayLength);

                            if (rayLength.HasValue)
                            {
                                basicEffect.DiffuseColor = Color.Red.ToVector3();
                            }
                            else
                            {
                                basicEffect.DiffuseColor = Vector3.One;
                            }
                            //------- PickRay Test -------

                            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                            {
                                pass.Begin();
                                cell[x, y].Draw(graphicsDevice, view, projection);
                                pass.End();
                            }
                        }
                    }
                }
            }

            basicEffect.End();
        }
Example #8
0
        private void DrawMesh(Mesh mesh, Texture2D texture)
        {
            //glTranslatef(Character.Translation.x, Character.Translation.y, zoom + Character.Translation.z);
            //glRotatef(Character.Rotation.x, 1.0f, 0.0f, 0.0f);
            //glRotatef(Character.Rotation.y, 0.0f, 1.0f, 0.0f);
            //glRotatef(Character.Rotation.z, 0.0f, 0.0f, 1.0f);



            var device = GraphicsDevice;

            device.VertexDeclaration    = new VertexDeclaration(GraphicsDevice, MeshVertex.VertexElements);
            device.RenderState.CullMode = CullMode.None;

            var effect = new BasicEffect(GraphicsDevice, null);

            effect.Texture            = texture;
            effect.TextureEnabled     = true;
            effect.VertexColorEnabled = false;
            effect.World      = World;
            effect.View       = View;
            effect.Projection = Projection;
            effect.CommitChanges();

            effect.Begin();
            foreach (var pass in effect.Techniques[0].Passes)
            {
                pass.Begin();

                foreach (var face in mesh.FaceData)
                {
                    var vertexA = mesh.TransformedVertex[face.VertexA];
                    var vertexB = mesh.TransformedVertex[face.VertexB];
                    var vertexC = mesh.TransformedVertex[face.VertexC];

                    var vertexList = new MeshVertex[3] {
                        vertexA.Vertex, vertexB.Vertex, vertexC.Vertex
                    };
                    device.DrawUserPrimitives(PrimitiveType.TriangleList, vertexList, 0, 1);
                }

                //device.DrawUserPrimitives(PrimitiveType.TriangleList, mesh.TransformedVertexData, 0, mesh.TransformedVertexData.Length / 3);
                pass.End();
            }
            effect.End();
        }
        public static void Draw(this BoundingSphere sphere, Matrix view, Matrix projection)
        {
            if (effect == null)
            {
                throw new InvalidOperationException("You must call Initialize before you can render any spheres.");
            }



            // update our effect matrices
            effect.World      = Matrix.CreateScale(sphere.Radius) * Matrix.CreateTranslation(sphere.Center);
            effect.View       = view;
            effect.Projection = projection;

            effect.CommitChanges();

            effect.GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, lineCount);
        }
Example #10
0
        public static void RenderSphere(BoundingSphere sphere, Color color, ref Matrix view, ref Matrix projection)
        {
            //this null check is here in case we never ran the InitializeBuffers method of this class
            //if this is the case the device will be null
            if (device == null)
            {
                return;
            }

            device.VertexDeclaration = vertexDeclaration;
            device.Vertices[0].SetSource(sphereBuffer, 0, VertexPositionColor.SizeInBytes);

            effect.View       = view;
            effect.Projection = projection;

            Matrix scale       = Matrix.CreateScale(sphere.Radius);
            Matrix translation = Matrix.CreateTranslation(sphere.Center);

            effect.Begin(SaveStateMode.SaveState);

            for (int i = 0; i < effect.CurrentTechnique.Passes.Count; i++)
            {
                EffectPass pass = effect.CurrentTechnique.Passes[i];

                pass.Begin();

                effect.DiffuseColor = color.ToVector3();//Vector3.UnitY;
                effect.World        = scale * translation;
                effect.CommitChanges();
                device.DrawPrimitives(PrimitiveType.LineStrip, 0, numberOfSphereVerts - 1);

                effect.DiffuseColor = color.ToVector3(); //Vector3.UnitZ;
                effect.World        = scale * Matrix.CreateRotationX(MathHelper.PiOver2) * translation;
                effect.CommitChanges();
                device.DrawPrimitives(PrimitiveType.LineStrip, 0, numberOfSphereVerts - 1);

                effect.DiffuseColor = color.ToVector3(); //Vector3.UnitX;
                effect.World        = scale * Matrix.CreateRotationZ(MathHelper.PiOver2) * translation;
                effect.CommitChanges();
                device.DrawPrimitives(PrimitiveType.LineStrip, 0, numberOfSphereVerts - 1);

                pass.End();
            }

            effect.End();
        }
Example #11
0
        public override void Draw(Microsoft.Xna.Framework.Graphics.GraphicsDevice device)
        {
            Effect.View       = View;
            Effect.Projection = Projection;
            Effect.World      = World;

            Effect.Begin();
            foreach (var pass in Effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                foreach (var binding in Bindings)
                {
                    Effect.Texture = binding.Texture;
                    Effect.CommitChanges();
                    binding.Mesh.Draw(device);
                }
                pass.End();
            }
            Effect.End();
        }
Example #12
0
        public void Draw(GraphicsDevice device)
        {
            device.RenderState.PointSize = 30.0f;
            device.VertexDeclaration     = new VertexDeclaration(device, VertexPositionColor.VertexElements);
            //device.RenderState.CullMode = CullMode.None;

            var effect = new BasicEffect(device, null);


            //effect.Texture = TextureUtils.TextureFromColor(device, color);
            //effect.TextureEnabled = true;

            effect.World              = Matrix.Identity;
            effect.View               = View;
            effect.Projection         = Projection;
            effect.VertexColorEnabled = true;
            //effect.EnableDefaultLighting();

            effect.CommitChanges();
            effect.Begin();
            foreach (var pass in effect.Techniques[0].Passes)
            {
                pass.Begin();

                var vertex     = new VertexPositionColor(Position, Color.Green);
                var vertexList = new VertexPositionColor[1] {
                    vertex
                };
                device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);

                vertex.Color    = Color.Red;
                vertex.Position = Target;
                device.DrawUserPrimitives(PrimitiveType.PointList, vertexList, 0, 1);


                pass.End();
            }
            effect.End();
        }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pDevice"></param>
        private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
        {
            /*m_SBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);
             *
             * m_SBatch.Draw(m_BackgroundTex, new Microsoft.Xna.Framework.Rectangle(0, 0, m_BackgroundTex.Width,
             *  m_BackgroundTex.Height), Microsoft.Xna.Framework.Graphics.Color.White);
             *
             * m_SBatch.End();*/

            Device.RenderState.DepthBufferEnable      = true;
            Device.RenderState.DepthBufferWriteEnable = true;
            Device.RenderState.AlphaBlendEnable       = false;
            Device.RenderState.PointSize = 10.0f;

            // Configure effects
            m_HeadEffect.World      = this.mWorldMat;
            m_HeadEffect.View       = mViewMat;
            m_HeadEffect.Projection = mProjectionMat;

            m_BodyEffect.World      = this.mWorldMat;
            m_BodyEffect.View       = mViewMat;
            m_BodyEffect.Projection = mProjectionMat;

            if (m_HeadTex != null)
            {
                m_HeadEffect.Texture        = m_HeadTex;
                m_HeadEffect.TextureEnabled = true;

                m_HeadEffect.EnableDefaultLighting();
            }

            if (m_BodyTex != null)
            {
                m_BodyEffect.Texture        = m_BodyTex;
                m_BodyEffect.TextureEnabled = true;

                m_BodyEffect.EnableDefaultLighting();
            }

            m_HeadEffect.CommitChanges();
            m_BodyEffect.CommitChanges();

            if (m_LoadBodyComplete)
            {
                /*m_CurrentMesh.TransformVertices2(m_Skeleton.Bones[0], ref mWorldMat);
                 * m_CurrentMesh.BlendVertices2();
                 * m_CurrentMesh.ProcessMesh();*/

                if (!m_RenderSkeleton)
                {
                    foreach (Face Fce in m_CurrentBodyMesh.Faces)
                    {
                        // Draw
                        m_BodyEffect.Begin();
                        m_BodyEffect.Techniques[0].Passes[0].Begin();

                        VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                        Vertex[0] = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.AVertexIndex];
                        Vertex[1] = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.BVertexIndex];
                        Vertex[2] = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.CVertexIndex];

                        Vertex[0].TextureCoordinate = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.AVertexIndex].TextureCoordinate;
                        Vertex[1].TextureCoordinate = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.BVertexIndex].TextureCoordinate;
                        Vertex[2].TextureCoordinate = m_CurrentBodyMesh.VertexTexNormalPositions[Fce.CVertexIndex].TextureCoordinate;

                        pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                                 Vertex, 0, 1);

                        m_BodyEffect.Techniques[0].Passes[0].End();
                        m_BodyEffect.End();
                    }
                }
                else
                {
                    if (m_SkelPoints != null)
                    {
                        m_BodyEffect.Begin();
                        m_BodyEffect.Techniques[0].Passes[0].Begin();
                        pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.PointList,
                                                                                 m_SkelPoints, 0, m_Skeleton.Bones.Length);
                        m_BodyEffect.Techniques[0].Passes[0].End();
                        m_BodyEffect.End();
                    }
                }
            }

            if (m_LoadHeadComplete)
            {
                foreach (Face Fce in m_CurrentHeadMesh.Faces)
                {
                    // Draw
                    m_HeadEffect.Begin();
                    m_HeadEffect.Techniques[0].Passes[0].Begin();

                    VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                    Vertex[0] = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.AVertexIndex];
                    Vertex[1] = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.BVertexIndex];
                    Vertex[2] = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.CVertexIndex];

                    Vertex[0].TextureCoordinate = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.AVertexIndex].TextureCoordinate;
                    Vertex[1].TextureCoordinate = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.BVertexIndex].TextureCoordinate;
                    Vertex[2].TextureCoordinate = m_CurrentHeadMesh.VertexTexNormalPositions[Fce.CVertexIndex].TextureCoordinate;

                    pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                             Vertex, 0, 1);

                    m_HeadEffect.Techniques[0].Passes[0].End();
                    m_HeadEffect.End();
                }
            }
        }
Example #14
0
        public override void Draw()
        {
            GraphicsDevice device = GameContainer.Graphics.GraphicsDevice;

            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.SourceBlend      = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;

            effect.LightingEnabled    = false;
            effect.VertexColorEnabled = false;
            effect.TextureEnabled     = true;
            effect.Alpha = 1;

            float scoreOffset = 1.85f;

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                device.VertexDeclaration = vertexDecl;
                device.Indices           = ib;
                device.Vertices[0].SetSource(vb, 0, VertexPositionColorTexture.SizeInBytes);

                switch (counter[PlayerIndex.One])
                {
                default: effect.Texture = score0; break;

                case 0: effect.Texture = score0; break;

                case 1: effect.Texture = score1; break;

                case 2: effect.Texture = score2; break;
                    //case 3: effect.Texture = score3; break;
                }

                effect.World      = Matrix.CreateTranslation(new Vector3(-(field.Width / 2) + (width / 2) + scoreOffset, 0.2f, 0));
                effect.View       = camera.View;
                effect.Projection = camera.Projection;
                effect.CommitChanges();

                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);

                switch (counter[PlayerIndex.Two])
                {
                default: effect.Texture = score0; break;

                case 0: effect.Texture = score0; break;

                case 1: effect.Texture = score1; break;

                case 2: effect.Texture = score2; break;
                    //case 3: effect.Texture = score3; break;
                }

                effect.World      = Matrix.CreateTranslation(new Vector3((field.Width / 2) - (width / 2) - scoreOffset, 0.2f, 0));
                effect.View       = camera.View;
                effect.Projection = camera.Projection;
                effect.CommitChanges();

                device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);

                pass.End();
            }
            effect.End();

            device.RenderState.AlphaBlendEnable = false;
        }
Example #15
0
 public void setViewMatrix(Matrix matrix)
 {
     m_BasicEffect.View = matrix;
     m_BasicEffect.CommitChanges();
 }
Example #16
0
        /// <summary>
        /// Renders the scene.
        /// </summary>
        private void mWinForm_OnFrameRender(GraphicsDevice pDevice)
        {
            Device.RenderState.DepthBufferEnable      = true;
            Device.RenderState.DepthBufferWriteEnable = true;
            Device.RenderState.AlphaBlendEnable       = false;
            Device.RenderState.PointSize = 10.0f;

            // Configure effects
            m_HeadEffect.World      = this.mWorldMat;
            m_HeadEffect.View       = mViewMat;
            m_HeadEffect.Projection = mProjectionMat;

            m_BodyEffect.World      = this.mWorldMat;
            m_BodyEffect.View       = mViewMat;
            m_BodyEffect.Projection = mProjectionMat;

            m_SkeletonEffect.World      = this.mWorldMat;
            m_SkeletonEffect.View       = mViewMat;
            m_SkeletonEffect.Projection = mProjectionMat;
            m_SkeletonEffect.EnableDefaultLighting();

            if (m_RenderSim.GetHeadTexture() != null)
            {
                m_HeadEffect.Texture        = m_RenderSim.GetHeadTexture();
                m_HeadEffect.TextureEnabled = true;

                m_HeadEffect.EnableDefaultLighting();
            }

            if (m_RenderSim.GetBodyTexture() != null)
            {
                m_BodyEffect.Texture        = m_RenderSim.GetBodyTexture();
                m_BodyEffect.TextureEnabled = true;

                m_BodyEffect.EnableDefaultLighting();
            }

            m_HeadEffect.CommitChanges();
            m_BodyEffect.CommitChanges();
            m_SkeletonEffect.CommitChanges();

            if (m_LoadBodyComplete)
            {
                if (!m_RenderSkeleton)
                {
                    foreach (Face Fce in m_RenderSim.GetBodyMesh().FaceData)
                    {
                        // Draw
                        m_BodyEffect.Begin();
                        m_BodyEffect.Techniques[0].Passes[0].Begin();

                        VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                        Vertex[0] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexA];
                        Vertex[1] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexB];
                        Vertex[2] = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexC];

                        Vertex[0].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                        Vertex[1].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                        Vertex[2].TextureCoordinate = m_RenderSim.GetBodyMesh().VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                        pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                                 Vertex, 0, 1);

                        m_BodyEffect.Techniques[0].Passes[0].End();
                        m_BodyEffect.End();
                    }

                    m_RenderSim.GetBodyMesh().TransformVertices(m_RenderSim.SimSkeleton.RootBone);
                    m_RenderSim.GetBodyMesh().ProcessMesh(m_RenderSim.SimSkeleton, false);
                }
                else
                {
                    DrawSkeleton(m_RenderSim.SimSkeleton);
                }
            }

            if (m_LoadHeadComplete)
            {
                foreach (Face Fce in m_RenderSim.GetHeadMesh().FaceData)
                {
                    // Draw
                    m_HeadEffect.Begin();
                    m_HeadEffect.Techniques[0].Passes[0].Begin();

                    VertexPositionNormalTexture[] Vertex = new VertexPositionNormalTexture[3];
                    Vertex[0] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexA];
                    Vertex[1] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexB];
                    Vertex[2] = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexC];

                    Vertex[0].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexA].TextureCoordinate;
                    Vertex[1].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexB].TextureCoordinate;
                    Vertex[2].TextureCoordinate = m_RenderSim.GetHeadMesh().VertexTexNormalPositions[Fce.VertexC].TextureCoordinate;

                    pDevice.DrawUserPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList,
                                                                             Vertex, 0, 1);

                    m_HeadEffect.Techniques[0].Passes[0].End();
                    m_HeadEffect.End();
                }

                m_RenderSim.GetHeadMesh().ProcessMesh(m_RenderSim.SimSkeleton, true);
            }
        }