예제 #1
0
        public void AddAggregatedAxis(string attributeName, AxisDirection dir, out float max, out float length)
        {
            var lom = Data.TypeOf(attributeName);

            switch (lom)
            {
            case LoM.NOMINAL:
                var mea = Data.nominalStatistics[attributeName];
                length = (mea.numberOfUniqueValues + 1) * .15f;
                max    = mea.distMax;
                break;

            default:
                var mea2 = Data.ordinalStatistics[attributeName];
                length = (mea2.numberOfUniqueValues + 1) * .15f;
                max    = mea2.distMax;
                break;
            }

            var yAxis = AxisFactory().CreateAutoTickedAxis("Amount", max);

            yAxis.transform.parent = Anchor;
            var comp = yAxis.GetComponent <AAxis>();

            comp.Assign(this);


            if (!Axes.ContainsKey(AxisDirection.Y))
            {
                Axes.Add(AxisDirection.Y, new List <AAxis>());
            }
            Axes[AxisDirection.Y].Add(yAxis.GetComponent <AAxis>());
        }
예제 #2
0
        /// <summary>
        /// Build the sculptor for the label.
        /// </summary>
        /// <param name="ad">An AxisDirection enum value.</param>
        /// <returns></returns>
        private SquareSculptor BuildLabelSculptor(AxisDirection ad)
        {
            SquareSculptor   sculptor = new SquareSculptor();
            Transform3DGroup tg       = new Transform3DGroup();
            double           xyLength = 0.2;

            tg.Children.Add(new ScaleTransform3D(xyLength, xyLength, 1.0));
            switch (ad)
            {
            case AxisDirection.X:
                // tg.Children.Add(new TranslateTransform3D(0.6, -0.27, 0.0));
                tg.Children.Add(new TranslateTransform3D(0.6, -(xyLength + Radius / 2.0), 0.0));
                break;

            case AxisDirection.Y:
                tg.Children.Add(new TranslateTransform3D(Radius / 2.0, 0.6, 0.0));
                break;

            case AxisDirection.Z:
                tg.Children.Add(
                    new RotateTransform3D(
                        new AxisAngleRotation3D(new Vector3D(0, -1, 0), 90)));
                // 2ème rotation pour que les 3 lettres X, Y zt Z soient dans le même sens
                tg.Children.Add(
                    new RotateTransform3D(
                        new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180)));
                tg.Children.Add(new TranslateTransform3D(0.0, -(xyLength + Radius / 2.0), 0.8));
                break;
            }
            sculptor.Transform(tg);
            sculptor.BuildMesh();
            return(sculptor);
        }
        /// <summary>
        /// Orients the camera.
        /// <remarks>This changes the LookDirection property.</remarks>
        /// </summary>
        /// <param name="angleOffset">Rotation angle (in degrees).</param>
        /// <param name="ad">An AxisDirection enum value.</param>
        public void Orient(float angleOffset, AxisDirection ad)
        {
            float  radAngleOffset = MathHelper.TwoPi - MathHelper.ToRadians(angleOffset);
            Matrix m = Matrix.Identity;

            switch (ad)
            {
            case AxisDirection.X:
                m = Matrix.CreateFromAxisAngle(Vector3.UnitX, radAngleOffset);
                break;

            case AxisDirection.Y:
                m = Matrix.CreateFromAxisAngle(Vector3.UnitY, radAngleOffset);
                break;

            case AxisDirection.Z:
                m = Matrix.CreateFromAxisAngle(Vector3.UnitZ, radAngleOffset);
                break;
            }
            Vector3 orient = _position - _lookTarget;

            orient      = Vector3.Transform(orient, m);
            _lookTarget = _position - orient;
            InvalidateView();
        }
예제 #4
0
 public SliverConstraints(
     AxisDirection axisDirection,
     GrowthDirection growthDirection,
     ScrollDirection userScrollDirection,
     double scrollOffset,
     double overlap,
     double remainingPaintExtent,
     double crossAxisExtent,
     AxisDirection crossAxisDirection,
     double viewportMainAxisExtent,
     double remainingCacheExtent,
     double cacheOrigin
     )
 {
     this.axisDirection          = axisDirection;
     this.growthDirection        = growthDirection;
     this.userScrollDirection    = userScrollDirection;
     this.scrollOffset           = scrollOffset;
     this.overlap                = overlap;
     this.remainingPaintExtent   = remainingPaintExtent;
     this.crossAxisExtent        = crossAxisExtent;
     this.crossAxisDirection     = crossAxisDirection;
     this.viewportMainAxisExtent = viewportMainAxisExtent;
     this.remainingCacheExtent   = remainingCacheExtent;
     this.cacheOrigin            = cacheOrigin;
 }
예제 #5
0
 internal QueryAxis(QueryAxisType type, AxisDirection direction, QueryNodeType principalNode, QueryNodeType validNodeTypes)
 {
     this.direction      = direction;
     this.principalNode  = principalNode;
     this.type           = type;
     this.validNodeTypes = validNodeTypes;
 }
예제 #6
0
 public AxisInput(int axisIndex, AxisDirection direction)
 {
     this.axisIndex = axisIndex;
     this.direction = direction == AxisDirection.Positive ? 1 : -1;
     previousState  = false;
     currentState   = false;
 }
