示例#1
0
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var actorPos = actor.CenterPosition;

            var a  = actorPos + new WVec(PointA.X, PointA.Y, VerticalTopOffset).Rotate(actor.Orientation);
            var b  = actorPos + new WVec(PointB.X, PointB.Y, VerticalTopOffset).Rotate(actor.Orientation);
            var aa = actorPos + new WVec(PointA.X, PointA.Y, VerticalBottomOffset).Rotate(actor.Orientation);
            var bb = actorPos + new WVec(PointB.X, PointB.Y, VerticalBottomOffset).Rotate(actor.Orientation);

            var offset1 = new WVec(a.Y - b.Y, b.X - a.X, 0);

            offset1 = offset1 * Radius.Length / offset1.Length;
            var offset2 = new WVec(aa.Y - bb.Y, bb.X - aa.X, 0);

            offset2 = offset2 * Radius.Length / offset2.Length;

            var c = Color.Yellow;

            RangeCircleRenderable.DrawRangeCircle(wr, a, Radius, 1, c, 0, c);
            RangeCircleRenderable.DrawRangeCircle(wr, b, Radius, 1, c, 0, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(a - offset1), wr.ScreenPosition(b - offset1) }, 1, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(a + offset1), wr.ScreenPosition(b + offset1) }, 1, c);

            RangeCircleRenderable.DrawRangeCircle(wr, aa, Radius, 1, c, 0, c);
            RangeCircleRenderable.DrawRangeCircle(wr, bb, Radius, 1, c, 0, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(aa - offset2), wr.ScreenPosition(bb - offset2) }, 1, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(aa + offset2), wr.ScreenPosition(bb + offset2) }, 1, c);
        }
示例#2
0
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var actorPos    = actor.CenterPosition;
            var orientation = new WRot(actor.Orientation.Roll, actor.Orientation.Pitch,
                                       new WAngle(actor.Orientation.Yaw.Angle + (RotateToIsometry ? 128 : 0)));

            var targetablePositions = actor.TraitsImplementing <ITargetablePositions>();

            if (ApplyToAllTargetablePositions && targetablePositions.Any())
            {
                var positions = targetablePositions.SelectMany(tp => tp.TargetablePositions(actor));
                foreach (var pos in positions)
                {
                    var vertsTop    = combatOverlayVertsTop.Select(v => wr.Screen3DPosition(pos + v.Rotate(orientation)));
                    var vertsBottom = combatOverlayVertsBottom.Select(v => wr.Screen3DPosition(pos + v.Rotate(orientation)));
                    wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
                    wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);
                }
            }
            else
            {
                var vertsTop    = combatOverlayVertsTop.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
                var vertsBottom = combatOverlayVertsBottom.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
                wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
                wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);
            }
        }
示例#3
0
 public ExitsDebugOverlay(Actor self, ExitsDebugOverlayInfo info)
 {
     this.info    = info;
     manager      = self.World.WorldActor.TraitOrDefault <ExitsDebugOverlayManager>();
     rgbaRenderer = Game.Renderer.WorldRgbaColorRenderer;
     exits        = self.Info.TraitInfos <ExitInfo>().ToArray();
 }
示例#4
0
        public Renderer(GraphicSettings graphicSettings, ServerSettings serverSettings)
        {
            var resolution = GetResolution(graphicSettings);

            var rendererName = serverSettings.Dedicated ? "Null" : graphicSettings.Renderer;
            var rendererPath = Platform.ResolvePath(".", "OpenRA.Platforms." + rendererName + ".dll");

            Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode);

            if (!serverSettings.Dedicated)
            {
                TempBufferSize = graphicSettings.BatchSize;
                SheetSize      = graphicSettings.SheetSize;
            }

            WorldSpriteRenderer     = new SpriteRenderer(this, Device.CreateShader("shp"));
            WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
            WorldRgbaColorRenderer  = new RgbaColorRenderer(this, Device.CreateShader("color"));
            WorldVoxelRenderer      = new VoxelRenderer(this, Device.CreateShader("vxl"));
            RgbaColorRenderer       = new RgbaColorRenderer(this, Device.CreateShader("color"));
            RgbaSpriteRenderer      = new SpriteRenderer(this, Device.CreateShader("rgba"));
            SpriteRenderer          = new SpriteRenderer(this, Device.CreateShader("shp"));

            tempBuffer = Device.CreateVertexBuffer(TempBufferSize);
        }
