Inheritance: IDisposable
Ejemplo n.º 1
0
 public void RenderMap(RTSRenderer renderer)
 {
     renderer.G.SetRenderTarget(Terrain);
     renderer.G.Clear(Color.Black);
     renderer.DrawMap(mV, mP);
     renderer.G.SetRenderTarget(null);
 }
Ejemplo n.º 2
0
        public void Hook(RTSRenderer renderer, GameState s, int ti, int unit)
        {
            // Filter For Unit Types
            RTSTeam team = s.teams[ti];

            Data = team.Race.Units[unit];

            // Always Add A Unit To List When Spawned
            team.OnUnitSpawn += OnUnitSpawn;

            // Create Instance Buffer
            visible   = new List <RTSUnit>();
            instVerts = new VertexRTSAnimInst[Data.MaxCount];
            instances = new List <RTSUnit>(Data.MaxCount);
            dead      = new List <RTSUnit>();
            for (int i = 0; i < team.Units.Count; i++)
            {
                OnUnitSpawn(team.Units[i]);
            }

            for (int i = 0; i < instVerts.Length; i++)
            {
                instVerts[i] = new VertexRTSAnimInst(Matrix.Identity, 0);
            }
            dvbInstances = renderer.CreateDynamicVertexBuffer(VertexRTSAnimInst.Declaration, instVerts.Length, BufferUsage.WriteOnly);
            dvbInstances.SetData(instVerts);
            dvbInstances.ContentLost += (sender, args) => { rebuildDVB = true; };
            rebuildDVB = false;
        }
Ejemplo n.º 3
0
        private void BuildFireModel(RTSRenderer renderer, int div)
        {
            VertexPositionTexture[] verts = new VertexPositionTexture[4 * div];
            short[] inds   = new short[6 * div];
            double  dTheta = Math.PI / div;

            for (int i = 0, ii = 0, vi = 0; i < div; i++)
            {
                inds[ii++] = (short)(vi + 0);
                inds[ii++] = (short)(vi + 1);
                inds[ii++] = (short)(vi + 2);
                inds[ii++] = (short)(vi + 2);
                inds[ii++] = (short)(vi + 1);
                inds[ii++] = (short)(vi + 3);
                float x = (float)Math.Cos(i * dTheta);
                float z = -(float)Math.Sin(i * dTheta);
                verts[vi++] = new VertexPositionTexture(new Vector3(-x, 1, -z), Vector2.Zero);
                verts[vi++] = new VertexPositionTexture(new Vector3(x, 1, z), Vector2.UnitX);
                verts[vi++] = new VertexPositionTexture(new Vector3(-x, 0, -z), Vector2.UnitY);
                verts[vi++] = new VertexPositionTexture(new Vector3(x, 0, z), Vector2.One);
            }

            plFires.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            plFires.VBuffer.SetData(verts);
            plFires.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, inds.Length, BufferUsage.WriteOnly);
            plFires.IBuffer.SetData(inds);
        }
Ejemplo n.º 4
0
        private void BuildBloodModel(RTSRenderer renderer)
        {
            plBloods.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 12, BufferUsage.WriteOnly);
            plBloods.VBuffer.SetData(new VertexPositionTexture[] {
                new VertexPositionTexture(new Vector3(0, 1, -1), Vector2.Zero),
                new VertexPositionTexture(new Vector3(0, 1, 1), Vector2.UnitX),
                new VertexPositionTexture(new Vector3(0, -1, -1), Vector2.UnitY),
                new VertexPositionTexture(new Vector3(0, -1, 1), Vector2.One),

                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),

                new VertexPositionTexture(new Vector3(-1, 1, 0), Vector2.Zero),
                new VertexPositionTexture(new Vector3(1, 1, 0), Vector2.UnitX),
                new VertexPositionTexture(new Vector3(-1, -1, 0), Vector2.UnitY),
                new VertexPositionTexture(new Vector3(1, -1, 0), Vector2.One)
            });
            plBloods.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, 18, BufferUsage.WriteOnly);
            plBloods.IBuffer.SetData(new short[] {
                0, 1, 2, 2, 1, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 10, 9, 11
            });
        }
Ejemplo n.º 5
0
        public void Load(RTSRenderer renderer, ParticleOptions o)
        {
            // Create Bullet System
            plBullets = new ParticleList <BulletParticle, VertexBulletInstance>(renderer, o.BulletMaxCount, ParticleType.Bullet);
            using (var fs = File.OpenRead(o.BulletModel)) {
                LoadBulletModel(renderer, fs, ParsingFlags.ConversionOpenGL);
            }
            LoadBulletTexture(renderer, o.BulletTexture);

            // Create Fire System
            plFires = new ParticleList <FireParticle, VertexFireInstance>(renderer, o.FireMaxCount, ParticleType.Fire);
            BuildFireModel(renderer, o.FireDetail);
            LoadFireShader(renderer, o.FireNoise, o.FireColor, o.FireAlpha);

            // Create Lightning System
            plBolts = new ParticleList <LightningParticle, VertexLightningInstance>(renderer, o.LightningMaxCount, ParticleType.Lightning);
            BuildLightningModel(renderer);
            LoadLightningShader(renderer, o.LightningImage, o.LightningNumTypes);

            // Create Alert System
            plAlerts = new ParticleList <AlertParticle, VertexAlertInstance>(renderer, o.AlertMaxCount, ParticleType.Alert);
            BuildAlertModel(renderer);
            tAlert = renderer.LoadTexture2D(o.AlertImage);

            // Create Blood System
            plBloods = new ParticleList <BloodParticle, VertexAlertInstance>(renderer, o.BloodMaxCount, ParticleType.Blood);
            BuildBloodModel(renderer);
            tBlood = renderer.LoadTexture2D(o.BloodImage);
        }
