Exemple #1
0
        public override void Step(Framework.Settings settings)
        {
            Manifold manifold = new Manifold();

            Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB);

            WorldManifold worldManifold = new WorldManifold(ref manifold, ref _transformA, _polygonA._radius, ref _transformB, _polygonB._radius);

            _debugDraw.DrawString(50, _textLine, "point count = {0:n}", manifold._pointCount);
            _textLine += 15;

            {
                Color color             = new ColorR(0.9, 0.9, 0.9);
                FixedArray8 <Vector2> v = new FixedArray8 <Vector2>();
                for (int i = 0; i < _polygonA._vertexCount; ++i)
                {
                    v[i] = MathUtils.Multiply(ref _transformA, _polygonA._vertices[i]);
                }
                _debugDraw.DrawPolygon(ref v, _polygonA._vertexCount, color);

                for (int i = 0; i < _polygonB._vertexCount; ++i)
                {
                    v[i] = MathUtils.Multiply(ref _transformB, _polygonB._vertices[i]);
                }
                _debugDraw.DrawPolygon(ref v, _polygonB._vertexCount, color);
            }

            for (int i = 0; i < manifold._pointCount; ++i)
            {
                _debugDraw.DrawPoint(worldManifold._points[i], 0.5f, new ColorR(0.9, 0.3, 0.3));
            }
        }
Exemple #2
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            base.Update(settings);

            PolyShapesCallback callback = new PolyShapesCallback();

            callback.Circle.Radius   = 2.0f;
            callback.Circle.Position = new Vector2(0.0f, 1.1f);
            callback.Transform.SetIdentity();
            callback.DebugDraw = DebugView;

            AABB aabb;

            callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0);


            World.QueryAABB(callback.ReportFixture, ref aabb);

            Color color = new ColorR(0.4f, 0.7f, 0.8f);

            DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color);


            DrawString("Press 1-5 to drop stuff");
            DrawString("Press a to (de)activate some bodies");
            DrawString("Press d to destroy a body");
        }
Exemple #3
0
        public override void Step(Framework.Settings settings)
        {
            base.Step(settings);

            PolyShapesCallback callback = new PolyShapesCallback();

            callback._circle._radius = 2.0f;
            callback._circle._p      = new Vector2(0.0f, 2.1f);
            callback._transform.SetIdentity();
            callback._debugDraw = _debugDraw;

            AABB aabb;

            callback._circle.ComputeAABB(out aabb, ref callback._transform, 0);

            _world.QueryAABB(callback.ReportFixture, ref aabb);

            Color color = new ColorR(0.4, 0.7, 0.8);

            _debugDraw.DrawCircle(callback._circle._p, callback._circle._radius, color);

            _debugDraw.DrawString(50, _textLine, "Press 1-5 to drop stuff");
            _textLine += 15;
            _debugDraw.DrawString(50, _textLine, "Press a to (de)activate some bodies");
            _textLine += 15;
            _debugDraw.DrawString(50, _textLine, "Press d to destroy a body");
            _textLine += 15;
        }