示例#5
0
        public Renderer(DefaultPlatform platform, GraphicSettings graphicSettings)
        {
            this.platform = platform;
            var resolution = GetResolution(graphicSettings);

            Window  = platform.CreateWindow(new Size(resolution.Width, resolution.Height), graphicSettings.Mode, graphicSettings.BatchSize, Game.Settings.Graphics.DisableWindowsDPIScaling, Game.Settings.Game.LockMouseWindow, Game.Settings.Graphics.DisableWindowsRenderThread);
            Context = Window.Context;

            TempBufferSize = graphicSettings.BatchSize;
            SheetSize      = graphicSettings.SheetSize;

            WorldSpriteRenderer     = new SpriteRenderer("WorldSpriteRenderer", this, Context.CreateShader("combined"));         // каждый имеет vertex массив, VAO это tempbuffer.
            WorldRgbaSpriteRenderer = new RgbaSpriteRenderer(WorldSpriteRenderer);
            WorldRgbaColorRenderer  = new RgbaColorRenderer(WorldSpriteRenderer);
            WorldModelRenderer      = new ModelRenderer(this, Context.CreateShader("model"));                               // каждый имеет vertex массив, VAO это tempbuffer
            SpriteRenderer          = new SpriteRenderer("SpriteRenderer", this, Context.CreateShader("combined"));         // каждый имеет vertex массив, VAO это tempbuffer.
            RgbaSpriteRenderer      = new RgbaSpriteRenderer(SpriteRenderer);                                               // эти пишут в родительский VBO
            RgbaColorRenderer       = new RgbaColorRenderer(SpriteRenderer);                                                // эти пишут в родительский VBO
            FontSpriteRenderer      = new SpriteRenderer("FontSpriteRenderer", this, Context.CreateShader("text"));         // каждый имеет свой vertex массив, VAO это tempbuffer.
            ImguiSpriteRenderer     = new SpriteRenderer("ImguiSpriteRenderer", this, Context.CreateShader("combined"));    // для ImGui
            PixelDumpRenderer       = new PixelDumpRenderer("ImguiSpriteRenderer", this, Context.CreateShader("combined")); // для ImGui

            sproc = new ShaderIF_API();
            IntPtr context = ImGui.CreateContext();

            ImGui.SetCurrentContext(context);

            RendererVertexBuffer = Context.CreateVertexBuffer(TempBufferSize, "Renderer");
        }
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var actorPos = actor.CenterPosition;

            RangeCircleRenderable.DrawRangeCircle(
                wr, actorPos + new WVec(0, 0, VerticalTopOffset), Radius, 1, Color.Yellow, 0, Color.Yellow);
            RangeCircleRenderable.DrawRangeCircle(
                wr, actorPos + new WVec(0, 0, VerticalBottomOffset), Radius, 1, Color.Yellow, 0, Color.Yellow);
        }
示例#7
0
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var actorPos = actor.CenterPosition;

            var vertsTop    = combatOverlayVertsTop.Select(v => wr.ScreenPosition(actorPos + v.Rotate(actor.Orientation)));
            var vertsBottom = combatOverlayVertsBottom.Select(v => wr.ScreenPosition(actorPos + v.Rotate(actor.Orientation)));

            wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
            wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);
        }
示例#8
0
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var actorPos    = actor.CenterPosition;
            var orientation = actor.Orientation + WRot.FromYaw(LocalYaw);

            var vertsTop    = combatOverlayVertsTop.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));
            var vertsBottom = combatOverlayVertsBottom.Select(v => wr.Screen3DPosition(actorPos + v.Rotate(orientation)));

            wcr.DrawPolygon(vertsTop.ToArray(), 1, Color.Yellow);
            wcr.DrawPolygon(vertsBottom.ToArray(), 1, Color.Yellow);

            RangeCircleRenderable.DrawRangeCircle(wr, actorPos, OuterRadius, 1, Color.LimeGreen, 0, Color.LimeGreen);
        }
示例#9
0
        public Renderer(GraphicsSettings graphicSettings, IGraphicsDevice device)
        {
            this.Device    = device;
            TempBufferSize = graphicSettings.BatchSize;
            SheetSize      = graphicSettings.SheetSize;

            WorldModelRenderer      = new ModelRenderer(this, Device.CreateShader("model"));
            WorldSpriteRenderer     = new SpriteRenderer(this, Device.CreateShader("shp"));
            WorldRgbaColorRenderer  = new RgbaColorRenderer(this, Device.CreateShader("color"));
            WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
            SpriteRenderer          = new SpriteRenderer(this, Device.CreateShader("shp"));
            RgbaColorRenderer       = new RgbaColorRenderer(this, Device.CreateShader("color"));
            RgbaSpriteRenderer      = new SpriteRenderer(this, Device.CreateShader("rgba"));
            tempBuffer = Device.CreateVertexBuffer(TempBufferSize);
        }
示例#10
0
        public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
        {
            var a = actor.CenterPosition + new WVec(PointA.X, PointA.Y, 0).Rotate(actor.Orientation);
            var b = actor.CenterPosition + new WVec(PointB.X, PointB.Y, 0).Rotate(actor.Orientation);

            var offset = new WVec(a.Y - b.Y, b.X - a.X, 0);

            offset = offset * Radius.Length / offset.Length;

            var c = Color.Yellow;

            RangeCircleRenderable.DrawRangeCircle(wr, a, Radius, 1, c, 0, c);
            RangeCircleRenderable.DrawRangeCircle(wr, b, Radius, 1, c, 0, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(a - offset), wr.ScreenPosition(b - offset) }, 1, c);
            wcr.DrawLine(new[] { wr.ScreenPosition(a + offset), wr.ScreenPosition(b + offset) }, 1, c);
        }
