48
edits
|  (Created page with "== Introduction == Controlling Objects in Unity with The Captury<br>  - Cover the OSC syntax and how to get nodes as matrix / vector, absolute and relative<br> - How to create ob...") | No edit summary | ||
| Line 33: | Line 33: | ||
| Convert quaternion to 4×4 Rotation matrix.<br> | Convert quaternion to 4×4 Rotation matrix.<br> | ||
| <source> |  <source lang="C#"> | ||
| Quaternion q = Quaternion.LookRotation(new Vector3(0,0.5,1));    | Quaternion q = Quaternion.LookRotation(new Vector3(0,0.5,1));    | ||
| Matrix4x4 rot = new Matrix4x4();    | Matrix4x4 rot = new Matrix4x4();    | ||
| Line 40: | Line 40: | ||
| Convert  4×4 Rotation matrix to quaternion.<br> | Convert  4×4 Rotation matrix to quaternion.<br> | ||
| <source> |  <source lang="C#"> | ||
| Matrix4x4 rot = new Matrix4x4();    | Matrix4x4 rot = new Matrix4x4();    | ||
| rot.SetTRS(new Vector3(0,0,0),q,new Vector3(1,1,1));  //It’s the same “q” that mentioned above | rot.SetTRS(new Vector3(0,0,0),q,new Vector3(1,1,1));  //It’s the same “q” that mentioned above | ||
| Vector4 vy = rot.GetColumn(1);    | Vector4 vy = rot.GetColumn(1);    | ||
| Vector4 vz = rot.GetColumn(2);    | Vector4 vz = rot.GetColumn(2);    | ||
| Quaternion newQ = Quaternion.LookRotation(new Vector3(vz.x,vz.y,vz.z),new Vector3(vy.x,vy.y,vy.z));    | Quaternion newQ = Quaternion.LookRotation(new Vector3(vz.x,vz.y,vz.z),new Vector3(vy.x,vy.y,vy.z));    | ||
| </source> | </source> | ||
| Line 86: | Line 85: | ||
| == How to animate these Objects == | == How to animate these Objects == | ||
| Asking for data;<br> | Asking for data;<br> | ||
| <source> |  <source lang="javac=script"> | ||
| 	msg = handler.StringToOscMessage("/subscribe/fiona/blender/Root/vector 50.0 0.0 20.0");   | 	msg = handler.StringToOscMessage("/subscribe/fiona/blender/Root/vector 50.0 0.0 20.0");   | ||
| 	handler.Send(msg); | 	handler.Send(msg); | ||
| Line 92: | Line 91: | ||
| 2.   Getting data;<br> | 2.   Getting data;<br> | ||
| <source> |  <source lang="javascript"> | ||
| switch (msgAddress){ | switch (msgAddress){ | ||
|              case "/Fiona_fit/blender/Root/vector": |              case "/Fiona_fit/blender/Root/vector": | ||
| Line 102: | Line 101: | ||
| 3.  Giving the data to the object.<br> | 3.  Giving the data to the object.<br> | ||
| <source> |  <source lang="javascript"> | ||
| 	var transHip = GameObject.Find("Cube_hip1"); | 	var transHip = GameObject.Find("Cube_hip1"); | ||
| 	transHip.transform.position = Vector3(hip[0], -hip[2], hip[1]); | 	transHip.transform.position = Vector3(hip[0], -hip[2], hip[1]); | ||
edits