public static Vector2 Div(this Vector2 vector, Vector2 otherVector, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
            vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;

            return vector;
        }
    // Update is called once per frame
    void Update()
    {
        //bool enabled = Input.GetKey(key);

        if (axes == null || axes.horizontal == null || axes.horizontal.Length == 0)
            axes = FetchAxis0();

        if (axes != null)
        {
            Vector3 vec = this.transform.localEulerAngles;
            float v = ResolveAxis(axes.vertical);
            float h = ResolveAxis(axes.horizontal);
            float z = ResolveAxis(axes.other);
            vec.x = Mathf.Clamp(v*0.7f + h * orientation, -1f, 1f) * 35f + 3.2f;
            vec.y = Mathf.Clamp(z,-1f,1f) * -25f + 180f;
            this.transform.localEulerAngles = vec;

            float f = Mathf.Max( Mathf.Max(ResolveAxis(axes.acceleration) , 0f), Mathf.Max(Mathf.Max(Mathf.Abs(h),Mathf.Abs(v)),Mathf.Abs(z)));

            if (sys != null)
            {
                sys.enableEmission = f != 0f;
                sys.startLifetime = f * maxLifetime;
            }

            if (force != null)
            {
                force.relativeForce = new Vector3(0,0,maxForce * f);
            }
        }
    }
 /// <summary>
 /// Get the acceleration of one axis in Gs.
 /// </summary>
 /// <param name="axis">The axis to read from.</param>
 /// <returns>Acceleration of the ADXL345 in Gs.</returns>
 public override double GetAcceleration(Axes axis)
 {
     byte[] transferBuffer = new byte[3];
     transferBuffer[0] = (byte)((AddressRead | AddressMultiByte | DataRegister) + (byte)axis);
     m_spi.Transaction(transferBuffer, transferBuffer, 3);
     return BitConverter.ToInt16(transferBuffer, 1) * GsPerLSB;
 }
        public static float Average(this Vector4 vector, Axes axis)
        {
            float average = 0;
            int axisCount = 0;

            if (axis.Contains(Axes.X)) {
                average += vector.x;
                axisCount += 1;
            }

            if (axis.Contains(Axes.Y)) {
                average += vector.y;
                axisCount += 1;
            }

            if (axis.Contains(Axes.Z)) {
                average += vector.z;
                axisCount += 1;
            }

            if (axis.Contains(Axes.W)) {
                average += vector.w;
                axisCount += 1;
            }

            return average / axisCount;
        }
        public static float Distance(this Vector3 vector, Vector3 target, Axes axes)
        {
            float distance = 0f;

            switch (axes)
            {
                case Axes.X:
                    distance = Mathf.Abs(vector.x - target.x);
                    break;
                case Axes.Y:
                    distance = Mathf.Abs(vector.y - target.y);
                    break;
                case Axes.Z:
                    distance = Mathf.Abs(vector.z - target.z);
                    break;
                case Axes.XY:
                    distance = Vector2.Distance(vector, target);
                    break;
                case Axes.XZ:
                    distance = Vector2.Distance(new Vector2(vector.x, vector.z), new Vector2(target.x, target.z));
                    break;
                case Axes.YZ:
                    distance = Vector2.Distance(new Vector2(vector.y, vector.z), new Vector2(target.y, target.z));
                    break;
                case Axes.XYZ:
                    distance = Vector3.Distance(vector, target);
                    break;
            }

            return distance;
        }
        public static float Average(this Vector3 vector, Axes axes)
        {
            float average = 0f;
            int axisCount = 0;

            if ((axes & Axes.X) != 0)
            {
                average += vector.x;
                axisCount += 1;
            }

            if ((axes & Axes.Y) != 0)
            {
                average += vector.y;
                axisCount += 1;
            }

            if ((axes & Axes.Z) != 0)
            {
                average += vector.z;
                axisCount += 1;
            }

            return average / axisCount;
        }
        public static Vector2 Lerp(this Vector2 vector, Vector2 target, float time, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) && Mathf.Abs(target.x - vector.x) > epsilon ? Mathf.Lerp(vector.x, target.x, time) : vector.x;
            vector.y = axis.Contains(Axes.Y) && Mathf.Abs(target.y - vector.y) > epsilon ? Mathf.Lerp(vector.y, target.y, time) : vector.y;

            return vector;
        }
        public static Vector3 Div(this Vector3 vector, Vector3 otherVector, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
            vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
            vector.z = axis.Contains(Axes.Z) ? vector.z / otherVector.z : vector.z;

            return vector;
        }
		/// <summary>
		/// Sets the value of the Y axe.
		/// </summary>

		public Vector3 SetY (float y)
		{
			if (y != value.y)
			{
				value.y = y;
				axes |= Axes.Y;
			}
			return value;
		}
示例#10
0
        public static Vector4 Div(this Vector4 vector, Vector4 otherVector, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) ? vector.x / otherVector.x : vector.x;
            vector.y = axis.Contains(Axes.Y) ? vector.y / otherVector.y : vector.y;
            vector.z = axis.Contains(Axes.Z) ? vector.z / otherVector.z : vector.z;
            vector.w = axis.Contains(Axes.W) ? vector.w / otherVector.w : vector.w;

            return vector;
        }
		/// <summary>
		/// Sets the value of the X axe.
		/// </summary>

		public Vector3 SetX (float x)
		{
			if (x != value.x)
			{
				value.x = x;
				axes |= Axes.X;
			}
			return value;
		}
示例#12
0
#pragma warning restore 649

		private NodeSet CreateNodeTest (Axes axis, object nodeTest, ArrayList plist)
		{
			NodeSet test = CreateNodeTest (axis, nodeTest);
			if (plist != null) {
				for (int i = 0; i < plist.Count; i++)
					test = new ExprFilter (test,
						(Expression) plist [i]);
			}
			return test;
		}
        public static Vector2 Ceil(this Vector2 vector, Axes axes)
        {
            if ((axes & Axes.X) != 0)
                vector.x = Mathf.Ceil(vector.x);

            if ((axes & Axes.Y) != 0)
                vector.y = Mathf.Ceil(vector.y);

            return vector;
        }
        public static Vector2 Lerp(this Vector2 vector, Vector2 target, float time, Axes axes)
        {
            if ((axes & Axes.X) != 0 && Mathf.Abs(target.x - vector.x) > _epsilon)
                vector.x = Mathf.Lerp(vector.x, target.x, time);

            if ((axes & Axes.Y) != 0 && Mathf.Abs(target.y - vector.y) > _epsilon)
                vector.y = Mathf.Lerp(vector.y, target.y, time);

            return vector;
        }
 public static void AccelerateTowards(this Rigidbody2D rigidbody, Vector2 targetAcceleration, float speed, InterpolationModes interpolation, Axes axis = Axes.XY)
 {
     switch (interpolation) {
         case InterpolationModes.Quadratic:
             rigidbody.SetVelocity(rigidbody.velocity.Lerp(targetAcceleration, Time.fixedDeltaTime * speed, axis), axis);
             break;
         case InterpolationModes.Linear:
             rigidbody.SetVelocity(rigidbody.velocity.LerpLinear(targetAcceleration, Time.fixedDeltaTime * speed, axis), axis);
             break;
     }
 }
 public static void AccelerateTowards(this Rigidbody2D rigidbody, Vector2 targetSpeed, float acceleration, float deltaTime, InterpolationModes interpolation = InterpolationModes.Quadratic, Axes axes = Axes.XY)
 {
     switch (interpolation)
     {
         case InterpolationModes.Quadratic:
             rigidbody.SetVelocity(rigidbody.velocity.Lerp(targetSpeed, deltaTime * acceleration, axes), axes);
             break;
         case InterpolationModes.Linear:
             rigidbody.SetVelocity(rigidbody.velocity.LerpLinear(targetSpeed, deltaTime * acceleration, axes), axes);
             break;
     }
 }
示例#17
0
        public static Axes Resolve(Axes axis1, Axes axis2)
        {
            if (axis1 == axis2)
                throw new ArgumentException("Cannot resolve duplicate axes.");

            if ((axis1 == Axes.X || axis1 == Axes.Y) && (axis2 == Axes.X || axis2 == Axes.Y))
                return Axes.Z;
            else if ((axis1 == Axes.X || axis1 == Axes.Z) && (axis2 == Axes.X || axis2 == Axes.Z))
                return Axes.Y;
            else
                return Axes.X;
        }
