| @@ -0,0 +1,88 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| public static class g_Utils | ||
| { | ||
| public static float normalize(float val, float min, float max) | ||
| { | ||
| return (val - min) / (max - min); | ||
| } | ||
|
|
||
| public static float lerp(float norm, float min, float max) | ||
| { | ||
| return (max - min) * norm + min; | ||
| } | ||
|
|
||
| public static float map(float val, float sourceMin, float sourceMax, float destMin, float destMax) | ||
| { | ||
| return lerp(normalize(val, sourceMin, sourceMax), destMin, destMax); | ||
| } | ||
|
|
||
| public static float randomRange(float min, float max) | ||
| { | ||
| return min + Random.value * (max - min); | ||
| } | ||
|
|
||
| public static bool InRange(float value, float min, float max) | ||
| { | ||
| return value >= Mathf.Min(min, max) && value <= Mathf.Max(min, max); | ||
| } | ||
|
|
||
| public static bool pointInRect(float x, float y, Vector3 p1, Vector3 p2) | ||
| { | ||
| return InRange(x, p1.x, p2.x) && InRange(y, p1.y, p2.y); | ||
| } | ||
|
|
||
| public static bool pointInCube(Vector3 p0, Vector3 p1, Vector3 p2) | ||
| { | ||
| return InRange(p0.x, p1.x, p2.x) && InRange(p0.y, p1.y, p2.y) && InRange(p0.z, p1.z, p2.z); | ||
| } | ||
|
|
||
| public static int roundNearest(float value, float nearest) | ||
| { | ||
| return (int)(Mathf.Round(value / nearest) * nearest); | ||
| } | ||
|
|
||
| public static Vector3 roundNearestVector(Vector3 value, Vector3 nearest) | ||
| { | ||
| return new Vector3((Mathf.Round(value.x / nearest.x) * nearest.x), | ||
| (Mathf.Round(value.y / nearest.y) * nearest.y), | ||
| (Mathf.Round(value.z / nearest.z) * nearest.z)); | ||
| } | ||
|
|
||
| public static bool rangeIntersect(float min0, float max0, float min1, float max1) | ||
| { | ||
| return Mathf.Max(min0, max0) >= Mathf.Min(min1, max1) && | ||
| Mathf.Min(min0, max0) <= Mathf.Max(min1, max1); | ||
| } | ||
|
|
||
| public static bool rectIntersect(Quad left, Quad right) | ||
| { | ||
| return rangeIntersect(left.vertexPoints[2].vertice.x, left.vertexPoints[3].vertice.x, right.vertexPoints[2].vertice.x, right.vertexPoints[3].vertice.x) | ||
| && rangeIntersect(left.vertexPoints[0].vertice.y, left.vertexPoints[2].vertice.y, right.vertexPoints[0].vertice.y, right.vertexPoints[2].vertice.y); | ||
|
|
||
| //return rangeIntersect(tile.x1, tile.x2, box.topLeft.x, box.topRight.x) | ||
| // && rangeIntersect(tile.y1, tile.y4, box.bottomLeft.y, box.topLeft.y); | ||
| } | ||
|
|
||
| public static Color RandomColor() | ||
| { | ||
| return new Color(randomRange(0, 1.0f), randomRange(0, 1.0f), randomRange(0, 1.0f), 1.0f); | ||
| } | ||
|
|
||
| public static Sprite getSprite(Texture2D _set, int i, int j, int tileWidth, int tileHeight) | ||
| { | ||
|
|
||
| Sprite spr = Sprite.Create(_set, | ||
| new Rect(tileWidth * i, | ||
| tileHeight * j, | ||
| tileWidth, tileHeight), | ||
| new Vector2(0f, 0f), | ||
| 1, | ||
| 1, | ||
| SpriteMeshType.FullRect, | ||
| new Vector4(1, 1, 1, 1)); | ||
| return (Sprite)spr; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,177 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| public class renderBox | ||
| { | ||
| public Vector2 centre; | ||
| public Vector2 topLeft; | ||
| public Vector2 topRight; | ||
| public Vector2 bottomLeft; | ||
| public Vector2 bottomRight; | ||
|
|
||
| public byte sizeW; | ||
| public byte sizeH; | ||
|
|
||
| public int size; | ||
|
|
||
| public renderBox() | ||
| { | ||
| centre = Camera.main.transform.position; | ||
|
|
||
| Vector2 centreScreen = Camera.main.WorldToViewportPoint(centre); | ||
|
|
||
| topLeft = Camera.main.ViewportToWorldPoint(new Vector2(-0.5f, 0.5f) + centreScreen); | ||
|
|
||
| topRight = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.5f) + centreScreen); | ||
|
|
||
| bottomLeft = Camera.main.ViewportToWorldPoint(new Vector2(-0.5f, -0.5f) + centreScreen); | ||
|
|
||
| bottomRight = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, -0.5f) + centreScreen); | ||
|
|
||
| sizeW = (byte)Mathf.RoundToInt(Mathf.Abs(bottomLeft.x - bottomRight.x)); | ||
| sizeH = (byte)Mathf.RoundToInt(Mathf.Abs(bottomLeft.y - topLeft.y)); | ||
|
|
||
| size = sizeW * sizeH; | ||
| } | ||
|
|
||
| void readData() | ||
| { | ||
| //OverWorld.overWorldGrid. | ||
| } | ||
|
|
||
| public void updateBox() | ||
| { | ||
| centre = Camera.main.transform.position; | ||
|
|
||
| Vector2 centreScreen = Camera.main.WorldToViewportPoint(centre); | ||
|
|
||
| topLeft = Camera.main.ViewportToWorldPoint(new Vector2(-0.5f, 0.5f) + centreScreen); | ||
|
|
||
| topRight = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, 0.5f) + centreScreen); | ||
|
|
||
| bottomLeft = Camera.main.ViewportToWorldPoint(new Vector2(-0.5f, -0.5f) + centreScreen); | ||
|
|
||
| bottomRight = Camera.main.ViewportToWorldPoint(new Vector2(0.5f, -0.5f) + centreScreen); | ||
|
|
||
| sizeW = (byte)Mathf.RoundToInt(Mathf.Abs(bottomLeft.x - bottomRight.x)); | ||
| sizeH = (byte)Mathf.RoundToInt(Mathf.Abs(bottomLeft.y - topLeft.y)); | ||
|
|
||
| size = sizeW * sizeH; | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| public class CamWorldView : MonoBehaviour | ||
| { | ||
| public static renderBox viewBox; | ||
| public SpriteRenderer worldSprRnd; | ||
| public int inti; | ||
| public Sprite tile00, tile01, tile02, tile03; | ||
| public GameObject[,] viewPortData; | ||
|
|
||
| void Start() | ||
| { | ||
| viewBox = new renderBox(); | ||
| viewPortData = new GameObject[(Mathf.RoundToInt((viewBox.sizeH/16) * 2)), (Mathf.RoundToInt((viewBox.sizeW / 16) * 2))]; | ||
|
|
||
| for (int i = 0; i < Mathf.RoundToInt(viewBox.sizeH/16) * 2; i+= 1) | ||
| { | ||
| for (int j = 0; j < Mathf.RoundToInt(viewBox.sizeW/16) * 2; j += 1) | ||
| { | ||
| //GameObject obj = new GameObject(); | ||
| //obj.transform.position = (new Vector3(((i * 16)) - viewBox.sizeH, ((j * 16)) - viewBox.sizeW, 10)); | ||
| //obj.transform.parent = this.transform; | ||
| //SpriteRenderer sprRnd = obj.AddComponent<SpriteRenderer>(); | ||
| //sprRnd.sprite = tile00; | ||
| ////sprRnd.material.color = g_Utils.RandomColor(); | ||
| //viewPortData[i, j] = obj; | ||
| //inti++; | ||
| //obj.name = inti.ToString(); | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| void Update () | ||
| { | ||
| viewBox.updateBox(); | ||
| //DrawTile(); | ||
| // | ||
| //Vector3 mPosView1 = Camera.main.ScreenToViewportPoint(Input.mousePosition); | ||
| //GameObject curObj1 = viewPortData[2, 2].gameObject; | ||
| //Vector3 curObjPos1 = Camera.main.ScreenToViewportPoint(curObj1.transform.position); | ||
|
|
||
|
|
||
| for (int i = 0; i < Mathf.RoundToInt(viewBox.sizeH / 16) * 2; i += 1) | ||
| { | ||
| for (int j = 0; j < Mathf.RoundToInt(viewBox.sizeW / 16) * 2; j += 1) | ||
| { | ||
| //GameObject curObj = viewPortData[i, j].gameObject; | ||
| // | ||
| //Vector3 w_p1 = new Vector3(curObj.transform.position.x - 8, | ||
| // curObj.transform.position.y - 8, | ||
| // curObj.transform.position.z); | ||
| // | ||
| //Vector3 w_p2 = new Vector3(curObj.transform.position.x + 8, | ||
| // curObj.transform.position.y + 8, | ||
| // curObj.transform.position.z); | ||
| // | ||
| // | ||
| //Vector3 p1 = w_p1;//Camera.main.ScreenToViewportPoint(w_p1); | ||
| //Vector3 p2 = w_p2;// Camera.main.ScreenToViewportPoint(w_p2); | ||
| // | ||
| //Vector3 mPosView = Camera.main.ScreenToWorldPoint(Input.mousePosition); | ||
| // | ||
| //SpriteRenderer curObjSprRnd = curObj.GetComponent<SpriteRenderer>(); | ||
| // | ||
| //if (g_Utils.pointInRect(mPosView.x, mPosView.y, p2, p1) && Input.GetMouseButton(0)) | ||
| //{ | ||
| // Debug.Log("Anus"); | ||
| // //Color | ||
| // //curObjSprRnd.material.color = new Color(curObjSprRnd.material.color.r - 1.0f, curObjSprRnd.material.color.g -1.0f, curObjSprRnd.material.color.b - 1.0f, 1.0f); | ||
| // curObjSprRnd.sprite = tile03; | ||
| //} | ||
| //else | ||
| //{ | ||
| // //curObjSprRnd.material.color = Color.white; | ||
| //} | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void OnDrawGizmos() | ||
| { | ||
|
|
||
| if (Application.isPlaying) | ||
| { | ||
| for (int i = 0; i < Mathf.RoundToInt(viewBox.sizeH / 16) * 2; i++) | ||
| { | ||
| for (int j = 0; j < Mathf.RoundToInt(viewBox.sizeW / 16) * 2; j++) | ||
| { | ||
|
|
||
| //Gizmos.color = Color.red; | ||
| // | ||
| //GameObject curObj = viewPortData[i, j].gameObject; | ||
| //Vector3 w_p1 = new Vector3(curObj.transform.position.x, | ||
| // curObj.transform.position.y, | ||
| // curObj.transform.position.z); | ||
| // | ||
| //Vector3 w_p2 = new Vector3(curObj.transform.position.x, | ||
| // curObj.transform.position.y, | ||
| // curObj.transform.position.z); | ||
| // | ||
| // | ||
| //Vector3 p1 = Camera.main.ScreenToViewportPoint(w_p1); | ||
| //Vector3 p2 = Camera.main.ScreenToViewportPoint(w_p2); | ||
| // | ||
| //// Gizmos.DrawCube(w_p1, new Vector3(16.0f, 16.0f, 1.0f)); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,32 @@ | ||
| using System; | ||
| using UnityEngine; | ||
|
|
||
| public class Camera_Input : MonoBehaviour | ||
| { | ||
| public float mouseSensitivity = 100.0f; | ||
| public float clampAngle = 80.0f; | ||
|
|
||
| private float rotY = 0.0f; // rotation around the up/y axis | ||
| private float rotX = 0.0f; // rotation around the right/x axis | ||
|
|
||
| void Start() | ||
| { | ||
| Vector3 rot = transform.localRotation.eulerAngles; | ||
| rotY = rot.y; | ||
| rotX = rot.x; | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
| float mouseX = Input.GetAxis("Mouse X"); | ||
| float mouseY = -Input.GetAxis("Mouse Y"); | ||
|
|
||
| rotY += mouseX * mouseSensitivity * Time.deltaTime; | ||
| rotX += mouseY * mouseSensitivity * Time.deltaTime; | ||
|
|
||
| rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle); | ||
|
|
||
| Quaternion localRotation = Quaternion.Euler(rotX, rotY, 0.0f); | ||
| transform.rotation = localRotation; | ||
| } | ||
| } |
| @@ -0,0 +1,163 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using System; | ||
|
|
||
| [Serializable] | ||
| public class OverWorld : MonoBehaviour | ||
| { | ||
| public static OverWorld oWorld_instance = null; | ||
| public int worldSize = 100; | ||
| public int tileW, tileH; | ||
| public WorldTileInfo[,] overWorldGrid; | ||
| public WorldData worldData; | ||
|
|
||
|
|
||
| public static OverWorld instance | ||
| { | ||
| get | ||
| { | ||
| if(oWorld_instance == null) | ||
| { | ||
| //Magic Time Baby | ||
| oWorld_instance = FindObjectOfType(typeof(OverWorld)) as OverWorld; | ||
| } | ||
|
|
||
| if(oWorld_instance == null) | ||
| { | ||
| GameObject obj = new GameObject("OverWorld Manager"); | ||
| oWorld_instance = obj.AddComponent(typeof(OverWorld)) as OverWorld; | ||
| Debug.Log("Couldnt Find OverWorld Manager, So I made a new one"); | ||
| } | ||
|
|
||
| return oWorld_instance; | ||
| } | ||
| } | ||
|
|
||
| void OnApplicationQuit() | ||
| { | ||
| oWorld_instance = null; | ||
| } | ||
|
|
||
| void Awake () | ||
| { | ||
| GenereteWorld(); | ||
| worldData.createWorld(); | ||
|
|
||
| } | ||
|
|
||
| void GenereteWorld() | ||
| { | ||
|
|
||
| //Initilizing/Creating World Data | ||
| overWorldGrid = new WorldTileInfo[worldSize, worldSize]; | ||
|
|
||
| for (int i = 0; i < worldSize; i++) | ||
| { | ||
| for (int j = 0; j < worldSize; j++) | ||
| { | ||
| overWorldGrid[i % worldSize, j % worldSize].tileCol = g_Utils.RandomColor(); | ||
| overWorldGrid[i % worldSize, j % worldSize].tileID = Mathf.RoundToInt(UnityEngine.Random.Range(0, 255)); | ||
| overWorldGrid[i % worldSize, j % worldSize].centre.x = (i * tileW); | ||
| overWorldGrid[i % worldSize, j % worldSize].centre.y = (j * tileH); | ||
|
|
||
| overWorldGrid[i % worldSize, j % worldSize].sizeX = tileW; | ||
| overWorldGrid[i % worldSize, j % worldSize].sizeY = tileH; | ||
|
|
||
| overWorldGrid[i % worldSize, j % worldSize].setup(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public struct WorldTileInfo | ||
| { | ||
| public int x1; | ||
| public int y1; | ||
| public int x2; | ||
| public int y2; | ||
| public int x3; | ||
| public int y3; | ||
| public int x4; | ||
| public int y4; | ||
|
|
||
| public Vector2 centre; | ||
|
|
||
| public int sizeX, sizeY; | ||
| public int tileID; | ||
|
|
||
| public Color tileCol; | ||
|
|
||
| public void setup() | ||
| { | ||
|
|
||
| int sXHalf = sizeX / 2; | ||
| int sYHalf = sizeY / 2; | ||
|
|
||
| x1 = Mathf.RoundToInt(centre.x - sXHalf); | ||
| y1 = Mathf.RoundToInt(centre.y + sYHalf); | ||
| x2 = Mathf.RoundToInt(centre.x + sXHalf); | ||
| y2 = Mathf.RoundToInt(centre.y + sYHalf); | ||
| x3 = Mathf.RoundToInt(centre.x + sXHalf); | ||
| y3 = Mathf.RoundToInt(centre.y - sYHalf); | ||
| x4 = Mathf.RoundToInt(centre.x - sXHalf); | ||
| y4 = Mathf.RoundToInt(centre.y - sYHalf); | ||
| } | ||
|
|
||
| public void DrawTile(Color col) | ||
| { | ||
| //Gizmos.color = col; | ||
| // | ||
| //Vector3 c = new Vector3(centre.x, centre.y, Camera.main.farClipPlane - 1); | ||
| // | ||
| //Vector3 p1 = new Vector3(x1, y1, Camera.main.farClipPlane - 1); | ||
| //Vector3 p2 = new Vector3(x2, y2, Camera.main.farClipPlane - 1); | ||
| //Vector3 p3 = new Vector3(x3, y3, Camera.main.farClipPlane - 1); | ||
| //Vector3 p4 = new Vector3(x4, y4, Camera.main.farClipPlane - 1); | ||
| // | ||
| //Gizmos.color = Color.black; | ||
| //Gizmos.DrawLine(p1, p2); | ||
| //Gizmos.color = Color.yellow; | ||
| //Gizmos.DrawLine(p2, p3); | ||
| //Gizmos.color = Color.magenta; | ||
| //Gizmos.DrawLine(p3, p4); | ||
| //Gizmos.color = Color.blue; | ||
| //Gizmos.DrawLine(p4, p1); | ||
| // | ||
| ////Gizmos.DrawSphere(p1, .1f); | ||
| ////Gizmos.DrawSphere(p2, .1f); | ||
| ////Gizmos.DrawSphere(p3, .1f); | ||
| ////Gizmos.DrawSphere(p4, .1f); | ||
| // | ||
| //Gizmos.color = Color.green; | ||
| ////Gizmos.DrawSphere(c, .1f); | ||
| } | ||
| } | ||
|
|
||
| public struct WorldData | ||
| { | ||
| public int[,] worldData; | ||
|
|
||
| public void createWorld() | ||
| { | ||
| worldData = NewWorld(); | ||
| } | ||
|
|
||
| int[,] NewWorld() | ||
| { | ||
| int[,] newWorld = new int[,] | ||
| { | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 2, 2, 1, 1, 1}, | ||
| {1, 1, 1, 2, 2, 1, 1, 1}, | ||
| {1, 1, 1, 2, 2, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1}, | ||
| {1, 1, 1, 1, 1, 1, 1, 1} | ||
| }; | ||
|
|
||
| return newWorld; | ||
| } | ||
| } |
| @@ -0,0 +1,17 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| [ExecuteInEditMode] | ||
| public class Distance_JPA : MonoBehaviour | ||
| { | ||
|
|
||
| //public Shader m_Shader = null; | ||
| public Material DT_JPA; | ||
| public RenderTexture JPA_STORE; | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
| Graphics.Blit(src, dst, DT_JPA); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,16 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
|
|
||
| public class Distance_SnapShot : MonoBehaviour | ||
| { | ||
| public Material DT_SnapeShot; | ||
| public RenderTexture JPA_SNAPSHOT; | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
| Graphics.Blit(src, dst, DT_SnapeShot); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,55 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
|
|
||
| public class Distance_Transform : MonoBehaviour | ||
| { | ||
| public Material DT_Final; | ||
|
|
||
|
|
||
| public Texture RampText; | ||
| Vector3 camScreen; | ||
| // Use this for initialization | ||
| public RenderTexture Outline_Texture; | ||
| public Texture Noise_Texture; | ||
| public GameObject canvas; | ||
| void OnValidate() | ||
| { | ||
|
|
||
| Shader.SetGlobalTexture("_Outline_Tex", Outline_Texture); | ||
| Shader.SetGlobalTexture("_Noise", Noise_Texture); | ||
| //Shader.SetGlobalTexture("_JPA_Store", JPA_STORE); | ||
| //Shader.SetGlobalTexture("_SNAPSHOT_Store", JPA_SNAPSHOT); | ||
| Shader.SetGlobalTexture("_RampTex", RampText); | ||
| //canvas.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = JPA_Snap2; | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
| //JPA_Snap2 = getTexture2DFromRenderTexture(Outline_Texture); | ||
| Vector2 M_Pos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); | ||
| DT_Final.SetVector("_M", M_Pos); | ||
|
|
||
| } | ||
|
|
||
| public Texture2D getTexture2DFromRenderTexture(RenderTexture rTex) | ||
| { | ||
|
|
||
| Texture2D texture2D = new Texture2D(rTex.width, rTex.height); | ||
| RenderTexture.active = rTex; | ||
| texture2D.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0); | ||
| texture2D.Apply(); | ||
| return texture2D; | ||
|
|
||
| } | ||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
|
|
||
| //Graphics.Blit(Outline_Texture, JPA_STORE, DT_JPA); | ||
| //Graphics.Blit(JPA_STORE, JPA_SNAPSHOT, DT_SnapeShot); | ||
| Graphics.Blit(src, dst, DT_Final); | ||
| //DT_Final.mainTexture = screenRT; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,70 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
|
|
||
| public class Kuwahara : MonoBehaviour | ||
| { | ||
|
|
||
| //public Shader m_Shader = null; | ||
| private Material m_Material; | ||
|
|
||
| RenderTexture screenRT; | ||
| RenderTexture finalRT; | ||
| RenderTexture depthRT; | ||
| public Texture2D m_noiseTextre; | ||
|
|
||
| Shader SSAO_Shader; | ||
|
|
||
| public Camera mainCam; | ||
|
|
||
| // Use this for initialization | ||
| void Awake() | ||
| { | ||
| screenRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| screenRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| finalRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| finalRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
| //depthRT.DepthTextureMode = DepthTextureMode.DepthNormals; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
|
|
||
| SSAO_Shader = Shader.Find("Custom/Gene/PostEffect/OilPainter"); | ||
| m_Material = new Material(SSAO_Shader); | ||
|
|
||
| mainCam = GetComponent<Camera>(); | ||
| mainCam.depthTextureMode = DepthTextureMode.DepthNormals; | ||
| mainCam.SetTargetBuffers(screenRT.colorBuffer, depthRT.depthBuffer); | ||
| mainCam.cullingMask &= ~(1 << LayerMask.NameToLayer("OilPanter")); | ||
| } | ||
|
|
||
| void OnPostRender() | ||
| { | ||
| //Final = Screen + Depth | ||
| screenRT.DiscardContents(); | ||
| finalRT.DiscardContents(); | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
|
|
||
| } | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
| if (SSAO_Shader && m_Material) | ||
| { | ||
| Graphics.Blit(src, dst, m_Material); | ||
| // Graphics.Blit(src, screenRT, m_Material); | ||
|
|
||
| m_Material.mainTexture = screenRT; | ||
| // m_Material.SetTexture("_NoiseTex", m_noiseTextre); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,48 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
|
|
||
| public class Kuwahara_Filter : MonoBehaviour | ||
| { | ||
|
|
||
| //public Shader m_Shader = null; | ||
| public Material Oil_Mat; | ||
|
|
||
| [Range(1, 10)] | ||
| public int Iterations = 1; | ||
| Vector3 camScreen; | ||
| public RenderTexture Outline_Texture; | ||
| public RenderTexture DT_Texture; | ||
| // Use this for initialization | ||
| RenderTexture screenRT; | ||
| void Start() | ||
| { | ||
| screenRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| screenRT.wrapMode = TextureWrapMode.Repeat; | ||
| } | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
|
|
||
| Oil_Mat.SetTexture("_Outline_Tex", Outline_Texture); | ||
| Oil_Mat.SetTexture("_DT_Tex", DT_Texture); | ||
| Oil_Mat.mainTexture = screenRT; | ||
| //render | ||
| RenderTexture rt = RenderTexture.GetTemporary(src.width, src.height); | ||
| Graphics.Blit(src, rt); | ||
|
|
||
|
|
||
| for(int i = 0; i < Iterations; i++) | ||
| { | ||
| RenderTexture rt2 = RenderTexture.GetTemporary(rt.width, rt.height); | ||
| Graphics.Blit(rt, rt2, Oil_Mat); | ||
| RenderTexture.ReleaseTemporary(rt); | ||
| rt = rt2; | ||
| } | ||
|
|
||
| Graphics.Blit(rt, dst, Oil_Mat); | ||
| RenderTexture.ReleaseTemporary(rt); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,72 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
| public class SSAO : MonoBehaviour { | ||
|
|
||
| //public Shader m_Shader = null; | ||
| private Material m_Material; | ||
|
|
||
| RenderTexture screenRT; | ||
| RenderTexture finalRT; | ||
| RenderTexture depthRT; | ||
|
|
||
| [Range(0,10)] public float DepthValue = 1; | ||
|
|
||
| public Texture2D m_noiseTextre; | ||
|
|
||
| Shader SSAO_Shader; | ||
|
|
||
| public Camera mainCam; | ||
|
|
||
| // Use this for initialization | ||
| void Awake () | ||
| { | ||
| screenRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| screenRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| finalRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| finalRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
| //depthRT.DepthTextureMode = DepthTextureMode.DepthNormals; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
|
|
||
| SSAO_Shader = Shader.Find("Custom/Gene/PostEffect/SSAO"); | ||
| m_Material = new Material(SSAO_Shader); | ||
|
|
||
| mainCam = GetComponent<Camera>(); | ||
| mainCam.depthTextureMode = DepthTextureMode.DepthNormals; | ||
| mainCam.SetTargetBuffers(screenRT.colorBuffer, depthRT.depthBuffer); | ||
| mainCam.cullingMask &= ~(1 << LayerMask.NameToLayer("SSAO")); | ||
| } | ||
|
|
||
| void OnPostRender() | ||
| { | ||
| //Final = Screen + Depth | ||
| screenRT.DiscardContents(); | ||
| finalRT.DiscardContents(); | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
| m_Material.SetFloat("_DepthValue", DepthValue); | ||
| } | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
| if (SSAO_Shader && m_Material) | ||
| { | ||
| Graphics.Blit(src, dst, m_Material); | ||
| Graphics.Blit(src, screenRT, m_Material); | ||
|
|
||
| m_Material.mainTexture = screenRT; | ||
| m_Material.SetTexture("_NoiseTex", m_noiseTextre); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,76 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| [RequireComponent(typeof(Camera))] | ||
| [ExecuteInEditMode] | ||
|
|
||
| public class V_Painter : MonoBehaviour | ||
| { | ||
|
|
||
| //public Shader m_Shader = null; | ||
| public Material Voronoi_Diagram_Material; | ||
|
|
||
| RenderTexture screenRT; | ||
| RenderTexture finalRT; | ||
| RenderTexture depthRT; | ||
| public Texture BrushDistort; | ||
|
|
||
| public RenderTexture OutPut; | ||
|
|
||
| public Shader VORONOI_PAINTER_SHADER; | ||
|
|
||
| public Camera Cam; | ||
| // Use this for initialization | ||
| void Awake() | ||
| { | ||
| screenRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| screenRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| finalRT = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default); | ||
| finalRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
| depthRT = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.Depth); | ||
| depthRT.wrapMode = TextureWrapMode.Repeat; | ||
|
|
||
|
|
||
| VORONOI_PAINTER_SHADER = Shader.Find("Custom/Gene/PostEffect/Voronoi_Diagram"); | ||
| Voronoi_Diagram_Material = new Material(VORONOI_PAINTER_SHADER); | ||
|
|
||
|
|
||
| Cam = GetComponent<Camera>(); | ||
| Cam.depthTextureMode = DepthTextureMode.DepthNormals; | ||
| Cam.SetTargetBuffers(screenRT.colorBuffer, depthRT.depthBuffer); | ||
| Cam.cullingMask &= ~(1 << LayerMask.NameToLayer("OilPanter")); | ||
|
|
||
| if (VORONOI_PAINTER_SHADER && Voronoi_Diagram_Material) | ||
| { | ||
| Cam.targetTexture = OutPut; | ||
| } | ||
| } | ||
|
|
||
| void OnPostRender() | ||
| { | ||
| //Final = Screen + Depth | ||
|
|
||
| screenRT.DiscardContents(); | ||
| finalRT.DiscardContents(); | ||
| OutPut.DiscardContents(); | ||
| } | ||
|
|
||
| void Update() | ||
| { | ||
| } | ||
|
|
||
| void OnRenderImage(RenderTexture src, RenderTexture dst) | ||
| { | ||
| if (VORONOI_PAINTER_SHADER && Voronoi_Diagram_Material) | ||
| { | ||
| Graphics.Blit(src, dst, Voronoi_Diagram_Material); | ||
| Voronoi_Diagram_Material.SetTexture("_Brush_Map_Tex", (Texture)BrushDistort); | ||
| Voronoi_Diagram_Material.mainTexture = screenRT; | ||
|
|
||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,77 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| public class Map_Sprite_Editor : MonoBehaviour | ||
| { | ||
| public Texture2D mapTMP; | ||
| public Texture2D loadedTexture; | ||
|
|
||
| public bool autoUpdate; | ||
|
|
||
| void Awake () | ||
| { | ||
| if (Resources.Load("Textures/Saved_Map") as Texture2D != null) | ||
| { | ||
| loadedTexture = Resources.Load("Textures/Saved_Map") as Texture2D; | ||
| loadedTexture.filterMode = FilterMode.Point; | ||
| loadedTexture.Apply(); | ||
| } | ||
| else | ||
| NewMap(); | ||
| } | ||
|
|
||
| void Start () | ||
| { | ||
| mapTMP.SetPixels(loadedTexture.GetPixels()); | ||
| mapTMP.Apply(); | ||
| this.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = mapTMP; | ||
| } | ||
|
|
||
| void Update () | ||
| { | ||
| } | ||
|
|
||
| public void Undo() | ||
| { | ||
| mapTMP.SetPixels(loadedTexture.GetPixels()); | ||
| mapTMP.Apply(); | ||
| this.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = mapTMP; | ||
| } | ||
|
|
||
| public void Reset() | ||
| { | ||
| } | ||
|
|
||
| public void Load() | ||
| { | ||
|
|
||
| } | ||
|
|
||
| public void Save() | ||
| { | ||
| GetComponent<PNGUploader>().UploadPNG(mapTMP); | ||
| } | ||
|
|
||
| public void NewMap() | ||
| { | ||
|
|
||
| mapTMP = new Texture2D(16 * 10, 16 * 10); | ||
| mapTMP.name = "Saved_Map"; | ||
| mapTMP.filterMode = FilterMode.Point; | ||
| mapTMP.Apply(); | ||
|
|
||
| GetComponent<PNGUploader>().UploadPNG(mapTMP); | ||
| this.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = mapTMP; | ||
| } | ||
|
|
||
|
|
||
| void OnApplicationQuit() | ||
| { | ||
| this.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = loadedTexture; | ||
| } | ||
|
|
||
| void OnDrawGizmos() | ||
| { | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,40 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
| using System.IO; | ||
|
|
||
| public class PNGUploader : MonoBehaviour | ||
| { | ||
| //Take a shot immeditely | ||
| // IEnumerator Start() | ||
| //{ | ||
| // yield return UploadPNG(); | ||
| // } | ||
|
|
||
| public void UploadPNG(Texture2D tex) | ||
| { | ||
| //We should only read the screen buffer after rendering is complete | ||
| //Create | ||
| tex.filterMode = FilterMode.Point; | ||
| byte[] bytes = tex.EncodeToPNG(); | ||
| string texName = tex.name + ".png"; | ||
| //For testing purposes, also write to a gile in the project folder | ||
| File.WriteAllBytes(Application.dataPath + "/../Assets/Resources/Textures/" + texName, bytes); | ||
| //Create a Web Form | ||
| WWWForm form = new WWWForm(); | ||
| form.AddBinaryData("fileUpload", bytes); | ||
|
|
||
| //Upload to a cgi script?????? | ||
| WWW w = new WWW("http://localhost/cgi-bin/env.cgi?post", form); | ||
| //yield return w; | ||
|
|
||
|
|
||
| if(w.error != null) | ||
| { | ||
| Debug.Log(w.error); | ||
| } | ||
| else | ||
| { | ||
| Debug.Log("FINISHED"); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,160 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| public class Sprite_Paint : MonoBehaviour | ||
| { | ||
| public GameObject Map, m_Icon; | ||
| public Map_Sprite_Editor mapTMP2D; | ||
| public int ResX, ResY, iteration; | ||
|
|
||
| int x, y, oldX, oldY; | ||
| bool update = true, skip; | ||
| Color[,] brushColor, curTileColor; | ||
| Vector2 pixelUV; | ||
|
|
||
| void Awake () | ||
| { | ||
| mapTMP2D = FindObjectOfType<Map_Sprite_Editor>(); | ||
|
|
||
| brushColor = new Color[ResX, ResY]; | ||
| curTileColor = new Color[ResX, ResY]; | ||
| } | ||
|
|
||
| public void ChangePaint(Texture2D img) | ||
| { | ||
| m_Icon.GetComponent<MeshRenderer>().sharedMaterial.mainTexture = img; | ||
| img.filterMode = FilterMode.Point; | ||
| for (int i = 0; i < ResX; i++) | ||
| { | ||
| for (int j = 0; j < ResY; j++) | ||
| { | ||
| brushColor[i, j] = img.GetPixel(i, j); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void Update () | ||
| { | ||
| if (UI_CONTROL.editMode) | ||
| { | ||
| EditMap(); | ||
| } | ||
| } | ||
|
|
||
| void EditMap() | ||
| { | ||
|
|
||
| RaycastHit hit; | ||
|
|
||
| if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) | ||
| { | ||
| pixelUV = hit.textureCoord; | ||
| pixelUV.x *= mapTMP2D.mapTMP.width; | ||
| pixelUV.y *= mapTMP2D.mapTMP.height; | ||
| x = g_Utils.roundNearest(pixelUV.x - 8, mapTMP2D.mapTMP.width / (float)10); | ||
| y = g_Utils.roundNearest(pixelUV.y - 8, mapTMP2D.mapTMP.height / (float)10); | ||
| //if Index Has Changed, update that shit | ||
|
|
||
| if (Input.GetMouseButton(0)) | ||
| { | ||
| PaintBlock(x, y); | ||
| iteration = 0; | ||
| update = true; | ||
| } | ||
| else | ||
| { | ||
| if (update) | ||
| { | ||
| GetPaintBlockInfo(x, y); | ||
| update = false; | ||
| } | ||
|
|
||
| if (oldX != x && iteration >= 1 | ||
| || oldY != y && iteration >= 1) | ||
| { | ||
| ResetPaintBlock(oldX, oldY); | ||
| update = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| else | ||
| { | ||
| if (iteration >= 1) | ||
| { | ||
| ResetPaintBlock(oldX, oldY); | ||
| update = true; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| void PaintBlock(int _x, int _y) | ||
| { | ||
| for (int i = 0; i < ResX; i++) | ||
| { | ||
| for (int j = 0; j < ResY; j++) | ||
| { | ||
| //Then Apply HighLight to Area | ||
| mapTMP2D.mapTMP.SetPixel(_x + i, _y + j, brushColor[i, j]); | ||
| } | ||
| } | ||
|
|
||
| mapTMP2D.mapTMP.Apply(); | ||
| } | ||
|
|
||
| void GetPaintBlockInfo(int _x, int _y) | ||
| { | ||
| for (int i = 0; i < ResX; i++) | ||
| { | ||
| for (int j = 0; j < ResY; j++) | ||
| { | ||
| //Get Current Tile Colors Before Applying | ||
| curTileColor[i, j] = mapTMP2D.mapTMP.GetPixel(_x + i, _y + j); | ||
|
|
||
| //Then Apply HighLight to Area | ||
| mapTMP2D.mapTMP.SetPixel(_x + i, _y + j, Color.red * curTileColor[i, j]); | ||
| } | ||
| } | ||
|
|
||
| //Saving Prevois Pixel Data and index | ||
| CaptureBlockInfo(_x, _y, curTileColor); | ||
| mapTMP2D.mapTMP.Apply(); | ||
| iteration++; | ||
| } | ||
|
|
||
| void CaptureBlockInfo(int _x, int _y, Color[,] col) | ||
| { | ||
| oldX = _x; | ||
| oldY = _y; | ||
|
|
||
| curTileColor = col; | ||
| } | ||
|
|
||
| void ResetPaintBlock(int oldx, int oldy) | ||
| { | ||
| for (int i = 0; i < ResX; i++) | ||
| { | ||
| for (int j = 0; j < ResY; j++) | ||
| { | ||
| mapTMP2D.mapTMP.SetPixel(oldx + i, oldy + j, curTileColor[i, j]); | ||
| } | ||
| } | ||
|
|
||
| mapTMP2D.mapTMP.Apply(); | ||
| } | ||
|
|
||
| void Log<T>(T _log) | ||
| { | ||
| Debug.Log(_log); | ||
| } | ||
|
|
||
| void OnDrawGizmos() | ||
| { | ||
| if(Application.isPlaying) | ||
| { | ||
|
|
||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,83 @@ | ||
| using UnityEngine; | ||
| using UnityEngine.UI; | ||
| using UnityEngine.EventSystems; | ||
| using System.Collections.Generic; | ||
|
|
||
| public class UI_CONTROL : MonoBehaviour | ||
| { | ||
| public static bool editMode; | ||
|
|
||
| public GameObject Edit_Border; | ||
| public Button editButton; | ||
| public Sprite_Paint SprPaint; | ||
| public List<Button> tileIcon = new List<Button>(); | ||
| public Button curButton; | ||
| public Button iconButton; | ||
| public GameObject editBorder; | ||
|
|
||
| void Awake () | ||
| { | ||
| SprPaint = FindObjectOfType<Sprite_Paint>(); | ||
| } | ||
|
|
||
| public void Start () | ||
| { | ||
| for(int i = 0; i < 9; i++) | ||
| { | ||
| Button b = Instantiate(iconButton); | ||
| b.transform.position = new Vector3(iconButton.transform.position.x, 400 - (i * 35f) + 5, 1); | ||
| b.onClick.AddListener(() => ChangeSpritePaint()); | ||
| b.transform.SetParent(editBorder.transform); | ||
| b.name = i.ToString(); | ||
| b.image.sprite = getTile(i % 3, i / 3); | ||
| tileIcon.Add(b); | ||
| } | ||
| } | ||
|
|
||
| public void ChangeSpritePaint() | ||
| { | ||
| Debug.Log("Sprite Changed"); | ||
| Sprite imgPull = (EventSystem.current.currentSelectedGameObject.GetComponent<Image>().sprite); | ||
|
|
||
| Texture2D croppedTexture = new Texture2D(16, 16); | ||
|
|
||
| Color[] pixels = new Color[(int)imgPull.rect.width * (int)imgPull.rect.height]; | ||
|
|
||
| pixels = imgPull.texture.GetPixels((int)imgPull.rect.x, | ||
| (int)imgPull.rect.y, | ||
| (int)imgPull.rect.width, | ||
| (int)imgPull.rect.height); | ||
|
|
||
| croppedTexture.SetPixels(pixels); | ||
| croppedTexture.Apply(); | ||
| SprPaint.ChangePaint(croppedTexture); | ||
| } | ||
|
|
||
| Sprite getTile(int i, int j) | ||
| { | ||
| Texture2D imgLoad = Resources.Load("TileMaps/Tile_Sheet_00") as Texture2D; | ||
| return g_Utils.getSprite(imgLoad, i, j, 16, 16); | ||
| } | ||
|
|
||
| public void Edit() | ||
| { | ||
| editMode = !editMode; | ||
| } | ||
|
|
||
| void Update () | ||
| { | ||
|
|
||
| if(editMode) | ||
| { | ||
| Edit_Border.SetActive(true); | ||
| } | ||
| else | ||
| { | ||
| Edit_Border.SetActive(false); | ||
| } | ||
| } | ||
|
|
||
| void OnDrawGizmos() | ||
| { | ||
| } | ||
| } |
| @@ -0,0 +1,185 @@ | ||
| using UnityEngine; | ||
| using System.Collections; | ||
|
|
||
| [ExecuteInEditMode] | ||
| public struct Matrix3D | ||
| { | ||
| public float r0c0, r0c1, r0c2; | ||
| public float r1c0, r1c1, r1c2; | ||
| public float r2c0, r2c1, r2c2; | ||
|
|
||
| public Matrix3D(float _r0c0 = 1f, float _r0c1 = 0f, float _r0c2 = 0f, | ||
| float _r1c0 = 0f, float _r1c1 = 1f, float _r1c2 = 0f, | ||
| float _r2c0 = 0f, float _r2c1 = 0f, float _r2c2 = 1f) | ||
| { | ||
| r0c0 = _r0c0; | ||
| r0c1 = _r0c1; | ||
| r0c2 = _r0c2; | ||
| r1c0 = _r1c0; | ||
| r1c1 = _r1c1; | ||
| r1c2 = _r1c2; | ||
| r2c0 = _r2c0; | ||
| r2c1 = _r2c1; | ||
| r2c2 = _r2c2; | ||
| } | ||
|
|
||
| public void DebugMatrix() | ||
| { | ||
| //Debug.Log("r0c0 : " + r0c0); | ||
| } | ||
|
|
||
| public Matrix3D RotateZ(float angle) | ||
| { | ||
| float Cosine = Mathf.Cos(angle); | ||
| float Sine = Mathf.Sin(angle); | ||
|
|
||
| Matrix3D Rz = new Matrix3D | ||
| ( | ||
| Cosine, -Sine, 0, | ||
| Sine, Cosine, 0, | ||
| 0, 0, 1 | ||
| ); | ||
|
|
||
| return Rz; | ||
| } | ||
|
|
||
| public Matrix3D RotateX(float angle) | ||
| { | ||
| float Cosine = Mathf.Cos(angle); | ||
| float Sine = Mathf.Sin(angle); | ||
|
|
||
| Matrix3D Rx = new Matrix3D | ||
| ( | ||
| 1, 0, 0, | ||
| 0, Cosine, -Sine, | ||
| 0, Sine, Cosine | ||
| ); | ||
|
|
||
| return Rx; | ||
| } | ||
|
|
||
| public Matrix3D RotateY(float angle) | ||
| { | ||
| float Cosine = Mathf.Cos(angle); | ||
| float Sine = Mathf.Sin(angle); | ||
|
|
||
| Matrix3D Ry = new Matrix3D | ||
| ( | ||
| Cosine, 0, Sine, | ||
| 0, 1, 0, | ||
| -Sine, 0, Cosine | ||
| ); | ||
|
|
||
| return Ry; | ||
| } | ||
|
|
||
| public static Vector3 operator *(Matrix3D matrix, Vector3 vector) | ||
| { | ||
| return new Vector3 | ||
| ( | ||
| matrix.r0c0 * vector.x + matrix.r0c1 * vector.y + matrix.r0c2 * vector.z, | ||
| matrix.r1c0 * vector.x + matrix.r1c1 * vector.y + matrix.r1c2 * vector.z, | ||
| matrix.r2c0 * vector.x + matrix.r2c1 * vector.y + matrix.r2c2 * vector.z); | ||
| } | ||
|
|
||
|
|
||
| public static Matrix3D operator *(Matrix3D left, Matrix3D right) | ||
| { | ||
|
|
||
| return new Matrix3D( | ||
| (left.r0c0 * right.r0c0) + (left.r0c1 * right.r1c0) + (left.r0c2 * right.r2c0), | ||
| (left.r0c0 * right.r0c1) + (left.r0c1 * right.r1c1) + (left.r0c2 * right.r2c1), | ||
| (left.r0c0 * right.r0c2) + (left.r0c1 * right.r1c2) + (left.r0c2 * right.r2c2), | ||
|
|
||
| (left.r1c0 * right.r0c0) + (left.r1c1 * right.r1c0) + (left.r1c2 * right.r2c0), | ||
| (left.r1c0 * right.r0c1) + (left.r1c1 * right.r1c1) + (left.r1c2 * right.r2c1), | ||
| (left.r1c0 * right.r0c2) + (left.r1c1 * right.r1c2) + (left.r1c2 * right.r2c2), | ||
|
|
||
| (left.r2c0 * right.r0c0) + (left.r2c1 * right.r1c0) + (left.r2c2 * right.r2c0), | ||
| (left.r2c0 * right.r0c1) + (left.r2c1 * right.r1c1) + (left.r2c2 * right.r2c1), | ||
| (left.r2c0 * right.r0c2) + (left.r2c1 * right.r1c2) + (left.r2c2 * right.r2c2)); | ||
| } | ||
|
|
||
| public static Matrix3D operator +(Matrix3D left, Matrix3D right) | ||
| { | ||
|
|
||
| return new Matrix3D( | ||
| (left.r0c0 + right.r0c0) , (left.r0c1 + right.r0c1) , (left.r0c2 + right.r0c2), | ||
| (left.r1c0 + right.r1c0) , (left.r1c1 + right.r1c1) , (left.r1c2 + right.r1c2), | ||
| (left.r2c0 + right.r2c0) , (left.r2c1 + right.r2c1) , (left.r2c2 + right.r2c2)); | ||
| } | ||
|
|
||
| } | ||
| /// <summary> | ||
| /// fuck my asshole | ||
| /// </summary> | ||
| public class Water_Diagnostic : MonoBehaviour { | ||
|
|
||
|
|
||
| public Transform mast; | ||
| public float angleX, angleY, angleZ; | ||
| Mesh mesh; | ||
| Vector3[] normals; | ||
| Matrix3D op; | ||
| void Awake() | ||
| { | ||
| //Quaternion | ||
| //transform.Rotate | ||
| mesh = GetComponent<MeshFilter>().mesh; | ||
| normals = mesh.normals; | ||
| } | ||
| // Use this for initialization | ||
| void Start () | ||
| { | ||
| op = new Matrix3D(1, 0, 0, | ||
| 0, 1, 0, | ||
| 0, 0, 1); | ||
|
|
||
| } | ||
|
|
||
| // Update is called once per frame | ||
| void Update () | ||
| { | ||
| } | ||
|
|
||
| void OnDrawGizmos() | ||
| { | ||
| if(Application.isPlaying) | ||
| { | ||
|
|
||
| op = op.RotateX(angleX) * op.RotateY(angleY) * op.RotateZ(angleZ); | ||
| for (uint i = 0; i < normals.Length; i++) | ||
| { | ||
|
|
||
| Gizmos.color = Color.red; | ||
| Vector3 Vector = transform.TransformDirection(mesh.vertices[i]) + transform.TransformDirection(mesh.normals[i]); | ||
|
|
||
| for (uint j = 0; j < normals.Length; j++) | ||
| { | ||
| Vector = op * Vector; | ||
| } | ||
| ////Original Vertex + Normal Direction | ||
| ////Drawing The Vector..Vector | ||
| Gizmos.DrawRay(transform.TransformDirection(mesh.vertices[i]), Vector); | ||
|
|
||
| //Vector3 normalsDir = op * ((Vector - mast.transform.position) * (Mathf.Sin(Time.time) * 0.5f)); | ||
| //Gizmos.color = Color.blue; | ||
|
|
||
| ////Tip To direction - the current Mast | ||
| //Gizmos.DrawRay(Vector, normalsDir / 4); | ||
|
|
||
| //Vector3 Vector2 = (Vector + normalsDir / 4); | ||
|
|
||
| //Vector3 normalDir2 = transform.TransformDirection(mesh.vertices[i]) - Vector2; | ||
|
|
||
| //Gizmos.color = Color.green; | ||
|
|
||
| //Gizmos.DrawRay(Vector2, normalDir2); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } |
| @@ -0,0 +1 @@ | ||
| 5;0;6;-1 |
| @@ -0,0 +1,4 @@ | ||
| sceneSetups: | ||
| - path: Assets/Scenes/Pixel_Lab.unity | ||
| isLoaded: 1 | ||
| isActive: 1 |
| @@ -0,0 +1,2 @@ | ||
| unityRebuildLibraryVersion: 11 | ||
| unityForwardCompatibleVersion: 40 |
| @@ -0,0 +1,2 @@ | ||
| 0000.58087744.0000 | ||
| 0000.58087766.0000 |
| @@ -0,0 +1,2 @@ | ||
| Base path: C:/Program Files/Unity/Editor/Data | ||
| Cmd: getPlatforms |
| @@ -0,0 +1,2 @@ | ||
| m_EditorVersion: 5.4.2f2 | ||
| m_StandardAssetsVersion: 0 |