Beispiel #1
0
 /// <summary>
 /// pass in true if you want to enable antialiasing. it will then default to on
 /// </summary>
 protected d3dChrController(GraphicsHW g, bool antialias, int w, int h, int w2x, int h2x)
 {
     this.w = w; this.h = h;
     this.antialias = antialias;
     image = g.newImage(w,h);
     if(antialias && !Config.disableModelAntialiasing) {
         b = new Blitter(image);
         this.w2x = w2x; this.h2x = h2x;
         image2x = g.newImage(w2x,h2x);
     }
     this.g = g;
 }
Beispiel #2
0
 /// <summary>
 /// render your frame into the specified image. if you asked for it to be antialiased, then its twice as big as the size you specified.
 /// however, you can establish a projection transform with the desired size and you wont even have to know it.
 /// </summary>
 protected abstract void render(FunkImage dest);
Beispiel #3
0
        protected override void render(FunkImage dest)
        {
            g.begin3d();

            g.setDestAndDepthBuffer(dest);
            g.clearDest();

            g.setRenderMode(GraphicsHW.RenderMode.Texture);
            g.setLinearFiltering();
            g.device.RenderState.CullMode = d3d.Cull.CounterClockwise;
            g.device.RenderState.ZBufferEnable = true;
            g.device.VertexFormat = GraphicsHW.FVFNormal.format;
            //g.device.SetTexture(0, model.tex);
            g.setTex(model.tex);

            //float rads = DateTime.Now.Ticks % 5000000 * 2.0f * 3.14f / 5000000f;
            float rads = DateTime.Now.Ticks % 5000000 * 2.0f * 3.14f / 5000000f;
            g.device.Transform.View = dx.Matrix.LookAtLH(new Microsoft.DirectX.Vector3(0, 0, -200), new dx.Vector3(0, 0, 0), new dx.Vector3(0, 1, 0));
            g.device.Transform.Projection = dx.Matrix.PerspectiveFovLH(3.14f*2.0f*60.0f/360.0f, 1, 1, 1000);
            g.device.Transform.World = dx.Matrix.Identity;

            g.device.Transform.World *= dx.Matrix.RotationY(angle - 3.14f);

            g.device.Transform.World *= dx.Matrix.RotationX(-2.0f * 3.14f / 8);
            g.device.Transform.World *= dx.Matrix.Scaling(200 / model.scale, 200 / model.scale, 1);
            g.device.Transform.World *= dx.Matrix.Translation(0, (float)Math.Sin(rads)*5.0f, 0);

            model.render();
        }
Beispiel #4
0
 protected override void render(FunkImage dest)
 {
     g.setDest(dest);
     dest.clear(0);
     g.setRenderMode(GraphicsHW.RenderMode.Gradient);
     g.device.Transform.Projection = g.generatePixelPerfectProjectionTransform(16, 32);
     g.device.Transform.View = g.generatePixelPerfectViewTransform(16, 32);
     g.device.Transform.World = Microsoft.DirectX.Matrix.Identity;
     g.device.Transform.World *= Microsoft.DirectX.Matrix.RotationZ(DateTime.Now.Ticks % 10000000 * 2.0f * 3.14f / 10000000f);
     g.device.Transform.World *= Microsoft.DirectX.Matrix.Scaling(6, 6, 1);
     g.device.Transform.World *= Microsoft.DirectX.Matrix.Translation(8, 24, 0);
     g.device.Transform.World *= Microsoft.DirectX.Matrix.Translation(0, -(float)Math.Abs(Math.Sin(DateTime.Now.Ticks % 8000000 * 2.0f * 3.14f / 8000000f)) * 12.0f, 0);
     g.device.DrawUserPrimitives(Microsoft.DirectX.Direct3D.PrimitiveType.TriangleFan, 2, model);
     g.device.Transform.World = Microsoft.DirectX.Matrix.Identity;
     //g.resetState();
 }
Beispiel #5
0
        protected override void render(FunkImage dest)
        {
            g.begin3d();
            g.setDestAndDepthBuffer(dest);
            g.clearDest();
            g.setRenderMode(GraphicsHW.RenderMode.Texture);
            //??
            g.device.Transform.View = Microsoft.DirectX.Matrix.LookAtLH(new Microsoft.DirectX.Vector3(0, 0, -50), new Microsoft.DirectX.Vector3(0, 0, 0), new Microsoft.DirectX.Vector3(0, 1, 0));
            g.device.Transform.Projection = dx.Matrix.PerspectiveFovLH(1.04719755f, 1.33333f, 1, 1000);
            //??
            //g.device.Transform.World = dx.Matrix.Scaling(1, 1, 1);
            g.device.Transform.World = dx.Matrix.Identity;
            //g.device.Transform.World = dx.Matrix.Scaling(20, 20, 20);
            g.device.RenderState.AlphaBlendEnable = false;
            g.device.RenderState.CullMode = Microsoft.DirectX.Direct3D.Cull.CounterClockwise;
            g.device.RenderState.ZBufferEnable = true;
            g.device.RenderState.Lighting = false;
            g.setLinearFiltering();

            MatrixStack ms = new MatrixStack(g.device.Transform.World);
            ms.Scale(1, 1, -1);
            ms.RotateX(Lib.rads(45));
            ms.Translate(0, -10, 0);
            ms.Scale(1.2f);
            if(facing == Directions.w) ms.RotateAxisLocal(0, 0, 1, Lib.rads(90));
            else if(facing == Directions.s) ms.RotateAxisLocal(0, 0, 1, Lib.rads(180));
            else if(facing == Directions.e) ms.RotateAxisLocal(0, 0, 1, Lib.rads(270));
            g.device.Transform.World = ms.Top;

            g.setRenderColor(1, Color.SpringGreen);
            g.setRenderMode(GraphicsHW.RenderMode.Color);
            //g.renderLine(0, 0, 0, 0, 0, 20);
            //g.renderLine(-4, 0, 0, 4, 0, 0);
            //g.renderLine(0, 4, 0, 0, -4, 0);
            g.setRenderMode(GraphicsHW.RenderMode.Texture);
            model.Render();
        }