private void Update() { if (queue.Count != 0) { if (isRunning == false) { EquationSet es = queue.Dequeue(); var go = new GameObject("Mesh Visualizer" + meshVisuals.Count); go.transform.SetParent(transform); go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; var mrenderer = go.AddComponent <MeshRenderer>(); mrenderer.material = new Material(Shader.Find("Wireframe")); MeshFilter meshVisual = go.AddComponent <MeshFilter>(); meshVisuals.Add(meshVisual); uMin = es.uMin; uMax = es.uMax; vMin = es.vMin; vMax = es.vMax; solver.SetGlobalVariable("u", uMin * Mathf.PI); solver.SetGlobalVariable("v", vMin * Mathf.PI); expX = solver.SymbolicateExpression(es.exprX); expY = solver.SymbolicateExpression(es.exprY); expZ = solver.SymbolicateExpression(es.exprZ); varU = solver.GetGlobalVariable("u"); varV = solver.GetGlobalVariable("v"); meshVisual.transform.localScale = Vector3.one * es.scale; positions.Clear(); normals.Clear(); faces.Clear(); uvs.Clear(); mappingCache = new Dictionary <Vector2, Vector3>(); Vector3 v0 = MapPoint01(0, 0); Vector3 n0 = GetNormal01(0, 0); positions.Add(v0); normals.Add(n0); uvs.Add(new Vector2(0, 0)); Vector3 v1 = MapPoint01(0, 1); Vector3 n1 = GetNormal01(0, 1); positions.Add(v1); normals.Add(n1); uvs.Add(new Vector2(0, 1)); Vector3 v2 = MapPoint01(1, 1); Vector3 n2 = GetNormal01(1, 1); positions.Add(v2); normals.Add(n2); uvs.Add(new Vector2(1, 1)); Vector3 v3 = MapPoint01(1, 0); Vector3 n3 = GetNormal01(1, 0); positions.Add(v3); normals.Add(n3); uvs.Add(new Vector2(1, 0)); Tessellate(ref meshVisual, 0, 1, 2, 3); //tessel = StartCoroutine(Tessellate(0, 1, 2, 3)); } } }
private void Update() { if (queue.Count != 0) { if (isRunning == false) { EquationSet es = queue.Dequeue(); uMin = es.uMin; uMax = es.uMax; vMin = es.vMin; vMax = es.vMax; solver.SetGlobalVariable("u", uMin * Mathf.PI); solver.SetGlobalVariable("v", vMin * Mathf.PI); expX = solver.SymbolicateExpression(es.exprX); expY = solver.SymbolicateExpression(es.exprY); expZ = solver.SymbolicateExpression(es.exprZ); varU = solver.GetGlobalVariable("u"); varV = solver.GetGlobalVariable("v"); positions.Clear(); normals.Clear(); faces.Clear(); uvs.Clear(); mappingCache = new Dictionary <Vector2, Vector3>(); Vector3 v0 = MapPoint01(0, 0); Vector3 n0 = GetNormal01(0, 0); positions.Add(v0); normals.Add(n0); uvs.Add(new Vector2(0, 0)); Vector3 v1 = MapPoint01(0, 1); Vector3 n1 = GetNormal01(0, 1); positions.Add(v1); normals.Add(n1); uvs.Add(new Vector2(0, 1)); Vector3 v2 = MapPoint01(1, 1); Vector3 n2 = GetNormal01(1, 1); positions.Add(v2); normals.Add(n2); uvs.Add(new Vector2(1, 1)); Vector3 v3 = MapPoint01(1, 0); Vector3 n3 = GetNormal01(1, 0); positions.Add(v3); normals.Add(n3); uvs.Add(new Vector2(1, 0)); Tessellate(0, 1, 2, 3); //tessel = StartCoroutine(Tessellate(0, 1, 2, 3)); } } }
// Use this for initialization void Start() { solver = new ExpressionSolver(); expZ = new AK.Expression(); //Variable varU = new Variable(), varV = new Variable(); positions = new List <Vector3>(); normals = new List <Vector3>(); uvs = new List <Vector2>(); faces = new List <int>(); /* TEST */ solver.SetGlobalVariable("x", -5); solver.SetGlobalVariable("y", -5); expZ = solver.SymbolicateExpression(expressionZ); varU = solver.GetGlobalVariable("x"); varV = solver.GetGlobalVariable("y"); uMin = (float)solver.EvaluateExpression(u_min); uMax = (float)solver.EvaluateExpression(u_max); vMin = (float)solver.EvaluateExpression(v_min); vMax = (float)solver.EvaluateExpression(v_max); TessellateSurface(); left.mesh = TessellateCurve(0, 1, 0, null); right.mesh = TessellateCurve(0, 1, 1, null); back.mesh = TessellateCurve(0, null, 0, 1); front.mesh = TessellateCurve(1, null, 0, 1); }