示例#18
0
 // ShowAxis
 private static void ShowAxis( ref Axes axis, string label )
 {
     GUILayout.BeginHorizontal();
     axis.enabled = EditorGUILayout.Toggle( axis.enabled, GUILayout.Width( 15f ) );
     GUILayout.Label( "Axis " + label, GUILayout.Width( 50f ) );
     GUI.enabled = axis.enabled;
     axis.Name = EditorGUILayout.TextField( axis.Name, GUILayout.Width( 100f ) );
     GUILayout.Space( 10f );
     axis.inverse = EditorGUILayout.Toggle( axis.inverse, GUILayout.Width( 15f ) );
     GUILayout.Label( "Inverse", GUILayout.Width( 55f ) );
     GUI.enabled = true;
     GUILayout.EndHorizontal();
 }
		/// <summary>
		/// Construct a new generic constraint.
		/// </summary>
		/// <param name="bodyA">The first constrained body.</param>
		/// <param name="bodyB">The second constrained body.</param>
		/// <param name="basis">The world-space frame of the second body against which the first body will be constrained. This value
		/// must contain the initial position and orientation of the second body at the time the constraint was created.</param>
		/// <param name="limitedPosAxes">Specifies which axes around which to constrain position.</param>
		/// <param name="minPos">The minimum distances between the two bodies along each axis.</param>
		/// <param name="maxPos">The maximum distances between the two bodies along each axis.</param>
		/// <param name="limitedRotAxes">Specifies which axes around which to constrain rotation.</param>
		/// <param name="minAngles">The minimum relative angles, in radians, around each axis.</param>
		/// <param name="maxAngles">The maximum relative angles, in radians, around each axis.</param>
		public GenericConstraint(RigidBody bodyA, RigidBody bodyB, Frame basis, Axes limitedPosAxes,
			Vector3 minPos, Vector3 maxPos, Axes limitedRotAxes, Vector3 minAngles, Vector3 maxAngles)
			: base(bodyA, bodyB)
		{
			Frame.Transform(ref basis, ref bodyA.WorldInverse, out _bodyBasisA);
			Frame.Transform(ref basis, ref bodyB.WorldInverse, out _bodyBasisB);
			_limitedPosAxes = limitedPosAxes;
			_limitedRotAxes = limitedRotAxes;
			_minPos = minPos;
			_maxPos = maxPos;
			_minAngles = minAngles;
			_maxAngles = maxAngles;
		}
        public PhysicalHeliState(Quaternion orientation, Vector3 pos, Vector3 velocity, Vector3 acceleration)
        {
            Orientation = orientation;
            Position = pos;
            Velocity = velocity;
            Acceleration = acceleration;

            Matrix orientationMatrix = Matrix.CreateFromQuaternion(orientation);
            Axes = VectorHelper.GetAxes(orientation);
            PitchAngle = VectorHelper.GetPitchAngle(orientationMatrix);
            RollAngle = VectorHelper.GetRollAngle(orientationMatrix);
            HeadingAngle = VectorHelper.GetHeadingAngle(orientationMatrix);
        }
示例#21
0
 public void Reflect(Axes axis)
 {
     switch (axis)
     {
         case Axes.X:
             ReflectX();
             break;
         case Axes.Y:
             ReflectY();
             break;
         case Axes.Z:
             ReflectZ();
             break;
     }
 }
示例#22
0
		private NodeTest CreateNodeTest (Axes axis, object test)
		{
			if (test is XPathNodeType)
				return new NodeTypeTest (axis,
					(XPathNodeType) test, null);
			else if (test is string || test == null)
				return new NodeTypeTest (axis,
					XPathNodeType.ProcessingInstruction,
					(string) test);
			XmlQualifiedName q = (XmlQualifiedName) test;
			if (q == XmlQualifiedName.Empty)
				return new NodeTypeTest (axis);
			else
				return new NodeNameTest (axis, q, Context);
		}
        public static Vector4 Ceil(this Vector4 vector, Axes axes)
        {
            if ((axes & Axes.X) != 0)
                vector.x = Mathf.Ceil(vector.x);

            if ((axes & Axes.Y) != 0)
                vector.y = Mathf.Ceil(vector.y);

            if ((axes & Axes.Z) != 0)
                vector.z = Mathf.Ceil(vector.z);

            if ((axes & Axes.W) != 0)
                vector.w = Mathf.Ceil(vector.w);

            return vector;
        }
示例#24
0
 /// <summary>
 /// Creates an instance of Options1.
 /// </summary>
 /// <param name="value">Value of TubeSize.</param>
 /// <param name="axes">States, if value is x (half width of rectangle) or y (half height of rectangle).</param>
 /// /// <remarks>Default values: <para>
 /// Use relative values for calculation of TubeSize: Relativity = Relativity.Relative <para/>
 /// Delimiter = ';' <para/>
 /// Separator = '.' <para/>
 /// Don't save log file: log = new Log()<para/>
 /// Don't save image: reportFolder = ""<para/>
 /// Don't show window: showWindow = false<para/>
 /// Show all (valid and invalid): ShowValidity = Validity.All<para/>
 /// Always use normal drawing methods, never fast drawing methods: drawFastAbove = 0<para/>
 /// Always draw points: drawPointsBelow = Int32.MaxValue
 /// </para></remarks>
 public Options1(double value, Axes axes)
 {
     this.val = value;
     this.axes = axes;
     relativity = Relativity.Relative;
     baseX = Double.NaN;
     baseY = Double.NaN;
     ratio = Double.NaN;
     log = new Log();
     reportFolder = "";
     showWindow = false;
     showValidity = Validity.All;
     drawFastAbove = 0;
     drawPointsBelow = Int32.MaxValue;
     formerBaseAndRatio = false;
     drawLabelNumber = false;
 }
        /// <summary>
        ///   Returns a new physical state where the values represent the error in the estimated state to
        ///   the given true state. I.e. position = estimatedPosition - truePosition.
        /// </summary>
        /// <param name="trueState"></param>
        /// <param name="estimatedState"></param>
        /// <returns></returns>
        public static PhysicalHeliState GetError(PhysicalHeliState trueState, PhysicalHeliState estimatedState)
        {
            var axesError = new Axes
                                {
                                    Forward = estimatedState.Axes.Forward - trueState.Axes.Forward,
                                    Right = estimatedState.Axes.Right - trueState.Axes.Right,
                                    Up = estimatedState.Axes.Up - trueState.Axes.Up
                                };

            //            var rotationError = new Matrix {Forward = axesError.Forward, Right = axesError.Right, Up = axesError.Up};

            // TODO Verify this works, since axes were originally used to compute state instead of orientation (but should equivalent)
            return new PhysicalHeliState(
                Quaternion.Identity, // TODO Not sure how to represent rotation error in quaternion representation
                estimatedState.Position - trueState.Position,
                estimatedState.Velocity - trueState.Velocity,
                estimatedState.Acceleration - trueState.Acceleration);
        }
        public static Quaternion Round(this Quaternion quaternion, float step, Axes axes)
        {
            if (step <= 0)
                return quaternion;

            if ((axes & Axes.X) != 0)
                quaternion.x = quaternion.x.Round(step);

            if ((axes & Axes.Y) != 0)
                quaternion.y = quaternion.y.Round(step);

            if ((axes & Axes.Z) != 0)
                quaternion.z = quaternion.z.Round(step);

            if ((axes & Axes.W) != 0)
                quaternion.w = quaternion.w.Round(step);

            return quaternion;
        }
        public static float Distance(this Vector2 vector, Vector2 target, Axes axes)
        {
            float distance = 0f;

            switch (axes)
            {
                case Axes.X:
                    distance = Mathf.Abs(vector.x - target.x);
                    break;
                case Axes.Y:
                    distance = Mathf.Abs(vector.y - target.y);
                    break;
                case Axes.XY:
                    distance = Vector2.Distance(vector, target);
                    break;
            }

            return distance;
        }
示例#28
0
 public override float GetAxis( Axes axis )
 {
     switch( axis )
     {
         case Axes.LeftStickX:
         return GetAxis( "LeftStickX" );
         case Axes.LeftStickY:
         return GetAxis( "LeftStickY" );
         case Axes.RightStickX:
         return GetAxis( "RightStickX" );
         case Axes.RightStickY:
         return GetAxis( "RightStickY" );
         case Axes.LeftTrigger:
         return GetAxis( "LeftTrigger" );
         case Axes.RightTrigger:
         return GetAxis( "RightTrigger" );
         default:
         return 0f;
     }
 }
示例#29
0
 /// <summary>
 /// Returns value from Vector based on axis
 /// </summary>
 /// <param name="values">Vector to get axis from</param>
 /// <param name="axis">Axis to get (values.x, values.y, values.z)</param>
 /// <returns></returns>
 public static float GetAxes(Vector3 values, Axes axis)
 {
     return(values[(int)axis]);
 }
