纳金网
标题:
以贴图中心旋转
[打印本页]
作者:
她。
时间:
2012-4-12 15:29
标题:
以贴图中心旋转
using UnityEngine;
using System.Collections;
public class RotateTexture : MonoBehaviour {
public float rotateSpeed = 10f;
public Vector2 pivot = new Vector2(0.5f, 0.5f);
public Texture texture;
// Use this for initialization
void Start () {
Material m = new Material (
"Shader "Rotating Texture" {" +
"roperties { _MainTex ("Base", 2D) = "white" {} }" +
"SubShader {" +
" Pass {" +
" Material { Diffuse (1,1,1,0) Ambient (1,1,1,0) }" +
" Lighting On" +
" SetTexture [_MainTex] {" +
" matrix [_Rotation]" +
" combine texture * primary double, texture" +
" }" +
" }" +
"}" +
"}"
);
m.mainTexture = texture;
renderer.material = m;
}
// Update is called once per frame
void Update () {
// Construct a rotation matrix and set it for the shader
Quaternion rotation = Quaternion.Euler(0, 0, Time.time * rotateSpeed);
Matrix4x4 r = Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one);
Matrix4x4 t = Matrix4x4.TRS(-pivot, Quaternion.identity, Vector3.one);
Matrix4x4 tInv = Matrix4x4.TRS(pivot, Quaternion.identity, Vector3.one);
renderer.material.SetMatrix("_Rotation", tInv*r*t);
}
}
作者:
她。
时间:
2012-11-7 09:15
发现看的人还是蛮多的,但是没有人顶个
作者:
艾西格亚
时间:
2012-11-7 11:58
呵呵,用力顶起
感谢分享
作者:
may
时间:
2012-11-19 01:42
顶下,支持楼主的分享!
作者:
其实我是神
时间:
2012-11-28 17:24
www.narkii.com这里好东西很多。
作者:
她。
时间:
2012-11-28 17:28
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5