本文整理汇总了C#中UnityEngine.Quaternion.SetEulerRotation方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.SetEulerRotation方法的具体用法?C# Quaternion.SetEulerRotation怎么用?C# Quaternion.SetEulerRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Quaternion
的用法示例。
在下文中一共展示了Quaternion.SetEulerRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// void OnDrawGizmos () {
// Debug.Log ("_________________________");
// Debug.Log (counter);
// Debug.Log ("_________________________");
// if (vertices == null || counter == 5)
// return;
// Gizmos.color = Color.black;
// for (int i = 0; i <vertices.Length; i++) {
// //Debug.Log (i);
// if (vertices [i] != null) {
// Gizmos.DrawSphere (vertices [i], .05f);
// Debug.Log (vertices[i]);
// Debug.Log("Point: "+vertices[i/2]);
// } else {
// Debug.Log ("NULL");
// }
// }
// }
// Use this for initialization
void Start()
{
lastRightFence = new Vector3 ();
lastLeftFence = new Vector3 ();
lastLeftDxDy = new Vector3 ();
lastRightDxDy = new Vector3 ();
Mesh mesh = new Mesh ();
MeshFilter m = GetComponent<MeshFilter>();
m.mesh.Clear ();
//
string text = System.IO.File.ReadAllText(Application.dataPath + "/Scripts/WriteToFile.txt");
string[] lines = text.Split ('\n');
string sep = "\t";
Vector3 oldV = new Vector3();
List<Vector3> array = new List<Vector3> ();
for (int i=0; i<lines.Length-1; i++) {
string s = lines [i];
string[] split = s.Split (sep.ToCharArray());
float x = float.Parse (split [0]);
float y = float.Parse (split [1]);
float z = float.Parse (split [2]);
Vector3 tempp = new Vector3 (x, y, z);
if (Vector3.Magnitude (tempp - oldV) < MIN_DISTANCE)
continue;
array.Add(tempp);
oldV = tempp;
}
Vector3[] sampleinput = array.ToArray ();
vertices = new Vector3[sampleinput.Length * 2];
float dz = sampleinput[1].z - sampleinput[0].z;
float dx = sampleinput[1].x - sampleinput[0].x;
temp.Set (-1 * dz, dx);
temp.Normalize();
temp *= width;
float moveZ = temp.y;
float moveX = temp.x;
vertices [0] = new Vector3 (sampleinput [0].x + moveX, 0, sampleinput [0].z + moveZ);
vertices [1] = new Vector3 (sampleinput [0].x - moveX, 0, sampleinput [0].z - moveZ);
//-------------------------------------------------------
Transform fence = GameObject.FindGameObjectWithTag("FenceHolder").transform;
ArrayList fences = new ArrayList ();
for (int i = 1; i < sampleinput.Length-1; i++) {
// if (i % 10 == 0) {
// GameObject o = Instantiate (Resources.Load ("BetterFence"), sampleinput [i], Quaternion.identity) as GameObject;
// o.transform.SetParent (fence);
// fences.Add (o);
// }
dz = sampleinput[i+1].z - sampleinput[i-1].z;
dx = sampleinput[i+1].x - sampleinput[i-1].x;
temp.Set (-1 * dz, dx);
temp.Normalize();
temp *= width;
moveZ = temp.y;
moveX = temp.x;
vertices [i*2] = new Vector3 (sampleinput [i].x + moveX, 0, sampleinput [i].z + moveZ);
vertices [i*2 + 1] = new Vector3 (sampleinput [i].x - moveX, 0, sampleinput [i].z - moveZ);
if (lastLeftFence == null || Vector3.Distance(lastLeftFence,vertices[i*2]) > FENCE_LENGTH) {
Vector3 tempp;
if (lastLeftDxDy == null) {
tempp = vertices [i * 2];
lastLeftDxDy.Set (moveX, 0, moveZ);
lastLeftDxDy.Normalize ();
} else {
tempp = lastLeftFence + (lastLeftDxDy * FENCE_LENGTH / 2);
lastLeftDxDy.Set (moveX, 0, moveZ);
lastLeftDxDy.Normalize ();
tempp += (lastLeftDxDy * FENCE_LENGTH / 2);
}
lastLeftFence = vertices [i * 2];
float angle = Mathf.Atan (lastLeftDxDy.x / lastLeftDxDy.z);
Quaternion q = new Quaternion ();
q.SetEulerRotation (0, angle, 0);
GameObject o1 = Instantiate (Resources.Load ("BetterFence"), tempp,q) as GameObject;
//.........这里部分代码省略.........