示例#30
0
        /// <summary>Creates an axis reader for the specified object</summary>
        /// <param name="joystick">Joystick providing the control object</param>
        /// <param name="axis">Axis a reader will be created for</param>
        /// <param name="control">Control description for the axis</param>
        /// <returns>A new axis reader for the specified axis</returns>
        private static IAxisReader createAxisReader(
            Joystick joystick, Axes axis, DeviceObjectInstance control
            )
        {
            int id = (int)control.ObjectType;
            ObjectProperties properties = joystick.GetObjectPropertiesById(id);

            int min = properties.LowerRange;
            int max = properties.UpperRange;

            switch (axis)
            {
            case Axes.X:
            {
                return(new XAxisReader(min, max));
            }

            case Axes.Y:
            {
                return(new YAxisReader(min, max));
            }

            case Axes.Z:
            {
                return(new ZAxisReader(min, max));
            }

            case Axes.VelocityX:
            {
                return(new VelocityXAxisReader(min, max));
            }

            case Axes.VelocityY:
            {
                return(new VelocityYAxisReader(min, max));
            }

            case Axes.VelocityZ:
            {
                return(new VelocityZAxisReader(min, max));
            }

            case Axes.AccelerationX:
            {
                return(new AccelerationXAxisReader(min, max));
            }

            case Axes.AccelerationY:
            {
                return(new AccelerationYAxisReader(min, max));
            }

            case Axes.AccelerationZ:
            {
                return(new AccelerationZAxisReader(min, max));
            }

            case Axes.ForceX:
            {
                return(new ForceXAxisReader(min, max));
            }

            case Axes.ForceY:
            {
                return(new ForceYAxisReader(min, max));
            }

            case Axes.ForceZ:
            {
                return(new ForceZAxisReader(min, max));
            }

            case Axes.RotationX:
            {
                return(new RotationXAxisReader(min, max));
            }

            case Axes.RotationY:
            {
                return(new RotationYAxisReader(min, max));
            }

            case Axes.RotationZ:
            {
                return(new RotationZAxisReader(min, max));
            }

            case Axes.AngularVelocityX:
            {
                return(new AngularVelocityXAxisReader(min, max));
            }

            case Axes.AngularVelocityY:
            {
                return(new AngularVelocityYAxisReader(min, max));
            }

            case Axes.AngularVelocityZ:
            {
                return(new AngularVelocityZAxisReader(min, max));
            }

            case Axes.AngularAccelerationX:
            {
                return(new AngularAccelerationXAxisReader(min, max));
            }

            case Axes.AngularAccelerationY:
            {
                return(new AngularAccelerationYAxisReader(min, max));
            }

            case Axes.AngularAccelerationZ:
            {
                return(new AngularAccelerationZAxisReader(min, max));
            }

            case Axes.TorqueX:
            {
                return(new TorqueXAxisReader(min, max));
            }

            case Axes.TorqueY:
            {
                return(new TorqueYAxisReader(min, max));
            }

            case Axes.TorqueZ:
            {
                return(new TorqueZAxisReader(min, max));
            }

            default:
            {
                return(null);
            }
            }
        }
示例#31
0
        public GraphData(TimeSpan startTime, string title,
                         ChartConfig chartConfig)
        {
            _startTime = startTime;
            this.Title = title;
            _clipMax   = chartConfig.ClipMax;

            LinearAcceleration = new LineSeries()
            {
                Title     = "LinearAccelereation",
                YAxisKey  = "LinearAccelereation",
                LineStyle = LineStyle.Solid,
                Color     = OxyColor.FromRgb(0xff, 0, 0),
            };

            AngularVelocity = new LineSeries()
            {
                Title     = "AngularVelocity",
                YAxisKey  = "AngularVelocity",
                LineStyle = LineStyle.Solid,
                Color     = OxyColor.FromRgb(0, 0xff, 0),
            };

            Angle = new LineSeries()
            {
                Title     = "Angle",
                YAxisKey  = "Angle",
                LineStyle = LineStyle.Solid,
                Color     = OxyColor.FromRgb(0, 0, 0xff),
            };


            Axes.Add(new LinearAxis
            {
                Key      = "LinearAccelereation",
                Position = AxisPosition.Left,
                Minimum  = chartConfig.LinearAccelerationMin,
                Maximum  = chartConfig.LinearAccelerationMax,
            });


            Axes.Add(new LinearAxis
            {
                Key      = "AngularVelocity",
                Position = AxisPosition.Left,
                Minimum  = chartConfig.AngularVelocityMin,
                Maximum  = chartConfig.AngularVelocityMax,
            });

            Axes.Add(new LinearAxis
            {
                Key      = "Angle",
                Position = AxisPosition.Left,
                Minimum  = chartConfig.AngleMin,
                Maximum  = chartConfig.AngleMax,
            });

            //Axes.Add(new LinearAxis
            //{
            //    Position = AxisPosition.Left,
            //    Minimum = Math.Min(Math.Min(chartConfig.LinearAccelerationMin, chartConfig.AngularVelocityMin), chartConfig.AngleMin),
            //    Maximum = Math.Max(Math.Max(chartConfig.LinearAccelerationMax, chartConfig.AngularVelocityMax), chartConfig.AngleMax),
            //});

            this.IsLegendVisible = true;


            this.Series.Add(LinearAcceleration);
            this.Series.Add(AngularVelocity);
            this.Series.Add(Angle);

            //this.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));
        }
示例#32
0
 /// <summary>
 /// Adds a plan instruction for simultaneous controll of two axes.
 /// The instruction type has to be same for the axes.
 /// </summary>
 /// <param name="instructionX">instruction for the x axis.</param>
 /// <param name="instructionY">instruction for the y axis.</param>
 public void AddXY(StepInstrution instructionX, StepInstrution instructionY)
 {
     _plan.Add(Axes.XY(instructionX, instructionY));
 }
示例#33
0
 protected bool Equals(ControllerState other)
 {
     return(Axes.SequenceEqual(other.Axes) && Buttons.SequenceEqual(other.Buttons) && Hats.SequenceEqual(other.Hats));
 }
        /// <summary>
        /// Rotates a group of entities by a specified angle around a specified axis.
        /// </summary>
        /// <param name="entitiesToRotate">The group of entities that are to be rotated.</param>
        /// <param name="rotationAxis">The axis around which the entities are to be rotated.</param>
        /// <param name="rotationAngle">The angle by which the entities are to be rotated.</param>
        /// <param name="copiesToCreate">The number of copies to create of the original entities.</param>
        /// <param name="rotationOrigin">The origin of the rotation axis.</param>
        /// <returns>A list of entities created by the operation.  If numberOfCopies is 0, an .empty list is returned.</returns>
        public static List <PSEntity> RotateEntities(
            List <IPSRotateable> entitiesToRotate,
            Axes rotationAxis,
            DG.Degree rotationAngle,
            int copiesToCreate,
            DG.Point rotationOrigin = null)
        {
            // Get PowerSHAPE instance
            _powerSHAPE = ((PSEntity)entitiesToRotate.First()).PowerSHAPE;

            // Add all IRotatables
            ((PSEntity)entitiesToRotate.First()).AddToSelection(true);
            int numberOfEntities = entitiesToRotate.Count();

            for (int i = 1; i <= numberOfEntities - 1; i++)
            {
                ((PSEntity)entitiesToRotate[i]).AddToSelection(false);
            }

            // Carry out operation
            _powerSHAPE.DoCommand("EDIT ROTATE");

            // Determine whether a copy is to be created
            if (copiesToCreate == 0)
            {
                _powerSHAPE.DoCommand("NOKEEP");
            }
            else
            {
                _powerSHAPE.DoCommand("KEEP");
                _powerSHAPE.DoCommand("COPIES " + copiesToCreate);
            }

            // If a different rotation origin has been defined, set it within PowerSHAPE
            if (rotationOrigin != null)
            {
                _powerSHAPE.DoCommand("AXIS");
                _powerSHAPE.DoCommand(rotationOrigin.ToString());
            }

            // Set the active plane, which determines the axis of rotation
            _powerSHAPE.SetActivePlane(rotationAxis.AxisToPlane());

            // Enter rotation angle
            _powerSHAPE.DoCommand("ANGLE " + rotationAngle);
            if (_powerSHAPE.Version >= new Version("11.2"))
            {
                _powerSHAPE.DoCommand("APPLY", "DISMISS");
            }
            else
            {
                _powerSHAPE.DoCommand("CANCEL");
            }

            // If no copies were made, return an empty list
            if (copiesToCreate == 0)
            {
                return(new List <PSEntity>());
            }

            // If copies were made, add them to their appropriate collections and return new entities
            List <PSEntity> copiedEntities = new List <PSEntity>();

            foreach (PSEntity copiedEntity in _powerSHAPE.ActiveModel.CreatedItems)
            {
                _powerSHAPE.ActiveModel.Add(copiedEntity);
                copiedEntities.Add(copiedEntity);
            }

            return(copiedEntities);
        }
