Realtime graph.

Hello wise ones…

Anybody got an idea on creating a realtime graph?

I have a script putting out a new random number every 30 seconds or so and I want to visually see where the value has been in the form of a simple graph.

I thought I could make a kind of Richter scale and link an empty’s position with the value and have it spit out a semi-constant stream of tiny planes which slowly move away from the emitter. But it wouldn’t draw a line between the values it would just —____ step. I could get around that with a slow parent scenario I guess.

But that would all be very busy with a few graphs going. So any bright ideas? Is there some drawing line function or other important feature I may be missing?

Also on a side note. How do you call an other scene with python? I know you can getCurrentScene() but is there a getAllScenes()? Well I know there’s not a getAllScenes() but you know what I mean.

Any help greatly appreciated. Or just an idea?

Ta.


import GameLogic
activeScenes = GameLogic.getSceneList()

There is a draw line function in the render module (from bge import render): render.drawLine(). You can read about it near the bottom if this page http://www.blender.org/documentation/blender_python_api_2_60_release/bge.render.html from the Python API Reference. You’ll need to give it the points to draw between and the color.

To get another scene you can use the logic.getSceneList() function, but the scene will have to be loaded, as in an overlay scene or background scene. It is also in the Python API Reference here http://www.blender.org/documentation/blender_python_api_2_60_release/bge.logic.html under general functions.

great thanks. render.drawLine() looks like what I want. But from the sounds of it I would need to add a new line for every section of the graph?

Yes you would have to unfortunately, it only draws a straight line. You may be able to pick up a few tips from Goran’s tutorial on drawing an arc (http://www.youtube.com/watch?v=ZRFNlJFrpEI), you could probably make the function recursive.

have you tried the new dynamic paint feature? I didn’t but it could probably do the job.

That’s only for the Render Engine.

I helped a guy a little while back do a similar thing. I ended up just offering support though, he was better at it than me…
But I can tell you how he did it, even if i cannot do it myself.

He created an object each time some new data was made. That object was a plane with a “wire” material. Then he used the python mesh editing functions and moved the plane so a line was drawn where he wanted it to be.

Wow, lots of good ideas.

Thanks Monster, much appreciated. Was lazy of me to ask though :slight_smile:

Well I think the drawLine() function is what I am after so I will experiment and return promptly with more inquisitions :slight_smile:

Thanks again all who made suggestions. :slight_smile: