public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[0]; // // if(init){ // for(int i = 0; i < pulseCenter.Length; i++){ // if(Vector3.Distance(pulseCenter[i], linePos) <= // Vector3.Distance(pulseCenter[i], pulseClosest[i])){ // pulseClosest[i] = linePos; // } // } // } // result = new Vector3[2]; result[0] = UtilScript.CloneVec3(linePos); result[1] = UtilScript.CloneVec3(linePos); result[0].y = topY; result[1].y = bottomY; return(result); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[2]; Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); float midX = ((topX + bottomX) / 2); float midZ = ((topZ + bottomZ) / 2); float xPos = linePos.x; float zPos = linePos.z; float hypot = Mathf.Sqrt(Mathf.Pow(xPos - midX, 2) + Mathf.Pow(zPos - midZ, 2)); float hypotAdjusted = hypot - counter * 130f; float mod = (Mathf.Sin(linePos.x / 200f + linePos.z / 200f + counter / 3f) + Mathf.Sin(linePos.x / 200f - linePos.z / 200f - counter / 3f)) / 2f; float waveHeight = linePos.y + mod * topY * .4f; result[0] = new Vector3(xPos, waveHeight, zPos); result[1] = new Vector3(xPos, waveHeight - 50f, zPos); return(result); }
//TODO calc vert positions once, save performance List <float> GetIntersectList(Vector3 vec) { result.Clear(); for (int i = 0; i < tris.Length; i += 3) { int vert1 = tris[i]; int vert2 = tris[i + 1]; int vert3 = tris[i + 2]; vec1 = verts[vert1]; vec2 = verts[vert2]; vec3 = verts[vert3]; Vector3 inter = UtilScript.CloneVec3(vec); inter.y = front[2].y * 10; Vector3 normal = (normals[vert1] + normals[vert2] + normals[vert3]) / 3; inter = checkIntersectTri(vec1, vec2, vec3, inter, down, temp, normal); if (inter.y > -1001) { result.Add(inter.y); } } return(result); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { if (frontBottomY < bottomY) { frontBottomY = bottomY; } if (frontBottomZ > bottomZ) { frontBottomZ = bottomZ; // + 0.01f; } Vector3[] result = new Vector3[2]; Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = bottomY; vec2.y = bottomY; Vector3 pivot = new Vector3(vec1.x, frontBottomY, bottomZ); float dist = Vector3.Distance(vec1, pivot); if (maxDist < dist) { maxDist = dist; } float angle = Mathf.PI * 2; vec1.y = frontBottomY; vec1.z = dist + frontBottomZ; if (lineNum == 500) { // 500: 0.4266512 ,-0.3809375, -0.1321059 // 500: 0.4266512 ,-0.3809375, -0.1321059 print("500: " + vec1.x + " ," + vec1.y + ", " + vec1.z); } if (Time.frameCount == 10) { print("HERE"); botList.Add(vec1); topList.Add(new Vector3(linePos.x, topY, linePos.z)); } vec2 = new Vector3(vec1.x + 0.01f, vec1.y, vec1.z); result[0] = vec2; result[1] = vec1; return(result); }
void DrawLine(Vector3 top, Vector3 bottom, Material rMat) { if (top.y < bottom.y) { Vector3 temp = top; top = bottom; bottom = temp; } if (recordName) { Debug.Log(rMat.name); currentFrame.AddLine(new LumarcaLine(top, bottom, rMat.name)); } //Calc Dots float dotSize = cfs.physicalHeight / 75f; Vector3 newTop = UtilScript.CloneVec3(top); newTop.y -= dotSize; Vector3 newBot = UtilScript.CloneVec3(bottom); newBot.y += dotSize; //Draw material lines rMat.SetPass(0); GL.Begin(GL.LINES); if (calibration) { GL.Color(Color.red); } GL.Vertex(newTop); GL.Vertex(newBot); GL.End(); //Add Dots mat.SetPass(0); GL.Begin(GL.LINES); GL.Color(Color.white); GL.Vertex(newTop); GL.Vertex(top); GL.Vertex(newBot); GL.Vertex(bottom); GL.End(); }
// Use this for initialization void Start() { // float input = 237.5654665f; // // float part1 = GetColorPart1(input, 0, 1024); // float part2 = GetColorPart2(input, 0, 1024); // // Debug.Log ("MAP1: " + part1); // Debug.Log ("MAP2: " + part2); // Debug.Log ("Convert: " + PartsToFloat(part1, part2, 0, 1024)); cam = Camera.main; cfs = cam.GetComponent <CameraFrustrumScript>(); front = cfs.GetFrontPlane(); back = new Vector3[4]; for (int i = 0; i < front.Length; i++) { back[i] = UtilScript.CloneVec3(front[i]); back[i].z = front[0].z + cam.farClipPlane - cam.nearClipPlane; } totalWidth = front[1].x - front[0].x; totalHeight = front[2].y - front[0].y; totalDepth = back[0].z - front[0].z; Debug.Log("totalWidth: " + totalWidth); Debug.Log("totalHeight: " + totalHeight); Debug.Log("totalDepth: " + totalDepth); camPos = cam.transform.position; gridDivide = (int)Mathf.Ceil(Mathf.Sqrt(lineConfiguration)); if (lumarcaMode == LUMARCA_MODE.Dots) { GenerateDots(); } else { GenerateLines(); MultiPerDepthAndCutOutsideOfCube(); } Debug.Log("Lines: " + lines.Count); SetColorToPart(); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); if (!lefts.Contains(lineNum) && !rights.Contains(lineNum)) { if (linePos.x <= 0) { AddedSortToList(lefts, lineNum, linePos); } else { AddedSortToList(rights, lineNum, linePos); } allPos.Add(lineNum, linePos); } else { if (lineNum == lineLeftNum) { Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; result.Add(vec1); result.Add(vec2); } else if (lineNum == lineRightNum) { Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; result.Add(vec1); result.Add(vec2); } } return(result.ToArray()); }
List <Vector3> drawLine(Vector3 linePos, Material pasMat, float topY, float bottomY) { List <Vector3> vecs = new List <Vector3>(); mat = pasMat; Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; vecs.Add(vec1); vecs.Add(vec2); return(vecs); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[2]; result[0] = UtilScript.CloneVec3(linePos); result[1] = UtilScript.CloneVec3(linePos); result[0].y += +10 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 100; result[1].y += -10 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 100; float col = UtilScript.Map(result[0].y, linePos.y - 100, linePos.y + 100, 0, 1); mat.color = new Color(col, 1 - col, 1, 1); return(result); }
// Use this for initialization void Start() { Cursor.visible = false; SetMaterial(); pool = new List <Vector3>(); for (int i = 0; i < 10000; i++) { pool.Add(new Vector3()); } result = new List <float>(); TextAsset asset = Resources.Load("positions") as TextAsset; Stream s = new MemoryStream(asset.bytes); BinaryReader reader = new BinaryReader(s); // BinaryReader reader = new BinaryReader(File.Open("positions.json", FileMode.Open)); JSONNode ja = SimpleJSON.JSONNode.Deserialize(reader); for (int i = 0; i < ja.Count; i++) { Vector3 vec = UtilScript.JsonToVector3(ja[i]); posList.Add(vec); } pos = posList.ToArray(); Debug.Log("Num Lines: " + pos.Length); CameraFrustumScript cfs = Camera.main.GetComponent <CameraFrustumScript>(); front = cfs.GetFrontPlane(); back = new Vector3[4]; for (int i = 0; i < front.Length; i++) { back[i] = UtilScript.CloneVec3(front[i]); back[i].z = Camera.main.farClipPlane - Camera.main.nearClipPlane; } }
public virtual Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; result.Add(vec1); result.Add(vec2); mat.color = new Color(1, 0, 0); return(result.ToArray()); }
void DrawLine(Vector3 top, Vector3 bottom, Material rMat) { rMat.SetPass(0); GL.Begin(GL.LINES); if (calibration) { GL.Color(Color.red); } GL.Vertex(top); GL.Vertex(bottom); GL.End(); mat.SetPass(0); Vector3 top2 = UtilScript.CloneVec3(top); top2.y += 10; Vector3 bottom2 = UtilScript.CloneVec3(bottom); bottom2.y -= 10; GL.Begin(GL.LINES); GL.Color(Color.white); GL.Vertex(top); GL.Vertex(top2); GL.End(); GL.Begin(GL.LINES); GL.Color(Color.white); GL.Vertex(bottom); GL.Vertex(bottom2); GL.End(); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = bottomY + 0.725f + Mathf.PerlinNoise(counter + linePos.x * 2, counter + linePos.z * 2) * 0.1f; vec2.y = vec1.y - 0.025f; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 1, linePos.y + 1, 0, 1); // Debug.Log(col); mat.color = new Color(0.15f, 0.35f, 0.5f, 1); return(result.ToArray()); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y += 300 + 5 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 50; vec2.y += 300 - 5 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 50; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 100, linePos.y + 100, 0, 1); // Debug.Log(col); mat.color = new Color(0.3f, 0.75f, 1, 1); return(result.ToArray()); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y += +0.1f + (Mathf.Sin(counter + linePos.x * 3) + Mathf.Sin(counter - linePos.z * -3)) * 0.11f; vec1.y += -0.1f + (Mathf.Sin(counter + linePos.x * 3) + Mathf.Sin(counter - linePos.z * -3)) * 0.11f; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 1, linePos.y + 1, 0, 1); // Debug.Log(col); mat.color = new Color(col, 1 - col, 1, 1); return(result.ToArray()); }
void showCalibrationLines() { if (drawCube) { DrawBox(); } if (depthList == null) { makeDepthList(); } Vector3 line = pos[depthList[currentLine]]; Vector3 top = UtilScript.CloneVec3(line); Vector3 bottom = UtilScript.CloneVec3(line); top.y = front[0].y; bottom.y = front[2].y; DrawLine(top, bottom, mat); if (drawAll) { foreach (Vector3 vec in pos) { top = UtilScript.CloneVec3(vec); bottom = UtilScript.CloneVec3(vec); top.y = front[0].y; bottom.y = front[2].y; DrawLine(top, bottom, mat); } } }
// Use this for initialization void Start() { Cursor.visible = false; ray = new Ray(); BinaryReader reader = new BinaryReader(File.Open("DotPositions.json", FileMode.Open)); // JSONNode ja = SimpleJSON.JSONNode.Deserialize(reader); string jsonStr = reader.ReadString(); JObject ja = JsonConvert.DeserializeObject(jsonStr) as JObject; for (int i = 0; i < ja.Count; i++) { Vector3 vec = UtilScript.JsonToVector3(ja[i]); posList.Add(vec); } Dictionary <int, List <Vector3> > sameDepth = new Dictionary <int, List <Vector3> >(); dotsByZY = new Dictionary <int, Dictionary <int, List <Vector3> > >(); quadsByZY = new Dictionary <int, Dictionary <int, List <GameObject> > >(); //Sort all the dots at the same depth into a temporary Dictionary foreach (Vector3 dPos in posList) { if (!sameDepth.ContainsKey((int)dPos.z)) { sameDepth.Add((int)dPos.z, new List <Vector3>()); } sameDepth[(int)dPos.z].Add(dPos); } //Sort all the dots into a Dictionary of Dictionarys, sorted by Z and Y //This makes rows of dots, or lines, which we can then use to check intersections foreach (int z in sameDepth.Keys) { dotsByZY.Add(z, new Dictionary <int, List <Vector3> >()); List <Vector3> list = sameDepth[z]; foreach (Vector3 zPos in list) { if (!dotsByZY[z].ContainsKey((int)zPos.y)) { dotsByZY[z].Add((int)zPos.y, new List <Vector3>()); } dotsByZY[z][(int)zPos.y].Add(zPos); } } int totalLines = 0; //Count up all the lines, create a Quad for each position foreach (int zVal in dotsByZY.Keys) { Dictionary <int, List <Vector3> > dict = dotsByZY[zVal]; if (debugMessages) { Debug.Log("->" + zVal + ": " + dict.Count); } quadsByZY.Add(zVal, new Dictionary <int, List <GameObject> >()); foreach (int yVal in dict.Keys) { List <Vector3> line = dict[yVal]; if (debugMessages) { Debug.Log("---->" + yVal + ": " + line.Count); } quadsByZY[zVal].Add(yVal, new List <GameObject>()); foreach (Vector3 vec in line) { GameObject q = Instantiate(Resources.Load("Quad")) as GameObject; q.transform.localScale = new Vector3(dotSize / 2, dotSize / 2, dotSize / 2); q.transform.position = vec; q.SetActive(false); quadsByZY[zVal][yVal].Add(q); } totalLines++; } } if (debugMessages) { Debug.Log("totalLines: " + totalLines); } int posCount = 0; CameraFrustrumScript cfs = Camera.main.GetComponent <CameraFrustrumScript>(); front = cfs.GetFrontPlane(); back = new Vector3[4]; for (int i = 0; i < front.Length; i++) { back[i] = UtilScript.CloneVec3(front[i]); back[i].z = Camera.main.farClipPlane - Camera.main.nearClipPlane; } }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); if (!lefts.Contains(lineNum) && !rights.Contains(lineNum)) { if (linePos.x <= 0) { AddedSortToList(lefts, lineNum, linePos); } else { AddedSortToList(rights, lineNum, linePos); } allPos.Add(lineNum, linePos); } else { if (calMode) { if (lefts.Contains(indexCallOut) && upCall) { indexLeft = lefts.IndexOf(indexCallOut); upCall = false; } else if (rights.Contains(indexCallOut) && upCall) { indexRight = rights.IndexOf(indexCallOut); upCall = false; } mat = mats[4]; if (lineNum == lineLeftNum) { lNum.text = "line: " + lineNum; Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; result.Add(vec1); result.Add(vec2); } else if (lineNum == lineRightNum) { rNum.text = "line: " + lineNum; Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = topY; vec2.y = bottomY; result.Add(vec1); result.Add(vec2); } } else { switch (lineNum) { // case 616: // result = drawLine(linePos, mats[0], topY, bottomY); // break; case 25: result = drawLine(linePos, mats[1], topY, bottomY); break; case 75: result = drawLine(linePos, mats[2], topY, bottomY); break; case 150: print(linePos); result = drawLine(linePos, mats[3], topY, bottomY); break; default: break; } } // if(lineNum == 616 || lineNum == 567 || lineNum == 62 || lineNum == 0){ // // rNum.text = "line: " + lineRightNum; // // Vector3 vec1 = UtilScript.CloneVec3(linePos); // Vector3 vec2 = UtilScript.CloneVec3(linePos); // // vec1.y = topY; // vec2.y = bottomY; // // result.Add(vec1); // result.Add(vec2); // } } return(result.ToArray()); }
// Use this for initialization void Start() { Cursor.visible = false; SetMaterial(); pool = new List <Vector3>(); for (int i = 0; i < 10000; i++) { pool.Add(new Vector3()); } result = new List <float>(); TextAsset asset = Resources.Load(jsonLineFile) as TextAsset; JObject j1 = JObject.Parse(asset.text); JArray ja = j1["positions"] as JArray; for (int i = 0; i < ja.Count; i++) { Vector3 vec = UtilScript.JsonToVector3(ja[i]); posList.Add(vec); } pos = posList.ToArray(); Debug.Log("Num Lines: " + pos.Length); cfs = Camera.main.GetComponent <CameraFrustrumScript>(); // jObject["lumarcaSize"] = cfs.physicalWidth; // jObject["ProjPos"] = UtilScript.Vector3ToJson(cfs.transform.position); // jObject["ThrowRatio"] = cfs.throwRatio; // jObject["PhysicalWidth"] = cfs.physicalWidth; // jObject["CeilingMount"] = cfs.ceilingMounted; // JArray jPositions = new JArray(); // jObject["positions"] = jPositions; Vector3 projPos = new Vector3( (float)j1[LumarcaGenerator.PROP_PROJ_POS]["x"], (float)j1[LumarcaGenerator.PROP_PROJ_POS]["y"], (float)j1[LumarcaGenerator.PROP_PROJ_POS]["z"]); cfs.SetupCamera( (float)j1[LumarcaGenerator.PROP_PHYSICAL_WIDTH], projPos, (float)j1[LumarcaGenerator.PROP_THROW_RATIO], (bool)j1[LumarcaGenerator.PROP_CEILING_MOUNT]); front = cfs.GetFrontPlane(); back = new Vector3[4]; for (int i = 0; i < front.Length; i++) { back[i] = UtilScript.CloneVec3(front[i]); back[i].z = front[0].z + Camera.main.farClipPlane - Camera.main.nearClipPlane; } foreach (LumarcaAnimation la in lumarcaAnimations) { la.LoadFromJSON(); } GetComponent <LumarcaAnimation>(); if (recordName) { recordAnimation = gameObject.AddComponent <LumarcaAnimation>(); } }