예제 #7
0
        /// <summary>
        /// Build the material for the label.
        /// </summary>
        /// <param name="ad">An AxisDirection enum value.</param>
        /// <returns></returns>
        private static Material BuildLabelMaterial(AxisDirection ad)
        {
            MaterialGroup mg = new MaterialGroup();

            mg.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.LightGray)));

            TextBlock tb = new TextBlock();

            tb.FontFamily          = new FontFamily("Verdana");
            tb.HorizontalAlignment = HorizontalAlignment.Center;
            tb.VerticalAlignment   = VerticalAlignment.Center;
            tb.TextAlignment       = TextAlignment.Center;
            VisualBrush vb = new VisualBrush();

            vb.Visual  = tb;
            vb.Stretch = Stretch.Uniform;
            switch (ad)
            {
            case AxisDirection.X:
                tb.Text = "X";
                break;

            case AxisDirection.Y:
                tb.Text = "Y";
                break;

            case AxisDirection.Z:
                tb.Text = "Z";
                break;
            }
            mg.Children.Add(new DiffuseMaterial(vb));
            return(mg);
        }
예제 #8
0
        public override float GetAxisValue(AxisDirection dir)
        {
            float axisValue = 0;

            if (dir == AxisDirection.Horizontal)
            {
                if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
                {
                    axisValue = -1F;
                }
                else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
                {
                    axisValue = 1F;
                }
            }
            else
            {
                if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
                {
                    axisValue = 1F;
                }
                else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
                {
                    axisValue = -1F;
                }
            }
            return(axisValue);
        }
예제 #9
0
    void TouchOrMouseChange(InputHandler handler)
    {
        if (!this.isTouched)
        {
            return;
        }

        InputHandlerPointer pointer       = (InputHandlerPointer)handler;
        Vector3             worldPosition = Camera.main.ScreenToWorldPoint(pointer.currentPosition);
        Vector3             newPosition   = new Vector3(worldPosition.x + offset.x, worldPosition.y + offset.y, gameObject.transform.position.z);
        Vector3             deltaPosition = this.previousPosition - newPosition;

        // This will lock the movement along one of the two axis
        if (this.onlyMoveAlongAxis)
        {
            this.direction = Math.Abs(deltaPosition.x) > Math.Abs(deltaPosition.y) ? AxisDirection.horizontal : AxisDirection.vertical;

            float xPos = (this.direction == AxisDirection.horizontal) ? (worldPosition.x + offset.x) : transform.position.x;
            float yPos = (this.direction == AxisDirection.vertical) ? (worldPosition.y + offset.y) : transform.position.y;
            newPosition = new Vector3(xPos, yPos, gameObject.transform.position.z);
        }

        this.previousPosition = newPosition;
        this.DragDidContinue(newPosition);
    }
예제 #10
0
        public override Widget build(BuildContext context)
        {
            AxisDirection axisDirection = this._getDirection(context);
            Widget        contents      = this.child;

            if (this.padding != null)
            {
                contents = new Padding(
                    padding: this.padding,
                    child: contents);
            }

            ScrollController scrollController = this.primary
                ? PrimaryScrollController.of(context)
                : this.controller;

            Scrollable scrollable = new Scrollable(
                axisDirection: axisDirection,
                controller: scrollController,
                physics: this.physics,
                viewportBuilder: (BuildContext subContext, ViewportOffset offset) => {
                return(new _SingleChildViewport(
                           axisDirection: axisDirection,
                           offset: offset,
                           child: contents));
            }
                );

            if (this.primary && scrollController != null)
            {
                return(PrimaryScrollController.none(child: scrollable));
            }

            return(scrollable);
        }
예제 #11
0
        /// <summary>
        ///     Gets the specified axis.
        /// </summary>
        /// <param name="plot">The plot to configure.</param>
        /// <param name="direction">The axis direction.</param>
        /// <param name="secondary">Indicates if the secondary axis should be retrieved.</param>
        /// <param name="configure">Configures the axis.</param>
        public static PlotConfigurator WithAxis <T>(this PlotConfigurator plot, AxisDirection direction, bool secondary,
                                                    Action <AxisConfigurator <T> >?configure = null)
            where T : Axis
        {
            IAxisConfigurator?existing = plot.Axes
                                         .FirstOrDefault(a
                                                         => a.Position.GetPosition() == AxisPositionConfigurator.CalculatePosition(direction, secondary));

            // Axis is null or another type
            if (existing is not AxisConfigurator <T> configurator)
            {
                if (existing != null)
                {
                    plot.Axes.Remove(existing);
                }

                configurator = new AxisConfigurator <T>();
                configurator.Position.ToIncludedState();
                configurator.Position.Direction   = direction;
                configurator.Position.IsSecondary = secondary;

                plot.Axes.Add(configurator);
            }

            configure?.Invoke(configurator);

            return(plot);
        }
예제 #12
0
 public SliverConstraints(
     AxisDirection axisDirection,
     GrowthDirection growthDirection,
     ScrollDirection userScrollDirection,
     float scrollOffset,
     float precedingScrollExtent,
     float overlap,
     float remainingPaintExtent,
     float crossAxisExtent,
     AxisDirection crossAxisDirection,
     float viewportMainAxisExtent,
     float remainingCacheExtent,
     float cacheOrigin
     )
 {
     this.axisDirection         = axisDirection;
     this.growthDirection       = growthDirection;
     this.userScrollDirection   = userScrollDirection;
     this.scrollOffset          = scrollOffset;
     this.precedingScrollExtent = precedingScrollExtent;
     this.overlap = overlap;
     this.remainingPaintExtent   = remainingPaintExtent;
     this.crossAxisExtent        = crossAxisExtent;
     this.crossAxisDirection     = crossAxisDirection;
     this.viewportMainAxisExtent = viewportMainAxisExtent;
     this.remainingCacheExtent   = remainingCacheExtent;
     this.cacheOrigin            = cacheOrigin;
 }