Exemple #4
0
        void SetHexString()
        {
            string hexA = Alpha.ToString("X");
            string hexR = ColorR.ToString("X");
            string hexG = ColorG.ToString("X");
            string hexB = ColorB.ToString("X");

            // .ToString("X") returns "0" for a 0 value, we want full hex pairs, so replace with "00"
            if (hexA == "0")
            {
                hexA = "00";
            }
            if (hexR == "0")
            {
                hexR = "00";
            }
            if (hexG == "0")
            {
                hexG = "00";
            }
            if (hexB == "0")
            {
                hexB = "00";
            }

            _hexColor = hexA + hexR + hexG + hexB;
        }
        private Particle GenerateParticle(int index)
        {
            float speedMultiplier    = 1 + random.NextFloat(-SpeedDeviation, SpeedDeviation);
            float rotationMultiplier = 1 + random.NextFloat(-RotationDeviation, RotationDeviation);
            float scaleMultiplier    = 1 + random.NextFloat(-ScaleDeviation, ScaleDeviation);

            return(new Particle(Texture, EmitterLocations[index] + new Vector2(Global.rand.NextFloat(0, 0.99f), Global.rand.NextFloat(0, 0.99f)),
                                Utils.Vector2FromSpeedAndDirection(Speed.Evaluate(0) * speedMultiplier, random.NextFloat(MinDirection, MaxDirection)),
                                speedMultiplier, Rotation.Evaluate(0) * rotationMultiplier, rotationMultiplier,
                                new Color(ColorR.Evaluate(0), ColorG.Evaluate(0), ColorB.Evaluate(0), ColorA.Evaluate(0)),
                                Scale.Evaluate(0), scaleMultiplier, random.NextFloat(MinLifetime, MaxLifetime), HurtsPlayer, DamageRatio));
        }
        public void Update(GameTime gameTime, PlayState map, bool emitParticles)
        {
            foreach (Particle particle in particles)
            {
                particle.Update(gameTime, map);
                float age = particle.Age / particle.Lifetime;

                Vector2 direction = particle.Velocity;
                if (direction != Vector2.Zero)
                {
                    direction.Normalize();
                }
                particle.Velocity = direction * Speed.Evaluate(age) * particle.SpeedMultiplier;
                particle.Rotation = Rotation.Evaluate(age) * particle.RotationMultiplier;
                particle.Scale    = Scale.Evaluate(age) * particle.ScaleMultiplier;

                particle.Color = new Color(ColorR.Evaluate(age), ColorG.Evaluate(age), ColorB.Evaluate(age), ColorA.Evaluate(age));
            }

            for (int i = 0; i < particles.Count; i++)
            {
                if (particles[i].Age >= particles[i].Lifetime)
                {
                    particles.RemoveAt(i);
                    i--;
                }
            }

            if (emitParticles)
            {
                for (int j = EmitterLocations.Count - 1; j >= 0; j--)
                {
                    float emission = (float)gameTime.ElapsedGameTime.TotalSeconds * EmissionRate;
                    emissionError += emission - (float)Math.Floor(emission);
                    emission      -= emission - (float)Math.Floor(emission);
                    emission      += (float)Math.Floor(emissionError);
                    emissionError -= (float)Math.Floor(emissionError);
                    for (int i = 0; i < emission; i++)
                    {
                        particles.Add(GenerateParticle(j));
                    }
                }
            }

            foreach (IParticleManipulator manipulator in Manipulators)
            {
                foreach (Particle particle in particles)
                {
                    manipulator.ManipulateParticle(particle);
                }
            }
        }
Exemple #7
0
        public override void Step(Framework.Settings settings)
        {
            base.Step(settings);

            DistanceInput input = new DistanceInput();

            input.proxyA.Set(_polygonA, 0);
            input.proxyB.Set(_polygonB, 0);
            input.transformA = _transformA;
            input.transformB = _transformB;
            input.useRadii   = true;
            SimplexCache cache = new SimplexCache();

            cache.count = 0;
            DistanceOutput output = new DistanceOutput();

            Distance.ComputeDistance(out output, out cache, ref input);

            _debugDraw.DrawString(50, _textLine, "distance = {0:n}", output.distance);
            _textLine += 15;

            _debugDraw.DrawString(50, _textLine, "iterations = {0:n}", output.iterations);
            _textLine += 15;

            {
                Color color             = new ColorR(0.9, 0.9, 0.9);
                FixedArray8 <Vector2> v = new FixedArray8 <Vector2>();
                for (int i = 0; i < _polygonA._vertexCount; ++i)
                {
                    v[i] = MathUtils.Multiply(ref _transformA, _polygonA._vertices[i]);
                }
                _debugDraw.DrawPolygon(ref v, _polygonA._vertexCount, color);

                for (int i = 0; i < _polygonB._vertexCount; ++i)
                {
                    v[i] = MathUtils.Multiply(ref _transformB, _polygonB._vertices[i]);
                }
                _debugDraw.DrawPolygon(ref v, _polygonB._vertexCount, color);
            }

            Vector2 x1 = output.pointA;
            Vector2 x2 = output.pointB;


            _debugDraw.DrawPoint(x1, 0.5f, new ColorR(1.0f, 0.0f, 0.0f));
            _debugDraw.DrawPoint(x2, 0.5f, new ColorR(1.0f, 0.0f, 0.0f));

            _debugDraw.DrawSegment(x1, x2, new ColorR(1.0f, 1.0f, 0.0f));
        }
