// This renders the sorted sector surfaces internal void RenderSectorSurfaces(D3DDevice graphics) { if (!resourcesunloaded) { int pass = Renderer.FullBrightness ? 2 : 1; //mxd graphics.Shaders.Display2D.Begin(); foreach (KeyValuePair <ImageData, List <SurfaceEntry> > imgsurfaces in surfaces) { // Set texture graphics.Shaders.Display2D.Texture1 = imgsurfaces.Key.Texture; graphics.Shaders.Display2D.BeginPass(pass); // Go for all surfaces VertexBuffer lastbuffer = null; foreach (SurfaceEntry entry in imgsurfaces.Value) { // Set the vertex buffer SurfaceBufferSet set = sets[entry.numvertices]; 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.numvertices * surfacevertexoffsetmul), entry.numvertices / 3); } graphics.Shaders.Display2D.EndPass(); } graphics.Shaders.Display2D.End(); } }
// Constructor internal Renderer(D3DDevice g) { // Initialize this.graphics = g; // Register as resource g.RegisterResource(this); // We have no destructor GC.SuppressFinalize(this); }
// 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; } }
// Disposer public void Dispose() { // Not already disposed? if (!isdisposed) { // Clean up UnloadResource(); // Unregister as resource device.UnregisterResource(this); // Done device = 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((float)General.Settings.VisualFOV)); // We have no destructor GC.SuppressFinalize(this); }
// This renders the sorted sector surfaces internal void RenderSectorSurfaces(D3DDevice graphics) { int counter = 0; 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.numvertices]; if (set.buffers[entry.bufferindex] != lastbuffer) { lastbuffer = set.buffers[entry.bufferindex]; graphics.Device.SetStreamSource(0, lastbuffer, 0, FlatVertex.Stride); } // Draw counter++; graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, entry.vertexoffset + (entry.numvertices * surfacevertexoffsetmul), entry.numvertices / 3); } graphics.Shaders.Display2D.EndPass(); } graphics.Shaders.Display2D.End(); } Console.WriteLine("Calls: " + counter); }
// This creates matrices for a camera view public void PositionAndLookAt(Vector3D pos, Vector3D lookat) { Vector3D delta; float anglexy, anglez; // Calculate delta vector cameraposition = pos; delta = lookat - pos; anglexy = delta.GetAngleXY(); anglez = delta.GetAngleZ(); // Create frustum frustum = new ProjectedFrustum2D(pos, anglexy, anglez, PROJ_NEAR_PLANE, General.Settings.ViewDistance, Angle2D.DegToRad((float)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 quad public void Render(D3DDevice device) { // Render the quad device.Device.DrawUserPrimitives(type, 0, 2, vertices); }