Ejemplo n.º 6
0
        public RTSUnitModel(RTSRenderer renderer, Stream sModel, Texture2D tAnim)
        {
            // Create With The Animation Texture
            AnimationTexture = tAnim;

            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[]       verts;
            int[] inds;
            if (!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
            {
                throw new ArgumentException("Bad Model File Format");
            }

            // Reformat Vertices
            verts = new VertexPositionTexture[pVerts.Length];
            for (int i = 0; i < verts.Length; i++)
            {
                verts[i].Position          = new Vector3((float)((i + 0.1) / AnimationTexture.Width), 0, 0);
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }
 public void Build(RTSRenderer renderer, string rootPath, string model, string[] tex)
 {
     using(var sModel = File.OpenRead(Path.Combine(rootPath, model))) {
         View = new RTSBuildingModel(renderer, sModel);
     }
     View.ModelTexture = renderer.LoadTexture2D(Path.Combine(rootPath, tex[0]));
     View.ColorCodeTexture = renderer.LoadTexture2D(Path.Combine(rootPath, tex[1]));
 }
Ejemplo n.º 8
0
        public RTSUnitDataPanel(RTSRenderer renderer, WidgetRenderer wr, UICUnitData _uic, UICCombatStats _uicCS)
        {
            uic = _uic;
            iconLib = renderer.IconLibrary;

            WidgetBase = new RectWidget(wr, renderer.LoadTexture2D(uic.PanelImage));
            WidgetBase.Width = uic.PanelSize.X;
            WidgetBase.Height = uic.PanelSize.Y;
            WidgetBase.Color = uic.PanelColor;

            icon = new RectWidget(wr);
            icon.Width = uic.IconSize;
            icon.Height = uic.IconSize;
            icon.Color = Color.White;
            icon.Offset = new Point(uic.IconBuffer, uic.IconBuffer);
            icon.Parent = WidgetBase;

            rectHealthBack = new RectWidget(wr);
            rectHealthBack.Width = uic.IconSize;
            rectHealthBack.Height = uic.HealthHeight;
            rectHealthBack.AlignX = Alignment.MID;
            rectHealthBack.OffsetAlignX = Alignment.MID;
            rectHealthBack.OffsetAlignY = Alignment.BOTTOM;
            rectHealthBack.Offset = new Point(0, uic.IconBuffer);
            rectHealthBack.Color = UserConfig.MainScheme.WidgetBorder;
            rectHealthBack.Parent = icon;

            rectHealthFore = new RectWidget(wr);
            rectHealthFore.Width = uic.IconSize;
            rectHealthFore.Height = uic.HealthHeight;
            rectHealthFore.AlignX = Alignment.MID;
            rectHealthFore.AlignY = Alignment.MID;
            rectHealthFore.OffsetAlignX = Alignment.MID;
            rectHealthFore.OffsetAlignY = Alignment.MID;
            rectHealthFore.Offset = new Point(0, 0);
            rectHealthFore.Color = uic.HealthMaxColor;
            rectHealthFore.Parent = rectHealthBack;

            txtName = new TextWidget(wr);
            txtName.Height = uic.TextHeight;
            txtName.OffsetAlignX = Alignment.RIGHT;
            txtName.Offset = new Point(uic.IconBuffer, 0);
            txtName.Color = UserConfig.MainScheme.Text;
            txtName.Parent = icon;

            combatData = new RectButton(wr, uic.CombatSize, uic.CombatSize, Color.Gray, Color.White, renderer.LoadTexture2D(uic.CombatImage));
            combatData.AlignX = Alignment.RIGHT;
            combatData.AlignY = Alignment.BOTTOM;
            combatData.OffsetAlignX = Alignment.RIGHT;
            combatData.OffsetAlignY = Alignment.BOTTOM;
            combatData.Parent = WidgetBase;

            uiCStats = new RTSUICombatStats(wr, _uicCS);
            uiCStats.WidgetBase.AlignY = Alignment.BOTTOM;
            uiCStats.WidgetBase.Anchor = new Point(1000000, 1000000);

            uiCSHover = new RTSUIHoverPanel(combatData, uiCStats.WidgetBase);
        }
Ejemplo n.º 9
0
        public void Build(RTSRenderer renderer, string image, Vector3 radii, Vector3 heights)
        {
            fx = renderer.CreateEffect();

            fx.FogEnabled         = false;
            fx.VertexColorEnabled = false;
            fx.LightingEnabled    = false;
            fx.TextureEnabled     = true;

            if (image == null || !File.Exists(image))
            {
                Texture = renderer.CreateTexture2D(3, 3, SurfaceFormat.Color, false);
                Texture.SetData(new Color[] {
                    Color.White, Color.Transparent, Color.White,
                    Color.Transparent, Color.Transparent, Color.Transparent,
                    Color.White, Color.Transparent, Color.White
                });
            }
            else
            {
                Texture = renderer.LoadTexture2D(image);
            }
            fx.Texture = Texture;

            VertexPositionTexture[] verts = new VertexPositionTexture[] {
                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(0.5f, 0)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(0.5f, 0.5f)),

                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0.5f, 0)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(1f, 0)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0.5f, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(1f, 0.5f)),

                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(0.5f, 0.5f)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0, 1f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(0.5f, 1f))
            };
            int[] inds = new int[] {
                0, 1, 2, 2, 1, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 10, 9, 11
            };
            for (int i = 0; i < 4; i++)
            {
                verts[i].Position     *= new Vector3(radii.X, heights.X, radii.X);
                verts[i + 4].Position *= new Vector3(radii.Y, heights.Y, radii.Y);
                verts[i + 8].Position *= new Vector3(radii.Z, heights.Z, radii.Z);
            }

            vb = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            vb.SetData(verts);
            ib = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, inds.Length, BufferUsage.WriteOnly);
            ib.SetData(inds);
        }