Exemple #8
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            base.Update(settings);

            DistanceInput input = new DistanceInput();

            input.ProxyA.Set(_polygonA, 0);
            input.ProxyB.Set(_polygonB, 0);
            input.TransformA = _transformA;
            input.TransformB = _transformB;
            input.UseRadii   = true;
            SimplexCache cache;

            cache.Count = 0;
            DistanceOutput output;

            Distance.ComputeDistance(out output, out cache, input);

            DrawString("Distance = " + output.Distance);
            DrawString("Iterations = " + output.Iterations);


            {
                Color     color = new ColorR(0.9f, 0.9f, 0.9f);
                Vector2[] v     = new Vector2[Alt.FarseerPhysics.Settings.MaxPolygonVertices];
                for (int i = 0; i < _polygonA.Vertices.Count; ++i)
                {
                    v[i] = MathUtils.Mul(ref _transformA, _polygonA.Vertices[i]);
                }
                DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color);

                for (int i = 0; i < _polygonB.Vertices.Count; ++i)
                {
                    v[i] = MathUtils.Mul(ref _transformB, _polygonB.Vertices[i]);
                }
                DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color);
            }

            Vector2 x1 = output.PointA;
            Vector2 x2 = output.PointB;

            DebugView.DrawPoint(x1, 0.5f, new ColorR(1.0f, 0.0f, 0.0f));
            DebugView.DrawPoint(x2, 0.5f, new ColorR(1.0f, 0.0f, 0.0f));

            DebugView.DrawSegment(x1, x2, new ColorR(1.0f, 1.0f, 0.0f));
        }
Exemple #9
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            base.Update(settings);

            DrawString("Press: (,) to explode at mouse position.");

            DrawString("Press: (A) to decrease the explosion radius, (S) to increase it.");

            DrawString("Press: (D) to decrease the explosion power, (F) to increase it.");

            // Fighting against double decimals
            double powernumber = (double)((int)(_force * 10)) / 10;

            DrawString("Power: " + powernumber);

            Color color = new ColorR(0.4f, 0.7f, 0.8f);

            DebugView.DrawCircle(_mousePos, _radius, color);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            //  Transformation Type
            rbBilinear.Select();

            groupBox_TransformationType.SelectionChanged += new GwenEventHandler(groupBox_TransformationType_SelectionChanged);

            //  update groupBox_TransformationType location
            DrawingPanel_Resize(null, EventArgs.Empty);



            //
            m_PolygonElement           = new PolygonElement(4, 5.0);
            m_PolygonElement.Color     = Color.FromArgb(200, Color.Yellow);
            m_PolygonElement.LineWidth = 2;
            m_DrawingPanel.AddElement(m_PolygonElement);



            //
            m_SVGPath = new SVGPath();
            m_x       = m_DrawingPanel.ClientWidth / 2;
            m_y       = m_DrawingPanel.ClientHeight / 2;

            m_EllipsePen   = new Pen(Color.LightGreen, 3);
            m_EllipseBrush = new SolidColorBrush(ColorR.FromArgb(0.4, 0.5, 0.3, 0.0));


            try
            {
                LoadSVG("AltData/SVG/lion.svg");
            }
            catch (SVGException)
            {
                //TEMP  message(.ToString(e.Message));

                return;
            }
        }
        protected override void Render(Alt.GUI.Temporary.Gwen.Skin.Base skin)
        {
            if (m_SpiralPen == null)
            {
                bool isUnityRender = skin.Renderer.Graphics.RenderSystemName == Graphics.RSN_Unity;

                m_GeometryAColor             = new ColorR(isUnityRender ? 0.5 : 0.2, 1, 1, 1);
                m_GeometryBColor             = new ColorR(isUnityRender ? 0.5 : 0.2, 0, 0, 0);
                m_SpiralPen                  = new Pen(m_GeometryAColor, 15);
                m_GreatBritainContourPen_SWR = new Pen(ColorR.Black, 0.1);
                m_GreatBritainContourPen_HWR = new Pen(ColorR.FromArgb(0.57, ColorR.Black));//, 0.1);
                m_ContourPen                 = new Pen(Color.FromArgb(isUnityRender ? 225 : 200, Color.Yellow));
            }

            base.Render(skin);

            groupBox_Geometry.SizeToChildren(false, true);
            groupBox_BooleanOperation.SizeToChildren(false, true);
            groupBox_Geometry.AutoSizeToContents         = false;
            groupBox_BooleanOperation.AutoSizeToContents = false;
        }
