Beispiel #1
0
        public void Render1()
        {
            dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, Color.Blue, 1.0f, 0);

            dx_device.BeginScene();
            dx_device.SetTexture(0, m_Tex);

            dx_device.SetTransform(TransformType.World, m_Camera.m_World);
            dx_device.SetTransform(TransformType.View, m_Camera.m_View);
            dx_device.SetTransform(TransformType.Projection, m_Camera.m_Projection);

            // 원래 객체를 그린다.
            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;
            //            m_Objects[4].render(dx_device);

            // 그림자 영역을 그린다.
            dx_device.RenderState.ZBufferWriteEnable = false;
            dx_device.RenderState.StencilEnable = true;
            dx_device.RenderState.ShadeMode = ShadeMode.Flat;
            dx_device.RenderState.StencilFunction = Compare.Always;
            dx_device.RenderState.StencilZBufferFail = StencilOperation.Keep;
            dx_device.RenderState.StencilFail = StencilOperation.Keep;
            dx_device.RenderState.ReferenceStencil = 1;
            dx_device.RenderState.StencilMask = -1;
            dx_device.RenderState.StencilWriteMask = -1;
            dx_device.RenderState.StencilPass = StencilOperation.Increment;
            dx_device.RenderState.AlphaBlendEnable = true;
            dx_device.RenderState.SourceBlend = Blend.Zero;
            dx_device.RenderState.DestinationBlend = Blend.One;

            //            dx_device.Transform.World = m_Camera.m_ShadowWorld;
            //            m_Objects[4].render(dx_device);
            //            dx_device.Transform.World = m_Camera.m_World;
            VertexBuffer tmp = m_Walls.m_shadow.BuildShadowVertex(dx_device, m_Camera.m_Position.pos);
            m_Walls.BuildVertexBuffer(dx_device, m_Camera.m_Position.pos);
            dx_device.SetStreamSource(0, tmp, 0);
            dx_device.VertexFormat = tmp.Description.VertexFormat;
            dx_device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_Walls.m_shadow.m_VertexCount / 3);

            // 원래 객체를 그린다.
            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;
            m_Objects[0].render(dx_device);
            m_Objects[1].render(dx_device);
            m_Walls.render(dx_device);

            dx_device.RenderState.Lighting = true;
            dx_device.Material = m_Material;
            dx_device.Transform.World =
                Matrix.Scaling(0.1f,2f,0.1f)
                * Matrix.Translation(m_Camera.m_Position.pos.X, 0, m_Camera.m_Position.pos.Y);
            m_Mesh.DrawSubset(0);
            dx_device.Transform.World = m_Camera.m_World;
            dx_device.RenderState.Lighting = false;

            // 그림자에 해당하는 부분을 다시 그린다.
            dx_device.RenderState.ZBufferEnable = true;
            dx_device.RenderState.ZBufferWriteEnable = false;
            dx_device.RenderState.StencilEnable = true;
            dx_device.RenderState.AlphaBlendEnable = true;
            dx_device.RenderState.SourceBlend = Blend.SourceAlpha;
            dx_device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].ColorArgument2 = TextureArgument.Constant;
            dx_device.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
            dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            dx_device.RenderState.ReferenceStencil = 1;
            dx_device.RenderState.StencilFunction = Compare.LessEqual;
            dx_device.RenderState.StencilPass = StencilOperation.Keep;

            m_Objects[0].render(dx_device);

            dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].ColorOperation = TextureOperation.Modulate;
            dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
            dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate;

            dx_device.RenderState.ShadeMode = ShadeMode.Gouraud;
            dx_device.RenderState.CullMode = Cull.None;
            dx_device.RenderState.ZBufferWriteEnable = true;
            dx_device.RenderState.StencilEnable = false;
            dx_device.RenderState.AlphaBlendEnable = false;

            FontDescription desc = new Microsoft.DirectX.Direct3D.FontDescription();
            Microsoft.DirectX.Direct3D.Font fnt = new Microsoft.DirectX.Direct3D.Font(dx_device, desc);

            fnt.DrawText(null, m_Camera.ToString() + "\n"
                + m_Walls.m_shadow + "\n"
                + m_Camera.getPicking(m_Cursor.m_MousePoint, dx_device.Viewport), new Point(5, 5), Color.Aquamarine);

            fnt.Dispose();

            dx_device.EndScene();

            dx_device.Present();
        }
Beispiel #2
0
        protected void CreateGraphicObjects(EventHandler progressReport)
        {
            SetupTextures(progressReport);
            _sprite = new Sprite(_device);

            _font = new Microsoft.DirectX.Direct3D.Font(_device, new System.Drawing.Font(FontFamily.GenericSerif, 11));
            FontDescription fd = new Microsoft.DirectX.Direct3D.FontDescription();
            fd.FaceName = "Franklin Gothic Demi";
            fd.PitchAndFamily = PitchAndFamily.DefaultPitch;
            fd.Weight = FontWeight.Thin;
            fd.Height = 20;
            fd.Quality = FontQuality.AntiAliased;
            _messageFont = new Microsoft.DirectX.Direct3D.Font(_device, fd);
        }
Beispiel #3
0
 public Font(Device device, FontDescription description)
 {
     throw new NotImplementedException();
 }