坐标转换
来源:互联网 发布:mac音量键在哪里设置 编辑:程序博客网 时间:2024/06/10 11:33
var worldPosition = trans.parent.TransformPoint(trans.localPosition);
return gameObject.transform.parent.InverseTransformPoint(worldPosition);
第一句把目标的local坐标转换成世界坐标。
第二句把世界坐标转换成自己的local坐标。
这里需要注意两次转换都应该调用父亲的转换函数
Unity3D的四种坐标系
World Space(世界坐标)
Screen Space(屏幕坐标)以像素来定义的,以屏幕的左下角为(0,0)点,右上角为(Screen.width,Screen.height),Z的位置是以相机的世界单位来衡量的。
ViewPort Space(视口坐标)视口坐标是标准的和相对于相机的。相机的左下角为(0,0)点,右上角为(1,1)点,Z的位置是以相机的世界单位来衡量的。
世界坐标→屏幕坐标:camera.WorldToScreenPoint(transform.position);这样可以将世界坐标转换为屏幕坐标。其中camera为场景中的camera对象。
屏幕坐标→视口坐标:camera.ScreenToViewportPoint(Input.GetTouch(0).position);这样可以将屏幕坐标转换为视口坐标。其中camera为场景中的camera对象。
视口坐标→屏幕坐标:camera.ViewportToScreenPoint();
视口坐标→世界坐标:camera.ViewportToWorldPoint();
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 坐标转换
- 百度坐标转换GPS坐标
- 大端和小端及如何判断
- [leetcode] Candy
- 硬盘中出现eula.1028.txt等垃圾文件的原因及是否可删
- poj 1657 Distance on Chessboard
- [leetcode] Gas Station
- 坐标转换
- Python如何调用C语言接口
- sqlite学习笔记9:C语言中使用sqlite之插入数据
- android 细节之android.view.InflateException: Binary XML file line #95: Error inflating class(out of m)
- 【LeetCode】Remove Duplicates from Sorted List & Remove Duplicates from Sorted List II
- 循环链表测试自编
- POJ-2472 106 miles to Chicago
- cocos2d-x类型转换(CCstring int string char UTF-8互转)
- 【UVaOJ】133 - The Dole Queue