Exemple #12
0
        void DrawFixture(Fixture fixture)
        {
            Color color = new ColorR(0.95f, 0.95f, 0.6f);

            Alt.Box2D.Transform xf;
            fixture.GetBody().GetTransform(out xf);

            switch (fixture.ShapeType)
            {
            case ShapeType.Circle:
            {
                CircleShape circle = (CircleShape)fixture.GetShape();

                Vector2 center = MathUtils.Multiply(ref xf, circle._p);
                double  radius = circle._radius;

                _debugDraw.DrawCircle(center, radius, color);
            }
            break;

            case ShapeType.Polygon:
            {
                PolygonShape poly        = (PolygonShape)fixture.GetShape();
                int          vertexCount = poly._vertexCount;
                Debug.Assert(vertexCount <= Alt.Box2D.Settings.b2_maxPolygonVertices);
                FixedArray8 <Vector2> vertices = new FixedArray8 <Vector2>();

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = MathUtils.Multiply(ref xf, poly._vertices[i]);
                }

                _debugDraw.DrawPolygon(ref vertices, vertexCount, color);
            }
            break;
            }
        }
Exemple #13
0
        void DrawFixture(Fixture fixture)
        {
            Color color = new ColorR(0.95f, 0.95f, 0.6f);

            Alt.FarseerPhysics.Common.Transform xf;
            fixture.Body.GetTransform(out xf);

            switch (fixture.Shape.ShapeType)
            {
            case ShapeType.Circle:
            {
                CircleShape circle = (CircleShape)fixture.Shape;

                Vector2 center = MathUtils.Mul(ref xf, circle.Position);
                double  radius = circle.Radius;

                DebugDraw.DrawSolidCircle(center, radius, Vector2.Zero, color);
            }
            break;

            case ShapeType.Polygon:
            {
                PolygonShape poly        = (PolygonShape)fixture.Shape;
                int          vertexCount = poly.Vertices.Count;
                Debug.Assert(vertexCount <= Alt.FarseerPhysics.Settings.MaxPolygonVertices);
                Vector2[] vertices = new Vector2[Alt.FarseerPhysics.Settings.MaxPolygonVertices];

                for (int i = 0; i < vertexCount; ++i)
                {
                    vertices[i] = MathUtils.Mul(ref xf, poly.Vertices[i]);
                }

                DebugDraw.DrawSolidPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
Exemple #14
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            Manifold manifold = new Manifold();

            Alt.FarseerPhysics.Collision.Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB);

            Vector2 normal;
            FixedArray2 <Vector2> points;

            ContactSolver.WorldManifold.Initialize(ref manifold, ref _transformA, _polygonA.Radius, ref _transformB, _polygonB.Radius, out normal, out points);

            DrawString("Point count = " + manifold.PointCount);


            {
                Color     color = new ColorR(0.9, 0.9, 0.9);
                Vector2[] v     = new Vector2[Alt.FarseerPhysics.Settings.MaxPolygonVertices];
                for (int i = 0; i < _polygonA.Vertices.Count; ++i)
                {
                    v[i] = MathUtils.Mul(ref _transformA, _polygonA.Vertices[i]);
                }
                DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color);

                for (int i = 0; i < _polygonB.Vertices.Count; ++i)
                {
                    v[i] = MathUtils.Mul(ref _transformB, _polygonB.Vertices[i]);
                }
                DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color);
            }

            for (int i = 0; i < manifold.PointCount; ++i)
            {
                DebugView.DrawPoint(points[i], 0.1f, new ColorR(0.9f, 0.3f, 0.3f));
                DrawString(points[i].ToString());
            }
        }
