Following a Spline

From Synfig Studio :: Documentation
Jump to: navigation, search
m (updated to use the newer way of linking things up)
m (See also: add link video)
(33 intermediate revisions by 11 users not shown)
Line 1: Line 1:
<!--Categories-->
+
<!-- Page info -->
[[Category:Tutorials]]
+
{{Title|Following a Spline}}
 
+
{{Category|Tutorials}}
 +
{{Category|Tutorials Advanced}}
 +
{{NewTerminology}}
 +
<!-- Page info end -->
 +
:Note: There is also a slightly out-of-date tutorial on this topic at [[Tracking Curves]].  It contains some info, particularly about link/export, '''which hasn't yet been added to this new tutorial'''.  There is also another [[Following a BLine (the very old way)|very out-of-date tutorial]] for synfig 0.61.08.
 
== Introduction ==
 
== Introduction ==
  
This is only a rough draft.  The content should be OK, but it needs tidying up and could really benefit from some screen shots.  If you follow the tutorial, please consider taking some shots as you do so and uploading them here...
+
This tutorial will demonstrate how to make an object follow the path of an arbitrary curve, rotating to face the direction of travel.
 
+
[http://sourceforge.net/tracker/index.php?func=detail&aid=1781903&group_id=144022&atid=757419 This bug report] suggested a feature:
+
 
+
<blockquote>
+
I would like to be able to draw a bline with N vertices and have
+
a shape move along that bline (the whole shape or individual vertices).
+
Currently the only way I have found to do what I want is to draw a bline,
+
and then move a shape along that line manually at fairly small intervals
+
(very frustrating).
+
 
+
Example: A triangle that should move along a sine curve always pointing in
+
the direction it is going to move next.
+
</blockquote>
+
 
+
The feature has recently been added to Synfig (23rd September 2007) and will be in the next release.
+
  
 
== Summary ==
 
== Summary ==
Line 25: Line 14:
 
We're going to:
 
We're going to:
  
* [[Following a BLine#Create the Layers|Draw a curve and an arrow]]
+
* {{l|Doc:Following a Spline#Create the Layers|Draw a curve and an arrow}}
* [[Following a BLine#Make the Arrow Move and Rotate|Link the arrow's Origin and Rotation]] to the bline so the arrow follows the curve
+
* {{l|Doc:Following a Spline#Make the Arrow Move and Rotate|Link the arrow's Origin and Rotation}} to the Spline so the arrow follows the curve
  
 
== Tutorial ==
 
== Tutorial ==
Line 38: Line 27:
 
=== Create the Layers ===
 
=== Create the Layers ===
  
select the BLine Tool
+
Select the {{l|Spline Tool}}
 +
[[File:Spline-tool-0.63.06.png|frame|none]]
  
 
enable just the Outline checkbox
 
enable just the Outline checkbox
  
draw a bline that you want the arrow to move along
+
draw a spline that you want the arrow to move along
  
click the "Make BLine" icon in the bottom left of the "Tool Options" panel to create the bline.
+
click the {{Literal|Make Spline}} icon in the bottom left of the {{l|Tool_Options_Panel}} to create the spline.
  
still in the bline tool, enable Fill and Outline checkboxes in tool options
+
still in the Spline Tool, enable {{Literal|Create Outline}} and {{Literal|Create Region}} checkboxes in tool options
 +
[[File:Spline-Tool-Options_0.63.06.png|frame|center]]
  
draw an arrow or whatever, pointing to the right
+
draw an arrow or whatever, pointing to the right.
  
switch to the "Normal" tool
+
Switch to the {{l|Transform Tool}}
  
select the outline, hit control-a to select all its ducks except the green position duck
+
select the outline, hit control-a to select all its {{l|Handle|handles}} except the green position handle
  
drag the ducks so that the arrow is centred around the green position duck
+
drag the handle so that the arrow is centred around the green position handle
  
add a rotate layer above the outline and region
+
Add a {{l|Rotate Layer}} above the outline and region
  
encapsulate the rotate, outline, and region layers
+
{{l|Group}} the rotate, outline, and region layers
  
so now you've got 2 top-level layers: a curved path, and an encapsulation containing an arrow and a rotate layer
+
so now you've got 2 top-level layers: a curved path, and a group containing an arrow and a rotate layer
  
 
=== Make the Arrow Move and Rotate ===
 
=== Make the Arrow Move and Rotate ===
  
select the "arrow" encapsulation layer by clicking it in the Layers panel
+
* Select the group layer by clicking it in the {{l|Layers Panel}}
 +
* Select its green position {{l|Handle|handle}} by clicking on it in the {{l|WorkArea}}
 +
** additionally select the Rotate layer by holding Control and clicking it in the Layers panel
 +
** additionally select the blue "rotation amount" handle by holding {{Shortcut|ctrl}} and clicking on it in the canvas window
  
select its green position duck by clicking on it in the canvas window
+
So now we should have 2 layers selected, and one handle from each of those 2 layers selected
  
additionally select the Rotate layer by holding Control and clicking it in the Layers panel
+
Now additionally select the curved spline layer (it should be the last layer in the Layer panel's list) by holding {{Shortcut|ctrl}} and clicking on it
  
additionally select the blue "rotation amount" duck by holding Control and clicking on it in the canvas window
+
Right-click on the dotted line that indicates the position of the curved spline - not on any handle, but on the dotted line between handle
  
so now we should have 2 layers selected, and one duck from each of those 2 layers selected
+
From the context menu that pops up, select {{Literal|Link to Spline}}
 +
[[Image:Spline-Link-to-0.63.06.png|none|frame|See also {{l|Command:Link_to_Spline}} ]]
  
now additionally select the curved bline layer (it should be the last layer in the Layer panel's list) by holding Control and clicking on it
+
The arrow group should move so that its green position handle is on the spline, and it should rotate so that the arrow points along the spline at that point
  
right-click on the dotted line that indicates the position of the curved bline - not on any duck, but on the dotted link between ducks
+
Select just the group layer, and drag its green handle around.  you'll see that the handle is constrained now to line on the spline, and that dragging it also affects the rotation of the arrow as expected
  
from the context menu that pops up, select "Link to BLine"
+
We can now animate the arrow. turn on {{l|Animate_Editing_Mode}} by clicking the icon in the bottom right of the canvas window.
  
the encapsulated arrow should move so that its green position duck is on the bline, and it should rotate so that the arrow points along the bline at that point
+
* at time '''0f''', drag the group layer's green position handle to one end of the spline
 +
* at time '''5s''', drag the same position handle to the other end of the spline
  
select just the encapsulation layer, and drag its green duck around. you'll see that the duck is constrained now to lie on the bline, and that dragging it also affects the rotation of the arrow as expected
+
Try {{c|<Caret Menu>|<File>|Preview|}} to watch the animation.
  
we can now animate the arrow.  turn on "animate edit mode" by clicking the icon in the bottom right of the canvas window.
+
== Results ==
  
at time 0f, drag the encapsulation layer's green position duck to one end of the bline
+
This is the animation I ended up with:
 +
[[File:Arrow-follows-bline.gif|center|alt Following a Spline example]]
  
at time 5s, drag the same position duck to the other end of the bline
+
Synfig project : {{l|Media:Arrow-follows-bline.sifz‎|Arrow-follows-bline.sifz‎}}
  
Try File > Preview or View > Play to watch the animation.
+
== Controlling the linear velocity ==
 
+
== Results ==
+
  
This is the animation I ended up with: [[Media:Arrow-follows-line-tut.sifz|arrow-follows-line-tut.sifz]]
+
By default, the arrow travels the whole spline with a constant velocity, independently of the spline structure.
  
== Commentary on the Feature ==
+
If you select the group layer and look at the Parameters Panel, then you'll see that its Origin parameter is {{L|convert|converted}} to {{Literal|Spline Vertex}} type. This is done automatically when you do "Link to Spline" action. You can disable the  "Homogenous" subparameter and then the speed of the arrow will depend on the spline structure - it will take the same time to move along each segment of the spline. So if there's a long straight part then a bendy complex part, the arrow will move much faster along the straight parts (since there will be less vertices in that part). In physics terms, the linear velocity (that is, the speed over the spline) is not constant.
  
Also, the arrow takes the same time to move along each segment of the bline. So if there's a long straight part then a bendy complex part, the arrow will move much faster along the straight parts (since there will be less vertices in that part).
+
For illustration of the "Homogenous" effect see [http://www.youtube.com/watch?v=3PGXroxBcuo this demo].
  
It would be good to have the option of having the arrow move at constant speed along the length of the curve.
+
== See also ==
 +
* Synfig forum : [http://www.synfig.org/forums/viewtopic.php?f=8&t=4563 Following a path duplicated]
 +
* Synfig forum : [http://www.synfig.org/forums/viewtopic.php?t=2803 animate a "travel path"]
 +
* Synfig forum : [http://www.synfig.org/forums/viewtopic.php?f=8&t=9157 A path of scraps(or any other object)]
 +
* Link to Spline command : {{l|Command:Link_to_Spline}}
 +
* A [https://youtu.be/crsCxM6Fxqg video link] showing the explanation of this page.

Revision as of 18:54, 23 February 2019

Languages Language: 

English • čeština • Deutsch • español • français • русский


Note: There is also a slightly out-of-date tutorial on this topic at Tracking Curves. It contains some info, particularly about link/export, which hasn't yet been added to this new tutorial. There is also another very out-of-date tutorial for synfig 0.61.08.

Introduction

This tutorial will demonstrate how to make an object follow the path of an arbitrary curve, rotating to face the direction of travel.

Summary

We're going to:

Tutorial

This is a brief tutorial giving an example of how to use it:

Create the Animation

File > New

Create the Layers

Select the Spline Tool

Spline-tool-0.63.06.png

enable just the Outline checkbox

draw a spline that you want the arrow to move along

click the "Make Spline" icon in the bottom left of the Tool Options Panel to create the spline.

still in the Spline Tool, enable "Create Outline" and "Create Region" checkboxes in tool options

Spline-Tool-Options 0.63.06.png

draw an arrow or whatever, pointing to the right.

Switch to the Transform Tool

select the outline, hit control-a to select all its handles except the green position handle

drag the handle so that the arrow is centred around the green position handle

Add a Rotate Layer above the outline and region

Group the rotate, outline, and region layers

so now you've got 2 top-level layers: a curved path, and a group containing an arrow and a rotate layer

Make the Arrow Move and Rotate

  • Select the group layer by clicking it in the Layers Panel
  • Select its green position handle by clicking on it in the WorkArea
    • additionally select the Rotate layer by holding Control and clicking it in the Layers panel
    • additionally select the blue "rotation amount" handle by holding Ctrl and clicking on it in the canvas window

So now we should have 2 layers selected, and one handle from each of those 2 layers selected

Now additionally select the curved spline layer (it should be the last layer in the Layer panel's list) by holding Ctrl and clicking on it

Right-click on the dotted line that indicates the position of the curved spline - not on any handle, but on the dotted line between handle

From the context menu that pops up, select "Link to Spline"

The arrow group should move so that its green position handle is on the spline, and it should rotate so that the arrow points along the spline at that point

Select just the group layer, and drag its green handle around. you'll see that the handle is constrained now to line on the spline, and that dragging it also affects the rotation of the arrow as expected

We can now animate the arrow. turn on Animate Editing Mode by clicking the icon in the bottom right of the canvas window.

  • at time 0f, drag the group layer's green position handle to one end of the spline
  • at time 5s, drag the same position handle to the other end of the spline

Try "<Caret Menu> → <File> → Preview" to watch the animation.

Results

This is the animation I ended up with:

alt Following a Spline example

Synfig project : Arrow-follows-bline.sifz‎

Controlling the linear velocity

By default, the arrow travels the whole spline with a constant velocity, independently of the spline structure.

If you select the group layer and look at the Parameters Panel, then you'll see that its Origin parameter is converted to "Spline Vertex" type. This is done automatically when you do "Link to Spline" action. You can disable the "Homogenous" subparameter and then the speed of the arrow will depend on the spline structure - it will take the same time to move along each segment of the spline. So if there's a long straight part then a bendy complex part, the arrow will move much faster along the straight parts (since there will be less vertices in that part). In physics terms, the linear velocity (that is, the speed over the spline) is not constant.

For illustration of the "Homogenous" effect see this demo.

See also


Languages Language: 

English • čeština • Deutsch • español • français • русский