Exemplo n.º 1
0
        void DrawSimple(ICamera cam, bool wireFrame)
        {
            Material mat = null;

            if (wireFrame || viewMode == M_FLAT)
            {
                mat = wireframeMaterial3db;
                mat.Update(cam);
            }
            else if (viewMode == M_NORMALS)
            {
                mat = normalsDebugMaterial;
                mat.Update(cam);
            }
            var matrix = Matrix4.CreateRotationX(rotation.Y) * Matrix4.CreateRotationY(rotation.X);

            if (viewMode == M_LIT)
            {
                drawable.DrawBuffer(buffer, matrix, ref lighting, mat);
            }
            else
            {
                drawable.DrawBuffer(buffer, matrix, ref Lighting.Empty, mat);
            }
        }
Exemplo n.º 2
0
        void DrawGL(int renderWidth, int renderHeight)
        {
            //Set state
            renderTarget.BindFramebuffer();
            rstate.Cull = true;
            var cc = rstate.ClearColor;

            rstate.DepthEnabled = true;
            rstate.ClearColor   = Color4.CornflowerBlue;
            rstate.ClearAll();
            vps.Push(0, 0, renderWidth, renderHeight);
            //Draw Model
            var cam = new ChaseCamera(new Viewport(0, 0, renderWidth, renderHeight));

            cam.ChasePosition         = Vector3.Zero;
            cam.ChaseOrientation      = Matrix4.CreateRotationX(MathHelper.Pi);
            cam.DesiredPositionOffset = new Vector3(drawable.GetRadius() * 2, 0, 0);
            cam.OffsetDirection       = Vector3.UnitX;
            cam.Reset();
            cam.Update(TimeSpan.FromSeconds(500));
            buffer.StartFrame();
            drawable.Update(cam, TimeSpan.Zero, TimeSpan.Zero);
            drawable.Update(cam, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0));
            drawable.DrawBuffer(buffer, Matrix4.Identity, Lighting.Empty);
            buffer.DrawOpaque(rstate);
            rstate.DepthWrite = false;
            buffer.DrawTransparent(rstate);
            rstate.DepthWrite = true;
            //Restore state
            rstate.Cull         = false;
            rstate.BlendMode    = BlendMode.Normal;
            rstate.DepthEnabled = false;
            rstate.ClearColor   = cc;
            RenderTarget2D.ClearBinding();
            vps.Pop();
        }