This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Quaternion ConvertMatrixToQuaternion (Matrix4x4 m) | |
| { | |
| var qw = Mathf.Sqrt (1.0f + m.m00 + m.m11 + m.m22) / 2.0f; | |
| var qx = (m.m21 - m.m12) / (4.0f * qw); | |
| var qy = (m.m02 - m.m20) / (4.0f * qw); | |
| var qz = (m.m10 - m.m01) / (4.0f * qw); | |
| return new Quaternion (qx, qy, qz, qw); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Matrix4x4 LookAtMatrix (Vector3 center, Vector3 eye, Vector3 up) { | |
| var F = (center - eye); | |
| var f = F / Mathf.Max (F.magnitude, Mathf.Epsilon); | |
| var s = Vector3.Cross (f, up); | |
| var S = s / Mathf.Max (s.magnitude, Mathf.Epsilon); | |
| var u = Vector3.Cross (s, f); | |
| Matrix4x4 m = new Matrix4x4 (); | |
| m.SetColumn (0, new Vector4 ( s.x, s.y, s.z, 0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class AutoInvisibleCursor : MonoBehaviour { | |
| [Range (0.0f, 15.0f)] | |
| public float TimeToHide = 5.0f; | |
| Vector2 previousMousePosition; | |
| Vector2 currentMousePosition; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System; | |
| using System.Collections; | |
| using System.Runtime.InteropServices; | |
| public class WindowLayout : MonoBehaviour { | |
| public string WindowName = "WindowName"; | |
| public int PositionX = 0; | |
| public int PositionY = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ------------------------------------------------------------ | |
| // Photoshop Color Blend | |
| // @author irishoak | |
| // ------------------------------------------------------------ | |
| // Branchless RGB2HSL implementation from : https://www.shadertoy.com/view/MsKGRW | |
| float3 rgb2hsl(float3 c){ | |
| float epsilon = 0.00000001; | |
| float cmin = min( c.r, min( c.g, c.b ) ); | |
| float cmax = max( c.r, max( c.g, c.b ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* -------------------------------- | |
| LineKnotPositionDataExporter | |
| @ author OISHI Hiroaki oishi@team-lab.com | |
| @ date 2016/03/30 | |
| @ update 2016/03/30 | |
| [Main Function] | |
| Export selected line knot position data to .csv file | |
| [csv format] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| obj = bpy.context.scene.objects['ObjectName'] | |
| ptr = obj.particle_systems["ParticleSystem"].particles | |
| text_file = open("vertices.txt", "w") | |
| for p in ptr: | |
| text_file.write(str(p.location) + "\n") | |
| text_file.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| /// Implementation for 3D from Gregory Schlomoff's Unity source: http://gregschlom.com/devlog/2014/06/29/Poisson-disc-sampling-Unity.html | |
| /// | |
| /// Usage: | |
| /// PoissonDiskSampler3D sampler = new PoissonDiskSampler3D(10, 5, 7.5f, 0.3f); | |
| /// foreach (Vector3 sample in sampler.Samples()) { | |
| /// // ... do something, like instantiate an object at (sample.x, sample.y, sample.z) for example: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://ridlow.wordpress.com/2014/10/22/uniform-random-points-in-disk-annulus-ring-cylinder-and-sphere/ | |
| Vector3 RandomInsideUnitSphere () { | |
| float phi = 2 * Mathf.PI * Random.value; | |
| float th = Mathf.Acos(1.0 - 2.0 * Random.value); | |
| float r = Mathf.Pow(Random.value, 0.333333333); | |
| float x = r * Mathf.Sin(th) * Mathf.Cos(phi); | |
| float y = r * Mathf.Sin(th) * Mathf.Sin(phi); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| using Windows.Kinect; | |
| public class DepthMapGenerator : MonoBehaviour { | |
| public GameObject depthSourceManager; | |
| private DepthSourceManager depthSourceManagerScript; | |
| [Range (1, 8000)] |