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


C# UnityEngine.Plane类代码示例

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


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

示例1: Update

		void Update() {
			if (navMeshAgent.remainingDistance < 0.5f) {
				if (idle != null && anim != null) anim.CrossFade(idle.name);
			} else {
				if (run != null && anim != null) anim.CrossFade(run.name);
			}
	 
			// Moves the Player if the Left Mouse Button was clicked:
			if (Input.GetMouseButtonDown((int) mouseButton) && GUIUtility.hotControl == 0) {
				Plane playerPlane = new Plane(Vector3.up, myTransform.position);
				Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);
				float hitdist = 0.0f;
	 
				if (playerPlane.Raycast(ray, out hitdist)) {
					navMeshAgent.SetDestination(ray.GetPoint(hitdist));
				}
			}
	 
			// Moves the player if the mouse button is held down:
			else if (Input.GetMouseButton((int) mouseButton) && GUIUtility.hotControl == 0) {
	 
				Plane playerPlane = new Plane(Vector3.up, myTransform.position);
				Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);
				float hitdist = 0.0f;
	 
				if (playerPlane.Raycast(ray, out hitdist)) {
					navMeshAgent.SetDestination(ray.GetPoint(hitdist));
				}
			}
		}
开发者ID:SHEePYTaGGeRNeP,项目名称:DialogGame,代码行数:30,代码来源:NavigateOnMouseClick.cs

示例2: ExtractFrustumPlanes

        /// <summary>
        /// Same functionality as GeometryUtility.CalculateFrustumPlanes, but doesn't allocate memory.
        /// </summary>
        public static void ExtractFrustumPlanes(Plane[] planes, Camera camera)
        {
            Matrix4x4 viewProjMatrix = camera.projectionMatrix * camera.worldToCameraMatrix;

            Vector3 normal = new Vector3(viewProjMatrix[3, 0] + viewProjMatrix[0, 0], viewProjMatrix[3, 1] + viewProjMatrix[0, 1], viewProjMatrix[3, 2] + viewProjMatrix[0, 2]);
            float length = normal.magnitude;
            planes[0].normal = normal.normalized;
            planes[0].distance = (viewProjMatrix[3, 3] + viewProjMatrix[0, 3]) / length;

            normal = new Vector3(viewProjMatrix[3, 0] - viewProjMatrix[0, 0], viewProjMatrix[3, 1] - viewProjMatrix[0, 1], viewProjMatrix[3, 2] - viewProjMatrix[0, 2]);
            length = normal.magnitude;
            planes[1].normal = normal.normalized;
            planes[1].distance = (viewProjMatrix[3, 3] - viewProjMatrix[0, 3]) / length;

            normal = new Vector3(viewProjMatrix[3, 0] + viewProjMatrix[1, 0], viewProjMatrix[3, 1] + viewProjMatrix[1, 1], viewProjMatrix[3, 2] + viewProjMatrix[1, 2]);
            length = normal.magnitude;
            planes[2].normal = normal.normalized;
            planes[2].distance = (viewProjMatrix[3, 3] + viewProjMatrix[1, 3]) / length;

            normal = new Vector3(viewProjMatrix[3, 0] - viewProjMatrix[1, 0], viewProjMatrix[3, 1] - viewProjMatrix[1, 1], viewProjMatrix[3, 2] - viewProjMatrix[1, 2]);
            length = normal.magnitude;
            planes[3].normal = normal.normalized;
            planes[3].distance = (viewProjMatrix[3, 3] - viewProjMatrix[1, 3]) / length;

            normal = new Vector3(viewProjMatrix[3, 0] + viewProjMatrix[2, 0], viewProjMatrix[3, 1] + viewProjMatrix[2, 1], viewProjMatrix[3, 2] + viewProjMatrix[2, 2]);
            length = normal.magnitude;
            planes[4].normal = normal.normalized;
            planes[4].distance = (viewProjMatrix[3, 3] + viewProjMatrix[2, 3]) / length;

            normal = new Vector3(viewProjMatrix[3, 0] - viewProjMatrix[2, 0], viewProjMatrix[3, 1] - viewProjMatrix[2, 1], viewProjMatrix[3, 2] - viewProjMatrix[2, 2]);
            length = normal.magnitude;
            planes[5].normal = normal.normalized;
            planes[5].distance = (viewProjMatrix[3, 3] - viewProjMatrix[2, 3]) / length;
        }
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:37,代码来源:LOSHelper.cs

示例3: Update

		void Update () {
			Plane playerPlane = new Plane(Vector3.up, transform.position + new Vector3(0, 0, 0));
			switch (state) {
			case State.Walking:
				Walking();
				break;
			case State.Attacking:
				Attacking();
				break;
			}

			if(state != nextState){
				state = nextState;
				switch(state){
				case State.Walking:
					WalkStart();
					break;
				case State.Attacking:
					AttackStart();
					break;
				case State.Died:
					Died();
					break;
				}
			}
		}