예제 #13
0
    public void SetDirection(AxisDirection dir)
    {
        switch (dir)
        {
        case AxisDirection.X:
            label.alignment = TextAlignment.Left;
            label.anchor    = TextAnchor.MiddleLeft;
            label.transform.localRotation = Quaternion.Euler(0, 0, -90);
            label.transform.localPosition = Vector3.down * .05f;
            break;

        case AxisDirection.Y:
            label.alignment = TextAlignment.Right;
            label.anchor    = TextAnchor.MiddleRight;
            label.transform.localRotation = Quaternion.Euler(0, 0, 0);
            label.transform.localPosition = Vector3.left * .05f;
            break;

        default:
            label.alignment = TextAlignment.Right;
            label.anchor    = TextAnchor.MiddleRight;
            label.transform.localRotation = Quaternion.Euler(0, 0, 0);
            label.transform.localPosition = Vector3.left * .05f;
            break;
        }
    }
예제 #14
0
        protected virtual Widget buildViewport(
            BuildContext context,
            ViewportOffset offset,
            AxisDirection axisDirection,
            List <Widget> slivers
            )
        {
            if (this.shrinkWrap)
            {
                return(new ShrinkWrappingViewport(
                           axisDirection: axisDirection,
                           offset: offset,
                           slivers: slivers
                           ));
            }

            return(new Viewport(
                       axisDirection: axisDirection,
                       offset: offset,
                       slivers: slivers,
                       cacheExtent: this.cacheExtent,
                       center: this.center,
                       anchor: this.anchor
                       ));
        }
예제 #15
0
        public void Init(string name, bool clean, AxisDirection dir = AxisDirection.Y)
        {
            if (clean)
            {
                this.attributeName = name;
                this.observers     = new HashSet <IObserver <AAxis> >();
                axisDirection      = dir;

                switch (dir)
                {
                case AxisDirection.X:
                    direction = Vector3.right;
                    break;

                case AxisDirection.Y:
                    direction = Vector3.up;
                    break;

                default:
                    direction = Vector3.forward;
                    break;
                }

                this.tipped = false;
                this.ticked = false;
            }
            else
            {
                Init(name, dir);
            }
        }
예제 #16
0
        /// <summary>
        /// Nominal axis initializer.
        /// </summary>
        public void Init(
            NominalAttributeStats stats,
            AxisDirection dir = AxisDirection.Y,
            bool manualLength = false,
            float length      = 1)
        {
            Init(stats as AttributeStats, dir);
            this.min = 0;
            this.max = stats.max;

            if (manualLength)
            {
                this.length         = length;
                this.tickResolution = 1f / (stats.numberOfUniqueValues - 1);
            }
            else
            {
                this.length         = .15f * stats.numberOfUniqueValues + .15f;
                this.tickResolution = .15f;
            }

            this.tipped = false;
            this.ticked = true;
            AssembleNominalAxis(stats, manualLength, this.tickResolution);
        }
예제 #17
0
 public RenderListBody(
     List <RenderBox> children   = null,
     AxisDirection axisDirection = AxisDirection.down)
 {
     _axisDirection = axisDirection;
     addAll(children);
 }
예제 #18
0
        public bool IsOverlappingOrOverhanging(TileProxy other, AxisDirection upDirection, float maxOverlap)
        {
            Vector3 overlaps = UnityUtil.CalculatePerAxisOverlap(other.Placement.Bounds, Placement.Bounds);
            float   overlap;

            // Check for overlaps only along the ground plane, disregarding the up-axis
            // E.g. For +Y up, check for overlaps along X & Z axes
            switch (upDirection)
            {
            case AxisDirection.PosX:
            case AxisDirection.NegX:
                overlap = Mathf.Min(overlaps.y, overlaps.z);
                break;

            case AxisDirection.PosY:
            case AxisDirection.NegY:
                overlap = Mathf.Min(overlaps.x, overlaps.z);
                break;

            case AxisDirection.PosZ:
            case AxisDirection.NegZ:
                overlap = Mathf.Min(overlaps.x, overlaps.y);
                break;

            default:
                throw new NotImplementedException("AxisDirection '" + upDirection + "' is not implemented");
            }

            return(overlap > maxOverlap);
        }
예제 #19
0
 public Viewport(
     Key key = null,
     AxisDirection axisDirection      = AxisDirection.down,
     AxisDirection?crossAxisDirection = null,
     float anchor                      = 0.0f,
     ViewportOffset offset             = null,
     Key center                        = null,
     float?cacheExtent                 = null,
     CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
     List <Widget> slivers             = null
     ) : base(key: key, children: slivers)
 {
     D.assert(offset != null);
     D.assert(slivers != null);
     D.assert(center == null || LinqUtils <Widget> .WhereList(slivers, ((Widget child) => child.key == center)).Count() == 1);
     D.assert(cacheExtentStyle != null);
     D.assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null);
     this.axisDirection      = axisDirection;
     this.crossAxisDirection = crossAxisDirection;
     this.anchor             = anchor;
     this.offset             = offset;
     this.center             = center;
     this.cacheExtent        = cacheExtent;
     this.cacheExtentStyle   = cacheExtentStyle;
 }
예제 #20
0
        /// <summary>
        /// Rotation of a point around one of the 3 axes according to a given angle
        /// </summary>
        /// <param name="point">Point to rotate</param>
        /// <param name="angle">Angle (in radians)</param>
        /// <param name="rotationAxis">Rotation axis : X, Y ou Z</param>
        /// <returns>A new Point3D object corresponding to the rotation</returns>
        public static Point3D RotatePoint(Point3D point, double angle, AxisDirection rotationAxis)
        {
            Vector3D axis = new Vector3D();

            switch (rotationAxis)
            {
            case AxisDirection.X:
                axis.X = 1.0;
                axis.Y = 0.0;
                axis.Z = 0.0;
                break;

            case AxisDirection.Y:
                axis.X = 0.0;
                axis.Y = 1.0;
                axis.Z = 0.0;
                break;

            case AxisDirection.Z:
                axis.X = 0.0;
                axis.Y = 0.0;
                axis.Z = 1.0;
                break;
            }
            return(RotatePoint(point, RadianToDegree(angle), axis));
        }
