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));
            }
        }
    }
Example #2
0
 private void Start()
 {
     solver = new ExpressionSolver();
     InitializeParticleSystem();
     varX    = solver.SetGlobalVariable("x", 0);
     varY    = solver.SetGlobalVariable("y", 0);
     xMin    = (float)solver.EvaluateExpression(expressionXMin);
     xMax    = (float)solver.EvaluateExpression(expressionXMax);
     expYMin = solver.SymbolicateExpression(expressionYMin);
     expYMax = solver.SymbolicateExpression(expressionYMax);
     expZMin = solver.SymbolicateExpression(expressionZMin);
     expZMax = solver.SymbolicateExpression(expressionZMax);
     Generate3DRegion();
 }
Example #3
0
    public void UpdateEquation()
    {
        Debug.Log("UpdateEquation()");
        positions = new List <Vector3>();
        normals   = new List <Vector3>();
        uvs       = new List <Vector2>();
        faces     = new List <int>();

        try
        {
            expZ = solver.SymbolicateExpression(expressionZ);
            uMin = (float)solver.EvaluateExpression(u_min);
            uMax = (float)solver.EvaluateExpression(u_max);
            vMin = (float)solver.EvaluateExpression(v_min);
            vMax = (float)solver.EvaluateExpression(v_max);
        }
        catch (AK.ESSyntaxErrorException e)
        {
            return;
        }
        TessellateSurface();
        //StartCoroutine(TessellateSurface());
        sphere.GetComponent <ConstraintGrabbable>().SetXRange(uMin, uMax);
        sphere.GetComponent <ConstraintGrabbable>().SetZRange(vMin, vMax);
    }
Example #4
0
 public void UpdateEquation()
 {
     try
     {
         xMin    = (float)solver.EvaluateExpression(expressionXMin);
         xMax    = (float)solver.EvaluateExpression(expressionXMax);
         expYMin = solver.SymbolicateExpression(expressionYMin);
         expYMax = solver.SymbolicateExpression(expressionYMax);
         expZMin = solver.SymbolicateExpression(expressionZMin);
         expZMax = solver.SymbolicateExpression(expressionZMax);
     }
     catch (AK.ESSyntaxErrorException e)
     {
         return;
     }
     Generate3DRegion();
 }
Example #5
0
    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));
            }
        }
    }
Example #6
0
    public void EvaluateExpression()
    {
        // Yeah...this is lazy, but we'll get a runtime error if it's null
        double result = -99999;

        try {
            // 'x' must be changed to '*' in order for the solver to read it as multiplication
            string expression = inputText.text.Replace('x', '*');
            result = solver.SymbolicateExpression(expression).Evaluate();
        } catch {
            result = -99999;
        }

        if (result == -99999)
        {
            currentResult.text = "--";
        }
        else
        {
            currentResult.text = result.ToString();
        }

        // Check if they got 24
        if (IsValidSolution(result))
        {
            // Award points now. That way, if they solve it with only .1 seconds left, they still get the points.
            score += diffPoints;
            currentResult.color = Color.white;
            // Play noise clip
            AudioSource.PlayClipAtPoint(is24Sound, Vector3.zero);
            // Instead of immediately loading the next card, we wait the fraction of a second
            // to give the player a moment of satisfaction
            Countdown();
        }
        else
        {
            currentResult.color = Color.black;
        }

        inputChanged = false;
    }
Example #7
0
    // 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);
    }