Ejemplo n.º 10
0
 public void Build(RTSRenderer renderer, string rootPath, string model, string[] tex)
 {
     using(var sModel = File.OpenRead(Path.Combine(rootPath, model))) {
         Texture2D tAnim = AnimationFromBitmap(renderer, Path.Combine(rootPath, tex[0]));
         View = new RTSUnitModel(renderer, sModel, tAnim);
     }
     View.ModelTexture = renderer.LoadTexture2D(Path.Combine(rootPath, tex[1]));
     View.ColorCodeTexture = renderer.LoadTexture2D(Path.Combine(rootPath, tex[2]));
 }
Ejemplo n.º 11
0
 public void Refresh(RTSRenderer renderer)
 {
     if (refreshFOW)
     {
         refreshFOW = false;
         RenderMap(renderer);
     }
     tbScanner.DoTasks(1f);
     RenderEntities();
 }
Ejemplo n.º 12
0
 public VoxMap(RTSRenderer renderer, int fw, int fh)
 {
     FW = fw;
     FH = fh;
     FogOfWar = new float[FW * FH];
     Array.Clear(FogOfWar, 0, FogOfWar.Length);
     Reset = false;
     FogOfWarTexture = renderer.CreateTexture2D(fw, fh, SurfaceFormat.Single, false);
     FogOfWarTexture.SetData(FogOfWar);
 }
Ejemplo n.º 13
0
 public VoxMap(RTSRenderer renderer, int fw, int fh)
 {
     FW       = fw;
     FH       = fh;
     FogOfWar = new float[FW * FH];
     Array.Clear(FogOfWar, 0, FogOfWar.Length);
     Reset           = false;
     FogOfWarTexture = renderer.CreateTexture2D(fw, fh, SurfaceFormat.Single, false);
     FogOfWarTexture.SetData(FogOfWar);
 }
Ejemplo n.º 14
0
        public void Build(RTSRenderer renderer, Effect _fx, Texture2D _tLMap, int numSplits)
        {
            fx = _fx;
            fx.CurrentTechnique = fx.Techniques[0];
            tLightning          = _tLMap;

            fxpWVP        = fx.Parameters["WVP"];
            fxpTime       = fx.Parameters["Time"];
            fxpSplitCount = fx.Parameters["Splits"];
            fxpSplitCount.SetValue(numSplits);
        }
Ejemplo n.º 15
0
        public void Build(RTSRenderer renderer, string image, Vector3 radii, Vector3 heights)
        {
            fx = renderer.CreateEffect();

            fx.FogEnabled = false;
            fx.VertexColorEnabled = false;
            fx.LightingEnabled = false;
            fx.TextureEnabled = true;

            if(image == null || !File.Exists(image)) {
                Texture = renderer.CreateTexture2D(3, 3, SurfaceFormat.Color, false);
                Texture.SetData(new Color[] {
                    Color.White, Color.Transparent, Color.White,
                    Color.Transparent, Color.Transparent, Color.Transparent,
                    Color.White, Color.Transparent, Color.White
                });
            }
            else {
                Texture = renderer.LoadTexture2D(image);
            }
            fx.Texture = Texture;

            VertexPositionTexture[] verts = new VertexPositionTexture[] {
                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(0.5f, 0)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(0.5f, 0.5f)),

                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0.5f, 0)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(1f, 0)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0.5f, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(1f, 0.5f)),

                new VertexPositionTexture(new Vector3(-1, 1f, -1), new Vector2(0, 0.5f)),
                new VertexPositionTexture(new Vector3(1, 1f, -1), new Vector2(0.5f, 0.5f)),
                new VertexPositionTexture(new Vector3(-1, 1f, 1), new Vector2(0, 1f)),
                new VertexPositionTexture(new Vector3(1, 1f, 1), new Vector2(0.5f, 1f))
            };
            int[] inds = new int[] {
                0, 1, 2, 2, 1, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 10, 9, 11
            };
            for(int i = 0; i < 4; i++) {
                verts[i].Position *= new Vector3(radii.X, heights.X, radii.X);
                verts[i + 4].Position *= new Vector3(radii.Y, heights.Y, radii.Y);
                verts[i + 8].Position *= new Vector3(radii.Z, heights.Z, radii.Z);
            }

            vb = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            vb.SetData(verts);
            ib = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, inds.Length, BufferUsage.WriteOnly);
            ib.SetData(inds);
        }
Ejemplo n.º 16
0
        public static RTSUnitModel ParseModel(RTSRenderer renderer, FileInfo infoFile, RTSRace race)
        {
            // Check File Existence
            if(infoFile == null || !infoFile.Exists) return null;

            ZXParser.SetEnvironment("FILEROOTDIR", infoFile.Directory.FullName);
            ZXParser.SetEnvironment("RENDERER", renderer);
            ZXParser.SetEnvironment("RACE", race);
            RTSUnitViewData vd = ZXParser.ParseFile(infoFile.FullName, typeof(RTSUnitViewData)) as RTSUnitViewData;
            return vd.View;
        }
Ejemplo n.º 17
0
        public void Build(RTSRenderer renderer, Effect _fx, Texture2D _tLMap, int numSplits)
        {
            fx = _fx;
            fx.CurrentTechnique = fx.Techniques[0];
            tLightning = _tLMap;

            fxpWVP = fx.Parameters["WVP"];
            fxpTime = fx.Parameters["Time"];
            fxpSplitCount = fx.Parameters["Splits"];
            fxpSplitCount.SetValue(numSplits);
        }
