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


C# Transform.TransformPoint方法代码示例

本文整理汇总了C#中UnityEngine.Transform.TransformPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.TransformPoint方法的具体用法?C# Transform.TransformPoint怎么用?C# Transform.TransformPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Transform的用法示例。


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

示例1: Construct

	    /// <summary>
	    /// construct a new bsp tree from unity mesh
	    /// </summary>
	    /// <param name="mesh">unity mesh</param>
	    /// <param name="meshTransform">transformation</param>
	    /// <param name="id">id of the mesh</param>
	    public void Construct(Mesh mesh, Transform meshTransform, int id)
        {
            // cache mesh data
            var trianglesNum = mesh.triangles.Length;
            var meshTriangles = mesh.triangles;
            var meshVertices = mesh.vertices;
            var meshNormals = mesh.normals;
            var meshUV = mesh.uv;

            Polygons = new List<CSGPolygon>(trianglesNum/3);

            for (int i = 0; i < trianglesNum; i+=3)
            {
                var id0 = meshTriangles[i];
                var id1 = meshTriangles[i + 1];
                var id2 = meshTriangles[i + 2];

                Polygons.Add(new CSGPolygon(id, new CSGVertex(meshTransform.TransformPoint(meshVertices[id0]), meshTransform.TransformDirection(meshNormals[id0]), meshUV[id0]),
                                             new CSGVertex(meshTransform.TransformPoint(meshVertices[id1]), meshTransform.TransformDirection(meshNormals[id1]), meshUV[id1]),
                                             new CSGVertex(meshTransform.TransformPoint(meshVertices[id2]), meshTransform.TransformDirection(meshNormals[id2]), meshUV[id2])));
            }

            root = new CSGNode();
            root.Build(Polygons);
        }
开发者ID:jfeng94,项目名称:Thesis,代码行数:31,代码来源:CSG.cs

示例2: DrawRect

	// Misc drawing
	public static void DrawRect( Rect r, Transform t ) {
		Vector3 p0 = t.TransformPoint (new Vector3(r.xMin, r.yMin, 0));
		Vector3 p1 = t.TransformPoint (new Vector3(r.xMax, r.yMin, 0));
		Vector3 p2 = t.TransformPoint (new Vector3(r.xMax, r.yMax, 0));
		Vector3 p3 = t.TransformPoint (new Vector3(r.xMin, r.yMax, 0));
		Vector3[] worldPts = new Vector3[5] { p0, p1, p2, p3, p0 };
		Handles.DrawPolyLine (worldPts);
	}
开发者ID:Ahere,项目名称:UnityIsometric,代码行数:9,代码来源:tk2dSceneHelper.cs

示例3: DrawRectWithOutline

 public static void DrawRectWithOutline(Transform transform, Rect rect, Color color, Color colorOutline)
 {
     Vector3[] rectVerts = {
     transform.TransformPoint(new Vector3(rect.x, rect.y, 0)),
     transform.TransformPoint(new Vector3(rect.x + rect.width, rect.y, 0)),
     transform.TransformPoint(new Vector3(rect.x + rect.width, rect.y + rect.height, 0)),
     transform.TransformPoint(new Vector3(rect.x, rect.y + rect.height, 0)) };
     Handles.DrawSolidRectangleWithOutline(rectVerts, color, colorOutline);
 }
开发者ID:yabos,项目名称:BattleHit,代码行数:9,代码来源:HandlesEx.cs

示例4: DrawTriangle

        public static void DrawTriangle(Vector3 a, Vector3 b, Vector3 c, Color color, Transform t)
        {
            a = t.TransformPoint(a);
            b = t.TransformPoint(b);
            c = t.TransformPoint(c);

            Debug.DrawLine(a, b, color);
            Debug.DrawLine(b, c, color);
            Debug.DrawLine(c, a, color);
        }
开发者ID:TheRealKbob,项目名称:BetterCharacterController,代码行数:10,代码来源:DebugDraw.cs

示例5: DrawDotOutline

 public static void DrawDotOutline(Transform transform, Vector3 position, float size, Color color, Color colorOutline)
 {
     Rect rDot = new Rect(-size / (2 * transform.localScale.x), -size / (2 * transform.localScale.y), size / transform.localScale.x, size / transform.localScale.y);
     Vector3[] rectVerts = {
     transform.TransformPoint( position + new Vector3(rDot.x, rDot.y, 0)),
     transform.TransformPoint( position + new Vector3(rDot.x + rDot.width, rDot.y, 0)),
     transform.TransformPoint( position + new Vector3(rDot.x + rDot.width, rDot.y + rDot.height, 0)),
     transform.TransformPoint( position + new Vector3(rDot.x, rDot.y + rDot.height, 0)) };
     Handles.DrawSolidRectangleWithOutline(rectVerts, color, colorOutline);
 }