示例#35
0
        public static Vector3 PositionHandle(PositionHandleIDs handleIDs, Vector3 position, Axes enabledAxes = Axes.XYZ)
        {
            var activeGrid = Grid.ActiveGrid;
            var rotation   = Quaternion.LookRotation(activeGrid.Forward, activeGrid.Up);

            return(PositionHandle(handleIDs, new[] { position }, position, rotation, enabledAxes)[0]);
        }
示例#36
0
 public static Vector3 PositionHandleOffset(PositionHandleIDs handleIDs, Vector3 position, Axes enabledAxes = Axes.XYZ)
 {
     return(PositionHandle(handleIDs, position, enabledAxes) - position);
 }
示例#37
0
        public static Vector3 Edge2DHandleOffset(int id, Vector3 from, Vector3 to, Vector3 slideDir1, Vector3 slideDir2, CapFunction capFunction = null, Axes axes = Axes.None, Vector3?snappingSteps = null, bool setCursor = true, bool renderEdge = true)
        {
            var midPoint  = (from + to) * 0.5f;
            var handleDir = Vector3.Cross(slideDir1, slideDir2);

            return(SceneHandles.Edge2DHandleOffset(id, from, to, midPoint, handleDir, slideDir1, slideDir2, 0, capFunction, axes, snappingSteps, setCursor: setCursor, renderEdge: renderEdge));
        }
示例#38
0
 public static Axes Combine(StepInstrution x, StepInstrution y, StepInstrution z)
 {
     return(Axes.UVXY(y, x, y, z));
 }
示例#39
0
        public static Vector3[] PositionHandle(Vector3[] points, Vector3 position, Quaternion rotation, Axes enabledAxes = Axes.XYZ)
        {
            var handleIDs = new PositionHandleIDs();

            SetPositionHandleIDs(ref handleIDs);
            return(PositionHandle(handleIDs, points, position, rotation, enabledAxes));
        }
示例#40
0
        public static Vector3[] PositionHandle(PositionHandleIDs handleIDs, Vector3[] points, Vector3 position, Quaternion rotation, Axes enabledAxes = Axes.XYZ)
        {
            var xAxisId   = handleIDs.xAxisId;
            var yAxisId   = handleIDs.yAxisId;
            var zAxisId   = handleIDs.zAxisId;
            var xzPlaneId = handleIDs.xzPlaneId;
            var xyPlaneId = handleIDs.xyPlaneId;
            var yzPlaneId = handleIDs.yzPlaneId;
            var centerId  = handleIDs.centerId;

            var isStatic     = (!Tools.hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));
            var prevDisabled = SceneHandles.disabled;

            var hotControl = GUIUtility.hotControl;

            var xAxisIsHot  = (xAxisId == hotControl);
            var yAxisIsHot  = (yAxisId == hotControl);
            var zAxisIsHot  = (zAxisId == hotControl);
            var xzAxisIsHot = (xzPlaneId == hotControl);
            var xyAxisIsHot = (xyPlaneId == hotControl);
            var yzAxisIsHot = (yzPlaneId == hotControl);
            var centerIsHot = (centerId == hotControl);

            var isControlHot = xAxisIsHot || yAxisIsHot || zAxisIsHot || xzAxisIsHot || xyAxisIsHot || yzAxisIsHot || centerIsHot;

            var handleSize    = UnityEditor.HandleUtility.GetHandleSize(position);
            var originalColor = SceneHandles.color;

            var activeAxes = Snapping.ActiveAxes;

            UnityEditor.HandleUtility.AddControl(centerId, UnityEditor.HandleUtility.DistanceToCircle(position, handleSize * 0.055f));


            var evt  = Event.current;
            var type = evt.GetTypeForControl(centerId);

            switch (type)
            {
            case EventType.MouseDown:
            {
                if (GUIUtility.hotControl != 0)
                {
                    break;
                }

                if ((UnityEditor.HandleUtility.nearestControl != centerId || evt.button != 0) &&
                    (GUIUtility.keyboardControl != centerId || evt.button != 2))
                {
                    break;
                }

                GUIUtility.hotControl = GUIUtility.keyboardControl = centerId;
                evt.Use();
                EditorGUIUtility.SetWantsMouseJumping(1);
                break;
            }

            case EventType.MouseDrag:
            {
                if (GUIUtility.hotControl != centerId)
                {
                    break;
                }
                break;
            }

            case EventType.MouseUp:
            {
                if (GUIUtility.hotControl == centerId && (evt.button == 0 || evt.button == 2))
                {
                    GUIUtility.hotControl      = 0;
                    GUIUtility.keyboardControl = 0;
                    evt.Use();
                    Snapping.ActiveAxes = Axes.XYZ;
                    EditorGUIUtility.SetWantsMouseJumping(0);
                    SceneView.RepaintAll();
                }
                break;
            }
            }

            //,.,.., look at 2018.1 how the position handle works w/ colors

            var xAxisDisabled   = isStatic || prevDisabled || ((enabledAxes & Axes.X) == 0) || Snapping.AxisLocking[0] || (isControlHot && !xAxisIsHot && !xzAxisIsHot && !xyAxisIsHot);
            var yAxisDisabled   = isStatic || prevDisabled || ((enabledAxes & Axes.Y) == 0) || Snapping.AxisLocking[1] || (isControlHot && !yAxisIsHot && !xyAxisIsHot && !yzAxisIsHot);
            var zAxisDisabled   = isStatic || prevDisabled || ((enabledAxes & Axes.Z) == 0) || Snapping.AxisLocking[2] || (isControlHot && !zAxisIsHot && !xzAxisIsHot && !yzAxisIsHot);
            var xzPlaneDisabled = isStatic || prevDisabled || ((enabledAxes & Axes.XZ) != Axes.XZ) || (Snapping.AxisLocking[0] || Snapping.AxisLocking[2]) || (isControlHot && !xzAxisIsHot);
            var xyPlaneDisabled = isStatic || prevDisabled || ((enabledAxes & Axes.XY) != Axes.XY) || (Snapping.AxisLocking[0] || Snapping.AxisLocking[1]) || (isControlHot && !xyAxisIsHot);
            var yzPlaneDisabled = isStatic || prevDisabled || ((enabledAxes & Axes.YZ) != Axes.YZ) || (Snapping.AxisLocking[1] || Snapping.AxisLocking[2]) || (isControlHot && !yzAxisIsHot);

            var currentFocusControl = SceneHandleUtility.focusControl;

            var xAxisIndirectlyFocused = (currentFocusControl == xyPlaneId || currentFocusControl == xzPlaneId);
            var yAxisIndirectlyFocused = (currentFocusControl == xyPlaneId || currentFocusControl == yzPlaneId);
            var zAxisIndirectlyFocused = (currentFocusControl == xzPlaneId || currentFocusControl == yzPlaneId);

            var xAxisIndirectlyActive = activeAxes == Axes.XY || activeAxes == Axes.XZ;
            var yAxisIndirectlyActive = activeAxes == Axes.XY || activeAxes == Axes.YZ;
            var zAxisIndirectlyActive = activeAxes == Axes.XZ || activeAxes == Axes.YZ;

            var xAxisSelected = xAxisIndirectlyFocused || xAxisIndirectlyActive || activeAxes == Axes.X;
            var yAxisSelected = yAxisIndirectlyFocused || yAxisIndirectlyActive || activeAxes == Axes.Y;
            var zAxisSelected = zAxisIndirectlyFocused || zAxisIndirectlyActive || activeAxes == Axes.Z;
            var xzAxiSelected = activeAxes == Axes.XZ;
            var xyAxiSelected = activeAxes == Axes.XZ;
            var yzAxiSelected = activeAxes == Axes.YZ;

            var xAxisColor   = SceneHandles.StateColor(SceneHandles.xAxisColor, xAxisDisabled, xAxisSelected);
            var yAxisColor   = SceneHandles.StateColor(SceneHandles.yAxisColor, yAxisDisabled, yAxisSelected);
            var zAxisColor   = SceneHandles.StateColor(SceneHandles.zAxisColor, zAxisDisabled, zAxisSelected);
            var xzPlaneColor = SceneHandles.StateColor(SceneHandles.yAxisColor, xzPlaneDisabled, xzAxiSelected);
            var xyPlaneColor = SceneHandles.StateColor(SceneHandles.zAxisColor, xyPlaneDisabled, xyAxiSelected);
            var yzPlaneColor = SceneHandles.StateColor(SceneHandles.xAxisColor, yzPlaneDisabled, yzAxiSelected);


            SceneHandles.disabled = xAxisDisabled;
            SceneHandles.color    = xAxisColor;
            points = Slider1DHandle(xAxisId, Axis.X, points, position, rotation * Vector3.right, Snapping.MoveSnappingSteps.x, handleSize, ArrowHandleCap, selectLockingAxisOnClick: true);

            SceneHandles.disabled = yAxisDisabled;
            SceneHandles.color    = yAxisColor;
            points = Slider1DHandle(yAxisId, Axis.Y, points, position, rotation * Vector3.up, Snapping.MoveSnappingSteps.y, handleSize, ArrowHandleCap, selectLockingAxisOnClick: true);

            SceneHandles.disabled = zAxisDisabled;
            SceneHandles.color    = zAxisColor;
            points = Slider1DHandle(zAxisId, Axis.Z, points, position, rotation * Vector3.forward, Snapping.MoveSnappingSteps.z, handleSize, ArrowHandleCap, selectLockingAxisOnClick: true);


            SceneHandles.disabled = xzPlaneDisabled;
            SceneHandles.color    = xzPlaneColor;
            points = PlanarHandle(xzPlaneId, PlaneAxes.XZ, points, position, rotation, handleSize * 0.3f, selectLockingAxisOnClick: true);

            SceneHandles.disabled = xyPlaneDisabled;
            SceneHandles.color    = xyPlaneColor;
            points = PlanarHandle(xyPlaneId, PlaneAxes.XY, points, position, rotation, handleSize * 0.3f, selectLockingAxisOnClick: true);

            SceneHandles.disabled = yzPlaneDisabled;
            SceneHandles.color    = yzPlaneColor;
            points = PlanarHandle(yzPlaneId, PlaneAxes.YZ, points, position, rotation, handleSize * 0.3f, selectLockingAxisOnClick: true);


            switch (type)
            {
            case EventType.Repaint:
            {
                SceneHandles.color = SceneHandles.StateColor(SceneHandles.centerColor, false, centerId == SceneHandleUtility.focusControl);
                SceneHandles.RenderBorderedCircle(position, handleSize * 0.05f);
                break;
            }
            }



            SceneHandles.disabled = prevDisabled;
            SceneHandles.color    = originalColor;

            return(points);
        }