Ejemplo n.º 18
0
 private void BuildAlertModel(RTSRenderer renderer)
 {
     plAlerts.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
     plAlerts.VBuffer.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)
     });
     plAlerts.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
     plAlerts.IBuffer.SetData(new short[] { 0, 1, 2, 2, 1, 3 });
 }
Ejemplo n.º 19
0
        public void Hook(RTSRenderer renderer, GameState s, int ti)
        {
            ImageWidth  = s.CGrid.numCells.X;
            ImageHeight = s.CGrid.numCells.Y;
            Terrain     = renderer.CreateRenderTarget2D(ImageWidth, ImageHeight, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, RenderTargetUsage.DiscardContents);
            TeamIndex   = ti;
            Team        = s.teams[TeamIndex];

            Vector3 center = new Vector3(s.CGrid.size.X * 0.5f, 0, s.CGrid.size.Y * 0.5f);

            float h = Grey.Vox.Region.HEIGHT + Camera.INITIAL_HIGH_SETTINGS.MaxDistance;

            mV  = Matrix.CreateLookAt(center + Vector3.Up * (h + 1f), center, -Vector3.UnitZ);
            mP  = Matrix.CreateOrthographic(s.CGrid.size.X, s.CGrid.size.Y, 0, h + 2f);
            mVP = mV * mP;

            fxCamera = renderer.CreateEffect();
            fxCamera.LightingEnabled    = false;
            fxCamera.FogEnabled         = false;
            fxCamera.TextureEnabled     = false;
            fxCamera.VertexColorEnabled = true;
            fxCamera.View       = mV;
            fxCamera.Projection = mP;
            fxCamera.World      = Matrix.Identity;

            mapPlanes = new Plane[6];
            float off = s.CGrid.size.Length() * 0.25f;

            mapPlanes[0] = new Plane(Vector3.UnitX, off);
            mapPlanes[1] = new Plane(Vector3.UnitY, 0);
            mapPlanes[2] = new Plane(Vector3.UnitZ, off);
            mapPlanes[3] = new Plane(-Vector3.UnitX, s.CGrid.size.X + off);
            mapPlanes[4] = new Plane(-Vector3.UnitY, h + 2f);
            mapPlanes[5] = new Plane(-Vector3.UnitZ, s.CGrid.size.Y + off);

            refreshFOW           = true;
            s.CGrid.OnFOWChange += (x, y, p, f) => {
                refreshFOW = refreshFOW | (p == ti);
            };

            TeamMap   = renderer.CreateTexture2D(s.CGrid.numCells.X, s.CGrid.numCells.Y, SurfaceFormat.Color, false);
            qSeen     = new Queue <SeenEntity>();
            tbScanner = new TimeBudget(SCAN_BINS);
            float r = (float)s.CGrid.numCells.X / SCAN_BINS;

            for (int i = 0; i < SCAN_BINS - 1; i++)
            {
                tbScanner.AddTask(new ScanTask((int)(r * i), (int)(r * (i + 1)), s.CGrid, Team, qSeen));
            }
            tbScanner.AddTask(new ScanTask((int)(r * (SCAN_BINS - 1)), s.CGrid.numCells.X, s.CGrid, Team, qSeen));
        }
Ejemplo n.º 20
0
        private void BuildLightningModel(RTSRenderer renderer)
        {
            VertexPositionTexture[] verts = new VertexPositionTexture[4];
            verts[0] = new VertexPositionTexture(new Vector3(-1, 1, 0), Vector2.Zero);
            verts[1] = new VertexPositionTexture(new Vector3(1, 1, 0), Vector2.UnitX);
            verts[2] = new VertexPositionTexture(new Vector3(-1, 0, 0), Vector2.UnitY);
            verts[3] = new VertexPositionTexture(new Vector3(1, 0, 0), Vector2.One);
            short[] inds = { 0, 1, 2, 2, 1, 3 };

            plBolts.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            plBolts.VBuffer.SetData(verts);
            plBolts.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, inds.Length, BufferUsage.WriteOnly);
            plBolts.IBuffer.SetData(inds);
        }
Ejemplo n.º 21
0
        public ParticleList(RTSRenderer renderer, int maxCount, ParticleType pt)
        {
            Type = pt;

            // Make The Lists
            particles = new List <PType>();
            vertices  = new VType[maxCount];

            // Create The Instance Buffer
            InstanceBuffer = renderer.CreateDynamicVertexBuffer(vertices[0].VertexDeclaration, MaxCount, BufferUsage.WriteOnly);
            InstanceBuffer.SetData(vertices);

            VBBinds    = new VertexBufferBinding[2];
            VBBinds[1] = new VertexBufferBinding(InstanceBuffer, 0, 1);
        }
Ejemplo n.º 22
0
 private void LoadBulletModel(RTSRenderer renderer, Stream s, ParsingFlags pf = ParsingFlags.ConversionOpenGL)
 {
     VertexPositionNormalTexture[] v;
     int[] inds;
     ObjParser.TryParse(s, out v, out inds, pf);
     VertexPositionTexture[] verts = new VertexPositionTexture[v.Length];
     for (int i = 0; i < verts.Length; i++)
     {
         verts[i].Position          = v[i].Position;
         verts[i].TextureCoordinate = v[i].TextureCoordinate;
     }
     plBullets.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
     plBullets.VBuffer.SetData(verts);
     plBullets.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, inds.Length, BufferUsage.WriteOnly);
     plBullets.IBuffer.SetData(inds);
 }
