Ejemplo n.º 1
0
 void OnEnable()
 {
     position.Clear();
     drawer.Draw(position.ToArray());
     drawer.ChangeMaterial(LineDrawer.MaterialType.Preparation);
     isActiveLine = false;
 }
Ejemplo n.º 2
0
        public void TestDraw()
        {
            Assert.ThrowsException <ArgumentNullException>(() => _lineDrawer.Draw(null));
            var graphics = new GraphicsMock();

            _lineDrawer.Draw(graphics);
            Assert.IsTrue(graphics.IsCalledDrawLine);
        }
Ejemplo n.º 3
0
        public void DrawLine(Vector2 waypoint1, Vector2 waypoint2)
        {
            Vector2 start = wowToScreen(new Vector2(waypoint1.X, waypoint1.Y));
            Vector2 end   = wowToScreen(new Vector2(waypoint2.X, waypoint2.Y));

            Line.Draw(start, end);
        }
Ejemplo n.º 4
0
        public List <GameObject> Query(Vector2 point, float size)
        {
            var result = new List <GameObject>();
            var index  = CalculateBucketIndex(point);

            for (int x = index.x - 1; x <= index.x + 1; x++)
            {
                for (int y = index.y - 1; y <= index.y + 1; y++)
                {
                    if (x >= 0 && y >= 0 && x < grid.GetLength(0) && y < grid.GetLength(1))
                    {
                        if (debug)
                        {
                            LineDrawer.Draw(new Vector2(x * gridSize, (y + 1) * gridSize), new Color(x * 0.1f, y * 0.1f, 1), (int)gridSize);
                        }

                        QueryBucket(grid[x, y], result, point, size);
                    }
                }
            }
            if (debug)
            {
                LineDrawer.Draw(new Vector2(index.x * gridSize, (index.y + 1) * gridSize), Color.white, (int)gridSize);
            }

            return(result);
        }
Ejemplo n.º 5
0
 void Draw(Vector3 destination, int dir, int dir2)
 {
     currentLine   = Instantiate(linePrefab, initialPos, Quaternion.identity);
     lineDrawer    = currentLine.GetComponent <LineDrawer>();
     lineDrawer.id = lastID++;
     lineDrawer.Draw(initialPos, destination, dir, dir2);
 }
Ejemplo n.º 6
0
        public override void Draw(IConsole buffer)
        {
            base.Draw(buffer);

            if (DrawBorders)
            {
                lines.Revalidate(buffer);
                lines.Draw(buffer);
            }
        }
Ejemplo n.º 7
0
        private void RenderEditorControls()
        {
            if (_controller != null && _controller.selected && SuperController.singleton.editModeToggle.isOn)
            {
                Graphics.DrawMesh(_controller.holdPositionMesh, _zoneRenderMatrix, _zoneMaterial,
                                  _controller.gameObject.layer, null, 0, null, false, false);

                if (_targetAtom != null && _targetController != null)
                {
                    _lineDrawer.SetLinePoints(_controller.transform.position, _targetController.transform.position);
                    _lineDrawer.Draw();
                }
            }
        }
Ejemplo n.º 8
0
        public void Draw3DLines(Camera camera, Matrix world, Vector3[] lines, Color color)
        {
            LineDrawer.Begin();
            List <Vector2> trans = new List <Vector2>();

            foreach (var v in lines)
            {
                var p = Vector3.Project(v, Viewport.X, Viewport.Y, Viewport.Width, Viewport.Height, Viewport.MinZ, Viewport.MaxZ, world * camera.ViewProjection);
                trans.Add(Common.Math.ToVector2(p));
            }
            LineDrawer.Draw(trans.ToArray(), color);
            //LineDrawer.DrawTransformed(lines, world * camera.View * camera.Projection, color);
            LineDrawer.End();
        }
