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 实现的更多相关文章
随机推荐
- ACM-ICPC 2018 徐州赛区网络预赛 D 杜教筛 前缀和
链接 https://nanti.jisuanke.com/t/31456 参考题解 https://blog.csdn.net/ftx456789/article/details/82590044 ...
- Codeforces 549C The Game Of Parity【博弈】
C语言纠错大赛的一道题,正好拿来补博弈~~ 给的代码写的略奇葩..不过还是直接在上面改了.. 题目链接: http://codeforces.com/problemset/problem/549/C ...
- Codeforces 658D Bear and Polynomials【数学】
题目链接: http://codeforces.com/contest/658/problem/D 题意: 给定合法多项式,改变一项的系数,使得P(2)=0,问有多少种方法? 分析: 暴力求和然后依次 ...
- Rust 1.7.0 语法基础 sep_token 和 non_special_token
一.分隔符 sep_token 指的是分隔符, 是除了 * 和 + 之外的不论什么符号,通常情况下是使用 , 逗号. 比如: 宏的多个參数分隔,以下代码中的逗号就是 sep_token (target ...
- maven 项目 spring mvc + jdbc 配置文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- .NET中lock的使用方法及注意事项[转]
标准-->ms官方: http://msdn.microsoft.com/zh-cn/library/c5kehkcz(v=vs.90).aspx A.为什么不要 "lock(this ...
- Redis实践系列丨Codis数据迁移原理与优化
Codis介绍 Codis 是一种Redis集群的实现方案,与Redis社区的Redis cluster类似,基于slot的分片机制构建一个更大的Redis节点集群,对于连接到codis的Redis客 ...
- 我的gulp.js清单
var gulp = require('gulp'), cssmin = require('gulp-clean-css'), //压缩css文件 concat = require('gulp-con ...
- autofac如何注册静态方法里的接口对象
标题可能是不准确的,因为我不知道如何描述.不知道的原因,是对依赖注入一知半解. Autofac可以自动注册对象实例到接口,人所尽知.而在asp.net mvc中,这个实例化的工作,通常在每个控制器的构 ...
- 2016/05/25 get和post的区别
get是从服务器上获取数据,post是向服务器传送数据. get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过HTTP ...