示例#41
0
        public virtual XPathNodeIterator SelectAncestors(XPathNodeType type, bool matchSelf)
        {
            Axes axis = (matchSelf) ? Axes.AncestorOrSelf : Axes.Ancestor;

            return(SelectTest(new NodeTypeTest(axis, type)));
        }
示例#42
0
 public TestRulesetContainer(Axes scrollingAxes, WorkingBeatmap beatmap, bool isForCurrentRuleset)
     : base(null, beatmap, isForCurrentRuleset)
 {
     this.scrollingAxes = scrollingAxes;
 }
示例#43
0
        /// <summary>Retrieves the state of the specified axis</summary>
        /// <param name="axis">Axis whose state will be retrieved</param>
        /// <returns>The state of the specified axis</returns>
        public float GetAxis(Axes axis)
        {
            switch (axis)
            {
            case Axes.X:
            {
                return(this.X);
            }

            case Axes.Y:
            {
                return(this.Y);
            }

            case Axes.Z:
            {
                return(this.Z);
            }

            case Axes.VelocityX:
            {
                return(this.VelocityX);
            }

            case Axes.VelocityY:
            {
                return(this.VelocityY);
            }

            case Axes.VelocityZ:
            {
                return(this.VelocityZ);
            }

            case Axes.AccelerationX:
            {
                return(this.AccelerationX);
            }

            case Axes.AccelerationY:
            {
                return(this.AccelerationY);
            }

            case Axes.AccelerationZ:
            {
                return(this.AccelerationZ);
            }

            case Axes.ForceX:
            {
                return(this.ForceX);
            }

            case Axes.ForceY:
            {
                return(this.ForceY);
            }

            case Axes.ForceZ:
            {
                return(this.ForceZ);
            }

            case Axes.RotationX:
            {
                return(this.RotationX);
            }

            case Axes.RotationY:
            {
                return(this.RotationY);
            }

            case Axes.RotationZ:
            {
                return(this.RotationZ);
            }

            case Axes.AngularVelocityX:
            {
                return(this.AngularVelocityX);
            }

            case Axes.AngularVelocityY:
            {
                return(this.AngularVelocityY);
            }

            case Axes.AngularVelocityZ:
            {
                return(this.AngularVelocityZ);
            }

            case Axes.AngularAccelerationX:
            {
                return(this.AngularAccelerationX);
            }

            case Axes.AngularAccelerationY:
            {
                return(this.AngularAccelerationY);
            }

            case Axes.AngularAccelerationZ:
            {
                return(this.AngularAccelerationZ);
            }

            case Axes.TorqueX:
            {
                return(this.TorqueX);
            }

            case Axes.TorqueY:
            {
                return(this.TorqueY);
            }

            case Axes.TorqueZ:
            {
                return(this.TorqueZ);
            }

            default:
            {
                throw new ArgumentOutOfRangeException("axis", "Invalid axis");
            }
            }
        }
示例#44
0
 public static Vector3 PositionHandle(Vector3 position, Quaternion rotation, Axes enabledAxes = Axes.XYZ)
 {
     return(PositionHandle(new[] { position }, position, rotation, enabledAxes)[0]);
 }
示例#45
0
 public ControllerState(List <double> axes, List <bool> buttons, List <Hat> hats)
 {
     Axes.AddRange(axes);
     Buttons.AddRange(buttons);
     Hats.AddRange(hats);
 }
示例#46
0
    private void DrawGridGraphics(Camera cam, Axes camAxis, Color col)
    {
        previousColor = Handles.color;
        Handles.color = col;

        // !-- TODO: Update this stuff only when necessary.  Currently it runs evvverrrryyy frame
        Vector3 bottomLeft  = SnapToFloor(cam.ScreenToWorldPoint(Vector2.zero));
        Vector3 bottomRight = SnapToFloor(cam.ScreenToWorldPoint(new Vector2(cam.pixelWidth, 0f)));
        Vector3 topLeft     = SnapToFloor(cam.ScreenToWorldPoint(new Vector2(0f, cam.pixelHeight)));
        Vector3 topRight    = SnapToFloor(cam.ScreenToWorldPoint(new Vector2(cam.pixelWidth, cam.pixelHeight)));

        Vector3 axis = VectorWithAxes(camAxis);

        float width  = Vector3.Distance(bottomLeft, bottomRight);
        float height = Vector3.Distance(bottomRight, topRight);

        // Shift lines to 1m forward of the camera
        bottomLeft  += axis * 2;
        topRight    += axis * 2;
        bottomRight += axis * 2;
        topLeft     += axis * 2;

        /**
         *	Draw Vertical Lines
         *	Add two because we want the grid to cover the entire screen.
         */
        Vector3 start = bottomLeft - cam.transform.up * (height + snapValue * 2);
        Vector3 end   = bottomLeft + cam.transform.up * (height + snapValue * 2);

        float _snapVal = snapValue;

        int segs = (int)Mathf.Ceil(width / _snapVal) + 2;

        float n = 2;

        while (segs > MAX_LINES)
        {
            _snapVal = _snapVal * n;
            segs     = (int)Mathf.Ceil(width / _snapVal);
            n++;
        }

        for (int i = -1; i < segs; i++)
        {
            Handles.DrawLine(
                start + (i * (cam.transform.right * _snapVal)),
                end + (i * (cam.transform.right * _snapVal)));
        }

        /**
         * Draw Horizontal Lines
         */
        start = topLeft - cam.transform.right * (width + snapValue * 2);
        end   = topLeft + cam.transform.right * (width + snapValue * 2);

        segs = (int)Mathf.Ceil(height / _snapVal) + 2;

        n = 1;
        while (segs > MAX_LINES)
        {
            _snapVal = _snapVal * n;
            n++;
            segs = (int)Mathf.Ceil(height / _snapVal);
        }

        for (int i = -1; i < segs; i++)
        {
            Handles.DrawLine(
                start + (i * (-cam.transform.up * _snapVal)),
                end + (i * (-cam.transform.up * _snapVal)));
        }

                #if PRO
        if (drawAngles)
        {
            Vector3 cen = SnapValue(((topRight + bottomLeft) / 2f));

            float half = (width > height) ? width : height;

            float opposite = Mathf.Tan(Mathf.Deg2Rad * angleValue) * half;

            Vector3 up    = cam.transform.up * opposite;
            Vector3 right = cam.transform.right * half;

            Vector3 bottomLeftAngle = cen - (up + right);
            Vector3 topRightAngle   = cen + (up + right);

            Vector3 bottomRightAngle = cen + (right - up);
            Vector3 topLeftAngle     = cen + (up - right);

            // y = 1x+1
            Handles.DrawLine(bottomLeftAngle, topRightAngle);

            // y = -1x-1
            Handles.DrawLine(topLeftAngle, bottomRightAngle);
        }
                #endif

        Handles.color = previousColor;
    }
