Esempio n. 1
0
        private void RenderDrawables(object sender, EventArgs e)
        {
            var renderArgs = e as VisualizationEventArgs;
            var rd         = renderArgs.Description;

            //aggregate all the render descriptions into one for this node.
            HelixPoints         = null;
            HelixLines          = null;
            HelixMesh           = null;
            HelixXAxes          = null;
            HelixYAxes          = null;
            HelixZAxes          = null;
            HelixPointsSelected = null;
            HelixLinesSelected  = null;
            HelixMeshSelected   = null;

            HelixPoints         = rd.Points;
            HelixLines          = rd.Lines;
            HelixMesh           = VisualizationManager.MergeMeshes(rd.Meshes);
            HelixXAxes          = rd.XAxisPoints;
            HelixYAxes          = rd.YAxisPoints;
            HelixZAxes          = rd.ZAxisPoints;
            HelixPointsSelected = rd.SelectedPoints;
            HelixLinesSelected  = rd.SelectedLines;
            HelixMeshSelected   = VisualizationManager.MergeMeshes(rd.SelectedMeshes);
        }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     if (!UIManager.Ping() || !VisualizationManager.Ping())
     {
         throw new System.Exception("Either UI Manager or Visualization Manager does not exist!");
     }
 }
        public void CanVisualizeASMPoints()
        {
            var model = dynSettings.Controller.DynamoModel;
            var viz   = dynSettings.Controller.VisualizationManager;

            string openPath = Path.Combine(GetTestDirectory(), @"core\visualization\ASM_points.dyn");

            model.Open(openPath);

            // check all the nodes and connectors are loaded
            Assert.AreEqual(3, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(4, model.CurrentWorkspace.Connectors.Count);

            // run the expression
            dynSettings.Controller.RunExpression(null);

            //ensure that the number of visualizations matches the
            //number of pieces of geometry in the collection
            var drawables   = VisualizationManager.GetAllDrawablesInModel();
            var renderables = viz.Visualizations.SelectMany(x => x.Value.Points);

            Assert.AreEqual(drawables.Values.SelectMany(x => x).Count(), renderables.Count());

            //adjust the number node's value - currently set to 0..5 (6 elements)
            var numNode = (DoubleInput)model.Nodes.First(x => x is DoubleInput);

            numNode.Value = "0..10";
            dynSettings.Controller.RunExpression(null);

            drawables   = VisualizationManager.GetAllDrawablesInModel();
            renderables = viz.Visualizations.SelectMany(x => x.Value.Points);
            Assert.AreEqual(drawables.Values.SelectMany(x => x).Count(), renderables.Count());
        }
    private void Start()
    {
        vm = Manager.GetComponent <VisualizationManager>();

        // Set up ovenBird stuff
        ovenBirdimages = new Sprite[51];
        for (int i = 1967; i < 2018; i++)
        {
            string    filename = "Data/Ovenbird_155/" + i.ToString();
            Texture2D tex      = Resources.Load <Texture2D>(filename);
            Rect      r        = new Rect(0, 0, tex.width, tex.height);
            Sprite    s        = Sprite.Create(tex, r, new Vector2(0.5f, 0.5f));

            ovenBirdimages[i % 1967] = s;
        }

        // Set up greatBlue Heron stuff
        greatBlueHeronImages = new Sprite[51];
        // Set our image array
        for (int i = 1967; i < 2018; i++)
        {
            string    filename = "Data/Great_Blue_Heron_35/" + i.ToString();
            Texture2D tex      = Resources.Load <Texture2D>(filename);
            Rect      r        = new Rect(0, 0, tex.width, tex.height);
            Sprite    s        = Sprite.Create(tex, r, new Vector2(0.5f, 0.5f));

            greatBlueHeronImages[i % 1967] = s;
        }
    }
Esempio n. 5
0
        /// <summary>
        /// Use the render description returned from the visualization manager to update the visuals.
        /// The visualization event arguments will contain a render description and an id representing
        /// the associated node. Visualizations for the background preview will return an empty id.
        /// </summary>
        /// <param name="e"></param>
        private void RenderDrawables(VisualizationEventArgs e)
        {
            //Debug.WriteLine(string.Format("Rendering full screen Watch3D on thread {0}.", System.Threading.Thread.CurrentThread.ManagedThreadId));

            //check the id, if the id is meant for another watch,
            //then ignore it
            if (e.Id != _id)
            {
                return;
            }

            var rd = e.Description;

            HelixPoints         = null;
            HelixLines          = null;
            HelixMesh           = null;
            HelixXAxes          = null;
            HelixYAxes          = null;
            HelixZAxes          = null;
            HelixPointsSelected = null;
            HelixLinesSelected  = null;
            HelixMeshSelected   = null;

            HelixPoints         = rd.Points;
            HelixLines          = rd.Lines;
            HelixPointsSelected = rd.SelectedPoints;
            HelixLinesSelected  = rd.SelectedLines;
            HelixXAxes          = rd.XAxisPoints;
            HelixYAxes          = rd.YAxisPoints;
            HelixZAxes          = rd.ZAxisPoints;
            HelixMesh           = VisualizationManager.MergeMeshes(rd.Meshes);
            HelixMeshSelected   = VisualizationManager.MergeMeshes(rd.SelectedMeshes);
        }
 private static void OnSelectionChanged()
 {
     if (VisualizationManager.isVisualizing)
     {
         VisualizationManager.UpdateSelectedGameObjects(Selection.gameObjects);
     }
 }
        /// <summary>
        /// Calculates a score given the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The score.
        /// </returns>
        public float Score(IAIContext context)
        {
            var score = _scorer.Score(context);

            this.lastScore = score.ToString("f0");

            ICustomVisualizer customVisualizer;

            if (VisualizationManager.TryGetVisualizerFor(_scorer.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(_scorer, context, _parent.parent.parent.id);
            }

            return(score);
        }
Esempio n. 8
0
        internal virtual void Execute(IAIContext context, bool doCallback)
        {
            _action.Execute(context);
            if (doCallback)
            {
                _parent.parent.parent.PostExecute();
            }

            ICustomVisualizer customVisualizer;

            if (VisualizationManager.TryGetVisualizerFor(_action.GetType(), out customVisualizer))
            {
                customVisualizer.EntityUpdate(_action, context, _parent.parent.parent.id);
            }
        }
Esempio n. 9
0
        public void RevolveSolid()
        {
            var model = dynSettings.Controller.DynamoModel;

            string samplePath = Path.Combine(_testPath, @".\Solid\RevolveSolid.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            model.Open(testPath);
            dynSettings.Controller.RunExpression(true);

            var    revolveNode  = dynSettings.Controller.DynamoModel.Nodes.First(x => x is CreateRevolvedGeometry);
            var    result       = (Solid)VisualizationManager.GetDrawablesFromNode(revolveNode).Values.First();
            double volumeMin    = 13300.0;
            double volumeMax    = 13550.0;
            double actualVolume = result.Volume;

            Assert.Greater(actualVolume, volumeMin);
            Assert.Less(actualVolume, volumeMax);
        }
Esempio n. 10
0
        public void ClosedCurve()
        {
            var model = dynSettings.Controller.DynamoModel;

            string samplePath = Path.Combine(_testPath, @".\ClosedCurve.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            model.Open(testPath);
            dynSettings.Controller.RunExpression(true);

            var extrudeNode = dynSettings.Controller.DynamoModel.Nodes.First(x => x is CreateExtrusionGeometry);

            var    result       = (Solid)VisualizationManager.GetDrawablesFromNode(extrudeNode).First();
            double volumeMin    = 3850;
            double volumeMax    = 4050;
            double actualVolume = result.Volume;

            Assert.Greater(actualVolume, volumeMin);
            Assert.Less(actualVolume, volumeMax);
        }
Esempio n. 11
0
        public void SolidBySkeleton()
        {
            if (!dynRevitSettings.Revit.Application.VersionNumber.Contains("2013") &&
                dynRevitSettings.Revit.Application.VersionName.Contains("Vasari"))
            {
                var model = dynSettings.Controller.DynamoModel;

                string samplePath = Path.Combine(_testPath, @".\Solid\SolidBySkeleton.dyn");
                string testPath   = Path.GetFullPath(samplePath);

                model.Open(testPath);
                dynSettings.Controller.RunExpression(true);

                var    skeletonNode = dynSettings.Controller.DynamoModel.Nodes.First(x => x is SkinCurveLoops);
                var    result       = (Solid)VisualizationManager.GetDrawablesFromNode(skeletonNode).Values.First();
                double volumeMin    = 82500.0;
                double volumeMax    = 84500.0;
                double actualVolume = result.Volume;
                Assert.Greater(actualVolume, volumeMin);
                Assert.Less(actualVolume, volumeMax);
            }
        }
Esempio n. 12
0
    // Use this for initialization
    void Start()
    {
        stepText  = new List <string>();
        _instance = this;

        if (bottles == null || bottles.Length == 0)
        {
            bottles = GameObject.FindObjectsOfType <Bottle>();
        }

        if (hG == null)
        {
            hG = GameObject.FindObjectOfType <HydrogenGenerator>();
        }

        if (hE == null)
        {
            hE = GameObject.FindObjectOfType <HydrogenEmitter>();
        }

        bottleNum = 0;
        foreach (Bottle bottle in bottles)
        {
            bottle.SetState(Bottle.BottleState.EMPTY);
        }

        //splashText = File.ReadAllText("Assets/Resources/Text/splash.txt");
        splashText            = Resources.Load <TextAsset>("Text/splash").text;
        splashTextInitialized = true;

        for (int i = 1; i <= stepCount; i++)
        {
            string stpTxt = Resources.Load <TextAsset>("Text/step_" + i.ToString()).text;
            stepText.Add(stpTxt);
        }
        stepTextLoaded = true;
    }
Esempio n. 13
0
        private void RenderDrawables(RenderDescription rd)
        {
            //Debug.WriteLine(string.Format("Rendering full screen Watch3D on thread {0}.", System.Threading.Thread.CurrentThread.ManagedThreadId));

            HelixPoints         = null;
            HelixLines          = null;
            HelixMesh           = null;
            HelixXAxes          = null;
            HelixYAxes          = null;
            HelixZAxes          = null;
            HelixPointsSelected = null;
            HelixLinesSelected  = null;
            HelixMeshSelected   = null;

            HelixPoints         = rd.Points;
            HelixLines          = rd.Lines;
            HelixPointsSelected = rd.SelectedPoints;
            HelixLinesSelected  = rd.SelectedLines;
            HelixXAxes          = rd.XAxisPoints;
            HelixYAxes          = rd.YAxisPoints;
            HelixZAxes          = rd.ZAxisPoints;
            HelixMesh           = VisualizationManager.MergeMeshes(rd.Meshes);
            HelixMeshSelected   = VisualizationManager.MergeMeshes(rd.SelectedMeshes);
        }
Esempio n. 14
0
 private void Awake()
 {
     Instance = this;
 }
Esempio n. 15
0
        /// <summary>
        /// Use the render description returned from the visualization manager to update the visuals.
        /// The visualization event arguments will contain a render description and an id representing
        /// the associated node. Visualizations for the background preview will return an empty id.
        /// </summary>
        /// <param name="e"></param>
        private void RenderDrawables(VisualizationEventArgs e)
        {
            //Debug.WriteLine(string.Format("Rendering full screen Watch3D on thread {0}.", System.Threading.Thread.CurrentThread.ManagedThreadId));

            //check the id, if the id is meant for another watch,
            //then ignore it
            if (e.Id != _id)
            {
                return;
            }

            var sw = new Stopwatch();

            sw.Start();

            var rd = e.Description;

            HelixPoints         = null;
            HelixLines          = null;
            HelixMesh           = null;
            HelixXAxes          = null;
            HelixYAxes          = null;
            HelixZAxes          = null;
            HelixPointsSelected = null;
            HelixLinesSelected  = null;
            HelixMeshSelected   = null;
            HelixText           = null;

            HelixPoints         = rd.Points;
            HelixLines          = rd.Lines;
            HelixPointsSelected = rd.SelectedPoints;
            HelixLinesSelected  = rd.SelectedLines;
            HelixXAxes          = rd.XAxisPoints;
            HelixYAxes          = rd.YAxisPoints;
            HelixZAxes          = rd.ZAxisPoints;
            HelixMesh           = VisualizationManager.MergeMeshes(rd.Meshes);
            HelixMeshSelected   = VisualizationManager.MergeMeshes(rd.SelectedMeshes);
            HelixText           = rd.Text;

            // http://www.japf.fr/2009/10/measure-rendering-time-in-a-wpf-application/comment-page-1/#comment-2892
            //Dispatcher.CurrentDispatcher.BeginInvoke(
            //    DispatcherPriority.Background,
            //    new Action(() =>
            //    {
            var sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine(string.Format("Rendering complete:"));
            sb.AppendLine(string.Format("Points: {0}", rd.Points.Count + rd.SelectedPoints.Count));
            sb.AppendLine(string.Format("Line segments: {0}", rd.Lines.Count / 2 + rd.SelectedLines.Count / 2));
            sb.AppendLine(string.Format("Mesh vertices: {0}",
                                        rd.Meshes.SelectMany(x => x.Positions).Count() +
                                        rd.SelectedMeshes.SelectMany(x => x.Positions).Count()));
            sb.Append(string.Format("Mesh faces: {0}",
                                    rd.Meshes.SelectMany(x => x.TriangleIndices).Count() / 3 +
                                    rd.SelectedMeshes.SelectMany(x => x.TriangleIndices).Count() / 3));
            //DynamoLogger.Instance.Log(sb.ToString());
            Debug.WriteLine(sb.ToString());
            sw.Stop();
            //DynamoLogger.Instance.Log(string.Format("{0} ellapsed for updating background preview.", sw.Elapsed));

            Debug.WriteLine(string.Format("{0} ellapsed for updating background preview.", sw.Elapsed));
            //}));
        }
Esempio n. 16
0
 // Use this for initialization
 void Start()
 {
     visman = Camera.main.gameObject.GetComponent <VisualizationManager>();
 }