当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.Quaternion类代码示例

本文整理汇总了C#中UnityEngine.Quaternion的典型用法代码示例。如果您正苦于以下问题:C# Quaternion类的具体用法?C# Quaternion怎么用?C# Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Quaternion类属于UnityEngine命名空间,在下文中一共展示了Quaternion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Quat

 public Quat(Quaternion _quat)
 {
     this.x = _quat.x;
     this.y = _quat.y;
     this.z = _quat.z;
     this.w = _quat.w;
 }
开发者ID:coconutinteractive,项目名称:shakedown,代码行数:7,代码来源:MySerializables.cs

示例2: Write

		public void Write(Quaternion quaternion)
		{
			Write(quaternion.x);
			Write(quaternion.y);
			Write(quaternion.z);
			Write(quaternion.w);
		}
开发者ID:Neproify,项目名称:ivmp,代码行数:7,代码来源:PlatformUnityExtras.cs

示例3: RotateTo

        // Rotate this target towards a position
        public void RotateTo(Vector3 position)
        {
            if (pivot == null) return;

            if (pivot != lastPivot) {
                defaultLocalRotation = pivot.localRotation;
                lastPivot = pivot;
            }

            // Rotate to the default local rotation
            pivot.localRotation = defaultLocalRotation;

            // Twisting around the twist axis
            if (twistWeight > 0f) {
                Vector3 targetTangent = transform.position - pivot.position;
                Vector3 n = pivot.rotation * twistAxis;
                Vector3 normal = n;
                Vector3.OrthoNormalize(ref normal, ref targetTangent);

                normal = n;
                Vector3 direction = position - pivot.position;
                Vector3.OrthoNormalize(ref normal, ref direction);

                Quaternion q = QuaTools.FromToAroundAxis(targetTangent, direction, n);
                pivot.rotation = Quaternion.Lerp(Quaternion.identity, q, twistWeight) * pivot.rotation;
            }

            // Swinging freely
            if (swingWeight > 0f) {
                Quaternion s = Quaternion.FromToRotation(transform.position - pivot.position, position - pivot.position);
                pivot.rotation = Quaternion.Lerp(Quaternion.identity, s, swingWeight) * pivot.rotation;
            }
        }
开发者ID:nickgirardo,项目名称:KADAPT,代码行数:34,代码来源:InteractionTarget.cs

示例4: Update

        // Update is called once per frame
        void Update()
        {
            if (target.gameObject == null) {

                if (_statusIndicators.gameObject != null) {
                    _statusIndicators.SetDirectors ();
                    Destroy (this.gameObject);
                }
                return;
            }

            _direction = target.transform.position - transform.position;
            //_direction.z = 0f;

            _lookRotation = Quaternion.LookRotation (_direction, Vector3.back);

            Quaternion rotateTo = Quaternion.Slerp (transform.rotation, _lookRotation, RotationSpeed);
            rotateTo.x = 0f;
            rotateTo.y = 0f;
            this.transform.rotation = rotateTo;

            if (_direction.magnitude > minDist) {
                newAlpha = 1 - _direction.magnitude / maxDist;
            } else {
                newAlpha = _direction.magnitude / minDist - 0.4f;
            }

            image.color = new Color (image.color.r, image.color.g, image.color.b, newAlpha);
            //Debug.Log("Normalized magnitude: " + (int)_direction.magnitude + " New Alpa: " +newAlpha );
        }
开发者ID:Kundara,项目名称:project1,代码行数:31,代码来源:Director.cs

示例5: Write

 public void Write(Quaternion qua)
 {
     writer.Write(qua.x);
     writer.Write(qua.y);
     writer.Write(qua.z);
     writer.Write(qua.w);
 }
开发者ID:johncoffee,项目名称:gyro,代码行数:7,代码来源:PhoneController.cs