示例#11
0
        void DrawArmaments(Actor self, AttackBase attack, WorldRenderer wr, RgbaColorRenderer wcr, float iz)
        {
            var c = Color.White;

            // Fire ports on garrisonable structures
            var garrison = attack as AttackGarrisoned;

            if (garrison != null)
            {
                var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
                foreach (var p in garrison.Info.Ports)
                {
                    var pos = self.CenterPosition + coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
                    var da  = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw + p.Cone)).Rotate(bodyOrientation));
                    var db  = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw - p.Cone)).Rotate(bodyOrientation));

                    var o = wr.Screen3DPosition(pos);
                    var a = wr.Screen3DPosition(pos + da * 224 / da.Length);
                    var b = wr.Screen3DPosition(pos + db * 224 / db.Length);
                    wcr.DrawLine(o, a, iz, c);
                    wcr.DrawLine(o, b, iz, c);
                }

                return;
            }

            foreach (var a in attack.Armaments)
            {
                if (a.IsTraitDisabled)
                {
                    continue;
                }

                foreach (var b in a.Barrels)
                {
                    var muzzle    = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.Screen3DPosition(muzzle);
                    var sd = wr.Screen3DPosition(muzzle + dirOffset);
                    wcr.DrawLine(sm, sd, iz, c);
                    TargetLineRenderable.DrawTargetMarker(wr, c, sm);
                }
            }
        }
示例#12
0
        public Renderer(IPlatform platform, GraphicSettings graphicSettings)
        {
            var resolution = GetResolution(graphicSettings);

            Device = platform.CreateGraphics(new Size(resolution.Width, resolution.Height), graphicSettings.Mode);

            TempBufferSize = graphicSettings.BatchSize;
            SheetSize      = graphicSettings.SheetSize;

            WorldSpriteRenderer     = new SpriteRenderer(this, Device.CreateShader("shp"));
            WorldRgbaSpriteRenderer = new SpriteRenderer(this, Device.CreateShader("rgba"));
            WorldRgbaColorRenderer  = new RgbaColorRenderer(this, Device.CreateShader("color"));
            WorldVoxelRenderer      = new VoxelRenderer(this, Device.CreateShader("vxl"));
            RgbaColorRenderer       = new RgbaColorRenderer(this, Device.CreateShader("color"));
            RgbaSpriteRenderer      = new SpriteRenderer(this, Device.CreateShader("rgba"));
            SpriteRenderer          = new SpriteRenderer(this, Device.CreateShader("shp"));

            tempBuffer = Device.CreateVertexBuffer(TempBufferSize);
        }
        public Renderer(IPlatform platform, GraphicSettings graphicSettings)
        {
            var resolution = GetResolution(graphicSettings);

            Window  = platform.CreateWindow(new Size(resolution.Width, resolution.Height), graphicSettings.Mode, graphicSettings.BatchSize);
            Context = Window.Context;

            TempBufferSize = graphicSettings.BatchSize;
            SheetSize      = graphicSettings.SheetSize;

            WorldSpriteRenderer     = new SpriteRenderer(this, Context.CreateShader("combined"));
            WorldRgbaSpriteRenderer = new RgbaSpriteRenderer(WorldSpriteRenderer);
            WorldRgbaColorRenderer  = new RgbaColorRenderer(WorldSpriteRenderer);
            WorldModelRenderer      = new ModelRenderer(this, Context.CreateShader("model"));
            SpriteRenderer          = new SpriteRenderer(this, Context.CreateShader("combined"));
            RgbaSpriteRenderer      = new RgbaSpriteRenderer(SpriteRenderer);
            RgbaColorRenderer       = new RgbaColorRenderer(SpriteRenderer);

            tempBuffer = Context.CreateVertexBuffer(TempBufferSize);
        }
示例#14
0
        public void SetViewportParams(int2 scroll, float zoom)
        {
            // PERF: Calling SetViewportParams on each renderer is slow. Only call it when things change.
            var resolutionChanged = lastResolution != Resolution;

            if (resolutionChanged)
            {
                lastResolution = Resolution;
                RgbaSpriteRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
                SpriteRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
                RgbaColorRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
            }

            // If zoom evaluates as different due to floating point weirdness that's OK, setting the parameters again is harmless.
            if (resolutionChanged || lastScroll != scroll || lastZoom != zoom)
            {
                lastScroll = scroll;
                lastZoom   = zoom;
                WorldRgbaSpriteRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
                WorldSpriteRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
                WorldVoxelRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldRgbaColorRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
            }
        }
示例#15
0
 public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
 {
     RangeCircleRenderable.DrawRangeCircle(wr, actor.CenterPosition, Radius, 1, Color.Yellow, 0, Color.Yellow);
 }
示例#16
0
 public void DrawCombatOverlay(WorldRenderer wr, RgbaColorRenderer wcr, Actor actor)
 {
 }