示例#47
0
 /// <summary>
 /// Adds a plan instruction for simultaneous controll of all axes.
 /// The instruction type has to be same for the axes.
 /// </summary>
 /// <param name="instructionU">instruction for the u axis.</param>
 /// <param name="instructionV">instruction for the v axis.</param>
 /// <param name="instructionX">instruction for the x axis.</param>
 /// <param name="instructionY">instruction for the y axis.</param>
 public void AddUVXY(StepInstrution instructionU, StepInstrution instructionV, StepInstrution instructionX, StepInstrution instructionY)
 {
     _plan.Add(Axes.UVXY(instructionU, instructionV, instructionX, instructionY));
 }
示例#48
0
        private static void GameOnDraw(EventArgs args)
        {
            var colorQ = MainMenu.Draw.GetColor("color.q");
            var widthQ = MainMenu.Draw.GetWidth("width.q");
            var colorW = MainMenu.Draw.GetColor("color.w");
            var widthW = MainMenu.Draw.GetWidth("width.w");
            var colorE = MainMenu.Draw.GetColor("color.e");
            var widthE = MainMenu.Draw.GetWidth("width.e");
            var colorR = MainMenu.Draw.GetColor("color.r");
            var widthR = MainMenu.Draw.GetWidth("width.r");

            if (!Value.Use("draw.disable"))
            {
                if (Value.Use("draw.q") && ((Value.Use("draw.ready") && _q.IsReady()) || !Value.Use("draw.ready")))
                {
                    if (GetBestAxe != null)
                    {
                        _axeLocation.Color  = colorQ;
                        _axeLocation.Radius = widthQ;
                        _axeLocation.Draw(GetBestAxe.Object.Position);
                    }

                    foreach (
                        var axe in
                        Axes.Where(x => x.Object.NetworkId != (GetBestAxe != null ? GetBestAxe.Object.NetworkId : 0))
                        )
                    {
                        _axeLocation.Color  = colorQ;
                        _axeLocation.Radius = widthQ;
                        _axeLocation.Draw(axe.Object.Position);
                    }
                }

                if (Value.Use("draw.w") && ((Value.Use("draw.ready") && _w.IsReady()) || !Value.Use("draw.ready")))
                {
                    new Circle
                    {
                        Color       = colorW,
                        Radius      = _w.Range,
                        BorderWidth = widthW
                    }.Draw(Player.Instance.Position);
                }
                if (Value.Use("draw.e") && ((Value.Use("draw.ready") && _e.IsReady()) || !Value.Use("draw.ready")))
                {
                    new Circle
                    {
                        Color       = colorE,
                        Radius      = _e.Range,
                        BorderWidth = widthE
                    }.Draw(Player.Instance.Position);
                }
                if (Value.Use("draw.r") && ((Value.Use("draw.ready") && _r.IsReady()) || !Value.Use("draw.ready")))
                {
                    new Circle
                    {
                        Color       = colorR,
                        Radius      = _q.Range,
                        BorderWidth = widthR
                    }.Draw(Player.Instance.Position);
                }
                if (Value.Use("draw.axe.catch") &&
                    ((Value.Use("draw.ready") && _q.IsReady()) || !Value.Use("draw.ready")))
                {
                    new Circle
                    {
                        Color       = colorQ,
                        Radius      = Value.Get("misc.axe.range"),
                        BorderWidth = widthQ
                    }.Draw(Game.CursorPos);
                }
            }
        }
 public AxisSpecifier(Axes axis)
 {
     this._axis = axis;
 }
示例#50
0
 public override int GetHashCode()
 {
     return(Axes.GetHashCode());
 }
示例#51
0
        /// <summary>Returns the axis index from a value in the axis enumeration</summary>
        /// <param name="axis">Axis enumeration values whose index will be returned</param>
        /// <returns>The index of the specified axis enumeration value</returns>
        private static int indexFromAxis(Axes axis)
        {
            switch (axis)
            {
            case Axes.X:
            {
                return(0);
            }

            case Axes.Y:
            {
                return(1);
            }

            case Axes.Z:
            {
                return(2);
            }

            case Axes.VelocityX:
            {
                return(3);
            }

            case Axes.VelocityY:
            {
                return(4);
            }

            case Axes.VelocityZ:
            {
                return(5);
            }

            case Axes.AccelerationX:
            {
                return(6);
            }

            case Axes.AccelerationY:
            {
                return(7);
            }

            case Axes.AccelerationZ:
            {
                return(8);
            }

            case Axes.ForceX:
            {
                return(9);
            }

            case Axes.ForceY:
            {
                return(10);
            }

            case Axes.ForceZ:
            {
                return(11);
            }

            case Axes.RotationX:
            {
                return(12);
            }

            case Axes.RotationY:
            {
                return(13);
            }

            case Axes.RotationZ:
            {
                return(14);
            }

            case Axes.AngularVelocityX:
            {
                return(15);
            }

            case Axes.AngularVelocityY:
            {
                return(16);
            }

            case Axes.AngularVelocityZ:
            {
                return(17);
            }

            case Axes.AngularAccelerationX:
            {
                return(18);
            }

            case Axes.AngularAccelerationY:
            {
                return(19);
            }

            case Axes.AngularAccelerationZ:
            {
                return(20);
            }

            case Axes.TorqueX:
            {
                return(21);
            }

            case Axes.TorqueY:
            {
                return(22);
            }

            case Axes.TorqueZ:
            {
                return(23);
            }

            default:
            {
                return(-1);
            }
            }
        }
示例#52
0
        /// <summary>
        /// glb をパースして、UnityObject化、さらにAsset化する
        /// </summary>
        /// <param name="scriptedImporter"></param>
        /// <param name="context"></param>
        /// <param name="reverseAxis"></param>
        protected static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis, RenderPipelineTypes renderPipeline)
        {
#if VRM_DEVELOP
            Debug.Log("OnImportAsset to " + scriptedImporter.assetPath);
#endif

            //
            // Import(create unity objects)
            //

            // 2 回目以降の Asset Import において、 Importer の設定で Extract した UnityEngine.Object が入る
            var extractedObjects = scriptedImporter.GetExternalObjectMap()
                                   .Where(x => x.Value != null)
                                   .ToDictionary(kv => new SubAssetKey(kv.Value.GetType(), kv.Key.name), kv => kv.Value);

            IMaterialDescriptorGenerator materialGenerator = GetMaterialGenerator(renderPipeline);

            using (var data = new AutoGltfFileParser(scriptedImporter.assetPath).Parse())
                using (var loader = new ImporterContext(data, extractedObjects, materialGenerator: materialGenerator))
                {
                    // Configure TextureImporter to Extracted Textures.
                    foreach (var textureInfo in loader.TextureDescriptorGenerator.Get().GetEnumerable())
                    {
                        TextureImporterConfigurator.Configure(textureInfo, loader.TextureFactory.ExternalTextures);
                    }

                    loader.InvertAxis = reverseAxis;
                    var loaded = loader.Load();
                    loaded.ShowMeshes();

                    loaded.TransferOwnership((k, o) =>
                    {
                        context.AddObjectToAsset(k.Name, o);
                    });
                    var root = loaded.Root;
                    GameObject.DestroyImmediate(loaded);

                    context.AddObjectToAsset(root.name, root);
                    context.SetMainObject(root);
                }
        }
 public static Vector3 SnapPoint(Vector3 position, Axes enabledAxes = Axes.XYZ)
 {
     return(SnapPoint(position, Grid.defaultGrid, enabledAxes));
 }