Ejemplo n.º 23
0
        public RTSBuildingModel(RTSRenderer renderer, Stream sModel)
        {
            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[] verts;
            int[] inds;
            if(!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
                throw new ArgumentException("Bad Model File Format");
            verts = new VertexPositionTexture[pVerts.Length];
            for(int i = 0; i < verts.Length; i++) {
                verts[i].Position = pVerts[i].Position;
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }
Ejemplo n.º 24
0
        public void DrawCamera(RTSRenderer renderer, Rectangle scissor)
        {
            BoundingFrustum f = new BoundingFrustum(renderer.Camera.View * renderer.Camera.Projection);

            Vector3[] corners = f.GetCorners();
            for (int i = 0; i < 4; i++)
            {
                Vector3 dir = corners[i + 4] - corners[i];
                float   min = dir.Length();
                dir /= min;
                Ray r = new Ray(corners[i], dir);

                foreach (Plane p in mapPlanes)
                {
                    float?v = r.Intersects(p);
                    if (v != null && v.Value < min)
                    {
                        min = v.Value;
                    }
                }

                corners[i + 4] = r.Position + (r.Direction * min);
            }
            VertexPositionColor[] verts =
            {
                new VertexPositionColor(corners[0], CAMERA_COLOR_START),
                new VertexPositionColor(corners[1], CAMERA_COLOR_START),
                new VertexPositionColor(corners[3], CAMERA_COLOR_START),
                new VertexPositionColor(corners[2], CAMERA_COLOR_START),
                new VertexPositionColor(corners[4], CAMERA_COLOR_END),
                new VertexPositionColor(corners[5], CAMERA_COLOR_END),
                new VertexPositionColor(corners[7], CAMERA_COLOR_END),
                new VertexPositionColor(corners[6], CAMERA_COLOR_END)
            };
            renderer.G.BlendState        = BlendState.Additive;
            renderer.G.DepthStencilState = DepthStencilState.None;
            renderer.G.RasterizerState   = RasterizerState.CullNone;
            fxCamera.CurrentTechnique.Passes[0].Apply();
            Viewport vp = renderer.G.Viewport;

            renderer.G.Viewport = new Viewport(scissor);
            renderer.G.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, verts, 0, 8, FRUSTUM_INDS, 0, 12);
            renderer.G.Viewport = vp;
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        public RTSUI(RTSRenderer renderer, string uicFile, bool showBuildPanel)
        {
            uic = ZXParser.ParseFile(uicFile, typeof(UICRTS)) as UICRTS;

            SpriteFont font = renderer.LoadFont(uic.Font);
            wrButtonPanel = new WidgetRenderer(renderer.G, font);
            wrMain = new WidgetRenderer(renderer.G, font);

            BuildBounds(renderer);
            BuildMinimap(renderer, uic.UICMinimap);
            BuildBBPanel(renderer);
            BuildBuildingPanel(showBuildPanel);
            BuildSelectionPanel(renderer);
            BuildUnitDataPanel(renderer);
            BuildBuildingDataPanel(renderer);
            BuildTeamDataPanel();
            AlertQueue = new RTSUIAlertQueue(wrMain, uic.UICAlertQueue);
            AlertQueue.WidgetBase.Parent = Minimap.WidgetBase;
            SelectionToggle = 0;
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        public RTSBuildingModel(RTSRenderer renderer, Stream sModel)
        {
            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[]       verts;
            int[] inds;
            if (!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
            {
                throw new ArgumentException("Bad Model File Format");
            }
            verts = new VertexPositionTexture[pVerts.Length];
            for (int i = 0; i < verts.Length; i++)
            {
                verts[i].Position          = pVerts[i].Position;
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }
Ejemplo n.º 29
0
        public RTSUIMinimap(RTSRenderer renderer, WidgetRenderer wr, Texture2D tPhys, Texture2D tImp, UICMinimap uic)
        {
            tPhysical = tPhys;
            tImpact = tImp;

            WidgetBase = new RectWidget(wr);
            WidgetBase.Width = uic.ButtonWidth + uic.MapSize + uic.Buffer * 2;
            WidgetBase.Height = uic.MapSize + uic.Buffer * 2;
            WidgetBase.Color = uic.BaseColor;

            int bh = uic.MapSize / 2;
            btnPhysical = new RectButton(wr, uic.ButtonWidth, bh,
                uic.PhysicalInactiveColor,
                uic.PhysicalActiveColor,
                renderer.LoadTexture2D(uic.PhysicalTexture)
                );
            btnImpact = new RectButton(wr, uic.ButtonWidth, bh,
                uic.ImpactInactiveColor,
                uic.ImpactActiveColor,
                renderer.LoadTexture2D(uic.ImpactTexture)
                );

            btnPhysical.Offset = new Point(uic.Buffer, uic.Buffer);
            btnPhysical.Parent = WidgetBase;
            btnImpact.OffsetAlignY = Alignment.BOTTOM;
            btnImpact.Parent = btnPhysical;

            MapRect = new RectWidget(wr, tPhysical);
            MapRect.Width = uic.MapSize;
            MapRect.Height = uic.MapSize;
            MapRect.Color = Color.White;
            MapRect.OffsetAlignX = Alignment.RIGHT;
            MapRect.Parent = btnPhysical;

            btnPhysical.OnButtonPress += (b, p) => {
                MapRect.Texture = tPhysical;
            };
            btnImpact.OnButtonPress += (b, p) => {
                MapRect.Texture = tImpact;
            };
        }
Ejemplo n.º 30
0
        public RTSUnitModel(RTSRenderer renderer, Stream sModel, Texture2D tAnim)
        {
            // Create With The Animation Texture
            AnimationTexture = tAnim;

            // Parse The Model File
            VertexPositionNormalTexture[] pVerts;
            VertexPositionTexture[] verts;
            int[] inds;
            if(!ObjParser.TryParse(sModel, out pVerts, out inds, MODEL_READ_FLAGS))
                throw new ArgumentException("Bad Model File Format");

            // Reformat Vertices
            verts = new VertexPositionTexture[pVerts.Length];
            for(int i = 0; i < verts.Length; i++) {
                verts[i].Position = new Vector3((float)((i + 0.1) / AnimationTexture.Width), 0, 0);
                verts[i].TextureCoordinate = pVerts[i].TextureCoordinate;
            }

            // Create Model Geometry
            RTSModelHelper.CreateBuffers(renderer, verts, VertexPositionTexture.VertexDeclaration, inds, out vbModel, out ibModel, BufferUsage.WriteOnly);
        }
Ejemplo n.º 31
0
        public void Hook(RTSRenderer renderer, GameState s, int ti, int fti, int building)
        {
            // Filter For Unit Types
            RTSTeam team = s.teams[ti];

            Data       = team.Race.Buildings[building];
            fTeam      = s.teams[fti];
            eTeamIndex = ti;
            fTeamIndex = fti;
            bType      = building;

            // Create Instance Buffer
            visible   = new List <VisibleBuilding>();
            instVerts = new VertexRTSAnimInst[Data.MaxCount];

            for (int i = 0; i < instVerts.Length; i++)
            {
                instVerts[i] = new VertexRTSAnimInst(Matrix.Identity, 1);
            }
            dvbInstances = renderer.CreateDynamicVertexBuffer(VertexRTSAnimInst.Declaration, instVerts.Length, BufferUsage.WriteOnly);
            dvbInstances.SetData(instVerts);
            dvbInstances.ContentLost += (sender, args) => { rebuildDVB = true; };
            rebuildDVB = false;
        }
Ejemplo n.º 32
0
 private void LoadBulletTexture(RTSRenderer renderer, string f)
 {
     tBullet = renderer.LoadTexture2D(f);
 }
Ejemplo n.º 33
0
 private void BuildUnitDataPanel(RTSRenderer renderer)
 {
     UnitDataPanel = new RTSUnitDataPanel(renderer, wrMain, uic.UICUnitData, uic.UICCombatStats);
     UnitDataPanel.WidgetBase.AlignX = Alignment.LEFT;
     UnitDataPanel.WidgetBase.AlignY = Alignment.BOTTOM;
     UnitDataPanel.WidgetBase.OffsetAlignX = Alignment.RIGHT;
     UnitDataPanel.WidgetBase.OffsetAlignY = Alignment.BOTTOM;
     UnitDataPanel.WidgetBase.Offset = new Point(0, 0);
     UnitDataPanel.WidgetBase.Parent = BBPanel.BackPanel;
 }
Ejemplo n.º 34
0
 private void LoadFireShader(RTSRenderer renderer, string fNoise, string fColor, string fAlpha)
 {
     tFireColor = renderer.LoadTexture2D(fColor);
     tFireNoise = renderer.LoadTexture2D(fNoise);
     tFireAlpha = renderer.LoadTexture2D(fAlpha);
 }
Ejemplo n.º 35
0
 private void LoadLightningShader(RTSRenderer renderer, string fLMap, int splits)
 {
     tLightningMap = renderer.LoadTexture2D(fLMap);
     fxParticle.LightningSplits = splits;
 }
Ejemplo n.º 36
0
 private void BuildAlertModel(RTSRenderer renderer)
 {
     plAlerts.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 4, BufferUsage.WriteOnly);
     plAlerts.VBuffer.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)
     });
     plAlerts.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, 6, BufferUsage.WriteOnly);
     plAlerts.IBuffer.SetData(new short[] { 0, 1, 2, 2, 1, 3 });
 }
