|
资源信息 Tutorial Information
教程名称: | 反向翻转法线实现一个天空盒(发帖教程) |
适用引擎: | Unity3D (适用引擎,为空默认为Unity) |
教程语种: | 中文 |
教程等级: | 1 |
教程格式: | 图文(请用IE9以上浏览器访问本版块) |
教程作者: | 转载自互联网 (如有问题请短消息联系作者或发表回复) |
下载地址: | 无 (兑换积分) |
[code=csharp]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// made by u3dchina.com
/// </summary>
public class FlipNormals : MonoBehaviour
{
// Use this for initialization
void Start()
{
Mesh mesh = this.GetComponent<MeshFilter>().mesh;
Vector3[] normals = mesh.normals;
for (int i = 0, lenI = normals.Length; i < lenI; i++)
{
normals = -1 * normals;
}
mesh.normals = normals;
Debug.Log("subMeshCount:"+mesh.subMeshCount);
for (int i = 0, lenI = mesh.subMeshCount; i < lenI; i++)
{
int[] tris = mesh.GetTriangles(i);
for (int j = 0, lenJ = tris.Length; j < lenJ; j+=3)
{
int temp = tris[j];
tris[j] = tris[j + 1];
tris[j + 1] = temp;
}
mesh.SetTriangles(tris, i);
}
}
// Update is called once per frame
void Update()
{
}
}[/code]
创建一个character controller、plane、及一个sphere当天空盒,把该脚本拉到sphere就ok了。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|