3
$\begingroup$

I am looking for some guidance and suggestions as to the best approach towards animating some elements of my goal - before I jump in and hack around in "the wrong" or awkward direction.

WHAT I AM TRYING TO ACHIEVE

I want to animate a travelling sine wave - with a graph view like an oscilloscope.

In other words unlike:

  • a traditional graph diagram
  • where the leading point of a wave travels forwards
    • (to the right)
  • from the 0 point on the time axis
  • a typical "history" graph

For the end result, I want:

  • the wave to travel from right to left
  • the leading edge of the wave to remain at a fixed point on the time axis
    • (on the far right edge)
  • which is effectively the current time
  • so it's more of a "live view" - like an oscilloscope
    • (or the machine that goes ping!)

Here is a sample target end result:

enter image description here

(modified) animated GIF image that I culled from Wikipedia

[ Thank you User:LucasVB/Gallery ]

WHAT I AM COMFORTABLE WITH

I should be fine with:

  • the stationary frame
    • pretty trivial/straight-forward
  • the leading edge plot point - the red dot
    • add a red sphere element of an apropriate size
    • use a location driver to move it up and down the Z-axis
    • python math sin(radians(current_frame))

ASSUMPTIONS

What is the simplest approach you suggest I should use for the:

1. The moving red sine wave

I'm thinking of:

  • generating a long stationary sine wave element
    • (length as long as the number of cycles as I need for the animation time)
  • use an X-axis location driver
    • current_frame
    • to move the element from right to left

Then I would need to:

  • mask the portions of the sine wave that lie outside the graph frame
    • left & right

2. The moving graph background

Pretty much the same approach as above.

  • generate a long background axis "strip"
  • move it as above with a driver
  • mask the portions of the background axis that lie outside the graph frame
    • left & right

1 & 2 Together

I could combine the two elements above into a single moving strip

  • and mask the portions of the single moving strip that lie outside the graph frame
    • left & right

REQUEST

Does anyone have any better suggestions for me ?

Simpler, faster, neater ?

As usual, I'm happy to read up if I am given some pointers.

I just want to make sure I use the best or most effective technique to skin the proverbial cat.

Thanks

$\endgroup$
  • $\begingroup$ Always a sinus or configurable for other functions ? $\endgroup$ – lemon Feb 9 '17 at 15:32
  • $\begingroup$ @lemon : Always a sine wave - I don't need a solution that is flexible for other math functions. I am animating a physics illustration - where a sphere expands and contracts, with radius = sine(time). So the graph required is a math plot to explain the radius expansion and contraction cycle. $\endgroup$ – TaoRich Feb 9 '17 at 15:38
  • $\begingroup$ So you just need to shift left or right a static texture (with sinus on it) along time ? By shift, I mean shift the UV coordinates $\endgroup$ – lemon Feb 9 '17 at 15:41
  • $\begingroup$ Yes - that pretty much sums it up - provided that I find a way to only show what is necessary in the graph frame, and hide/mask the rest of the static that is outside of the desired view. $\endgroup$ – TaoRich Feb 9 '17 at 15:44
  • 1
    $\begingroup$ I wont have time to write an answer but this is basically what you need to have UV Warp modifier youtube.com/watch?v=PnF6XdmNhCs. For the dot, make so the dot movement leads the warping of the UV. $\endgroup$ – lemon Feb 9 '17 at 15:50
4
$\begingroup$

UV Warp modifier (first approach) shifts, scales or rotates the UV map of an object depending of the relative positions, scales or rotations of 2 other objects (generally, you can use empties for these two objects).

enter image description here

So here, if we move one empty, the UV map shifts and so the texture of the plane looks like it was moving.

Here is the setup :

  • Create two empties : place one of them on X=0 (that will be easier later) and the second one elsewhere
  • Add the UV Warp modifier to you plane, like this :

enter image description here

And here is the setup of the plane material :

  • UV unwrap the plane and adjust the UV map to the sinusoid shape on the texture
  • Use this texture to mix two shaders : one for the red line and the other one for transparency

enter image description here

The transparency is need to show some grid behind the curve when rendered :

enter image description here

At this step, you can move one of the empty and see that the curve seems to move on the plane.