开发者ID:yabos,项目名称:BattleHit,代码行数:10,代码来源:HandlesEx.cs

示例6: pointsSurLeFrustum

    //4 "coins" du frustum a une distance donnee, par rapport au repere global
    void pointsSurLeFrustum(Transform origine, float fieldOfView, float aspect, float distance,
	                     out Vector3 hautGauche, out Vector3 hautDroite, out Vector3 basGauche, out Vector3 basDroite)
    {
        float demiHauteur = distance * Mathf.Tan(fieldOfView * 0.5f * Mathf.Deg2Rad );
        float demiLargeur = demiHauteur * aspect;
        hautDroite = origine.TransformPoint(demiLargeur, demiHauteur, distance);
        hautGauche = origine.TransformPoint(-demiLargeur, demiHauteur, distance);
        basDroite = origine.transform.TransformPoint(demiLargeur,-demiHauteur, distance);
        basGauche = origine.transform.TransformPoint(-demiLargeur,-demiHauteur, distance);
    }
开发者ID:AdrienVR,项目名称:eegSea,代码行数:11,代码来源:AdaptativeMeshSea.cs

示例7: DrawDottedLine

 public static void DrawDottedLine(Transform transform, Rect rect, float screenSpaceSize)
 {
     Vector3[] rectVerts = {
     transform.TransformPoint(new Vector3(rect.x, rect.y, 0)),
     transform.TransformPoint(new Vector3(rect.x + rect.width, rect.y, 0)),
     transform.TransformPoint(new Vector3(rect.x + rect.width, rect.y + rect.height, 0)),
     transform.TransformPoint(new Vector3(rect.x, rect.y + rect.height, 0)) };
     Handles.DrawDottedLine(rectVerts[0], rectVerts[1], screenSpaceSize);
     Handles.DrawDottedLine(rectVerts[1], rectVerts[2], screenSpaceSize);
     Handles.DrawDottedLine(rectVerts[2], rectVerts[3], screenSpaceSize);
     Handles.DrawDottedLine(rectVerts[3], rectVerts[0], screenSpaceSize);
 }
开发者ID:yabos,项目名称:BattleHit,代码行数:12,代码来源:HandlesEx.cs

示例8: DrawLineOfSight

 // hekp visualize the line of sight within the editor
 public static void DrawLineOfSight(Transform transform, float fieldOfViewAngle, float viewMagnitude)
 {
     #if UNITY_EDITOR
     float radius = viewMagnitude * Mathf.Sin(fieldOfViewAngle * Mathf.Deg2Rad);
     var oldColor = UnityEditor.Handles.color;
     UnityEditor.Handles.color = Color.yellow;
     // draw a disk at the end of the sight distance.
     UnityEditor.Handles.DrawWireDisc(transform.position + transform.forward * viewMagnitude, transform.forward, radius);
     // draw to lines to represent the left and right side of the line of sight
     UnityEditor.Handles.DrawLine(transform.position, transform.TransformPoint(new Vector3(radius, 0, viewMagnitude)));
     UnityEditor.Handles.DrawLine(transform.position, transform.TransformPoint(new Vector3(-radius, 0, viewMagnitude)));
     UnityEditor.Handles.color = oldColor;
     #endif
 }
开发者ID:JohnnyVox,项目名称:schoolfire,代码行数:15,代码来源:NPCViewUtilities.cs

示例9: UpdateFinger

    public override void UpdateFinger(Finger finger, Transform deviceTransform,
                                     Vector3 palm_normal, Vector3 palm_direction)
    {
        Vector3 last_bone_normal = palm_normal;
        Vector3 last_bone_direction = palm_direction;

        for (int i = 0; i < NUM_BONES; ++i) {
          // Set velocity.
          Vector3 next_bone_position = deviceTransform.TransformPoint(GetBonePosition(finger, i));
          bones[i].rigidbody.velocity = (next_bone_position - bones[i].transform.position) *
                                    ((1 - easing) / Time.fixedDeltaTime);

          // Set angular velocity.
          Vector3 bone_direction = deviceTransform.rotation * GetBoneDirection(finger, i);
          Vector3 bone_normal = Quaternion.FromToRotation(last_bone_direction, bone_direction) * last_bone_normal;

          Quaternion delta_rotation = Quaternion.LookRotation(bone_direction, -bone_normal) *
                                  Quaternion.Inverse(bones[i].transform.rotation);
          float angle = 0.0f;
          Vector3 axis = Vector3.zero;
          delta_rotation.ToAngleAxis(out angle, out axis);

          if (angle >= 180) {
        angle = 360 - angle;
        axis  = -axis;
          }
          if (angle != 0)
        bones[i].rigidbody.angularVelocity = (1 - easing) * angle * axis;

          last_bone_direction = bone_direction;
          last_bone_normal = bone_normal;
        }
    }
