// This updates the visual sector public void Update(RenderDevice graphics) { int numverts = 0; int v = 0; // Trash geometry buffer if (geobuffer != null) { geobuffer.Dispose(); } geobuffer = null; // Count the number of vertices there are foreach (VisualGeometry g in allgeometry) { if (g.Vertices != null) { numverts += g.Vertices.Length; } } // Any vertics? if (numverts > 0) { // Make a new buffer geobuffer = new VertexBuffer(); graphics.SetBufferData(geobuffer, numverts, VertexFormat.World); // Fill the buffer foreach (VisualGeometry g in allgeometry) { if ((g.Vertices != null) && (g.Vertices.Length > 0)) { graphics.SetBufferSubdata(geobuffer, v, g.Vertices); g.VertexOffset = v; v += g.Vertices.Length; } } } this.sector.UpdateFogColor(); //mxd // Done updategeo = false; }
// This updates the visual thing public virtual void Update() { RenderDevice graphics = General.Map.Graphics; // Do we need to update the geometry buffer? if (updategeo) { //mxd. Trash geometry buffers if (geobuffers != null) { foreach (VertexBuffer geobuffer in geobuffers) { geobuffer.Dispose(); } } // Any vertics? if (vertices.Length > 0) { geobuffers = new VertexBuffer[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { // Make a new buffer geobuffers[i] = new VertexBuffer(); // Fill the buffer graphics.SetBufferData(geobuffers[i], vertices[i]); } } //mxd. Check if thing is light CheckLightState(); // Done updategeo = false; } //mxd. Need to update thing cage? if (updatecage) { // Trash cage buffer if (cagebuffer != null) { cagebuffer.Dispose(); } cagebuffer = null; // Make a new cage List <WorldVertex> cageverts; if (sizeless) { WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, position_v3.Z); WorldVertex v1 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, position_v3.Z); WorldVertex v2 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, position_v3.Z); WorldVertex v3 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, position_v3.Z); WorldVertex v4 = new WorldVertex(position_v3.X, position_v3.Y, thing.Size + position_v3.Z); WorldVertex v5 = new WorldVertex(position_v3.X, position_v3.Y, -thing.Size + position_v3.Z); cageverts = new List <WorldVertex>(new[] { v0, v1, v2, v3, v4, v5 }); } else { float top = position_v3.Z + thing.Height; float bottom = position_v3.Z; WorldVertex v0 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, bottom); WorldVertex v1 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, bottom); WorldVertex v2 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, bottom); WorldVertex v3 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, bottom); WorldVertex v4 = new WorldVertex(-thing.Size + position_v3.X, -thing.Size + position_v3.Y, top); WorldVertex v5 = new WorldVertex(-thing.Size + position_v3.X, thing.Size + position_v3.Y, top); WorldVertex v6 = new WorldVertex(thing.Size + position_v3.X, thing.Size + position_v3.Y, top); WorldVertex v7 = new WorldVertex(thing.Size + position_v3.X, -thing.Size + position_v3.Y, top); cageverts = new List <WorldVertex>(new[] { v0, v1, v1, v2, v2, v3, v3, v0, v4, v5, v5, v6, v6, v7, v7, v4, v0, v4, v1, v5, v2, v6, v3, v7 }); } // Make new arrow if (Thing.IsDirectional) { Matrix transform = Matrix.Scaling(thing.Size, thing.Size, thing.Size) * (Matrix.RotationY((float)-Thing.RollRad) * Matrix.RotationX((float)-Thing.PitchRad) * Matrix.RotationZ((float)Thing.Angle)) * (sizeless ? position : position * Matrix.Translation(0.0f, 0.0f, thingheight / 2f)); WorldVertex a0 = new WorldVertex(Vector3D.Transform(0.0f, 0.0f, 0.0f, transform)); //start WorldVertex a1 = new WorldVertex(Vector3D.Transform(0.0f, -1.5f, 0.0f, transform)); //end WorldVertex a2 = new WorldVertex(Vector3D.Transform(0.2f, -1.1f, 0.2f, transform)); WorldVertex a3 = new WorldVertex(Vector3D.Transform(-0.2f, -1.1f, 0.2f, transform)); WorldVertex a4 = new WorldVertex(Vector3D.Transform(0.2f, -1.1f, -0.2f, transform)); WorldVertex a5 = new WorldVertex(Vector3D.Transform(-0.2f, -1.1f, -0.2f, transform)); cageverts.AddRange(new[] { a0, a1, a1, a2, a1, a3, a1, a4, a1, a5 }); } // Create buffer WorldVertex[] cv = cageverts.ToArray(); cagelength = cv.Length / 2; cagebuffer = new VertexBuffer(); graphics.SetBufferData(cagebuffer, cv); // Done updatecage = false; } }