예제 #21
0
 /// <summary>
 /// Update the object's position according to speed and strategy
 /// </summary>
 private void UpdatePosition()
 {
     if (transform.childCount > 0)
     {
         if (!isPrefabLoaded)
         {
             isPrefabLoaded = true;
             PositionModifier pm = GetComponentInChildren <PositionModifier>();
             if (pm != null)
             {
                 forwardDirection = pm.ForwardDirection;
             }
         }
         if (isMoving)
         {
             //Should the speed change randomly
             if (RandomSpeed)
             {
                 speedResetTime += Time.deltaTime;
                 if (speedResetTime > SpeedChangeInterval)
                 {
                     speedResetTime = 0;
                     //Pick a random speed
                     ImSpeed = UnityEngine.Random.Range(Speed * 0.2f, Speed);
                 }
             }
             Strategy.UpdateMovement();
         }
     }
 }
예제 #22
0
        bool _start(AxisDirection direction)
        {
            D.assert(_mode == null);
            D.assert(_isIndicatorAtTop == null);
            D.assert(_dragOffset == null);
            switch (direction)
            {
            case AxisDirection.down:
                _isIndicatorAtTop = true;
                break;

            case AxisDirection.up:
                _isIndicatorAtTop = false;
                break;

            case AxisDirection.left:
            case AxisDirection.right:
                _isIndicatorAtTop = null;
                return(false);
            }

            _dragOffset = 0.0f;
            _scaleController.setValue(0.0f);
            _positionController.setValue(0.0f);
            return(true);
        }
예제 #23
0
 internal QueryAxis(QueryAxisType type, AxisDirection direction, QueryNodeType principalNode, QueryNodeType validNodeTypes)
 {
     this.direction = direction;
     this.principalNode = principalNode;
     this.type = type;
     this.validNodeTypes = validNodeTypes;
 }
    public override GameObject CreateAutoTickedAxis(string name, AxisDirection direction, DataSet data)
    {
        GameObject axis       = Instantiate(Axis2DPrefab);
        Axis2D     axis2Dcomp = axis.GetComponent <Axis2D>();

        switch (data.TypeOf(name))
        {
        case LoM.NOMINAL:
            axis2Dcomp.Init(data.nominalStatistics[name], direction);
            break;

        case LoM.ORDINAL:
            axis2Dcomp.Init(data.ordinalStatistics[name], direction);
            break;

        case LoM.INTERVAL:
            axis2Dcomp.Init(data.intervalStatistics[name], direction);
            break;

        default:     // RATIO
            axis2Dcomp.Init(data.rationalStatistics[name], direction);
            break;
        }

        return(axis);
    }
예제 #25
0
        /// <summary>
        /// Rotation of a point around one of the 3 axes according to a given angle
        /// Remark : use this method only as a last resort,
        /// and prefer the WPF transformations, which use the GPU
        /// </summary>
        /// <param name="p">Point to rotate</param>
        /// <param name="angle">Angle (in radians)</param>
        /// <param name="rotationAxis">Rotation axis : X, Y ou Z</param>
        /// <returns>A new Point3D object corresponding to the rotation</returns>
        public static Point3D RotatePoint(Point3D p, double angle, AxisDirection rotationAxis)
        {
            Point3D pResult = new Point3D(0, 0, 0);

            switch (rotationAxis)
            {
            case AxisDirection.X:
                pResult = new Point3D(
                    p.X,
                    p.Y * Math.Cos(angle) + p.Z * Math.Sin(angle),
                    p.Y * Math.Sin(angle) + p.Z * Math.Cos(angle));
                break;

            case AxisDirection.Y:
                pResult = new Point3D(
                    p.Z * Math.Sin(angle) + p.X * Math.Cos(angle),
                    p.Y,
                    p.Z * Math.Cos(angle) + p.X * Math.Sin(angle));
                break;

            case AxisDirection.Z:
                pResult = new Point3D(
                    p.X * Math.Cos(angle) + p.Y * Math.Sin(angle),
                    p.X * Math.Sin(angle) + p.Y * Math.Cos(angle),
                    p.Z);
                break;
            }
            return(pResult);
        }
예제 #26
0
        public static string GetActionName(this InputAxis axis, AxisDirection direction)
        {
            switch (axis)
            {
            case InputAxis.Horizontal:
                switch (direction)
                {
                case AxisDirection.Positive:
                    return("gameplay_right");

                case AxisDirection.Negative:
                    return("gameplay_left");

                default:
                    throw new NotImplementedException("Missing AxisDirection " + direction.ToString());
                }

            case InputAxis.Vertical:
                switch (direction)
                {
                case AxisDirection.Positive:
                    return("gameplay_down");

                case AxisDirection.Negative:
                    return("gameplay_up");

                default:
                    throw new NotImplementedException("Missing AxisDirection " + direction.ToString());
                }

            default:
                throw new NotImplementedException("Missing InputAxis " + axis.ToString());
            }
        }
