unity:坐标变换 - 两个函数

本文介绍了Unity和Cocos两个游戏开发框架中的坐标变换方法。包括从本地坐标系到世界坐标系以及从世界坐标系回到本地坐标系的转换。通过对比不同框架中的实现方式,帮助开发者更好地理解坐标变换的基本原理。

在cocos中,我们知道有如下的坐标变换函数:

CCPoint convertToNodeSpace(const CCPoint& worldPoint);
CCPoint convertToWorldSpace(const CCPoint& nodePoint);
CCPoint convertToNodeSpaceAR(const CCPoint& worldPoint);
CCPoint convertToWorldSpaceAR(const CCPoint& nodePoint);

同样在untiy中也有类似的坐标变换函数:

Transform.TransformPoint

Transforms position from local space to world space.

本地坐标转换到世界坐标

Transform.InverseTransformPoint

Transforms position from world space to local space.

世界坐标转换到本地坐标

参考:

http://docs.unity3d.com/ScriptReference/Transform.InverseTransformPoint.html

http://www.ceeger.com/Script/Transform/Transform.TransformPoint.html

 

转载于:https://www.cnblogs.com/ZhYQ-Note/p/5861732.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值