Exemple #15
0
 public static UnityEngine.Color ToColor(ColorR color)
 {
     return(new UnityEngine.Color((float)color.R, (float)color.G, (float)color.B, (float)color.A));
 }
Exemple #16
0
        public static void Color(float r, float g, float b)
        {
            CurrentColor = ColorR.FromArgb(r, g, b);

            GL.Color3(r, g, b);
        }
Exemple #17
0
        public static void Color(float r, float g, float b, float a)
        {
            CurrentColor = ColorR.FromArgb(a, r, g, b);

            GL.Color4(r, g, b, a);
        }
Exemple #18
0
        public override void Update(FarseerPhysicsGameSettings settings)
        {
            _rayActor = null;
            for (int i = 0; i < ActorCount; ++i)
            {
                _actors[i].Fraction = 1.0f;
                _actors[i].Overlap  = false;
            }

            if (_automated)
            {
                int actionCount = Math.Max(1, ActorCount >> 2);

                for (int i = 0; i < actionCount; ++i)
                {
                    Action();
                }
            }

            Query();
            RayCast();


            for (int i = 0; i < ActorCount; ++i)
            {
                Actor actor = _actors[i];
                if (actor.ProxyId == -1)
                {
                    continue;
                }

                Color ca = new ColorR(0.9, 0.9, 0.9);
                if (actor == _rayActor && actor.Overlap)
                {
                    ca = new ColorR(0.9, 0.6, 0.6);
                }
                else if (actor == _rayActor)
                {
                    ca = new ColorR(0.6, 0.9, 0.6);
                }
                else if (actor.Overlap)
                {
                    ca = new ColorR(0.6, 0.6, 0.9);
                }

                DebugView.DrawAABB(ref actor.AABB, ca);
            }

            Color c = new ColorR(0.7, 0.7, 0.7);

            DebugView.DrawAABB(ref _queryAABB, c);

            DebugView.DrawSegment(_rayCastInput.Point1, _rayCastInput.Point2, c);

            Color c1 = new ColorR(0.2, 0.9, 0.2);
            Color c2 = new ColorR(0.9, 0.2, 0.2);

            DebugView.DrawPoint(_rayCastInput.Point1, 0.1f, c1);
            DebugView.DrawPoint(_rayCastInput.Point2, 0.1f, c2);

            if (_rayActor != null)
            {
                Color   cr = new ColorR(0.2f, 0.2f, 0.9f);
                Vector2 p  = _rayCastInput.Point1 + _rayActor.Fraction * (_rayCastInput.Point2 - _rayCastInput.Point1);
                DebugView.DrawPoint(p, 0.1f, cr);
            }


            int height = _tree.Height;

            DrawString("Dynamic tree Height = " + height);
        }