예제 #27
0
 /*
  * Storing Bend axes for arm directions. The directions and axes here were found empirically, feel free to edit, add or remove.
  * All vectors are in default character rotation space, where x is right and z is forward.
  * */
 private void StoreAxisDirections(ref AxisDirection[] axisDirections)
 {
     axisDirections[0] = new AxisDirection(Vector3.zero, new Vector3(-1f, 0f, 0f));                     // default
     axisDirections[1] = new AxisDirection(new Vector3(0.5f, 0f, -0.2f), new Vector3(-0.5f, -1f, 1f));  // behind head
     axisDirections[2] = new AxisDirection(new Vector3(-0.5f, -1f, -0.2f), new Vector3(0f, 0.5f, -1f)); // arm twist
     axisDirections[3] = new AxisDirection(new Vector3(-0.5f, -0.5f, 1f), new Vector3(-1f, -1f, -1f));  // cross heart
 }
예제 #28
0
파일: Ray.cs 프로젝트: tumcms/QL4BIM
        /// <summary>
        ///     Creates a new ray from the given starting point into the specified cartesian axis direction.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="axis"></param>
        /// <param name="dir"></param>
        public Ray(Vector <double> start, Axis axis, AxisDirection dir)
        {
            Start = start;

            int val = (dir == AxisDirection.Positive) ? 1 : -1;

            Direction = DenseVector.Create(3, i => ((Axis)i == axis) ? val : 0);
        }
예제 #29
0
        public Ray(Point start, Axis axis, AxisDirection dir)
        {
            Start = start;

            var val = dir == AxisDirection.Positive ? 1 : -1;

            Direction = DenseVector.Create(3, i => (Axis)i == axis ? val : 0);
        }
예제 #30
0
 public ScrollIntent(
     AxisDirection direction,
     ScrollIncrementType type = ScrollIncrementType.line
     ) : base(ScrollAction.key)
 {
     this.direction = direction;
     this.type      = type;
 }
예제 #31
0
 public _RenderMergeableMaterialListBody(
     List <RenderBox> children   = null,
     AxisDirection axisDirection = AxisDirection.down,
     List <BoxShadow> boxShadows = null
     ) : base(children: children, axisDirection: axisDirection)
 {
     this.boxShadows = boxShadows;
 }
		private GameObject GenerateQuadrant(ushort size, string name, AxisDirection xDirection, AxisDirection zDirection)
		{
			GameObject quadrant = new GameObject();
			quadrant.name = name;
			var meshFilter = quadrant.AddComponent<MeshFilter>();
			meshFilter.mesh = GenerateQuadrantSubMesh(size, xDirection, zDirection);
			quadrant.AddComponent<MeshRenderer>();
			return quadrant;
		}
예제 #33
0
        public bool canGoInDirection(AxisDirection dir)
        {
            switch (dir) {
            case AxisDirection.down:
                switch (type) {
                case TileType.TopHeadedT:
                case TileType.Empty:
                case TileType.Horizontal:
                case TileType.LeftBottomCorner:
                case TileType.RightBottomCorner:
                case TileType.Unknown:
                    return false;
                default:
                    return true;
                }
            case AxisDirection.up:
                switch (type) {
                case TileType.BottomHeadedT:
                case TileType.Empty:
                case TileType.Unknown:
                case TileType.Horizontal:
                case TileType.LeftTopCorner:
                case TileType.RightTopCorner:
                    return false;
                default:
                    return true;
                }

            case AxisDirection.left:
                switch (type) {
                case TileType.Empty:
                case TileType.Unknown:
                case TileType.RightHeadedT:
                case TileType.Vertical:
                case TileType.LeftTopCorner:
                case TileType.LeftBottomCorner:
                    return false;
                default:
                    return true;
                }
            case AxisDirection.right:
                switch (type) {
                case TileType.Empty:
                case TileType.Unknown:
                case TileType.LeftHeadedT:
                case TileType.Vertical:
                case TileType.RightTopCorner:
                case TileType.RightBottomCorner:
                    return false;
                default:
                    return true;
                }
            }

            return false;
        }
예제 #34
0
        public WmsTileSchema(string name, BruTile.Extent extent, string srs, string format, int tileSize, double highestResUnitsPerPixel, AxisDirection axis)
        {
            // Make us a new extent that is square
            double minx, miny, maxx, maxy, size;
            if (extent.Width > extent.Height)
            {
                minx = extent.MinX;
                maxx = extent.MaxX;
                size = maxx - minx;
                miny = extent.MinY;
                maxy = miny + size;

            }
            else
            {
                miny = extent.MinY;
                maxy = extent.MaxY;
                size = maxy - miny;
                minx = extent.MinX;
                maxx = minx + size;
            }
            int count = 0;
            double unitsPerPixel = size / tileSize;
            do
            {
                Resolutions[count.ToString(CultureInfo.InvariantCulture)] = new Resolution {Id = count.ToString(CultureInfo.InvariantCulture), UnitsPerPixel = unitsPerPixel};
                count++;
                //Resolutions.Add(unitsPerPixel);
                unitsPerPixel /= 2;
            } while (unitsPerPixel > highestResUnitsPerPixel);
            BruTile.Extent myExtent = new BruTile.Extent(minx, miny, maxx, maxy);
            //Extent myExtent = extent;
            Width = tileSize;
            Height = tileSize;
            Extent = myExtent;
            OriginX = myExtent.MinX;
            OriginY = myExtent.MinY;
            Name = name;
            Format = format;
            Axis = axis;
            Srs = srs;
        }
예제 #35
0
 public Ray lineForDirection(AxisDirection dir)
 {
     switch (dir) {
     case AxisDirection.down:
         return Ray.line(max, new Vector(min.x, max.y));
     case AxisDirection.left:
         return Ray.line(min, new Vector(min.x, max.y));
     case AxisDirection.right:
         return Ray.line(max, new Vector(max.x, min.y));
     case AxisDirection.up:
         return Ray.line(min, new Vector(max.x, min.y));
     default:
         return Ray.line(min, min);
     }
 }