Ejemplo n.º 37
0
 private void BuildBuildingDataPanel(RTSRenderer renderer)
 {
     BuildingDataPanel = new RTSBuildingDataPanel(renderer, wrMain, uic.UICBuildingData);
     BuildingDataPanel.WidgetBase.AlignX = Alignment.LEFT;
     BuildingDataPanel.WidgetBase.AlignY = Alignment.BOTTOM;
     BuildingDataPanel.WidgetBase.OffsetAlignX = Alignment.RIGHT;
     BuildingDataPanel.WidgetBase.OffsetAlignY = Alignment.BOTTOM;
     BuildingDataPanel.WidgetBase.Offset = new Point(0, 0);
     BuildingDataPanel.WidgetBase.Parent = BBPanel.BackPanel;
 }
Ejemplo n.º 38
0
 private void BuildMinimap(RTSRenderer renderer, UICMinimap uic)
 {
     Minimap = new RTSUIMinimap(renderer, wrMain, renderer.Minimap.Terrain, null, uic);
     Minimap.WidgetBase.AlignX = Alignment.RIGHT;
     Minimap.WidgetBase.AlignY = Alignment.BOTTOM;
     Minimap.WidgetBase.OffsetAlignX = Alignment.RIGHT;
     Minimap.WidgetBase.OffsetAlignY = Alignment.BOTTOM;
     Minimap.WidgetBase.Parent = rectBounds;
 }
Ejemplo n.º 39
0
 private void LoadBulletTexture(RTSRenderer renderer, string f)
 {
     tBullet = renderer.LoadTexture2D(f);
 }
Ejemplo n.º 40
0
        private void BuildBloodModel(RTSRenderer renderer)
        {
            plBloods.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, 12, BufferUsage.WriteOnly);
            plBloods.VBuffer.SetData(new VertexPositionTexture[] {
                new VertexPositionTexture(new Vector3(0, 1, -1), Vector2.Zero),
                new VertexPositionTexture(new Vector3(0, 1, 1), Vector2.UnitX),
                new VertexPositionTexture(new Vector3(0, -1, -1), Vector2.UnitY),
                new VertexPositionTexture(new Vector3(0, -1, 1), Vector2.One),

                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),

                new VertexPositionTexture(new Vector3(-1, 1, 0), Vector2.Zero),
                new VertexPositionTexture(new Vector3(1, 1, 0), Vector2.UnitX),
                new VertexPositionTexture(new Vector3(-1, -1, 0), Vector2.UnitY),
                new VertexPositionTexture(new Vector3(1, -1, 0), Vector2.One)
            });
            plBloods.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, 18, BufferUsage.WriteOnly);
            plBloods.IBuffer.SetData(new short[] {
                0, 1, 2, 2, 1, 3,
                4, 5, 6, 6, 5, 7,
                8, 9, 10, 10, 9, 11
            });
        }