开发者ID:nomad512,项目名称:unity,代码行数:33,代码来源:PhysicsFinger.cs

示例10: InstantiateWithParent

    public static FreePositionView InstantiateWithParent(TilePosition p_position, Transform p_parent, Player p_owner)
    {
        try {
            // Creation of the new instance.
            GameObject _new_instance = UnityEngine.Object.Instantiate (RESOURCE) as GameObject;
            _new_instance.transform.parent = p_parent;

            // Get the script associated with the new tile.
            FreePositionView _this = _new_instance.AddComponent<FreePositionView> ();

            // Set the common properties
            _this.m_position = p_position;
            _this.m_player = p_owner;
            if(_this.m_position != null)
            {
                // TODO Rework this Duplicate from TileView.
                Vector3 position = new Vector3(_this.m_position.x * 1.5f * TileView.OffsetX, 0, (_this.m_position.y + 1 ) * TileView.OffsetY);
                _this.transform.position = p_parent.TransformPoint(position);
            }
            else
            {
                Debug.LogError("Position for FreePositionView null !");
            }

            return _this;

        } catch (Exception) {
            Debug.LogError ("Error while instantiating FreePosition! Prefab not found !");
            return null;
        }
    }
开发者ID:dpekar,项目名称:suburbia,代码行数:31,代码来源:FreePositionView.cs

示例11: DrawLayoutOutline

	void DrawLayoutOutline(Transform t) {
		var layout = t.GetComponent<tk2dUILayout>();
		if (layout != null) {
			Vector3[] p = new Vector3[] {
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMin.y, 0.0f),
				new Vector3(layout.bMax.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMax.y, 0.0f),
				new Vector3(layout.bMin.x, layout.bMin.y, 0.0f),
			};
			for (int i = 0; i < p.Length; ++i) p[i] = t.TransformPoint(p[i]);
			Handles.color = Color.magenta;
			Handles.DrawPolyLine(p);

			var sizer = t.GetComponent<tk2dUILayoutContainerSizer>();
			if (sizer != null) {
				Handles.color = Color.cyan;
				float arrowSize = 0.3f * HandleUtility.GetHandleSize(p[0]);
				if (sizer.horizontal) {
					Handles.ArrowCap(0, (p[0] + p[3]) * 0.5f, Quaternion.LookRotation(p[1] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[1] + p[2]) * 0.5f, Quaternion.LookRotation(p[0] - p[1]), arrowSize);
				} else {
					Handles.ArrowCap(0, (p[0] + p[1]) * 0.5f, Quaternion.LookRotation(p[3] - p[0]), arrowSize);
					Handles.ArrowCap(0, (p[2] + p[3]) * 0.5f, Quaternion.LookRotation(p[0] - p[3]), arrowSize);
				}
			}
		}

		for (int i = 0; i < t.childCount; ++i)
			DrawLayoutOutline(t.GetChild(i));
	}
开发者ID:AtwoodDeng,项目名称:GGJ2015,代码行数:31,代码来源:tk2dUILayoutEditor.cs

示例12: Handle

		internal static void Handle(PivotType aSides, Transform aTransform, bool aLockX, bool aLockY, bool aLockZ, Vector3 aSnap, ref Vector3 lbf, ref Vector3 rtb, Handles.DrawCapFunction aCap) {
			Vector3 pt = new Vector3(0,0,0);
			Vector3 mask = new Vector3(aLockX?1:0, aLockY?1:0, aLockZ?1:0);
			if ((aSides & PivotType.Left  ) > 0) pt.x = lbf.x;
			if ((aSides & PivotType.Right ) > 0) pt.x = rtb.x;
			if ((aSides & PivotType.Top   ) > 0) pt.y = rtb.y;
			if ((aSides & PivotType.Bottom) > 0) pt.y = lbf.y;
			if ((aSides & PivotType.Front ) > 0) pt.z = lbf.z;
			if ((aSides & PivotType.Back  ) > 0) pt.z = rtb.z;
			pt = aTransform.TransformPoint(pt);
			
			Vector3 result = Handles.FreeMoveHandle(pt, Quaternion.identity, HandleUtility.GetHandleSize(pt) * mHandleSize, Vector3.zero, aCap);
			if (result != pt) {
				Vector3 dir = SuperCubeEditorUtil.CreateBillboardNormal(pt, aLockX, aLockY, aLockZ);
				result = SuperCubeEditorUtil.SnapVector(Vector3.Scale(SuperCubeEditorUtil.GetPlanePoint(result, new Plane(dir, pt)), mask), aSnap);
				result = aTransform.InverseTransformPoint(result);
				
				if ((aSides & PivotType.Left  ) > 0) lbf.x = result.x;
				if ((aSides & PivotType.Right ) > 0) rtb.x = result.x;
				if ((aSides & PivotType.Top   ) > 0) rtb.y = result.y;
				if ((aSides & PivotType.Bottom) > 0) lbf.y = result.y;
				if ((aSides & PivotType.Front ) > 0) lbf.z = result.z;
				if ((aSides & PivotType.Back  ) > 0) rtb.z = result.z;
			}
		}