예제 #36
0
 public Vector(AxisDirection dir)
     : this()
 {
     x = 0;
     y = 0;
     switch (dir) {
     case AxisDirection.down:
         this.x = Vector.down.x;
         this.y = Vector.down.y;
         break;
     case AxisDirection.left:
         this.x = Vector.left.x;
         this.y = Vector.left.y;
         break;
     case AxisDirection.right:
         this.x = Vector.right.x;
         this.y = Vector.right.y;
         break;
     case AxisDirection.up:
         this.x = Vector.up.x;
         this.y = Vector.up.y;
         break;
     }
 }
예제 #37
0
 public static bool isSameAxis(this AxisDirection a, AxisDirection b)
 {
     if (a == AxisDirection.left || a == AxisDirection.right) {
         return b == AxisDirection.right || b == AxisDirection.left;
     } else {
         return b == AxisDirection.up || b == AxisDirection.down;
     }
 }
예제 #38
0
 public static double getEnginePower(CarType carType, AxisDirection direction)
 {
     if (carType == CarType.Buggy) {
         if (direction == AxisDirection.up) {
             return buggyEngineForwardPower;
         } else {
             return buggyEngineRearPower;
         }
     } else {
         if (direction == AxisDirection.up) {
             return jeepEngineForwardPower;
         } else {
             return jeepEngineForwardPower;
         }
     }
 }
예제 #39
0
	public bool GetAxisButtonUp(MappedAxis axis, AxisDirection dir)
	{
		return axisButtonsActive[(int)axis] != dir && prevAxisButtonsActive[(int)axis] == dir;
	}
예제 #40
0
		/*
		 * Storing Bend axes for arm directions. The directions and axes here were found empirically, feel free to edit, add or remove.
		 * All vectors are in default character rotation space, where x is right and z is forward.
		 * */
		private void StoreAxisDirections(ref AxisDirection[] axisDirections) {
			axisDirections[0] = new AxisDirection(Vector3.zero, new Vector3(-1f, 0f, 0f)); // default
			axisDirections[1] = new AxisDirection(new Vector3(0.5f, 0f, -0.2f), new Vector3(-0.5f, -1f, 1f)); // behind head
			axisDirections[2] = new AxisDirection(new Vector3(-0.5f, -1f, -0.2f), new Vector3(0f, 0.5f, -1f)); // arm twist
			axisDirections[3] = new AxisDirection(new Vector3(-0.5f, -0.5f, 1f), new Vector3(-1f, -1f, -1f)); // cross heart
		}
예제 #41
0
        private Vector addPathBetween(Tile from, Tile to, Vector speedDir)
        {
            var q = new Queue<Tile>();
            var map = from.roadMap;

            var cost = new double[map.width, map.height];
            for (int x = 0; x < map.width; ++x) {
                for (int y = 0; y < map.height; ++y) {
                    cost[x, y] = double.MaxValue;
                }
            }

            cost[from.posX, from.posY] = 0;

            var backDir = new AxisDirection[map.width, map.height];

            {
                Vector speed = speedDir;

                foreach (AxisDirection dir in Enum.GetValues(typeof(AxisDirection))) {
                    if (!from.canGoInDirection(dir))
                        continue;

                    var next = from.nextTileInDirection(dir);

                    if (next == null)
                        continue;

                    cost[next.posX, next.posY] = (speed * new Vector(dir)) * 0.5 + 1;
                    backDir[next.posX, next.posY] = dir.back();
                    q.Enqueue(next);
                }
            }

            while (q.Count > 0) {
                var cur = q.Dequeue();

                Vector speed = new Vector(backDir[cur.posX, cur.posY].back());
                {
                    var prev = cur.nextTileInDirection(backDir[cur.posX, cur.posY]);
                    if (prev == from) {
                        speed += speedDir;
                    } else {
                        speed += new Vector(backDir[prev.posX, prev.posY].back());
                    }
                }
                speed = speed.normalized;

                foreach (AxisDirection dir in Enum.GetValues(typeof(AxisDirection))) {
                    if (!cur.canGoInDirection(dir))
                        continue;

                    var next = cur.nextTileInDirection(dir);

                    if (next == null)
                        continue;

                    var nextCost = cost[cur.posX, cur.posY] + (speed * new Vector(dir)) * -0.7   + 1;

                    if (nextCost < cost[next.posX, next.posY]) {
                        cost[next.posX, next.posY] = nextCost;
                        backDir[next.posX, next.posY] = dir.back();
                        q.Enqueue(next);
                    }
                }
            }

            {
                var localPath = new LinkedList<Tile>();

                var last = to;

                while (last != from && last != null) {
                    localPath.AddFirst(last);

                    last = last.nextTileInDirection(backDir[last.posX, last.posY]);
                }

                foreach (var tile in localPath) {
                    tilePath.Add(tile);
                }

            }

            Vector retSpeed = new Vector(backDir[to.posX, to.posY].back());
            {
                var prev = to.nextTileInDirection(backDir[to.posX, to.posY]);
                if (prev == from) {
                    retSpeed += speedDir;
                } else if (prev != null) {
                    retSpeed += new Vector(backDir[prev.posX, prev.posY].back());
                } else {
                    retSpeed += speedDir;
                }

                retSpeed = retSpeed.normalized;
            }

            return retSpeed;
        }