开发者ID:trananh1992,项目名称:3DActionGame,代码行数:26,代码来源:PlayerStatusController.cs

示例4: RaycastScreenPointFromCamera

 public RaycastScreenPointFromCamera(Camera targetCamera, Vector2 screenPosition)
 {
     this._targetCamera = targetCamera;
     this._screenPosition = screenPosition;
     _plane = new Plane(Vector3.down, Vector3.zero);
     Invalidate();
 }
开发者ID:NoxHarmonium,项目名称:flexicamera,代码行数:7,代码来源:RaycastScreenPointFromCamera.cs

示例5: OnUpdate

        // Update is called once per frame
        public override void OnUpdate()
        {
            var vrcam = SteamVR_Render.Top();
            GameObject go = Fsm.GetOwnerDefaultTarget(gazeObject);

                Ray r = new Ray(vrcam.transform.position, vrcam.transform.forward);
                Plane p = new Plane(vrcam.transform.forward, go.transform.position);

                float enter = 0.0f;
                if (p.Raycast(r, out enter))
                {
                    Vector3 intersect = vrcam.transform.position + vrcam.transform.forward * enter;
                    float dist = Vector3.Distance(intersect, go.transform.position);
                    //Debug.Log("Gaze dist = " + dist);
                    if (dist < gazeInCutoff.Value && !isInGaze.Value)
                    {
                        isInGaze.Value = true;
                        GazeEventArgsPlaymaker e;
                        e.distance = dist;
                        OnGazeOn(e);
                    }
                    else if (dist >= gazeOutCutoff.Value && isInGaze.Value)
                    {
                        isInGaze.Value = false;
                        GazeEventArgsPlaymaker e;
                        e.distance = dist;
                        OnGazeOff(e);
                    }

                }
        }
开发者ID:ttcurry,项目名称:YellowBowl,代码行数:32,代码来源:GetGaze.cs

示例6: AdjustEdgeHandleColor

 private void AdjustEdgeHandleColor(Vector3 handlePos, Vector3 slideDir1, Vector3 slideDir2, Matrix4x4 transform, float alphaFactor)
 {
     bool flag;
     Vector3 inPoint = transform.MultiplyPoint(handlePos);
     Vector3 normalized = transform.MultiplyVector(slideDir1).normalized;
     Vector3 rhs = transform.MultiplyVector(slideDir2).normalized;
     if (Camera.current.isOrthoGraphic)
     {
         flag = (Vector3.Dot(-Camera.current.transform.forward, normalized) < 0f) && (Vector3.Dot(-Camera.current.transform.forward, rhs) < 0f);
     }
     else
     {
         Plane plane = new Plane(normalized, inPoint);
         Plane plane2 = new Plane(rhs, inPoint);
         flag = !plane.GetSide(Camera.current.transform.position) && !plane2.GetSide(Camera.current.transform.position);
     }
     if (flag)
     {
         alphaFactor *= 0.2f;
     }
     if (alphaFactor < 1f)
     {
         Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * alphaFactor);
     }
 }
开发者ID:BenjaminMoore,项目名称:JPhysics,代码行数:25,代码来源:BoxEditor.cs

示例7: Update

        // Update is called once per frame
        void Update()
        {
            //Movement Input
            //Look Input
            Ray ray = viewCamera.ScreenPointToRay(Input.mousePosition);
            Plane groundPlane = new Plane(Vector3.up, Vector3.zero);

            float rayDistance;

            if (groundPlane.Raycast(ray, out rayDistance))
            {
                Vector3 point = ray.GetPoint(rayDistance);
                //Debug.DrawLine(ray.origin, point, Color.red);
            }

            if (hasMoveTarget)
            {
                StartCoroutine(UpdatePath());
            }

            //Movement
            if (Input.GetMouseButtonDown(1))
            {
                hasMoveTarget = true;
                moveTarget = new Vector3(Input.mousePosition.x, Input.mousePosition.y);
                Debug.Log("Right-Click: " + moveTarget);
            }
        }
开发者ID:Aidonis,项目名称:NotAllHeroes,代码行数:29,代码来源:Player.cs

示例8: Start

        /// <summary>
        /// Initialises the component.
        /// </summary>
        public void Start()
        {
            this.planeZ = new Plane(Vector3.back, Vector3.zero);

            // Get a refernce to the terrain's touchable component
            this.terrainTouchable = GameObject.Find("Terrain").GetComponent<TouchableComponent>();
        }
开发者ID:andynygard,项目名称:game-dwarves,代码行数:10,代码来源:TouchHandlerComponent.cs