Ejemplo n.º 41
0
        public void Hook(RTSRenderer renderer, GameState s, int ti, int unit)
        {
            // Filter For Unit Types
            RTSTeam team = s.teams[ti];
            Data = team.Race.Units[unit];

            // Always Add A Unit To List When Spawned
            team.OnUnitSpawn += OnUnitSpawn;

            // Create Instance Buffer
            visible = new List<RTSUnit>();
            instVerts = new VertexRTSAnimInst[Data.MaxCount];
            instances = new List<RTSUnit>(Data.MaxCount);
            dead = new List<RTSUnit>();
            for(int i = 0; i < team.Units.Count; i++) {
                OnUnitSpawn(team.Units[i]);
            }

            for(int i = 0; i < instVerts.Length; i++)
                instVerts[i] = new VertexRTSAnimInst(Matrix.Identity, 0);
            dvbInstances = renderer.CreateDynamicVertexBuffer(VertexRTSAnimInst.Declaration, instVerts.Length, BufferUsage.WriteOnly);
            dvbInstances.SetData(instVerts);
            dvbInstances.ContentLost += (sender, args) => { rebuildDVB = true; };
            rebuildDVB = false;
        }
Ejemplo n.º 42
0
        public void Load(RTSRenderer renderer, ParticleOptions o)
        {
            // Create Bullet System
            plBullets = new ParticleList<BulletParticle, VertexBulletInstance>(renderer, o.BulletMaxCount, ParticleType.Bullet);
            using(var fs = File.OpenRead(o.BulletModel)) {
                LoadBulletModel(renderer, fs, ParsingFlags.ConversionOpenGL);
            }
            LoadBulletTexture(renderer, o.BulletTexture);

            // Create Fire System
            plFires = new ParticleList<FireParticle, VertexFireInstance>(renderer, o.FireMaxCount, ParticleType.Fire);
            BuildFireModel(renderer, o.FireDetail);
            LoadFireShader(renderer, o.FireNoise, o.FireColor, o.FireAlpha);

            // Create Lightning System
            plBolts = new ParticleList<LightningParticle, VertexLightningInstance>(renderer, o.LightningMaxCount, ParticleType.Lightning);
            BuildLightningModel(renderer);
            LoadLightningShader(renderer, o.LightningImage, o.LightningNumTypes);

            // Create Alert System
            plAlerts = new ParticleList<AlertParticle, VertexAlertInstance>(renderer, o.AlertMaxCount, ParticleType.Alert);
            BuildAlertModel(renderer);
            tAlert = renderer.LoadTexture2D(o.AlertImage);

            // Create Blood System
            plBloods = new ParticleList<BloodParticle, VertexAlertInstance>(renderer, o.BloodMaxCount, ParticleType.Blood);
            BuildBloodModel(renderer);
            tBlood = renderer.LoadTexture2D(o.BloodImage);
        }
Ejemplo n.º 43
0
 public void Build(RTSRenderer renderer, string fxFile, string fLightningMap, int numSplits)
 {
     Build(renderer, renderer.LoadEffect(fxFile), renderer.LoadTexture2D(fLightningMap), numSplits);
 }
Ejemplo n.º 44
0
 private void BuildSelectionPanel(RTSRenderer renderer)
 {
     SelectionPanel = new RTSUISelectionPanel(wrMain, uic.SelectionRows, uic.SelectionColumns, uic.SelectionIconSize, uic.SelectionIconBuffer);
     SelectionPanel.BackPanel.Texture = renderer.LoadTexture2D(uic.SelectionTexture);
     SelectionPanel.IconLibrary = renderer.IconLibrary;
     SelectionPanel.BackPanel.AlignX = Alignment.LEFT;
     SelectionPanel.BackPanel.AlignY = Alignment.BOTTOM;
     SelectionPanel.BackPanel.OffsetAlignX = Alignment.RIGHT;
     SelectionPanel.BackPanel.OffsetAlignY = Alignment.BOTTOM;
     SelectionPanel.BackPanel.Color = UserConfig.MainScheme.WidgetBase;
     SelectionPanel.BackPanel.Offset = new Point(0, 0);
     SelectionPanel.BackPanel.Parent = BBPanel.BackPanel;
 }
Ejemplo n.º 45
0
        private void BuildFireModel(RTSRenderer renderer, int div)
        {
            VertexPositionTexture[] verts = new VertexPositionTexture[4 * div];
            short[] inds = new short[6 * div];
            double dTheta = Math.PI / div;
            for(int i = 0, ii = 0, vi = 0; i < div; i++) {
                inds[ii++] = (short)(vi + 0);
                inds[ii++] = (short)(vi + 1);
                inds[ii++] = (short)(vi + 2);
                inds[ii++] = (short)(vi + 2);
                inds[ii++] = (short)(vi + 1);
                inds[ii++] = (short)(vi + 3);
                float x = (float)Math.Cos(i * dTheta);
                float z = -(float)Math.Sin(i * dTheta);
                verts[vi++] = new VertexPositionTexture(new Vector3(-x, 1, -z), Vector2.Zero);
                verts[vi++] = new VertexPositionTexture(new Vector3(x, 1, z), Vector2.UnitX);
                verts[vi++] = new VertexPositionTexture(new Vector3(-x, 0, -z), Vector2.UnitY);
                verts[vi++] = new VertexPositionTexture(new Vector3(x, 0, z), Vector2.One);
            }

            plFires.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            plFires.VBuffer.SetData(verts);
            plFires.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, inds.Length, BufferUsage.WriteOnly);
            plFires.IBuffer.SetData(inds);
        }
