// Constructor
        internal Renderer(D3DDevice g)
        {
            // Initialize
            this.graphics = g;

            // Register as resource
            g.RegisterResource(this);

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Exemple #2
0
        // Constructor
        public ShaderManager(D3DDevice device)
        {
            // Initialize
            this.device = device;

            // Load
            ReloadResource();

            // Register as resource
            device.RegisterResource(this);

            // We have no destructor
            GC.SuppressFinalize(this);
        }
        // Disposer
        internal virtual void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Clean up

                // Unregister resource
                graphics.UnregisterResource(this);

                // Done
                graphics   = null;
                isdisposed = true;
            }
        }
        // Constructor
        internal Renderer3D(D3DDevice graphics) : base(graphics)
        {
            // Initialize
            CreateProjection();
            CreateMatrices2D();
            SetupThingCage();
            SetupTextures();
            renderthingcages = true;
            showselection    = true;
            showhighlight    = true;

            // Dummy frustum
            frustum = new ProjectedFrustum2D(new Vector2D(), 0.0f, 0.0f, PROJ_NEAR_PLANE,
                                             General.Settings.ViewDistance, Angle2D.DegToRad(General.Settings.VisualFOV));
        }
Exemple #5
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Clean up
                UnloadResource();

                // Unregister as resource
                device.UnregisterResource(this);

                // Done
                device     = null;
                isdisposed = true;
            }
        }
        // This creates matrices for a camera view
        public void PositionAndLookAt(Vector3D pos, Vector3D lookat)
        {
            // Calculate delta vector
            cameraposition = pos;
            Vector3D delta   = lookat - pos;
            float    anglexy = delta.GetAngleXY();
            float    anglez  = delta.GetAngleZ();

            // Create frustum
            frustum = new ProjectedFrustum2D(pos, anglexy, anglez, PROJ_NEAR_PLANE,
                                             General.Settings.ViewDistance, Angle2D.DegToRad(General.Settings.VisualFOV));

            // Make the view matrix
            view3d = Matrix.LookAtRH(D3DDevice.V3(pos), D3DDevice.V3(lookat), new Vector3(0f, 0f, 1f));

            // Make the billboard matrix
            billboard = Matrix.RotationZ(anglexy + Angle2D.PI);
        }
        // This renders the sorted sector surfaces
        internal void RenderSectorSurfaces(D3DDevice graphics)
        {
            if (!resourcesunloaded)
            {
                graphics.Shaders.Display2D.Begin();
                foreach (KeyValuePair <ImageData, List <SurfaceEntry> > imgsurfaces in surfaces)
                {
                    // Set texture
                    graphics.Shaders.Display2D.Texture1 = imgsurfaces.Key.Texture;
                    if (!graphics.Shaders.Enabled)
                    {
                        graphics.Device.SetTexture(0, imgsurfaces.Key.Texture);
                    }

                    graphics.Shaders.Display2D.BeginPass(1);

                    // Go for all surfaces
                    VertexBuffer lastbuffer = null;
                    foreach (SurfaceEntry entry in imgsurfaces.Value)
                    {
                        // Set the vertex buffer
                        SurfaceBufferSet set = sets[entry.VerticesCount];
                        if (set.buffers[entry.BufferIndex] != lastbuffer)
                        {
                            lastbuffer = set.buffers[entry.BufferIndex];
                            graphics.Device.SetStreamSource(0, lastbuffer, 0, FlatVertex.Stride);
                        }

                        // Draw
                        graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, entry.VertexOffset + (entry.VerticesCount * surfacevertexoffsetmul), entry.VerticesCount / 3);
                    }

                    graphics.Shaders.Display2D.EndPass();
                }
                graphics.Shaders.Display2D.End();
            }
        }
 // This renders the quad
 public void Render(D3DDevice device)
 {
     // Render the quad
     device.Device.DrawUserPrimitives <FlatVertex>(type, 0, 2, vertices);
 }