示例#54
0
        public static void Main(string[] args)
        {
            Application
                ExcelApp = null;

            Workbook
                Workbook = null;

            Sheets
                Sheets = null,
                Charts = null;

            Worksheet
                Sheet = null;

            Chart
                Chart = null;

            Series
                Series = null;

            Axes
                Axes = null;

            Axis
                Axis = null;

            Range
                Range  = null,
                Range2 = null;

            object
                tmpObject;

            try
            {
                try
                {
                    string
                        CurrentDirectory = System.IO.Directory.GetCurrentDirectory();

                    CurrentDirectory = CurrentDirectory.Substring(0, CurrentDirectory.LastIndexOf("bin", CurrentDirectory.Length - 1));

                    string
                    //InputFileName = CurrentDirectory + "test.xls",
                        InputFileName = "d:\\result.xlsx",
                        OutputDbf     = CurrentDirectory + "xls2dbf.dbf";

                    try
                    {
                        ExcelApp = (Application)Marshal.GetActiveObject("Excel.Application");
                    }
                    catch (COMException eException)
                    {
                        if (eException.ErrorCode == -2147221021)
                        {
                            ExcelApp = new Application();
                        }
                    }

                    ExcelApp.Visible       = true;
                    ExcelApp.DisplayAlerts = false;
                    ExcelApp.UserControl   = false;

                                        #if TEST_DATE
                    Workbook = ExcelApp.Workbooks.Add(Type.Missing);
                    Sheet    = (Worksheet)Workbook.ActiveSheet;
                    Sheet.Columns.get_Range("A1", "A1").ColumnWidth = 3;
                    Sheet.get_Range("A1", Type.Missing).Value       = "01.01.2001";
                    tmpObject = Sheet.get_Range("A1", Type.Missing).Value;
                    Workbook.Close(Type.Missing, Type.Missing, Type.Missing);
                                        #endif

                    Workbook = ExcelApp.Workbooks.Open(InputFileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                                        #if TEST_SAVE_AS
                    if (File.Exists(OutputDbf))
                    {
                        File.Delete(OutputDbf);
                    }
                    Workbook.SaveAs(OutputDbf, XlFileFormat.xlDBF4, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                                        #endif
                    Sheets = Workbook.Worksheets;
                    Sheet  = (Worksheet)Workbook.ActiveSheet;

                    double
                        points = ExcelApp.CentimetersToPoints(1.93d);

                    points = ExcelApp.CentimetersToPoints(2.70d);
                    points = ExcelApp.CentimetersToPoints(3.55d);

                    int
                        MaxRow = Sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing).Row,
                        MaxCol = Sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing).Column;

                    Range = Sheet.get_Range("A1", Type.Missing);
                    Range = Range.get_End(XlDirection.xlToRight);
                    Range = Range.get_End(XlDirection.xlDown);

                    string
                        CurrAddress = Range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);

                    Range = Sheet.get_Range("A1", CurrAddress);

                    CurrAddress = ColNoToName(MaxCol) + Convert.ToString(MaxRow);
                    Range       = Sheet.get_Range("A1", CurrAddress);

                    object[,]
                    values = (object[, ])Range.Value2;

                    int
                        MaxI = values.GetLength(0),                       // Row
                        MaxJ = values.GetLength(1);                       // Col

                    string
                        tmpString = string.Empty;

                    for (int i = 1; i <= MaxI; ++i)                // Row
                    {
                        for (int j = 1; j <= MaxJ; ++j)            // Col
                        {
                            tmpString += "[" + i + "," + j + "]=" + (values[i, j] != null ? values[i, j] : "null");
                            if (j <= MaxJ - 1)
                            {
                                tmpString += "\t";
                            }
                        }
                        tmpString += Environment.NewLine;
                    }
                    Console.WriteLine(tmpString);

                    Range = Sheet.get_Range("A10", "E18");
                    //Range.Formula=values;
                    Range.Value = values;

                    Range     = Sheet.get_Range(Sheet.Cells[1, 1], Sheet.Cells[10, 10]);
                    tmpObject = ((Range)Range.get_Item(1, 1)).Value;

                    Sheet.get_Range("A23", Type.Missing).Value = "A23";
                    tmpString = Convert.ToString(Sheet.get_Range("A23", Type.Missing).Value);
                    Sheet.get_Range("A24", "C24").Merge(true);

                    for (int _i = 1; _i <= 10; ++_i)
                    {
                        Sheet.get_Range("F" + _i, Type.Missing).Value = _i;
                    }
                    Sheet.get_Range("F11", Type.Missing).Formula     = "=яслл(F1:F10)";
                    Sheet.get_Range("F11", Type.Missing).Orientation = 30;
                    Sheet.get_Range("F11", Type.Missing).Font.Bold   = true;
                    Sheet.get_Range("F11", Type.Missing).Font.Size   = 25;

                    Range = Sheet.get_Range("F2", Type.Missing);

                    tmpObject = -4121;                   // 0xFFFFEFE7; /* xlShiftDown */
                    Range.Rows.Insert(tmpObject);

                    Range.Rows.Insert(Type.Missing);
                    Sheet.get_Range("F2", Type.Missing).Value = 999;

                    Sheet = (Worksheet)Sheets.get_Item(2);
                    Sheet.Activate();

                    string
                        CellDirect,
                        CellObject;

                    #region bool
                    CellDirect = "E1";
                    CellObject = "E2";
                    tmpString  = "bool";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F1";
                    CellObject = "F2";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = true;

                    bool
                        tmpBool = true;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpBool;
                    #endregion

                    #region byte
                    CellDirect = "E3";
                    CellObject = "E4";
                    tmpString  = "byte";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F3";
                    CellObject = "F4";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 255;

                    byte
                        tmpByte = 255;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpByte;
                    #endregion

                    #region sbyte
                    CellDirect = "E5";
                    CellObject = "E6";
                    tmpString  = "sbyte";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F5";
                    CellObject = "F6";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 127;

                    sbyte
                        tmpSByte = 127;

                    // !!!
                    Sheet.get_Range(CellObject, Type.Missing).Value = (int)tmpSByte;
                    #endregion

                    #region short
                    CellDirect = "E7";
                    CellObject = "E8";
                    tmpString  = "short";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F7";
                    CellObject = "F8";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 32767;

                    short
                        tmpShort = 32767;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpShort;
                    #endregion

                    #region ushort
                    CellDirect = "E9";
                    CellObject = "E10";
                    tmpString  = "ushort";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F9";
                    CellObject = "F10";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 65535;

                    ushort
                        tmpUShort = 65535;

                    // !!!
                    Sheet.get_Range(CellObject, Type.Missing).Value = (int)tmpUShort;
                    #endregion

                    #region int
                    CellDirect = "E11";
                    CellObject = "E12";
                    tmpString  = "int";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F11";
                    CellObject = "F12";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 2147483647;

                    int
                        tmpInt = 2147483647;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpInt;
                    #endregion

                    #region uint
                    CellDirect = "E13";
                    CellObject = "E14";
                    tmpString  = "uint";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F13";
                    CellObject = "F14";
                    // !!!
                    Sheet.get_Range(CellDirect, Type.Missing).Value = (double)4294967295U;

                    uint
                        tmpUInt = 4294967295U;

                    // !!!
                    Sheet.get_Range(CellObject, Type.Missing).Value = (double)tmpUInt;
                    #endregion

                    #region long
                    CellDirect = "E15";
                    CellObject = "E16";
                    tmpString  = "long";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F15";
                    CellObject = "F16";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = (double)999999999999999L;
                    //Sheet.get_Range(CellDirect,Type.Missing).Value=9223372036854775807L;

                    long
                        tmpLong = 999999999999999L;                       //9223372036854775807L;

                    Sheet.get_Range(CellObject, Type.Missing).Value = (double)tmpLong;
                    #endregion

                    #region ulong
                    CellDirect = "E17";
                    CellObject = "E18";
                    tmpString  = "ulong";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F17";
                    CellObject = "F18";
                    //Sheet.get_Range(CellDirect,Type.Missing).Value=18446744073709551615UL;

                    ulong
                        tmpULong = 18446744073709551615UL;

                    //Sheet.get_Range(CellObject,Type.Missing).Value=tmpULong;
                    #endregion

                    #region DateTime
                    CellDirect = "E19";
                    CellObject = "E20";
                    tmpString  = "DateTime";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F19";
                    CellObject = "F20";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = DateTime.Now;

                    DateTime
                        tmpDateTime = DateTime.Now;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpDateTime;
                    #endregion

                    #region TimeSpan
                    CellDirect = "E21";
                    CellObject = "E22";
                    tmpString  = "TimeSpan";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect  = "F21";
                    CellObject  = "F22";
                    tmpDateTime = new DateTime(0L);
                    // !!!
                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpDateTime + (new TimeSpan(1, 2, 3));

                    TimeSpan
                        tmpTimeSpan = new TimeSpan(1, 2, 3);

                    // !!!
                    tmpDateTime  = new DateTime(0L);
                    tmpDateTime += tmpTimeSpan;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpDateTime;
                    #endregion

                    #region float
                    CellDirect = "E23";
                    CellObject = "E24";
                    tmpString  = "float";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F23";
                    CellObject = "F24";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 9999.9999F;

                    float
                        tmpFloat = 9999.9999F;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpFloat;
                    #endregion

                    #region double
                    CellDirect = "E25";
                    CellObject = "E26";
                    tmpString  = "double";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F25";
                    CellObject = "F26";
                    Sheet.get_Range(CellDirect, Type.Missing).Value = 1.7E+3;

                    double
                        tmpDouble = 1.7E+3;

                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpDouble;
                    #endregion

                    #region decimal
                    CellDirect = "E27";
                    CellObject = "E28";
                    tmpString  = "decimal";

                    Sheet.get_Range(CellDirect, Type.Missing).Value = tmpString;
                    Sheet.get_Range(CellObject, Type.Missing).Value = tmpString;

                    CellDirect = "F27";
                    CellObject = "F28";
                    // !!!
                    Sheet.get_Range(CellDirect, Type.Missing).Value = (double)999999999.99m;

                    decimal
                        tmpDecimal = 999999999.99m;

                    // !!!
                    Sheet.get_Range(CellObject, Type.Missing).Value = (double)tmpDecimal;
                    #endregion

                    Sheet = (Worksheet)Sheets.get_Item(3);

                    Range       = Sheet.get_Range("A1", "A5");
                    Range.Value = "Some Value";
                    Range2      = Sheet.get_Range("A11", "A15");
                    Range.Copy(Range2);

                    Range       = Sheet.get_Range("B1", "B5");
                    Range.Value = "Some Value";
                    Range.Copy(Type.Missing);
                    Range2 = Sheet.get_Range("B11", "B15");
                    Sheet.Paste(Range2, Type.Missing);

                    Range2 = Sheet.get_Range("B20", Type.Missing);
                    Sheet.Activate();
                    Range2.Select();
                    Sheet.Paste(Type.Missing, Type.Missing);


                                        #if TEST_CHART
                    Sheet = (Excel.Worksheet)Sheets.get_Item(3);
                    Sheet.Activate();

                    for (int Col = 1; Col <= 20; ++Col)
                    {
                        Sheet.get_Range("A" + Col, Type.Missing).Value   = Col;
                        Sheet.get_Range("B" + Col, Type.Missing).Formula = "=sin(A" + Col + ")";
                        Sheet.get_Range("C" + Col, Type.Missing).Formula = "=cos(A" + Col + ")";
                        Sheet.get_Range("D" + Col, Type.Missing).Formula = "=B" + Col + "+C" + Col;
                    }

                    Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    Charts = ExcelApp.Charts;
                    Chart  = (Excel.Chart)Charts.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    //Chart.Type=65; // xlLineMarkers
                    Chart.Type = 4;                   // xlLine
                    Chart.SetSourceData(Sheet.get_Range("B1", "C20"), 2 /*xlColumns*/);
                    Chart  = Chart.Location(XlChartLocation.xlLocationAsObject, "кХЯР4");
                    Series = ((Excel.SeriesCollection)Chart.SeriesCollection(Type.Missing)).NewSeries();
                    MaxI   = ((Excel.SeriesCollection)Chart.SeriesCollection(Type.Missing)).Count;
                    Range  = Sheet.get_Range("A1", "A20");
                    for (int i = MaxI; i > 0; --i)
                    {
                        ((Excel.Series)Chart.SeriesCollection(i)).XValues = Range;
                        switch (i)
                        {
                        case 1:
                        {
                            ((Excel.Series)Chart.SeriesCollection(i)).Name = "sin";
                            break;
                        }

                        case 2:
                        {
                            ((Excel.Series)Chart.SeriesCollection(i)).Name = "cos";
                            break;
                        }
                        }
                    }

                    Range         = Sheet.get_Range("D1", "D20");
                    Series.Values = Range;
                    Series.Name   = "sin+cos";

                    Chart.HasTitle           = true;
                    Chart.ChartTitle.Caption = "Name of Chart";
                    Axis               = (Excel.Axis)Chart.Axes(1 /*xlCategory*/, XlAxisGroup.xlPrimary);
                    Axis.HasTitle      = true;
                    Axis.CategoryNames = "Name of Category";
                    Axis               = (Excel.Axis)Chart.Axes(2 /*xlValue*/, XlAxisGroup.xlPrimary);
                    Axis.HasTitle      = true;

                    Chart.HasLegend       = true;
                    Chart.Legend.Position = XlLegendPosition.xlLegendPositionBottom;
                                        #endif

                    ExcelApp.Quit();
                }
                catch (COMException eException)
                {
                    string
                        tmp = eException.GetType().FullName + Environment.NewLine + "ErrorCode: " + eException.ErrorCode + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + "StackTrace:" + Environment.NewLine + eException.StackTrace;

                    Console.WriteLine(tmp);
                }
                catch (ArgumentException eException)
                {
                    string
                        tmp = eException.GetType().FullName + Environment.NewLine + "ParamName: " + eException.ParamName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + "StackTrace:" + Environment.NewLine + eException.StackTrace;

                    Console.WriteLine(tmp);
                }
                catch (Exception eException)
                {
                    string
                        tmp = eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + "StackTrace:" + Environment.NewLine + eException.StackTrace;

                    Console.WriteLine(tmp);
                }
            }
            finally
            {
                if (Axes != null)
                {
                    Marshal.ReleaseComObject(Axes);
                    Axes = null;
                }
                if (Axis != null)
                {
                    Marshal.ReleaseComObject(Axis);
                    Axis = null;
                }
                if (Series != null)
                {
                    Marshal.ReleaseComObject(Series);
                    Series = null;
                }
                if (Chart != null)
                {
                    Marshal.ReleaseComObject(Chart);
                    Chart = null;
                }
                if (Charts != null)
                {
                    Marshal.ReleaseComObject(Charts);
                    Charts = null;
                }
                if (Range2 != null)
                {
                    Marshal.ReleaseComObject(Range2);
                    Range2 = null;
                }
                if (Range != null)
                {
                    Marshal.ReleaseComObject(Range);
                    Range = null;
                }
                if (Sheets != null)
                {
                    Marshal.ReleaseComObject(Sheets);
                    Sheets = null;
                }
                if (Sheet != null)
                {
                    Marshal.ReleaseComObject(Sheet);
                    Sheet = null;
                }
                if (Workbook != null)
                {
                    Marshal.ReleaseComObject(Workbook);
                    Workbook = null;
                }
                if (ExcelApp != null)
                {
                    ExcelApp.Quit();
                    Marshal.ReleaseComObject(ExcelApp);
                    ExcelApp = null;
                }
                //GC.Collect();
                GC.GetTotalMemory(true);
            }
        }