Ejemplo n.º 46
0
 private void LoadFireShader(RTSRenderer renderer, string fNoise, string fColor, string fAlpha)
 {
     tFireColor = renderer.LoadTexture2D(fColor);
     tFireNoise = renderer.LoadTexture2D(fNoise);
     tFireAlpha = renderer.LoadTexture2D(fAlpha);
 }
Ejemplo n.º 47
0
        public void Hook(RTSRenderer renderer, GameState s, int ti, int fti, int building)
        {
            // Filter For Unit Types
            RTSTeam team = s.teams[ti];
            Data = team.Race.Buildings[building];
            fTeam = s.teams[fti];
            eTeamIndex = ti;
            fTeamIndex = fti;
            bType = building;

            // Create Instance Buffer
            visible = new List<VisibleBuilding>();
            instVerts = new VertexRTSAnimInst[Data.MaxCount];

            for(int i = 0; i < instVerts.Length; i++)
                instVerts[i] = new VertexRTSAnimInst(Matrix.Identity, 1);
            dvbInstances = renderer.CreateDynamicVertexBuffer(VertexRTSAnimInst.Declaration, instVerts.Length, BufferUsage.WriteOnly);
            dvbInstances.SetData(instVerts);
            dvbInstances.ContentLost += (sender, args) => { rebuildDVB = true; };
            rebuildDVB = false;
        }
Ejemplo n.º 48
0
 private void LoadLightningShader(RTSRenderer renderer, string fLMap, int splits)
 {
     tLightningMap = renderer.LoadTexture2D(fLMap);
     fxParticle.LightningSplits = splits;
 }
Ejemplo n.º 49
0
        private void BuildLightningModel(RTSRenderer renderer)
        {
            VertexPositionTexture[] verts = new VertexPositionTexture[4];
            verts[0] = new VertexPositionTexture(new Vector3(-1, 1, 0), Vector2.Zero);
            verts[1] = new VertexPositionTexture(new Vector3(1, 1, 0), Vector2.UnitX);
            verts[2] = new VertexPositionTexture(new Vector3(-1, 0, 0), Vector2.UnitY);
            verts[3] = new VertexPositionTexture(new Vector3(1, 0, 0), Vector2.One);
            short[] inds = { 0, 1, 2, 2, 1, 3 };

            plBolts.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
            plBolts.VBuffer.SetData(verts);
            plBolts.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.SixteenBits, inds.Length, BufferUsage.WriteOnly);
            plBolts.IBuffer.SetData(inds);
        }
Ejemplo n.º 50
0
 private void BuildBounds(RTSRenderer renderer)
 {
     rectBounds = new RectWidget(wrMain);
     rectBounds.Color = Color.Transparent;
     rectBounds.Anchor = new Point(0, 0);
     rectBounds.AlignX = Alignment.LEFT;
     rectBounds.AlignY = Alignment.TOP;
     rectBounds.Width = renderer.G.Viewport.Width;
     rectBounds.Height = renderer.G.Viewport.Height;
     renderer.Window.ClientSizeChanged += (sender, args) => {
         rectBounds.Width = renderer.G.Viewport.Width;
         rectBounds.Height = renderer.G.Viewport.Height;
     };
     rectBounds.LayerDepth = 1f;
 }
Ejemplo n.º 51
0
 public void Build(RTSRenderer renderer, string fxFile, string fLightningMap, int numSplits)
 {
     Build(renderer, renderer.LoadEffect(fxFile), renderer.LoadTexture2D(fLightningMap), numSplits);
 }
Ejemplo n.º 52
0
 private static Texture2D AnimationFromBitmap(RTSRenderer renderer, string fi)
 {
     Texture2D t;
     float[] sData = null;
     int w, h;
     using(var bmp = System.Drawing.Bitmap.FromFile(fi) as System.Drawing.Bitmap) {
         w = bmp.Width;
         h = bmp.Height;
         sData = new float[w * h];
         System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(0, 0, w, h), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);
         System.Runtime.InteropServices.Marshal.Copy(data.Scan0, sData, 0, (data.Stride * data.Height) >> 2);
         bmp.UnlockBits(data);
     }
     t = renderer.CreateTexture2D(w, h, SurfaceFormat.Single);
     t.SetData(sData);
     return t;
 }
Ejemplo n.º 53
0
 private void LoadBulletModel(RTSRenderer renderer, Stream s, ParsingFlags pf = ParsingFlags.ConversionOpenGL)
 {
     VertexPositionNormalTexture[] v;
     int[] inds;
     ObjParser.TryParse(s, out v, out inds, pf);
     VertexPositionTexture[] verts = new VertexPositionTexture[v.Length];
     for(int i = 0; i < verts.Length; i++) {
         verts[i].Position = v[i].Position;
         verts[i].TextureCoordinate = v[i].TextureCoordinate;
     }
     plBullets.VBuffer = renderer.CreateVertexBuffer(VertexPositionTexture.VertexDeclaration, verts.Length, BufferUsage.WriteOnly);
     plBullets.VBuffer.SetData(verts);
     plBullets.IBuffer = renderer.CreateIndexBuffer(IndexElementSize.ThirtyTwoBits, inds.Length, BufferUsage.WriteOnly);
     plBullets.IBuffer.SetData(inds);
 }