示例9: RaycastSmoke

		public static bool RaycastSmoke(Ray ray)
		{
			if(!CMDropper.smokePool)
			{
				return false;
			}

			for(int i = 0; i < CMDropper.smokePool.size; i++)
			{
				Transform smokeTf = CMDropper.smokePool.GetPooledObject(i).transform;
				if(smokeTf.gameObject.activeInHierarchy)
				{
					Plane smokePlane = new Plane((ray.origin-smokeTf.position).normalized, smokeTf.position);
					float enter;
					if(smokePlane.Raycast(ray, out enter))
					{
						float dist = (ray.GetPoint(enter)-smokeTf.position).magnitude;
						if(dist < 16)
						{
							return true;
						}
					}
				}
			}

			return false;
		}
开发者ID:tetryds,项目名称:BDArmory,代码行数:27,代码来源:CMSmoke.cs

示例10: CameraToPlaneProjection

 /// <summary>
 /// Projects a screen point to a plane.
 /// </summary>
 /// <param name="position">Screen point.</param>
 /// <param name="camera">The camera.</param>
 /// <param name="projectionPlane">The projection plane.</param>
 /// <returns></returns>
 public static Vector3 CameraToPlaneProjection(Vector2 position, Camera camera, Plane projectionPlane)
 {
     var ray = camera.ScreenPointToRay(position);
     var relativeIntersection = 0f;
     projectionPlane.Raycast(ray, out relativeIntersection);
     return ray.origin + ray.direction*relativeIntersection;
 }
开发者ID:nobnak,项目名称:TouchScript,代码行数:14,代码来源:ProjectionUtils.cs

示例11: ScreenPointToWorldPointOnPlane

        public static Vector3 ScreenPointToWorldPointOnPlane(Vector3 screenPoint , Plane plane , Camera camera  )
        {
            // Set up a ray corresponding to the screen position
            Ray ray = camera.ScreenPointToRay(screenPoint);

            // Find out where the ray intersects with the plane
            return PlaneRayIntersection(plane, ray);
        }
开发者ID:haejoon,项目名称:realdedicated-unitylibrary,代码行数:8,代码来源:PlayerMovementController.cs

示例12: RaycastGUIPointToWorldHit

 internal static bool RaycastGUIPointToWorldHit(Vector2 guiPoint, Plane plane, out Vector3 hit)
 {
   Ray worldRay = HandleUtility.GUIPointToWorldRay(guiPoint);
   float enter = 0.0f;
   bool flag = plane.Raycast(worldRay, out enter);
   hit = !flag ? Vector3.zero : worldRay.GetPoint(enter);
   return flag;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:RectHandles.cs

示例13: RaycastGUIPointToWorldHit

		internal static bool RaycastGUIPointToWorldHit(Vector2 guiPoint, Plane plane, out Vector3 hit)
		{
			Ray ray = HandleUtility.GUIPointToWorldRay(guiPoint);
			float distance = 0f;
			bool flag = plane.Raycast(ray, out distance);
			hit = ((!flag) ? Vector3.zero : ray.GetPoint(distance));
			return flag;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:8,代码来源:RectHandles.cs

示例14: CameraToPlaneProjection

        /// <summary>
        /// Projects a screen point to a plane from a camera's point of view.
        /// </summary>
        /// <param name="position">Screen point.</param>
        /// <param name="camera">The camera.</param>
        /// <param name="projectionPlane">Projection plane.</param>
        /// <returns>Projected point on the plane in World coordinates.</returns>
        public static Vector3 CameraToPlaneProjection(Vector2 position, Camera camera, Plane projectionPlane)
        {
            var distance = 0f;
            var ray = camera.ScreenPointToRay(position);
            var result = projectionPlane.Raycast(ray, out distance);
            if (!result && Mathf.Approximately(distance, 0f)) return -projectionPlane.normal * projectionPlane.GetDistanceToPoint(Vector3.zero); // perpendicular to the screen

            return ray.origin + ray.direction * distance;
        }
开发者ID:RabitBox,项目名称:FlickBattler,代码行数:16,代码来源:ProjectionUtils.cs

示例15: ScreenToPlaneProjection

        /// <summary>
        /// Projects a screen point to a plane using parallel projection.
        /// </summary>
        /// <param name="position">Screen point.</param>
        /// <param name="projectionPlane">Projection plane.</param>
        /// <returns>Projected point on the plane in World coordinates.</returns>
        public static Vector3 ScreenToPlaneProjection(Vector2 position, Plane projectionPlane)
        {
            var distance = 0f;
            var ray = new Ray(position, Vector3.forward);
            var result = projectionPlane.Raycast(ray, out distance);
            if (!result && Mathf.Approximately(distance, 0f)) return -projectionPlane.normal * projectionPlane.GetDistanceToPoint(Vector3.zero); // perpendicular to the screen

            return ray.origin + new Vector3(0, 0, distance);
        }
开发者ID:RabitBox,项目名称:FlickBattler,代码行数:15,代码来源:ProjectionUtils.cs


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