示例#55
0
 private Axis FindModelAxis(AxisBase a)
 {
     return(Axes.FirstOrDefault(axis => axis.ModelAxis == a));
 }
示例#56
0
        public virtual XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)
        {
            Axes axis = (matchSelf) ? Axes.DescendantOrSelf : Axes.Descendant;

            return(SelectTest(new NodeTypeTest(axis, type)));
        }
示例#57
0
        public static Vector4 SetValues(this Vector4 vector, Vector4 values, Axes axis)
        {
            vector.x = axis.Contains(Axes.X) ? values.x : vector.x;
            vector.y = axis.Contains(Axes.Y) ? values.y : vector.y;
            vector.z = axis.Contains(Axes.Z) ? values.z : vector.z;
            vector.w = axis.Contains(Axes.W) ? values.w : vector.w;

            return vector;
        }
示例#58
0
 public void Reset()
 {
     Series.Clear();
     Axes.Clear();
     Annotations.Clear();
 }
示例#59
0
 public static Vector4 Div(this Vector4 vector, Vector3 otherVector, Axes axis)
 {
     return vector.Div((Vector4)otherVector, axis);
 }
示例#60
0
    void DrawRotation()
    {
        GUILayout.BeginHorizontal();
        {
            bool reset = GUILayout.Button("R", GUILayout.Width(20f));

            Vector3 visible = (serializedObject.targetObject as Transform).localEulerAngles;

            visible.x = WrapAngle(visible.x);
            visible.y = WrapAngle(visible.y);
            visible.z = WrapAngle(visible.z);

            Axes changed = CheckDifference(mRot);
            Axes altered = Axes.None;

            GUILayoutOption opt = GUILayout.MinWidth(30f);

            if (FloatField("X", ref visible.x, (changed & Axes.X) != 0, false, opt))
            {
                altered |= Axes.X;
            }
            if (FloatField("Y", ref visible.y, (changed & Axes.Y) != 0, false, opt))
            {
                altered |= Axes.Y;
            }
            if (FloatField("Z", ref visible.z, (changed & Axes.Z) != 0, false, opt))
            {
                altered |= Axes.Z;
            }

            if (reset)
            {
                mRot.quaternionValue = Quaternion.identity;
            }
            else if (altered != Axes.None)
            {
                RegisterUndo("Change Rotation", serializedObject.targetObjects);

                foreach (Object obj in serializedObject.targetObjects)
                {
                    Transform t = obj as Transform;
                    Vector3   v = t.localEulerAngles;

                    if ((altered & Axes.X) != 0)
                    {
                        v.x = visible.x;
                    }
                    if ((altered & Axes.Y) != 0)
                    {
                        v.y = visible.y;
                    }
                    if ((altered & Axes.Z) != 0)
                    {
                        v.z = visible.z;
                    }

                    t.localEulerAngles = v;
                }
            }
        }
        GUILayout.EndHorizontal();
    }