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; | |
using System.Linq; | |
using System; | |
public class FlowRoutine | |
{ | |
static CoroutineHost host; |
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
Bounds GetBoundsInSpace (IList<CameraFocusPoint> points, Matrix4x4 m) | |
{ | |
Bounds b = new Bounds(); | |
Vector3 min = Vector3.one * float.MaxValue; | |
Vector3 max = Vector3.one * float.MinValue; | |
for (int i = 0; i < points.Count; i++) | |
{ | |
var p = m.MultiplyPoint(points [i].position); | |
min = Vector3.Min (min, p); | |
max = Vector3.Max (max, p); |
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
void DrawBounds(Matrix4x4 m, Bounds b) | |
{ | |
Vector3 va = m.MultiplyPoint(new Vector3(b.min.x,b.min.y,b.min.z)); | |
Vector3 vb = m.MultiplyPoint(new Vector3(b.min.x,b.max.y,b.min.z)); | |
Vector3 vc = m.MultiplyPoint(new Vector3(b.max.x,b.max.y,b.min.z)); | |
Vector3 vd = m.MultiplyPoint(new Vector3(b.max.x,b.min.y,b.min.z)); | |
Vector3 ve = m.MultiplyPoint(new Vector3(b.min.x,b.min.y,b.max.z)); | |
Vector3 vf = m.MultiplyPoint(new Vector3(b.min.x,b.max.y,b.max.z)); | |
Vector3 vg = m.MultiplyPoint(new Vector3(b.max.x,b.max.y,b.max.z)); |
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
public static Matrix4x4 WorldSpaceToClipSpace(Camera c){ | |
return ( | |
Matrix4x4.Perspective (c.fov, c.aspect, c.nearClipPlane, c.farClipPlane) | |
* Matrix4x4.TRS (Vector3.zero, Quaternion.identity, new Vector3 (-1, -1, -1)) | |
* c.transform.worldToLocalMatrix | |
); | |
} | |
public static Matrix4x4 ClipSpaceToWorldSpace(Camera c){ | |
return WorldSpaceToClipSpace(c).inverse; | |
} |
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 System; | |
public class NewtonsMethod | |
{ | |
public const float APPROXIMATE_ZERO = 0.000001f; | |
/// <summary> | |
/// f(x) | |
/// </summary> | |
public Func<float, float> fx; |
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; | |
public class Sphere : MonoBehaviour | |
{ | |
public Color color = Color.red; | |
public float radius; | |
public bool Contains(Vector3 pPoint) | |
{ | |
if (Vector3.SqrMagnitude(pPoint - transform.position) > radius * radius) | |
return false; |
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
void AddTorqueAt(Vector3 torque, Vector3 pPosition) | |
{ | |
Vector3 torqueAxis = torque.normalized; | |
Vector3 ortho = transform.forward; | |
if ((torqueAxis - ortho).sqrMagnitude < Vector3.kEpsilon) | |
{ | |
ortho = transform.right; | |
} | |
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; | |
using System; | |
public class ManagedPool<Q, T> | |
{ | |
List<T> _pooledItems = new List<T>(); | |
List<T> _activeItems = new List<T>(); | |
public Func<T> allocateItem = null; |
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.Generic; | |
using System; | |
/// <summary> | |
/// A simple gui container class | |
/// tries to autoload a texture if a string is passed into the constructor | |
/// if no texture, container has no width or height | |
/// position, scale and rotation are implicit local transforms | |
/// </summary> | |
public class Container : IList<Container> |