Ejemplo n.º 9
0
        private void RenderEditorGizmos()
        {
            if (_zoneFreeController != null)
            {
                bool zoneSelected       = _zoneFreeController.selected && SuperController.singleton.editModeToggle.isOn;
                bool controllerSelected = _pluginFreeController != null && _pluginFreeController.selected &&
                                          SuperController.singleton.editModeToggle.isOn;

                bool showZone = zoneSelected || controllerSelected;

                if (showZone)
                {
                    Graphics.DrawMesh(_zoneFreeController.holdPositionMesh, _zoneRenderMatrix, _zoneMaterial,
                                      _zoneFreeController.gameObject.layer, null, 0, null, false, false);

                    float relTargetPos = _currentTargetPos.val / (99.0f * 2.0f);

                    Vector3 targetPosBoxScale = new Vector3(0.2f,
                                                            _targetZoneHeight.val * ZONE_MESH_SCALAR * relTargetPos * 2.0f, 0.2f);


                    Matrix4x4 targetPosMatrix = Matrix4x4.TRS(
                        _zoneFreeController.transform.position +
                        _zoneFreeController.transform.rotation * Vector3.right * (_targetZoneWidth.val + 0.01f) +
                        _zoneFreeController.transform.rotation * Vector3.down * _targetZoneHeight.val +
                        _zoneFreeController.transform.rotation * Vector3.up * _targetZoneHeight.val * relTargetPos *
                        2.0f,
                        _zoneFreeController.transform.rotation,
                        targetPosBoxScale);

                    Graphics.DrawMesh(_zoneFreeController.holdPositionMesh, targetPosMatrix, _targetPosMaterial,
                                      _zoneFreeController.gameObject.layer, null, 0, null, false, false);

                    if (_targetAtom != null && _targetController != null)
                    {
                        _lineDrawer0.SetLinePoints(_zoneFreeController.transform.position,
                                                   _targetController.transform.position);
                        _lineDrawer0.Draw();
                    }
                }

                if (controllerSelected)
                {
                    _lineDrawer1.SetLinePoints(_pluginFreeController.transform.position,
                                               _zoneFreeController.transform.position);
                    _lineDrawer1.Draw();
                }
            }
        }
Ejemplo n.º 10
0
        public void OnSimulatorUpdate(float prevPos, float newPos, float deltaTime)
        {
            if (_targetAnimationPattern == null)
            {
                if (!string.IsNullOrEmpty(_targetAnimationAtomChooser.val))
                {
                    _targetAnimationAtomChooser.SetVal("");
                }

                return;
            }

            if (_pluginFreeController.selected && SuperController.singleton.editModeToggle.isOn)
            {
                _lineDrawer0.SetLinePoints(_pluginFreeController.transform.position,
                                           _animationAtomController.transform.position);
                _lineDrawer0.Draw();
            }

            var currentTime = _targetAnimationPattern.GetFloatJSONParam("currentTime");

            float totalTime = _targetAnimationPattern.GetTotalTime();

            float normOldTime = currentTime.val / totalTime;

            float normalizedLaunchPos = Mathf.InverseLerp(_minPosition.val, _maxPosition.val, newPos);

            float newTime;

            if (_moveUpwards)
            {
                newTime = Mathf.Lerp(0.0f, totalTime * 0.5f, normalizedLaunchPos);
            }
            else
            {
                newTime = Mathf.Lerp(totalTime, totalTime * 0.5f, normalizedLaunchPos);
            }

            newTime = (newTime + (totalTime * _animationOffset.val)) % totalTime;

            float normNewTime = newTime / totalTime;

            if (Mathf.Abs(normNewTime - normOldTime) > 0.05f)
            {
                currentTime.SetVal(newTime);
            }
            _targetAnimationPattern.SetFloatParamValue("speed", totalTime / (_dirChangeDuration * 2.0f));
        }
