StretchedBillboard 实现
if (isShowLeft) rightward = -rightward;
Vector3 forward = (Camera.current.transform.position - transform.position).normalized;
if (isShowBack) forward = -forward;
float cosVal = Vector3.Dot(rightward, forward);
if (Mathf.Abs(cosVal) >= 0.999999f) return;
rightward = rightward * cosVal;
forward = forward - rightward;
//不能用forward改变,不能保证right朝向 有时候会反过来
if (cosVal > 0)
transform.rotation = Quaternion.LookRotation(forward, Vector3.Cross(rightward, forward));
else
transform.rotation = Quaternion.LookRotation(forward, Vector3.Cross(forward, rightward));
//角度旋转
if (billboardAngle != 0)
{
Vector3 oriAngle = transform.eulerAngles;
oriAngle.x += billboardAngle;
transform.eulerAngles = oriAngle;
}
x
Vector3 rightward = transform.parent.forward;
if (isShowLeft) rightward = -rightward;
Vector3 forward = (Camera.current.transform.position - transform.position).normalized;
if (isShowBack) forward = -forward;
float cosVal = Vector3.Dot(rightward, forward);
if (Mathf.Abs(cosVal) >= 0.999999f) return;
rightward = rightward * cosVal;
forward = forward - rightward;
//不能用forward改变,不能保证right朝向 有时候会反过来
if (cosVal > 0)
transform.rotation = Quaternion.LookRotation(forward, Vector3.Cross(rightward, forward));
else
transform.rotation = Quaternion.LookRotation(forward, Vector3.Cross(forward, rightward));
//角度旋转
if (billboardAngle != 0)
{
Vector3 oriAngle = transform.eulerAngles;
oriAngle.x += billboardAngle;
transform.eulerAngles = oriAngle;
}

StretchedBillboard 实现的更多相关文章
随机推荐
- msp430项目编程02
msp430中项目---液晶1602显示 1.液晶1602工作原理 2.电路原理说明 3.代码(静态显示) 4.代码(动态显示) 5.项目总结 msp430项目编程 msp430入门学习
- Linux MTD (Memory Technology Device) subsystem analysis -For Atheros char device
Linux MTD (Memory Technology Device) subsystem analysis For Atheros char device 读了Linux MTD 源代码分析 对这 ...
- HTTP请求示例
HTTP请求格式 当浏览器向Web服务器发出请求时,它向服务器传递了一个数据块,也就是请求信息,HTTP请求信息由3部分组成: l 请求方法URI协议/版本 l 请求头(Request Hea ...
- CSS布局之BFC和IFC
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/6708358.html <这是一篇css2-3的布局规 ...
- Jenkins系列之-—05 节点配置
一.节点配置 1. 进入[系统管理]-[节点管理]-[新建节点],录入节点名,选择Permanent Agent,下一步录入节点详细配置信息,如下: Name:节点名称 Description:节点描 ...
- Atitit. 软件GUIbutton与仪表盘--webserver区--获取apache配置文件路径 linux and apache的启动、停止、重新启动
Atitit. 软件GUIbutton与仪表盘--webserver区--获取apache配置文件路径 linux and apache的启动.停止.重新启动 能够通过"netstat ...
- A + B Problem II(杭电1002)
/*A + B Problem II Problem Description I have a very simple problem for you. Given two integers A an ...
- 求出全部的正整数对 使他们最大公约数为n,最小公倍数为m
题目大概是这种:cid=1021&pid=5http://" target="_blank">点击打开链接 大意就是 求出全部的正整数对 使他们最大公约数为 ...
- base64和图片互转
pom.xml添加 <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependen ...
- PL/SQL Developer导入导出Oracle数据库方法
前一篇博客介绍了Navicat工具备份Oracle的方法.这篇博客介绍一下使用PL/SQL Developer工具导入导出Oracle数据库的方法. PL/SQL Developer是Oracle数据 ...