开发者ID:2ty,项目名称:race3d,代码行数:25,代码来源:SuperCubeEditorUtil.cs

示例13: WithinSight

 // Determines if the targetObject is within sight of the transform. It will set the angle regardless of whether or not the object is within sight
 private static GameObject WithinSight(Transform transform, Vector3 positionOffset, float fieldOfViewAngle, float viewDistance, GameObject targetObject, Vector3 targetOffset, bool usePhysics2D, out float angle, int ignoreLayerMask)
 {
     // The target object needs to be within the field of view of the current object
     var direction = targetObject.transform.position - transform.TransformPoint(positionOffset);
     if (usePhysics2D)
     {
         angle = Vector3.Angle(direction, transform.up);
         direction.z = 0;
     }
     else
     {
         angle = Vector3.Angle(direction, transform.forward);
         direction.y = 0;
     }
     if (direction.magnitude < viewDistance && angle < fieldOfViewAngle * 0.5f)
     {
         // The hit agent needs to be within view of the current agent
         if (LineOfSight(transform, positionOffset, targetObject, targetOffset, usePhysics2D, ignoreLayerMask) == targetObject)
         {
             return targetObject; // return the target object meaning it is within sight
         }
         else if (targetObject.GetComponent<Collider>() == null && targetObject.GetComponent<Collider2D>() == null)
         {
             // If the linecast doesn't hit anything then that the target object doesn't have a collider and there is nothing in the way
             if (targetObject.gameObject.activeSelf)
                 return targetObject;
         }
     }
     // return null if the target object is not within sight
     return null;
 }
开发者ID:BiteMeInc,项目名称:bite-me,代码行数:32,代码来源:MovementUtility.cs

示例14: UpdateHand

    public override void UpdateHand(Transform deviceTransform)
    {
        Hand leap_hand = GetLeapHand();
        // Update all the fingers and palm.
        Vector3 palm_normal = deviceTransform.rotation * leap_hand.PalmNormal.ToUnityScaled();
        Vector3 palm_direction = deviceTransform.rotation * leap_hand.Direction.ToUnityScaled();
        Vector3 palm_center = GetPalmCenter(leap_hand);

        for (int f = 0; f < NUM_FINGERS; ++f) {
          if (fingers[f] != null) {
        fingers[f].UpdateFinger(leap_hand.Fingers[f], deviceTransform, palm_normal, palm_direction);
          }
        }

        if (palm != null) {
          // Set palm velocity.
          Vector3 next_position = deviceTransform.TransformPoint(palm_center);
          palm.rigidbody.velocity = (next_position - palm.transform.position) *
                                (1 - easing) / Time.fixedDeltaTime;

          // Set palm angular velocity.
          Quaternion delta_rotation = Quaternion.LookRotation(palm_normal, palm_direction) *
                                  Quaternion.Inverse(palm.transform.rotation);
          float angle = 0.0f;
          Vector3 axis = Vector3.zero;
          delta_rotation.ToAngleAxis(out angle, out axis);

          if (angle >= 180) {
        angle = 360 - angle;
        axis = -axis;
          }
          if (angle != 0)
        palm.rigidbody.angularVelocity = (1 - easing) * angle * axis;
        }
    }
开发者ID:nomad512,项目名称:unity,代码行数:35,代码来源:PhysicsHand.cs

示例15: ToWorldFrom

 public Line ToWorldFrom(Transform t)
 {
     Line ret = new Line();
     ret.from = t.TransformPoint(from);
     ret.to = ret.from + t.TransformDirection(to - from);
     return ret;
 }
开发者ID:IlyaBokovenko,项目名称:spear-fishing,代码行数:7,代码来源:FishObstacleAvoidingBehaviour.cs


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