Ejemplo n.º 1
0
 public override bool doTool()
 {
     newSide = trajectory.addSide(startNode.getID(), endNode.getID(), -1);
     if (newSide != null)
     {
         newSideDataControl = new SideDataControl(sceneDataControl, trajectoryDataControl, newSide);
         trajectoryDataControl.getSides().Add(newSideDataControl);
         return(true);
     }
     return(false);
 }
        public LineHandler(Trajectory.Node start, Trajectory.Node end, Trajectory.Side side)
        {
            this.start = start;
            this.end   = end;
            this.side  = side;

            float start_x = start.getX(), end_x = end.getX()
            , start_y = start.getY(), end_y = end.getY();

            this.function = new MathFunction(new Vector2(start_x, start_y), new Vector2(end_x, end_y));

            this.scale_function = new MathFunction(new Vector2(start_x, start.getScale()), new Vector2(end_x, end.getScale()));
        }
Ejemplo n.º 3
0
        public static void DivideSideByRect(Rectangle rect, Trajectory original, Trajectory.Side side, Trajectory outputTrajectory)
        {
            var startNode = original.getNodeForId(side.getIDStart());
            var endNode   = original.getNodeForId(side.getIDEnd());

            Math3DFunc scaleFunc = new Math3DFunc(
                new Vector3(startNode.getX(), startNode.getY(), startNode.getScale()),
                new Vector3(endNode.getX(), endNode.getY(), endNode.getScale()));
            Math3DFunc lengthFunc = new Math3DFunc(
                new Vector3(startNode.getX(), startNode.getY(), 0),
                new Vector3(endNode.getX(), endNode.getY(), side.getLength()));

            var startInside = outputTrajectory.getNodeForId(side.getIDStart()) == null;
            var endInside   = outputTrajectory.getNodeForId(side.getIDEnd()) == null;

            if (startInside && endInside)
            {
                return;
            }

            Vector2 start = LineHandler.nodeToVector2(startNode),
                    end   = LineHandler.nodeToVector2(endNode);

            Vector2[] intersections;
            if (LineRectangleIntersections(rect, start, end, out intersections))
            {
                if (!startInside)
                {
                    var cs   = ClosestPoint(start, intersections);
                    var csId = createRandomNodeId(cs.x, cs.y);
                    outputTrajectory.addNode(csId, (int)cs.x, (int)cs.y, scaleFunc.getZ(cs.x, cs.y));
                    outputTrajectory.addSide(side.getIDStart(), csId, (int)lengthFunc.getZ(cs.x, cs.y));
                }
                if (!endInside)
                {
                    var ce   = ClosestPoint(end, intersections);
                    var ceId = createRandomNodeId(ce.x, ce.y);
                    outputTrajectory.addNode(ceId, (int)ce.x, (int)ce.y, scaleFunc.getZ(ce.x, ce.y));
                    outputTrajectory.addSide(side.getIDEnd(), ceId, (int)(side.getLength() - lengthFunc.getZ(ce.x, ce.y)));
                }
            }
            else
            {
                outputTrajectory.addSide(side.getIDStart(), side.getIDEnd(), (int)side.getLength());
            }
        }
Ejemplo n.º 4
0
    public LineHandler(Trajectory.Node start, Trajectory.Node end, Trajectory.Side side)
    {
        this.start = start;
        this.end = end;
        this.side = side;

        float start_x = start.getX()/LineHandler.DIVISOR, end_x = end.getX()/LineHandler.DIVISOR
            , start_y = 60f - start.getY()/LineHandler.DIVISOR, end_y = 60f - end.getY()/LineHandler.DIVISOR;

        min_x = Mathf.Min(start_x, end_x);
        max_x = Mathf.Max(start_x, end_x);

        min_y = Mathf.Min(start_y, end_y);
        max_y = Mathf.Max(start_y, end_y);

        this.function = new MathFunction(new Vector2(start_x,start_y) ,new Vector2(end_x,end_y));

        this.scale_function = new MathFunction(new Vector2(start_x,start.getScale()), new Vector2(end_x,end.getScale()));
    }
Ejemplo n.º 5
0
    public LineHandler(Trajectory.Node start, Trajectory.Node end, Trajectory.Side side)
    {
        this.start = start;
        this.end   = end;
        this.side  = side;

        float start_x = start.getX() / LineHandler.DIVISOR, end_x = end.getX() / LineHandler.DIVISOR
        , start_y = 60f - start.getY() / LineHandler.DIVISOR, end_y = 60f - end.getY() / LineHandler.DIVISOR;


        min_x = Mathf.Min(start_x, end_x);
        max_x = Mathf.Max(start_x, end_x);

        min_y = Mathf.Min(start_y, end_y);
        max_y = Mathf.Max(start_y, end_y);


        this.function = new MathFunction(new Vector2(start_x, start_y), new Vector2(end_x, end_y));

        this.scale_function = new MathFunction(new Vector2(start_x, start.getScale()), new Vector2(end_x, end.getScale()));
    }
Ejemplo n.º 6
0
 /**
  * Constructor.
  *
  * @param sceneDataControl
  *            Parent scene controller
  * @param activeArea
  *            Exit of the data control structure
  */
 public SideDataControl(SceneDataControl sceneDataControl, TrajectoryDataControl trajectoryDataControl, Side side)
 {
     this.sceneDataControl      = sceneDataControl;
     this.trajectoryDataControl = trajectoryDataControl;
     this.side = side;
 }
Ejemplo n.º 7
0
 public SetSideLengthTool(Side side, int value)
 {
     this.side      = side;
     this.value     = value;
     this.oldLength = side.getLength();
 }