public RTSRenderer(GraphicsDeviceManager gdm, ContentManager cm, RendererInitArgs ria, GameWindow w) { window = w; gManager = gdm; cManager = cm; args = ria; toDispose = new ConcurrentBag <IDisposable>(); NonFriendlyUnitModels = new List <RTSUnitModel>(); FriendlyUnitModels = new List <RTSUnitModel>(); NonFriendlyBuildingModels = new List <RTSBuildingModel>(); FriendlyBuildingModels = new List <RTSBuildingModel>(); IconLibrary = new Dictionary <string, Texture2D>(); for (int i = 0; i < ria.Icons.Length; i += 2) { IconLibrary.Add(ria.Icons[i], LoadTexture2D(ria.Icons[i + 1])); } tPixel = CreateTexture2D(1, 1); tPixel.SetData(new Color[] { Color.White }); IconLibrary.Add("None", tPixel); fxMap = new RTSFXMap(LoadEffect(ria.FXMap)); fxSimple = CreateEffect(); fxSimple.LightingEnabled = false; fxSimple.FogEnabled = false; fxSimple.TextureEnabled = false; fxSimple.VertexColorEnabled = true; fxSimple.World = Matrix.Identity; fxSimple.Texture = tPixel; fxAnim = new RTSFXEntity(LoadEffect(ria.FXEntity)); fxAnim.World = Matrix.Identity; fxAnim.CPrimary = Vector3.UnitX; fxAnim.CSecondary = Vector3.UnitY; fxAnim.CTertiary = Vector3.UnitZ; tNoise = LoadTexture2D(ria.FXBuildNoise); healthView = new HealthViewer(); healthView.Build(this, fxAnim, ria.FXHealthTechnique, ria.FXHealthPass, ria.FXHealthTexture); UseFOW = true; pRenderer = new ParticleRenderer(LoadEffect(ria.FXParticle), ria.ParticleConfig); Minimap = new Minimap(); CamPointer = new CameraPointer(); CamPointer.Build(this, ria.CamPointerTexture, ria.CamPointerRadii, ria.CamPointerHeights); drawBox = false; MouseEventDispatcher.OnMousePress += OnMousePress; MouseEventDispatcher.OnMouseRelease += OnMouseRelease; MouseEventDispatcher.OnMouseMotion += OnMouseMove; }
public void Build(RTSRenderer renderer, RTSFXEntity fx, string technique, string pass, string texture) { vb = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly); vb.SetData(new VertexPositionTexture[] { new VertexPositionTexture(new Vector3(-1, 0, -1), Vector2.Zero), new VertexPositionTexture(new Vector3(1, 0, -1), Vector2.UnitX), new VertexPositionTexture(new Vector3(-1, 0, 1), Vector2.UnitY), new VertexPositionTexture(new Vector3(1, 0, 1), Vector2.One) }); ib = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, 6, BufferUsage.WriteOnly); ib.SetData(new int[] { 0, 1, 2, 2, 1, 3 }); dvb = renderer.CreateDynamicVertexBuffer(VertexHealthInstance.Declaration, MAX_COUNT, BufferUsage.WriteOnly); instances = new VertexHealthInstance[MAX_COUNT]; vbBinds = new VertexBufferBinding[]{ new VertexBufferBinding(vb), new VertexBufferBinding(dvb, 0, 1) }; fxPass = fx.GetEffectPass(technique, pass); }
public void Build(RTSRenderer renderer, RTSFXEntity fx, string technique, string pass, string texture) { vb = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly); vb.SetData(new VertexPositionTexture[] { new VertexPositionTexture(new Vector3(-1, 0, -1), Vector2.Zero), new VertexPositionTexture(new Vector3(1, 0, -1), Vector2.UnitX), new VertexPositionTexture(new Vector3(-1, 0, 1), Vector2.UnitY), new VertexPositionTexture(new Vector3(1, 0, 1), Vector2.One) }); ib = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, 6, BufferUsage.WriteOnly); ib.SetData(new int[] { 0, 1, 2, 2, 1, 3 }); dvb = renderer.CreateDynamicVertexBuffer(VertexHealthInstance.Declaration, MAX_COUNT, BufferUsage.WriteOnly); instances = new VertexHealthInstance[MAX_COUNT]; vbBinds = new VertexBufferBinding[] { new VertexBufferBinding(vb), new VertexBufferBinding(dvb, 0, 1) }; fxPass = fx.GetEffectPass(technique, pass); }
public RTSRenderer(GraphicsDeviceManager gdm, ContentManager cm, RendererInitArgs ria, GameWindow w) { window = w; gManager = gdm; cManager = cm; args = ria; toDispose = new ConcurrentBag<IDisposable>(); NonFriendlyUnitModels = new List<RTSUnitModel>(); FriendlyUnitModels = new List<RTSUnitModel>(); NonFriendlyBuildingModels = new List<RTSBuildingModel>(); FriendlyBuildingModels = new List<RTSBuildingModel>(); IconLibrary = new Dictionary<string, Texture2D>(); for(int i = 0; i < ria.Icons.Length; i += 2) { IconLibrary.Add(ria.Icons[i], LoadTexture2D(ria.Icons[i + 1])); } tPixel = CreateTexture2D(1, 1); tPixel.SetData(new Color[] { Color.White }); IconLibrary.Add("None", tPixel); fxMap = new RTSFXMap(LoadEffect(ria.FXMap)); fxSimple = CreateEffect(); fxSimple.LightingEnabled = false; fxSimple.FogEnabled = false; fxSimple.TextureEnabled = false; fxSimple.VertexColorEnabled = true; fxSimple.World = Matrix.Identity; fxSimple.Texture = tPixel; fxAnim = new RTSFXEntity(LoadEffect(ria.FXEntity)); fxAnim.World = Matrix.Identity; fxAnim.CPrimary = Vector3.UnitX; fxAnim.CSecondary = Vector3.UnitY; fxAnim.CTertiary = Vector3.UnitZ; tNoise = LoadTexture2D(ria.FXBuildNoise); healthView = new HealthViewer(); healthView.Build(this, fxAnim, ria.FXHealthTechnique, ria.FXHealthPass, ria.FXHealthTexture); UseFOW = true; pRenderer = new ParticleRenderer(LoadEffect(ria.FXParticle), ria.ParticleConfig); Minimap = new Minimap(); CamPointer = new CameraPointer(); CamPointer.Build(this, ria.CamPointerTexture, ria.CamPointerRadii, ria.CamPointerHeights); drawBox = false; MouseEventDispatcher.OnMousePress += OnMousePress; MouseEventDispatcher.OnMouseRelease += OnMouseRelease; MouseEventDispatcher.OnMouseMotion += OnMouseMove; }