public static DataAttribute ParseExpression(Visualisation visualisation, string strExpr) { if (strExpr == "") { return(new DataAttribute("", IATKDataType.Translate, new float[visualisation.DataSource.DataCount])); } SetInterpreterVariables(visualisation); object result = interpreter.Eval(strExpr); // If the end result is just a number, we treat it as a translate Attribute if (float.TryParse(result.ToString(), out float f)) { float[] floatArray = new float[visualisation.DataSource.DataCount]; for (int i = 0; i < visualisation.DataSource.DataCount; i++) { floatArray[i] = f; } return(new DataAttribute(strExpr, IATKDataType.Translate, floatArray)); } else { return((DataAttribute)result); } }
public static bool ParseBoolExpression(Visualisation visualisation, string strExpr) { if (strExpr == "") { return(true); } SetInterpreterVariables(visualisation); return((bool)interpreter.Eval(strExpr)); }
public static Vector3?ParseVector3Expression(Visualisation visualisation, string strExpr) { if (strExpr == "") { return(null); } SetInterpreterVariables(visualisation); object result = interpreter.Eval(strExpr); return((Vector3)interpreter.Eval(strExpr)); }
public static Quaternion?ParseQuaternionExpression(Visualisation visualisation, string strExpr) { if (strExpr == "") { return(null); } SetInterpreterVariables(visualisation); object result = interpreter.Eval(strExpr); return((Quaternion)interpreter.Eval(strExpr)); }
private static void SetInterpreterVariables(Visualisation visualisation) { currentVisualisationReference = visualisation; // Set parameters from data source if (visualisation.DataSource != null) { foreach (var da in visualisation.DataSource) { interpreter.SetVariable(da.Name, da); } } if (visualisation.EdgesDataSource != null) { foreach (var da in visualisation.EdgesDataSource) { interpreter.SetVariable(da.Name, da); } } }
public override void CreateView(Visualisation visualisationReference) { VisualisationReference = visualisationReference; DataSource = VisualisationReference.DataSource; GameObject geometryHolder = new GameObject("Geometry"); geometryHolder.transform.SetParent(transform); geometryHolder.transform.localPosition = Vector3.zero; geometryHolder.transform.localRotation = Quaternion.identity; geometry = geometryHolder.AddComponent <OptimisedGeometry>(); // Create material and view Material material = new Material(Shader.Find("Standard Unlit 2Sided")); material.renderQueue = 3000; material.enableInstancing = true; geometry.InitialiseView(material); }
public static float ParseFloatExpression(Visualisation visualisation, string strExpr) { if (strExpr == "") { return(0); } SetInterpreterVariables(visualisation); object result = interpreter.Eval(strExpr); // If the end result is just a number, we treat it as a translate Attribute if (float.TryParse(result.ToString(), out float f)) { return(f); } else { throw new Exception("Must return a float."); } }
public override void CreateView(Visualisation visualisationReference) { VisualisationReference = visualisationReference; DataSource = VisualisationReference.DataSource; GameObject geometryHolder = new GameObject("Geometry"); geometryHolder.transform.SetParent(transform); geometryHolder.transform.localPosition = Vector3.zero; geometryHolder.transform.localRotation = Quaternion.identity; geometry = geometryHolder.AddComponent <OptimisedGeometry>(); // Create material and view Material material = new Material(Shader.Find("NewIATK/ScatterplotShader")); material.mainTexture = Resources.Load("circle-outline-basic") as Texture2D; material.renderQueue = 3000; material.enableInstancing = true; geometry.InitialiseView(material); geometry.SetIndices(GenerateScatterIndices(), MeshTopology.Points); }
public abstract void CreateView(Visualisation visualisationReference);