Now the red dot :

  • Create the dot (a plain circle for instance)
  • Place it on the border of the plane
  • Add a driver to its Y position
  • The driver need to be dependent on the X position of the empty, and to follow a sinus function

As the UV map is 0 to 1, the UV map shifts of 1 when the empty moves of 1 unit. So we need to multiply the X value by 2 PI.

The setup is the following (can be seen in the graph editor, in drivers editing context) :

enter image description here

Edit : another approach You can also set up Cycles nodes to draw the curve directly. The main interest here, there is no need of a "static" texture.

Here is an example, made rapidly and so to enhance (using more calculation via drivers, instead of doing it with nodes, surely).

enter image description here

The principle is the following (quickly described) :

  • Add a keyframe to an input value (to define the speed of the curve)
  • Use it in the node editor to calculate where the sinus is depending on this value
  • Use the result on a mix shader node to output red or white, and so draw the curve

enter image description here

Here is this second blend file :

This is to enhance : more calculations need to be done outside of the nodes (using drivers probably), so that math expressions are more accurate and the nodes setup simplified.

$\endgroup$
  • $\begingroup$ Thank you for all the effort - a clear and detailed answer. I will look at both approaches today; learn and understand some new techniques. I think my final solution may very well be a combination of the two - First approach: UV Warp modifier to move a static texture for the graphing background. Another approach: Cycles nodes to draw the sinus. When I have made progress I'll report back with an edit, and tick your answer as my accepted solution. $\endgroup$ – TaoRich Feb 10 '17 at 8:16
  • $\begingroup$ I've got your sinus.blend open in one Blender instance, and am trying to recreate it myself from scratch in another Blender instance. I'm getting stuck at assigning the material=curve and the texture=tex When I add a material I see these properties [Surface][Wire][Volume][Halo] which I don't see in your sinus.blend. I've spent an hour on this and just don't seem to know enough to work out what to do. I'm quite new Blender and this is my first attempt to use textures - so there's obviously a gap in my understanding or knowledge. $\endgroup$ – TaoRich Feb 19 '17 at 11:51
  • $\begingroup$ Hi. I don't get what you mean above. Which approach are you attempting to do? And... my setting are Cycles settings and [Surface][Wire][Volume][Halo] are for Blender Internal. But for the first approach the principle is the same for both renderers $\endgroup$ – lemon Feb 19 '17 at 12:00
  • $\begingroup$ Hi & thanks. Working on UV Warp modifier (first approach). Started with default (empty) .blend. First, I created the 2 empties empty.static and empty.move then added the location transformation for empty.move to emulate your sample. I then added the plane and its UV Modifier From:empty.move` & To:empty.static and the behaviour follows what your sample does. I have the plane selected and chose data properties Material & add new material which I named curve. That's where the material data property options differ. [screenshots] (pasteall.org/pic/index.php?id=112713) $\endgroup$ – TaoRich Feb 19 '17 at 13:07
  • $\begingroup$ After taking a break to clear my head, I've gone back to basics and am reading up on how to add an image to a plane, and will come back at the problem with some more understanding. Appreciate the help - really didn't mean to bug you for step-by-step hand holding. $\endgroup$ – TaoRich Feb 19 '17 at 13:13
1
$\begingroup$

Another way of doing this task is to use F-Curve Sine Modifier.

  1. Create a cube and scale it down to your needs. Apply the scale.
  2. Insert a location keyframe at frame 0
  3. Go to frame 100 and move the cube on the x axis about 10 units and add another location keyframe.
  4. Now go in Graph Editor and delete the Y location channel and leave X and Z Location channels.
  5. Select the X Location channel and execute Channel-> Extrapolation Mode -> Linear Extrapolation.
  6. Select Z Location channel and go in Properties-> Modifiers Tab.
  7. Choose Add Modifier -> Built-In Function and Select Sine.
  8. Adjust the parameters of the Sine modifier as needed. For example: Amplitude 2.5; Phase Multiplier: 0.1; Phase Offset: -0.1
  9. Create a vertex inside the Cube. For example: In edit mode select all vertices then Shift+D to duplicate and Alt+M-> At Center to merge the duplicates into one vertex. Still selected that vertex - press Ctrl+G to add it in a vertex group.
  10. Add particle system to the cube, that should emit from vertices and from vertex group that you've just created - see the attached file.
  11. Subdivide (Subsurf Modifier) the cube to make it more rounder.
  12. Add material to the cube and particles - A halo material will suffice - see the attached file.
  13. Finally Make the camera look at the cube and create a Copy Location constraint to it so that the camera should follow th X location of the cube with offset.

    This short description took longer than making the solution :)

The blend file:

And Simplified Version if there is no need of Sine accuracy. Simple Sphere and Cylinder animated with Sine like Bezier Curve as constraint and modifier:

$\endgroup$
  • $\begingroup$ Ooh, I like this one, super simple. $\endgroup$ – 3pointedit Jun 19 '17 at 22:42
  • $\begingroup$ @3pointedit There is even simpler if you don't insist much on precision. Just Create a Bezier Curve and shape it as closely to sine curve as possible. Then Add it to the Sphere as Clamp To constraint. Also create a Cylinder object with lots of horizontal loops and add Curve Modifier to it using the sine curve as deforming object. Moving the Sphere and the Cylinder will create similar motion tho the given above. $\endgroup$ – Rumen Belev Jun 21 '17 at 14:15
  • $\begingroup$ Needs to be a proper answer with illustrations or it never happened Rumen ;-) $\endgroup$ – 3pointedit Jun 21 '17 at 20:42
  • $\begingroup$ @3pointedit I know :) But I'll be glad if somebody finds it useful by reading and exploring the blend files. I don't like visual learning too much - it makes the brain lazy. $\endgroup$ – Rumen Belev Jun 22 '17 at 7:56
  • $\begingroup$ @RumenBelev : Thanks for this alternative approach. I did manage to solve my requirement using lemon's UVWarp solution which I accepted as my preferred answer. I need a fairly precise illustration for a physics animation - four different fundamental sine waves are superposed to produce a composite model. I will try to explore your suggestion when I have some time ... always good to learn ! $\endgroup$ – TaoRich Jul 13 '17 at 12:16
0
$\begingroup$

You could also do this mechanically so to speak. Remember to use an Ortho camera to eliminate distortion.

Example image

Make a rotating vertex object and spawn particles from it. More particles = smoother drawn line.

make vert from plane

Create a plane then shrink all vertices to 0 and Remove Duplicate vertices. Off set this vertex by 1 Unit in the Y direction, make sure that the vertex is selected when you leave edit mode. This will be the Tracer.

Vertex offset

Create a Sphere object, add a colored emission material (red), then select it followed by the Tracer. Parent by Vertex. Offset the object by -1 Y units to line up with the Tracer Vertex.

add ball Make it red

Select the Tracer object Go to the first frame and set a rotation keyframe at 0.0, move 1 second and rotate the object around the X axis 180deg, make another keyframe. In the F-curve window select the rotation curve and set it to Linear Extrapolation with a Cycle modifier.

edit curve

Then add a Particle modifier. Set it to emit 2000 particles from the -X direction at value 1.0 and turn of Field Gravity (set to 0). Select the Red sphere object as Render Object.

Particles

Now particles will stream away in a sine wave.

Create a plane and scale it to fill the screen. Apply a Simple Subdivide modifier to split into a grid. Add an array modifier to expand the grid coverage across the screen. Apply a Displace modifier, set Direction to X and keyframe it's strength to 0.0 at the first frame, then -1.0 a second later.

Side scrolling Grid example

Go to the modifiers F-curve and apply a cycle modifier, this will make the grid appear to travel right to left for ever.

Add a Wireframe modifier and change the thickness to taste.

$\endgroup$
  • $\begingroup$ Same thanks as above ... I did manage to solve my requirement using lemon's UVWarp solution which I accepted as my preferred answer. I need a fairly precise illustration for a physics animation - four different fundamental sine waves are superposed to produce a composite model. I will try to explore your suggestion when I have some time ... always good to learn ! $\endgroup$ – TaoRich Jul 13 '17 at 12:18
  • $\begingroup$ Damn, I also see that I got the period wrong based on your example. Drat $\endgroup$ – 3pointedit Jul 14 '17 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.