Exemple #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (X != 0F)
            {
                hash ^= X.GetHashCode();
            }
            if (Y != 0F)
            {
                hash ^= Y.GetHashCode();
            }
            if (Vx != 0F)
            {
                hash ^= Vx.GetHashCode();
            }
            if (Vy != 0F)
            {
                hash ^= Vy.GetHashCode();
            }
            if (Rotation != 0F)
            {
                hash ^= Rotation.GetHashCode();
            }
            if (Omega != 0F)
            {
                hash ^= Omega.GetHashCode();
            }
            if (InitLife != 0F)
            {
                hash ^= InitLife.GetHashCode();
            }
            if (Life != 0F)
            {
                hash ^= Life.GetHashCode();
            }
            if (Scale != 0F)
            {
                hash ^= Scale.GetHashCode();
            }
            if (Alpha != 0F)
            {
                hash ^= Alpha.GetHashCode();
            }
            if (Mass != 0F)
            {
                hash ^= Mass.GetHashCode();
            }
            if (IsDead != false)
            {
                hash ^= IsDead.GetHashCode();
            }
            if (ColorR != 0F)
            {
                hash ^= ColorR.GetHashCode();
            }
            if (ColorG != 0F)
            {
                hash ^= ColorG.GetHashCode();
            }
            if (ColorB != 0F)
            {
                hash ^= ColorB.GetHashCode();
            }
            if (CurrentAnimationFrame != 0)
            {
                hash ^= CurrentAnimationFrame.GetHashCode();
            }
            return(hash);
        }
Exemple #20
0
 get => new MyColor(ColorR, ColorG, ColorB, ColorAlpha);