예제 #42
0
 /// <summary>
 /// Scans the given line in the quarter bitmap and resolves the path graph vertices there.
 /// </summary>
 /// <param name="vertexLines">Dictonary of scaned position events</param>
 /// <param name="sweepDirection">Direction of the scanned line</param>
 private void SweepPathVertices(Dictionary<int, SortedDictionary<int, PathGraphVertex>> vertexLines, AxisDirection sweepDirection)
 {
     foreach(KeyValuePair<int, SortedDictionary<int, PathGraphVertex>> vertexLine in vertexLines)
     {
         using (SortedDictionary<int, PathGraphVertex>.Enumerator enumerator = vertexLine.Value.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 int x1, y1, x2, y2;
                 x1 = x2 = y1 = y2 = 0;
                 switch (sweepDirection)
                 {
                     case AxisDirection.Horizontal:
                         y1 = y2 = vertexLine.Key;
                         x1 = enumerator.Current.Key;
                         break;
                     case AxisDirection.Vertical:
                         x1 = x2 = vertexLine.Key;
                         y1 = enumerator.Current.Key;
                         break;
                     default:
                         throw new InvalidOperationException("Unknown AxisDirection.");
                 }
                 PathGraphVertex vertex1 = enumerator.Current.Value;
                 while (enumerator.MoveNext())
                 {
                     PathGraphVertex vertex2 = enumerator.Current.Value;
                     switch (sweepDirection)
                     {
                         case AxisDirection.Horizontal:
                             x2 = enumerator.Current.Key;
                             break;
                         case AxisDirection.Vertical:
                             y2 = enumerator.Current.Key;
                             break;
                         default:
                             throw new InvalidOperationException("Unknown AxisDirection.");
                     }
                     //Special foreach begin
                     bool clearForWalking = true;
                     int roadCount = 0;
                     switch (sweepDirection)
                     {
                         case AxisDirection.Horizontal:
                             for (int i = x1 + 1; i < x2; i++)
                             {
                                 if (mapBitmap.Index2D(bitmapSize.Height, i, y1) == MapFillType.Empty)
                                 {
                                     clearForWalking = false;
                                     break;
                                 }
                                 else if (mapBitmap.Index2D(bitmapSize.Height, i, y1) != MapFillType.Sidewalk)
                                 {
                                     roadCount++;
                                     if (roadCount > 1)
                                     {
                                         clearForWalking = false;
                                         break;
                                     }
                                 }
                             }
                             break;
                         case AxisDirection.Vertical:
                             for (int i = y1 + 1; i < y2; i++)
                             {
                                 if (mapBitmap.Index2D(bitmapSize.Height, x1, i) == MapFillType.Empty)
                                 {
                                     clearForWalking = false;
                                     break;
                                 }
                                 else if (mapBitmap.Index2D(bitmapSize.Height, x1, i) != MapFillType.Sidewalk)
                                 {
                                     roadCount++;
                                     if (roadCount > 1)
                                     {
                                         clearForWalking = false;
                                         break;
                                     }
                                 }
                             }
                             break;
                         default:
                             throw new InvalidOperationException("Unknown AxisDirection.");
                     }
                     if (clearForWalking)
                     {
                         vertex1.AddNeighborBothDirection(vertex2, vertex1.Position.MinimalDistanceTo(vertex2.Position));
                     }
                     //Special foreach end
                     vertex1 = vertex2;
                     switch (sweepDirection)
                     {
                         case AxisDirection.Horizontal:
                             x1 = x2;
                             break;
                         case AxisDirection.Vertical:
                             y1 = y2;
                             break;
                         default:
                             throw new InvalidOperationException("Unknown AxisDirection.");
                     }
                 }
             }
         }
     }
 }
		private UnityEngine.Mesh GenerateQuadrantSubMesh(ushort size, AxisDirection xDirection, AxisDirection zDirection)
		{
			if (size > 0)
			{
				var vertices = new List<Vector3>();
				var indices = new List<int>();

				var step = 0;
				for (var z = 0; z < (size + 1); z++)
				{
					for (var x = 0; x < ((size + 1) - step); x++)
					{
						var xPosition = (x * _tileSizeInUnityUnits * (int)xDirection);
						var zPosition = (z * _tileSizeInUnityUnits * (int)zDirection);
						vertices.Add(new Vector3(xPosition, 0, zPosition));

						if (z > 0 && x > 0)
						{
							// Wire up triangle indices

						}
					}

					if (z > 0) { step++; }
				}

				var mesh = new UnityEngine.Mesh()
				{
					vertices = vertices.ToArray(),
					triangles = null
				};

				return mesh;
			}
			else
			{
				throw new ArgumentException("Map size must be greater than zero.");
			}
		}
예제 #44
0
 public Tile nextTileInDirection(AxisDirection dir)
 {
     switch (dir) {
     case AxisDirection.up:
         return roadMap.tileAt(posX, posY - 1);
     case AxisDirection.down:
         return roadMap.tileAt(posX, posY + 1);
     case AxisDirection.left:
         return roadMap.tileAt(posX - 1, posY);
     case AxisDirection.right:
         return roadMap.tileAt(posX + 1, posY);
     }
     return null;
 }
예제 #45
0
        public AxisDirection? borderAnyIntersectionDirection(Ray ray, AxisDirection? exceptDir = null)
        {
            foreach (AxisDirection dir in Enum.GetValues(typeof(AxisDirection))) {
                if (dir == exceptDir)
                    continue;

                var side = lineForDirection(dir);
                if (ray.intersect(side) != null) {
                    //(ray.intersect(side) ?? new Vector(0, 0)).draw(0xFF0000);
                    return dir;
                }

            }
            return null;
        }
