- Home /
Best way to draw an ECG trace.
Ok my desired effect is as thus: http://www.youtube.com/watch?v=7N4viIanngg&feature=fvw as I am sure you have seen on ER and suchlike.
Looking at this as a 2d depiction I am using the x axis as a constant rate of movement where after 30 seconds you return to the start position. The height of the Y axis needs to be take from a a script that returns a TotalAmplitude at any given time. So increases in the amount of blips is controlled by that changing rather than the x axis speeding up. I would like the x-axis to be plotted every 1/25th of a second.
Now I want to get a nice crisp display so I was wondering will this be possible to "plot" on the GUI layer (I am using the Indie version) or would I be best sticking with what I am doing at the moment that being attempting to move a sphere with an attached trail renderer.
Any help setting me along the right path would be appreciated as this will take some time for me to figure out no matter which route is best and I'd rather know I was not barking up the wrong tree!
Here is my code for the trail render version. This however disappears my trace to early with a TrailRender time of 30. I am just using the Y Cos function for now as a trial.
var TotalAmplitude: float; var ECGTrace: Transform;
function Start() {
yield WaitForSeconds (15);
Instantiate (ECGTrace, Vector3(-10, 0, 50), Quaternion.identity);
yield WaitForSeconds (15);
Destroy (gameObject);
}
function Update() {
y = Mathf.Cos (3.142 * TotalAmplitude) / 10;
transform.position += Vector3(2 * Time.deltaTime, y, 0);
TotalAmplitude = TotalAmplitude + 0.01;
}
If people don't understand what I mean by my trace disappearing early I can upload a video to show this.
2D line drawing would help. If you want Unity devs to implement GUI.DrawLine then please vote for my feature request ... http://feedback.unity3d.com/forums/15792-unity/suggestions/1451375-gui-drawline
Answer by Ende · Mar 03, 2010 at 02:41 PM
Ok using a trail renderer on an invisible object is the way to go using the above script as an example. Here is a video of what I have got - http://www.youtube.com/watch?v=donNeloSZGI
However, I am cheating and smacking a plane infront of the traces to hide the fact that they still disappear suddenly when their life has terminated. This is not a real issue I guess.
Link is dead. Can you please update it? Also, I'd love to see the code on how you achieve this if you're willing to share it!
Answer by xxMDAxx · Mar 06, 2014 at 12:23 AM
Please look at the following blog if you want to achieve this effect. Various methods are given there to achieve the effect along with source code and webplayer (shader, particle and mesh creation).
Your answer
Follow this Question
Related Questions
Choosing the right resolution 1 Answer
2D Post Processing Not Working in Unity 2020.3.0f1 0 Answers
Store/Stack Items 0 Answers
Developing 2D games in Unity 1 Answer
GUI Texture Resolution 0 Answers