Exemple #21
0
        /// <summary>
        /// Called when it is time to render the next frame. Add your rendering code here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        void QuickFontControl_Paint(object sender, PaintEventArgs e)
        {
            Graphics      graphics = e.Graphics;
            GraphicsState state;

            switch (currentDemoPage)
            {
            case 1:
            {
                double yOffset = 0;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(Width * 0.5f, yOffset + 10);
                heading1.Print("AltGUI QuickFont", QFontAlignment.Centre);
                yOffset += heading1.Measure("QuickFont").Height;
                graphics.Restore(state);


                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Introduction", QFontAlignment.Left);
                yOffset += heading2.Measure("Introduction").Height;
                graphics.Restore(state);


                state = graphics.Save();
                graphics.TranslateTransform(30f, yOffset + 20);
                mainText.Print(introduction, Width - 60, QFontAlignment.Justify);
                graphics.Restore(state);

                QFont.End();
            }
            break;

            case 2:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Easy as ABC!", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);


                PrintComment(graphics, usingQuickFontIsSuperEasy, ref yOffset);
                PrintCode(graphics, loadingAFont1, ref yOffset);

                PrintComment(graphics, andPrintWithIt, ref yOffset);
                PrintCode(graphics, printWithFont1, ref yOffset);

                PrintComment(graphics, itIsAlsoEasyToMeasure, ref yOffset);
                PrintCode(graphics, measureText1, ref yOffset);

                PrintComment(graphics, oneOfTheFirstGotchas, ref yOffset);
                PrintCode(graphics, loadingAFont2, ref yOffset);

                QFont.End();
            }
            break;

            case 3:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Alignment", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);

                PrintCommentWithLine(graphics, whenPrintingText, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                PrintCode(graphics, printWithFont2, ref yOffset);


                PrintCommentWithLine(graphics, righAlignedText, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 10f;

                PrintCommentWithLine(graphics, centredTextAsYou, QFontAlignment.Centre, Width * 0.5f, ref yOffset);

                QFont.End();
            }
            break;

            case 4:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Bounds and Justify", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);

                state    = graphics.Save();
                yOffset += 20;
                graphics.TranslateTransform((int)(Width * 0.5), yOffset);
                controlsText.Options.Colour = Color.Yellow;
                controlsText.Print("Press [Up], [Down] or [Enter]!", QFontAlignment.Centre);
                yOffset += controlsText.Measure("[]").Height;
                graphics.Restore(state);

                double boundShrink = (int)(350 * (1 - Math.Cos(boundsAnimationCnt * Math.PI * 2)));

                yOffset += 15;
                PrintWithBounds(graphics, mainText, ofCourseItsNot, new Rect(30f + boundShrink * 0.5f, yOffset, Width - 60 - boundShrink, 350f), cycleAlignment, ref yOffset);

                string printWithBounds = "myFont.Print(text, 400f, QFontAlignment." + cycleAlignment + ");";
                yOffset += 15f;
                PrintCode(graphics, printWithBounds, ref yOffset);

                QFont.End();
            }
            break;

            case 5:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, anotherCoolFeature, ref yOffset);
                PrintCode(graphics, textureFontCode1, ref yOffset);
                PrintComment(graphics, thisWillHaveCreated, ref yOffset);

                QFont.End();
            }
            break;

            case 6:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, ifYouDoIntend, ref yOffset);
                PrintCode(graphics, textureFontCode2, ref yOffset);
                PrintComment(graphics, actuallyTexturing, ref yOffset);
                PrintCode(graphics, textureFontCode3, ref yOffset);

                QFont.End();
            }
            break;

            case 7:
            {
                double yOffset = 20;

                QFont.Begin();

                heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Drop Shadows", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.16f, 0.16f);         //back to default

                mainText.Options.DropShadowActive  = true;
                mainText.Options.DropShadowOpacity = 0.7f;
                mainText.Options.DropShadowOffset  = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

                PrintComment(graphics, asIhaveleant, ref yOffset);
                PrintCode(graphics, dropShadowCode1, ref yOffset);
                PrintComment(graphics, thisWorksFine, ref yOffset);
                PrintCode(graphics, dropShadowCode2, ref yOffset);
                PrintComment(graphics, onceAFont, ref yOffset);

                mainText.Options.DropShadowActive = false;

                QFont.End();
            }
            break;

            case 8:
            {
                double yOffset = 20;

                QFont.Begin();

                monoSpaced.Options.CharacterSpacing = 0.05f;

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Monospaced Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);


                PrintComment(graphics, monoSpaced, hereIsSomeMono, QFontAlignment.Left, ref yOffset);
                PrintCode(graphics, monoCode1, ref yOffset);
                PrintComment(graphics, monoSpaced, theDefaultMono, QFontAlignment.Left, ref yOffset);

                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Centre, Width * 0.5f, ref yOffset);
                yOffset += 2f;

                monoSpaced.Options.CharacterSpacing = 0.5f;
                PrintComment(graphics, monoSpaced, "As usual, you can adjust character spacing with myFont.Options.CharacterSpacing.", QFontAlignment.Left, ref yOffset);

                QFont.End();
            }
            break;

            case 9:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("In Conclusion", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, thereAreActually, ref yOffset);

                QFont.End();
            }
            break;
            }


            QFont.Begin();

            Color pressColor = new ColorR(0.8, 0.2, 0.2);// new ColorR(0.8, 0.1, 0.1);

            if (currentDemoPage != lastPage)
            {
                state = graphics.Save();
                graphics.TranslateTransform(Width - 15 - 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 17);
                controlsText.Options.Colour = pressColor;
                controlsText.Print("Press [Right] ->", QFontAlignment.Right);
                graphics.Restore(state);
            }

            if (currentDemoPage != 1)
            {
                state = graphics.Save();
                graphics.TranslateTransform(15 + 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 17);
                controlsText.Options.Colour = pressColor;
                controlsText.Print("<- Press [Left]", QFontAlignment.Left);
                graphics.Restore(state);
            }

            QFont.End();
        }
