Exemplo n.º 1
0
        public void AddBeamBolt(Vector3 p, Vector3 normal, BeamBolt bolt)
        {
            boltCount++;
            //Head
            CoordsFromTexture(bolt.HeadTexture, out var tl, out var tr, out var bl, out var br, out var mid);

            //Core, tip and trail
            CoordsFromTexture(bolt.TrailTexture, out tl, out tr, out bl, out br, out mid);
        }
Exemplo n.º 2
0
        public override void Draw()
        {
            ImGui.Columns(2);
            ImGui.BeginChild("##munitions");
            foreach (var m in projectileList)
            {
                if (ImGui.Selectable(m.Nickname, currentMunition == m))
                {
                    currentMunition = m;
                    constEffect     = effects.FindEffect(m.ConstEffect);
                    bolt            = effects.BeamBolts.FirstOrDefault(x =>
                                                                       x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    beam = effects.BeamSpears.FirstOrDefault(x =>
                                                             x.Nickname.Equals(constEffect.VisBeam, StringComparison.OrdinalIgnoreCase));
                    viewport.ResetControls();
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            ImGui.BeginChild("##rendering");
            ViewerControls.DropdownButton("Camera Mode", ref cameraMode, camModes);
            viewport.Mode = (CameraModes)camModes[cameraMode].Tag;
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                viewport.ResetControls();
            }
            viewport.Begin();
            Matrix4x4 rot = Matrix4x4.CreateRotationX(viewport.CameraRotation.Y) *
                            Matrix4x4.CreateRotationY(viewport.CameraRotation.X);
            var dirRot = Matrix4x4.CreateRotationX(viewport.ModelRotation.Y) * Matrix4x4.CreateRotationY(viewport.ModelRotation.X);
            var norm   = Vector3.TransformNormal(-Vector3.UnitZ, dirRot);
            var dir    = Vector3.Transform(-Vector3.UnitZ, rot);
            var to     = viewport.CameraOffset + (dir * 10);

            if (viewport.Mode == CameraModes.Arcball)
            {
                to = Vector3.Zero;
            }
            camera.Update(viewport.RenderWidth, viewport.RenderHeight, viewport.CameraOffset, to, rot);
            mw.Commands.StartFrame(mw.RenderState);
            beams.Begin(mw.Commands, mw.Resources, camera);
            var position = Vector3.Zero;

            if (beam != null)
            {
                beams.AddBeamSpear(position, norm, beam);
            }
            else if (bolt != null)
            {
                Vector2 tl, tr, bl, br;
                //CoordsFromTexture(bolt.HeadTexture, out tl, out tr, out bl, out br);
            }
            beams.End();
            fxPool.Draw(camera, null, mw.Resources, null);
            mw.Commands.DrawOpaque(mw.RenderState);
            mw.RenderState.DepthWrite = false;
            mw.Commands.DrawTransparent(mw.RenderState);
            mw.RenderState.DepthWrite = true;
            if (constEffect != null)
            {
                mw.Renderer2D.Start(viewport.RenderWidth, viewport.RenderHeight);
                var debugText = new StringBuilder();
                debugText.AppendLine($"ConstEffect: {constEffect.Nickname}");
                if (bolt != null)
                {
                    debugText.AppendLine($"Bolt: {bolt.Nickname}");
                }
                if (beam != null)
                {
                    debugText.AppendLine($"Beam: {beam.Nickname}");
                }
                mw.Renderer2D.DrawString("Arial", 10, debugText.ToString(), Vector2.One, Color4.White);
                mw.Renderer2D.Finish();
            }
            viewport.End();
            ImGui.EndChild();
        }
Exemplo n.º 3
0
        public void AddBeamBolt(Vector3 p, Vector3 normal, BeamBolt bolt, float maxTrailLen)
        {
            //Head
            CoordsFromTexture(bolt.HeadTexture, out var tl, out var tr, out var bl, out var br, out var mid);
            var right = Vector3.Cross(normal, Vector3.UnitY);

            right.Normalize();
            var up = Vector3.Cross(right, normal);

            up.Normalize();
            var hRad   = bolt.HeadWidth / 2;
            var cRad   = bolt.CoreWidth / 2;
            var secRad = bolt.SecCoreWidth / 2;

            //Quad Center
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p, bolt.CoreColor, mid);
            //Quad TL
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p + (up * hRad) - (right * hRad), bolt.OuterColor, tl);
            //Quad TR
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p + (up * hRad) + (right * hRad), bolt.OuterColor, tr);
            //Quad BL
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p - (up * hRad) - (right * hRad), bolt.OuterColor, bl);
            //Quad BR
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p - (up * hRad) + (right * hRad), bolt.OuterColor, br);
            //Tip and trail
            CoordsFromTexture(bolt.TrailTexture, out tl, out tr, out bl, out br, out mid);
            //Mid-Mid
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p, bolt.CoreColor, bl);
            //Mid-Top
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p + (up * cRad), bolt.CoreColor, br);
            //Mid-Bottom
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p - (up * cRad), bolt.CoreColor, br);
            //Mid-Left
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p - (right * cRad), bolt.CoreColor, br);
            //Mid-Right
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p + (right * cRad), bolt.CoreColor, br);

            //sec
            var coreLen = Math.Min(maxTrailLen, bolt.CoreLength);
            var p2      = p - (normal * coreLen);

            //Sec-Mid
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p2, bolt.SecCoreColor, bl);
            //Sec-Top
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p2 + (up * secRad), bolt.SecOuterColor, br);
            //Sec-Bottom
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p2 - (up * secRad), bolt.SecOuterColor, br);
            //Sec-Left
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p2 - (right * secRad), bolt.SecOuterColor, br);
            //Sec-Right
            verticesBolt[vertexCountBolt++] = new VertexPositionColorTexture(p2 + (right * secRad), bolt.SecOuterColor, br);

            //Tip
            verticesBolt[vertexCountBolt++] =
                new VertexPositionColorTexture(p + (normal * bolt.TipLength), bolt.TipColor, tr);
            //Trail
            var tailLength = Math.Min(maxTrailLen, bolt.TailLength + bolt.CoreLength);

            verticesBolt[vertexCountBolt++] =
                new VertexPositionColorTexture(p - (normal * tailLength), bolt.TailColor, tr);
            boltCount++;
        }