예제 #46
0
 public Ray edgeInDirection(AxisDirection dir)
 {
     switch (dir) {
     case AxisDirection.down:
         return Ray.line(
             (position + new Vector(-width, height).rotate(angle)),
             (position + new Vector(width, height).rotate(angle))
         );
     case AxisDirection.left:
         return Ray.line(
             (position + new Vector(-width, height).rotate(angle)),
             (position + new Vector(-width, -height).rotate(angle))
         );
     case AxisDirection.right:
         return Ray.line(
             (position + new Vector(width, height).rotate(angle)),
             (position + new Vector(width, -height).rotate(angle))
         );
     case AxisDirection.up:
         return Ray.line(
             (position + new Vector(-width, -height).rotate(angle)),
             (position + new Vector(width, -height).rotate(angle))
         );
     }
     return new Ray(Vector.up, Vector.up);
 }
예제 #47
0
		/*
		 * Storing Bend axes for arm directions. The directions and axes here were found empirically, feel free to edit, add or remove.
		 * All vectors are in default character rotation space, where x is right and z is forward.
		 * */
		private void StoreAxisDirections() {
			AxisDirection axisDefault = new AxisDirection(Vector3.zero, new Vector3(-1f, 0f, 0f));
			
			AxisDirection axisBehindHead = new AxisDirection(new Vector3(0.5f, 0f, -0.2f), new Vector3(-0.5f, -1f, 1f));
			AxisDirection axisArmTwist = new AxisDirection(new Vector3(-0.5f, -1f, -0.2f), new Vector3(0f, 0.5f, -1f));
			AxisDirection axisCrossHeart = new AxisDirection(new Vector3(-0.5f, -0.5f, 1f), new Vector3(-1f, -1f, -1f));
			
			axisDirections = new AxisDirection[4] { axisDefault, axisBehindHead, axisArmTwist, axisCrossHeart };
		}
예제 #48
0
        public static LinkedList<TilePathNode> findPathBetween(Tile from, Tile to, Vector startDirection)
        {
            var roadMap = from.roadMap;

            var cost = new double[roadMap.width, roadMap.height];
            for (int x = 0; x < roadMap.width; ++x) {
                for (int y = 0; y < roadMap.height; ++y) {
                    cost[x, y] = double.MaxValue;
                }
            }

            var backDir = new AxisDirection[roadMap.width, roadMap.height];
            var speedDir = new Vector[roadMap.width, roadMap.height];

            var queue = new Queue<Tile>();
            queue.Enqueue(from);

            cost[from.posX, from.posY] = 0;
            speedDir[from.posX, from.posY] = startDirection;

            while (queue.Count > 0) {
                var current = queue.Dequeue();

                foreach (AxisDirection dir in Enum.GetValues(typeof(AxisDirection))) {
                    if (current.canGoInDirection(dir)) {
                        var next = current.nextTileInDirection(dir);
                        if (next != null) {

                            double nextCost = cost[current.posX, current.posY] + 1;
                            if (speedDir[current.posX, current.posY] * new Vector(dir) < 0.01)
                                nextCost += 1;

                            if (cost[next.posX, next.posY] > nextCost) {
                                cost[next.posX, next.posY] = nextCost;
                                backDir[next.posX, next.posY] = dir.back();
                                speedDir[next.posX, next.posY] = new Vector(dir);

                                if (!queue.Contains(next))
                                    queue.Enqueue(next);
                            }
                        }
                    }
                }

            }

            var list = new LinkedList<TilePathNode>();

            {
                var current = to;

                if (cost[to.posX, to.posY] == -1)
                    return list; // SHEEIT, UNKNOWN TILES

                while (current != from) {
                    list.AddFirst(new TilePathNode(current));
                    current = current.nextTileInDirection(backDir[current.posX, current.posY]);
                    if (current == null)
                        return list;
                }
            }

            return list;
        }
예제 #49
0
 void FetchAxisMapping(ref KeyCode fetchedKey, ref GamePad.Axis fetchedAxis, ref AxisDirection fetchedDirection, bool ignored = false)
 {
     if (CurrentControllerType == ControllerType.Keyboard)
     {
         KeyCode key = PressedKeyOrButton();
         if (key != KeyCode.None)
         {
             fetchedKey = key;
             CurrentPhase++;
             PlaySound(InputClip, Players[CurrentPlayer - 1]);
         }
     }
     else
     {
         if (GamePad.GetAxis(GamePad.Axis.Dpad, GamePadIndex).magnitude > 0.3f)
         {
             if (!ignored)
             {
                 fetchedAxis = GamePad.Axis.Dpad;
                 fetchedDirection = ToDirection(GamePad.GetAxis(GamePad.Axis.Dpad, GamePadIndex));
             }
             CurrentPhase++;
             WaitingForAxisReset = true;
             PlaySound(InputClip, Players[CurrentPlayer - 1]);
         }
         else if (GamePad.GetAxis(GamePad.Axis.LeftStick, GamePadIndex).magnitude > 0.3f)
         {
             if (!ignored)
             {
                 fetchedAxis = GamePad.Axis.LeftStick;
                 fetchedDirection = ToDirection(GamePad.GetAxis(GamePad.Axis.LeftStick, GamePadIndex));
             }
             CurrentPhase++;
             WaitingForAxisReset = true;
             PlaySound(InputClip, Players[CurrentPlayer - 1]);
         }
         else if (GamePad.GetAxis(GamePad.Axis.RightStick, GamePadIndex).magnitude > 0.3f)
         {
             if (!ignored)
             {
                 fetchedAxis = GamePad.Axis.RightStick;
                 fetchedDirection = ToDirection(GamePad.GetAxis(GamePad.Axis.RightStick, GamePadIndex));
             }
             CurrentPhase++;
             WaitingForAxisReset = true;
             PlaySound(InputClip, Players[CurrentPlayer - 1]);
         }
     }
 }