Exemple #22
0
        public override void Step(Framework.Settings settings)
        {
            _rayActor = null;
            for (int i = 0; i < e_actorCount; ++i)
            {
                _actors[i].fraction = 1.0f;
                _actors[i].overlap  = false;
            }

            if (_automated == true)
            {
                int actionCount = Math.Max(1, e_actorCount >> 2);

                for (int i = 0; i < actionCount; ++i)
                {
                    Action();
                }
            }

            Query();
            RayCast();

            for (int i = 0; i < e_actorCount; ++i)
            {
                Actor actor = _actors[i];
                if (actor.proxyId == -1)
                {
                    continue;
                }

                Color ca = new ColorR(0.9, 0.9, 0.9);
                if (actor == _rayActor && actor.overlap)
                {
                    ca = new ColorR(0.9, 0.6, 0.6);
                }
                else if (actor == _rayActor)
                {
                    ca = new ColorR(0.6, 0.9, 0.6);
                }
                else if (actor.overlap)
                {
                    ca = new ColorR(0.6, 0.6, 0.9);
                }

                _debugDraw.DrawAABB(ref actor.aabb, ca);
            }

            Color c = new ColorR(0.7, 0.7, 0.7);

            _debugDraw.DrawAABB(ref _queryAABB, c);

            _debugDraw.DrawSegment(_rayCastInput.p1, _rayCastInput.p2, c);

            Color c1 = new ColorR(0.2, 0.9, 0.2);
            Color c2 = new ColorR(0.9, 0.2, 0.2);

            _debugDraw.DrawPoint(_rayCastInput.p1, 6.0, c1);
            _debugDraw.DrawPoint(_rayCastInput.p2, 6.0, c2);

            if (_rayActor != null)
            {
                Color   cr = new ColorR(0.2, 0.2, 0.9);
                Vector2 p  = _rayCastInput.p1 + _rayActor.fraction * (_rayCastInput.p2 - _rayCastInput.p1);
                _debugDraw.DrawPoint(p, 6.0, cr);
            }

            {
                int height = _tree.ComputeHeight();
                _debugDraw.DrawString(5, _textLine, "dynamic tree Height = %d", height);
                _textLine += 15;
            }

            ++_stepCount;
        }
Exemple #23
0
        void Render(BrushMaterial brushMaterial, Unity_RenderPrimitive renderPrimitive)
        {
            if (brushMaterial == null ||
                renderPrimitive == null)
            {
                return;
            }

            if (renderPrimitive.PreRender())
            {
                Material material = (brushMaterial as IUnity_BrushMaterial).GetMaterial(renderPrimitive);
                if (material != null)
                {
                    ColorR color = ColorR.White;
                    if (brushMaterial is SolidColorBrushMaterial)
                    {
                        color = (brushMaterial as SolidColorBrushMaterial).Color;
                    }

                    double alpha = color.A * brushMaterial.Opacity * brushMaterial.RenderContext.Opacity;
                    color.A        = alpha;
                    material.color = new UnityEngine.Color((float)color.R, (float)color.G, (float)color.B, (float)color.A);


                    Alt.Sketch.Matrix4 mat = brushMaterial.FinalTransform;
                    //bool matIsIdentity = mat.IsIdentity;
                    //if (!matIsIdentity)
                    {
                        GL.PushMatrix();

                        //NoNeed	SizeI renderTargetSize = RenderTargetSize;
                        if (renderPrimitive.PrimitiveTypeIsLines)
                        {
                            mat = mat * m_WorldMatrixLines;
                        }
                        else
                        {
                            mat = mat * m_WorldMatrix;
                        }
                        mat.Transpose();

                        GL.MultMatrix(Unity_RenderManager.ToMatrix(mat));
                    }


                    try
                    {
                        if (m_CurrentUnityEngineRenderer != null)
                        {
                            m_CurrentUnityEngineRenderer.material = material;

                            //	material already setted, so we passed null
                            renderPrimitive.Render(null);
                        }
                        else
                        {
                            renderPrimitive.Render(material);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        //if (!matIsIdentity)
                        {
                            GL.PopMatrix();
                        }
                    }
                }
            }
            renderPrimitive.PostRender();
        }