Ejemplo n.º 11
0
        public virtual void Draw(Graphics g, Maze maze)
        {
            if (!maze.solved && !solving)
            {
                return;
            }

            if (solution == null)
            {
                return;
            }

            for (int i = 0; i < solution.Length; i++)
            {
                if (solution[i] < 0)
                {
                    continue;
                }

                pathDrawer.Draw(g, i, solution[i], maze.width, Length(i), Color.Black);
                //DrawLine(g, i, solution[i], maze.width, Color.Black);
            }

            if (maze.solved)
            {
                int        current = maze.end;
                LineDrawer drawer  = new LineDrawer();
                while (current != maze.start)
                {
                    drawer.Draw(g, current, solution[current], maze.width, 0, Color.LightGreen);
                    //DrawLine(g, current, solution[current], maze.width, Color.LightGreen);

                    current = solution[current];
                }
            }
            else if (Global.showPosition && current != 0)
            {
                DrawCurrentPosition(g, maze);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(.41f, .41f, .45f, 1));

            var viewMatrix       = Camera.ViewMatrix;
            var projectionMatrix = Camera.ProjectionMatrix;

            if (displayEntities)
            {
                ModelDrawer.Draw(viewMatrix, projectionMatrix);
            }

            if (displayConstraints)
            {
                ConstraintDrawer.Draw(viewMatrix, projectionMatrix);
            }

            LineDrawer.LightingEnabled    = false;
            LineDrawer.VertexColorEnabled = true;
            LineDrawer.World      = Matrix.Identity;
            LineDrawer.View       = MathConverter.Convert(viewMatrix);
            LineDrawer.Projection = MathConverter.Convert(projectionMatrix);

            if (displayContacts)
            {
                ContactDrawer.Draw(LineDrawer, currentSimulation.Space);
            }

            if (displayBoundingBoxes)
            {
                BoundingBoxDrawer.Draw(LineDrawer, currentSimulation.Space);
            }

            if (displaySimulationIslands)
            {
                SimulationIslandDrawer.Draw(LineDrawer, currentSimulation.Space);
            }


            //This doesn't actually draw the elements in the demo (that's the modeldrawer's job),
            //but some demos can specify their own extra stuff to draw.
            currentSimulation.Draw();

            base.Draw(gameTime);

            #region UI Drawing

            UIDrawer.Begin();
            int bottom = GraphicsDevice.Viewport.Bounds.Height;
            int right  = GraphicsDevice.Viewport.Bounds.Width;
            if (displayUI)
            {
                FPStotalSinceLast += gameTime.ElapsedGameTime.TotalSeconds;
                FPStotalFramesSinceLast++;
                if (gameTime.TotalGameTime.TotalSeconds - FPSlastTime > .25 && gameTime.ElapsedGameTime.TotalSeconds > 0)
                {
                    double avg = FPStotalSinceLast / FPStotalFramesSinceLast;
                    FPSlastTime             = gameTime.TotalGameTime.TotalSeconds;
                    FPStoDisplay            = Math.Round(1 / avg, 1);
                    averagePhysicsTime      = Math.Round(1000 * currentSimulation.PhysicsTime, 1);
                    FPStotalSinceLast       = 0;
                    FPStotalFramesSinceLast = 0;
                }

                DataTextDrawer.Draw("FPS: ", FPStoDisplay, new Vector2(50, bottom - 150));
                DataTextDrawer.Draw("Physics Time (ms): ", averagePhysicsTime, new Vector2(50, bottom - 133));
                DataTextDrawer.Draw("Collision Pairs: ", currentSimulation.Space.NarrowPhase.Pairs.Count, new Vector2(50, bottom - 116));
                if (displayActiveEntityCount)
                {
                    int countActive = 0;
                    for (int i = 0; i < currentSimulation.Space.Entities.Count; i++)
                    {
                        if (currentSimulation.Space.Entities[i].ActivityInformation.IsActive)
                        {
                            countActive++;
                        }
                    }
                    DataTextDrawer.Draw("Active Objects: ", countActive, new Vector2(50, bottom - 99));
                }
#if !WINDOWS
                DataTextDrawer.Draw("Press Start for Controls", new Vector2(50, bottom - 82));
#else
                DataTextDrawer.Draw("Press F1 for Controls", new Vector2(50, bottom - 82));
#endif

                TinyTextDrawer.Draw("Current Simulation: ", currentSimulationIndex, new Vector2(right - 200, bottom - 100));
                TinyTextDrawer.Draw(currentSimulation.Name, new Vector2(right - 180, bottom - 86));

                currentSimulation.DrawUI();
            }
            if (displayMenu)
            {
                UIDrawer.Draw(controlsMenu, new Rectangle(right / 2 - 400, bottom / 2 - 300, 800, 600), Color.White);
            }
            UIDrawer.End();

            #endregion
        }