示例6: Start

        public void Start()
        {
            key = GameObject.Find("Key").gameObject;

            dupMarker = Quaternion.Euler(0, transform.rotation.eulerAngles.y + 45, 0);
            originMarker = Quaternion.Euler(0, originDoor.transform.rotation.eulerAngles.y - 45, 0);
        }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:7,代码来源:Door.cs

示例7: DrawCircle

		public static void DrawCircle(Vector3 origin, Quaternion rotation, float radius, int pieceCount, Color color)
		{
			if (3 > pieceCount)
			{
				return;
			}
			if (0 >= radius)
			{
				return;
			}

			float pieceAngle = 360.0f / pieceCount;

			Vector3 p0 = origin + rotation * Vector3.forward * radius;
			Vector3 p1 = p0;
			for (int i = 0; i < pieceCount-1; ++i)
			{
				var r = Quaternion.Euler(0, pieceAngle*(i+1), 0);
				Vector3 p2 = origin + rotation * (r * Vector3.forward * radius);
				Debug.DrawLine(p1, p2, color);

				p1 = p2;
			}
			Debug.DrawLine(p0, p1, color);
		}
开发者ID:siwenRen,项目名称:Wolf,代码行数:25,代码来源:DebugUtils.cs

示例8: PrepareGridRender

 public DrawGridParameters PrepareGridRender(Camera camera, Vector3 pivot, Quaternion rotation, float size, bool orthoMode, bool gridVisible)
 {
   bool flag1 = false;
   bool flag2 = false;
   bool flag3 = false;
   if (gridVisible)
   {
     if (orthoMode)
     {
       Vector3 vector3 = rotation * Vector3.forward;
       if ((double) Mathf.Abs(vector3.y) > 0.200000002980232)
         flag2 = true;
       else if (vector3 == Vector3.left || vector3 == Vector3.right)
         flag1 = true;
       else if (vector3 == Vector3.forward || vector3 == Vector3.back)
         flag3 = true;
     }
     else
       flag2 = true;
   }
   this.xGrid.target = flag1;
   this.yGrid.target = flag2;
   this.zGrid.target = flag3;
   DrawGridParameters drawGridParameters;
   drawGridParameters.pivot = pivot;
   drawGridParameters.color = (Color) SceneViewGrid.kViewGridColor;
   drawGridParameters.size = size;
   drawGridParameters.alphaX = this.xGrid.faded;
   drawGridParameters.alphaY = this.yGrid.faded;
   drawGridParameters.alphaZ = this.zGrid.faded;
   return drawGridParameters;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:32,代码来源:SceneViewGrid.cs

示例9: UpdateGravity

        private void UpdateGravity()
        {
            _GravityDirection = GetGravityDirection();

            _Rigidbody.AddForce(_GravityDirection * Gravity, ForceMode2D.Force);
            _TargetRotation = Quaternion.Euler(new Vector3(0f, 0f, VectorUtils.GetAngle(Vector2.down, _GravityDirection)));
        }
开发者ID:chrismcmath,项目名称:LD33,代码行数:7,代码来源:HumanHitBehaviour.cs

示例10: LimitSwing

		/*
		 * Apply the swing rotation limits
		 * */
		public Quaternion LimitSwing(Quaternion rotation) {
			if (axis == Vector3.zero) return rotation; // Ignore with zero axes
			if (rotation == Quaternion.identity) return rotation; // Assuming initial rotation is in the reachable area
			
			// Get the rotation angle orthogonal to Axis
			Vector3 swingAxis = rotation * axis;
			float angle = GetOrthogonalAngle(swingAxis, secondaryAxis, axis);
			
			// Convert angle from 180 to 360 degrees representation
			float dot = Vector3.Dot(swingAxis, crossAxis);
			if (dot < 0) angle = 180 + (180 - angle);
			
			// Evaluate the limit for this angle
			float limit = spline.Evaluate(angle);
			
			// Get the limited swing axis
			Quaternion swingRotation = Quaternion.FromToRotation(axis, swingAxis);
			Quaternion limitedSwingRotation = Quaternion.RotateTowards(Quaternion.identity, swingRotation, limit);
			
			// Rotation from current(illegal) swing rotation to the limited(legal) swing rotation
			Quaternion toLimits = Quaternion.FromToRotation(swingAxis, limitedSwingRotation * axis);
			
			// Subtract the illegal rotation
			return toLimits * rotation;
		}
开发者ID:cupsster,项目名称:ExtremeBusiness,代码行数:28,代码来源:RotationLimitSpline.cs

示例11: LimitRotation

		/*
		 * Limits the rotation in the local space of this instance's Transform.
		 * */
		protected override Quaternion LimitRotation(Quaternion rotation) {		
			// Subtracting off-limits swing
			Quaternion swing = LimitSwing(rotation);
			
			// Apply twist limits
			return LimitTwist(swing, axis, secondaryAxis, twistLimit);
		}
开发者ID:cupsster,项目名称:ExtremeBusiness,代码行数:10,代码来源:RotationLimitSpline.cs

示例12: ObscuredQuaternion

		private ObscuredQuaternion(RawEncryptedQuaternion value)
		{
			currentCryptoKey = cryptoKey;
			hiddenValue = value;
			fakeValue = initialFakeValue;
			inited = true;
		}
开发者ID:predominant,项目名称:Treasure_Chest,代码行数:7,代码来源:ObscuredQuaternion.cs

示例13: DrawDoubleCircle

		public static void DrawDoubleCircle(Vector3 origin, Quaternion rotation, float radius1, float radius2, int pieceCount, Color color)
		{
			if (3 > pieceCount)
			{
				return;
			}
			if (0 >= radius1 || 0 >= radius2)
			{
				return;
			}
			
			float pieceAngle = 360.0f / pieceCount;
			
			Vector3 p0_1 = origin + rotation * Vector3.forward * radius1;
			Vector3 p0_2 = origin + rotation * Vector3.forward * radius2;
			Vector3 p1_1 = p0_1;
			Vector3 p1_2 = p0_2;
			for (int i = 0; i < pieceCount-1; ++i)
			{
				var r = Quaternion.Euler(0, pieceAngle*(i+1), 0);
				Vector3 p2_1 = origin + rotation * (r * Vector3.forward * radius1);
				Vector3 p2_2 = origin + rotation * (r * Vector3.forward * radius2);
				Debug.DrawLine(p1_1, p2_1, color);
				Debug.DrawLine(p1_2, p2_2, color);
				Debug.DrawLine(p2_1, p2_2, color);
				
				p1_1 = p2_1;
				p1_2 = p2_2;
			}
			Debug.DrawLine(p0_1, p1_1, color);
			Debug.DrawLine(p0_1, p0_2, color);
		}
开发者ID:siwenRen,项目名称:Wolf,代码行数:32,代码来源:DebugUtils.cs

示例14: UpdateRotation

 private void UpdateRotation(Quaternion currentRotation, float currentDegrees)
 {
     float closerDegress = GetCloserDegrees (currentDegrees);
     Vector3 newAngles = new Vector3 (currentRotation.eulerAngles.x,closerDegress,currentRotation.eulerAngles.z);
     Quaternion newRot = Quaternion.Euler (newAngles);
     myTransform.localRotation = Quaternion.Lerp (currentRotation,newRot,Time.deltaTime * currentSpeed);
 }
开发者ID:juliancruz87,项目名称:madbricks,代码行数:7,代码来源:SnapRotator.cs

示例15: ActivateObject

        public static GameObject ActivateObject(string objectName, Vector3 pos, Quaternion rotation)
        {
            ObjectPool pool = Instance.pools.FirstOrDefault(t => t.ObjectName == objectName);
            if (pool == null) return null;

            return pool.GetObject(pos, rotation);
        }
开发者ID:AkuKuylaars,项目名称:Blocklands,代码行数:7,代码来源:ObjectPoolManager.cs


注:本文中的UnityEngine.Quaternion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。