Ejemplo n.º 13
0
        public bool OnUpdate(ref byte outPos, ref byte outSpeed)
        {
            if (_targetAnimationPattern == null)
            {
                if (!string.IsNullOrEmpty(_targetAnimationAtomChooser.val))
                {
                    _targetAnimationAtomChooser.SetVal("");
                }
                return(false);
            }

            if (_pluginFreeController.selected && SuperController.singleton.editModeToggle.isOn)
            {
                _lineDrawer0.SetLinePoints(_pluginFreeController.transform.position,
                                           _animationAtomController.transform.position);
                _lineDrawer0.Draw();
            }

            if (_targetAnimationPattern.steps.Length <= 1)
            {
                return(false);
            }

            float minPos, maxPos;

            GenerateMotionPointsFromPattern(_targetAnimationPattern, ref _motionPoints, out minPos, out maxPos);

            if (_includeMidPoints.val && _pluginFreeController.selected &&
                SuperController.singleton.editModeToggle.isOn)
            {
                for (int i = 0; i < _motionPoints.Count; i++)
                {
                    if (i % 2 == 0)
                    {
                        continue;
                    }

                    var boxMatrix = Matrix4x4.TRS(_motionPoints[i].Position, Quaternion.identity,
                                                  new Vector3(0.1f, 0.1f, 0.1f));

                    Graphics.DrawMesh(_animationAtomController.holdPositionMesh, boxMatrix,
                                      _animationAtomController.linkLineMaterial,
                                      _animationAtomController.gameObject.layer, null, 0, null, false, false);
                }
            }

            int p0, p1;

            if (GetMotionPointIndices(_patternTime.val, _motionPoints, out p0, out p1))
            {
                if (p0 != _lastPointIndex)
                {
                    float yFactor = Mathf.InverseLerp(minPos, maxPos, GetPositionForPlane(_motionPoints[p1].Position));

                    float timeToNextPoint;
                    if (p1 > p0)
                    {
                        timeToNextPoint = _motionPoints[p1].Time - _patternTime.val;
                    }
                    else
                    {
                        timeToNextPoint = _targetAnimationPattern.GetTotalTime() - _patternTime.val +
                                          _motionPoints[p1].Time;
                    }

                    timeToNextPoint /= Mathf.Max(_patternSpeed.val, 0.001f);

                    float launchFactor = _invertPosition.val ? 1.0f - yFactor : yFactor;

                    float launchPos   = Mathf.Lerp(_minPosition.val, _maxPosition.val, launchFactor);
                    float launchSpeed = LaunchUtils.PredictMoveSpeed(_lastLaunchPos, launchPos, timeToNextPoint);

                    outPos   = (byte)launchPos;
                    outSpeed = (byte)launchSpeed;

                    _lastPointIndex = p0;
                    _lastLaunchPos  = launchPos;

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 14
0
 void Move(Vector3 pos)
 {
     lineDrawer.Draw(pos);
 }
Ejemplo n.º 15
0
    public void Draw()
    {
        Vector3 dir = GetDirection();

        drawer.Draw(Origin, Point);
    }
Ejemplo n.º 16
0
 // Line drawing utility functions
 public void Draw2DLines(Vector2[] vertices, Color color)
 {
     LineDrawer.Begin();
     LineDrawer.Draw(vertices, color);
     LineDrawer.End();
 }