Difference between revisions of "Doc:Following a Spline"

From Synfig Studio :: Documentation
Jump to: navigation, search
m (Results: add gif)
m (Added reference to useful forum discussion)
 
(11 intermediate revisions by 5 users not shown)
Line 5: Line 5:
 
{{NewTerminology}}
 
{{NewTerminology}}
 
<!-- Page info end -->
 
<!-- 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 ==
 
If you are using version 0.61.08 or lower, please see the {{l|Following a Spline (the old way)|old version}} of this tutorial, since this version is about the 0.61.09 version.
 
  
 
This tutorial will demonstrate how to make an object follow the path of an arbitrary curve, rotating to face the direction of travel.
 
This tutorial will demonstrate how to make an object follow the path of an arbitrary curve, rotating to face the direction of travel.
Line 17: Line 15:
  
 
* {{l|Doc:Following a Spline#Create the Layers|Draw a curve and an arrow}}
 
* {{l|Doc:Following a Spline#Create the Layers|Draw a curve and an arrow}}
* {{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
+
* {{l|Doc:Following a Spline#Make the Arrow Move and Rotate|Link the arrow's Origin and Rotation}} to the Spline so that the arrow follows the curve
  
 
== Tutorial ==
 
== Tutorial ==
  
This is a brief tutorial giving an example of how to use it:
+
The tutorial is intended to provide a demonstration on how to use this feature.
 +
 
  
 
=== Create the Animation ===
 
=== Create the Animation ===
  
File > New
+
* Create a new animation by selecting from the menu {{c|File|New}}.
 +
 
  
 
=== Create the Layers ===
 
=== Create the Layers ===
  
Select the {{l|Spline Tool}}
+
First step, let's draw the Spline:
[[File:Spline-tool-0.63.06.png|frame|none]]
+
  
enable just the Outline checkbox
+
# Select the {{l|Spline Tool}} from the Toolbox: [[File:Spline-tool-0.63.06.png|frame|none]]
 +
# In the {{l|Tool_Options_Panel}}, enable only the Outline Layer type.
 +
# Draw a Spline that you want the arrow to move along.
 +
# Click the {{Literal|Make Spline}} icon in the bottom left of the {{l|Tool_Options_Panel}} to create the Spline.
  
draw a spline that you want the arrow to move along
 
  
click the {{Literal|Make Spline}} icon in the bottom left of the {{l|Tool_Options_Panel}} to create the spline.
+
Second step, let's draw the arrow:
  
still in the Spline Tool, enable {{Literal|Create Outline}} and {{Literal|Create Region}} checkboxes in tool options
+
# Select the {{l|Spline Tool}}, this time enabling {{Literal|Create Outline}} and {{Literal|Create Region}} Layer types: [[File:Spline-Tool-Options_0.63.06.png|frame|none]]
[[File:Spline-Tool-Options_0.63.06.png|frame|center]]
+
# Draw an arrow (or any another arbitrary shape) pointing to the right side of the Canvas.
 +
# Switch to the {{l|Transform Tool}} and select the Outline, press {{Shortcut|Ctrl}}{{Shortcut|A}} to select all its {{l|Handle|handles}} except the green position handle.
 +
# Drag the handles so that the arrow is centered around the green position handle.
 +
# Add a {{l|Rotate Layer}} above the Outline and Region Layers.
 +
# {{l|Group}} the Rotate, Outline, and Region Layers. At this point there are 2 top-level Layers:
 +
## an Outline Layer
 +
## a Group Layer containing the arrow and the Rotate Layer
  
draw an arrow or whatever, pointing to the right.
 
 
Switch to the {{l|Transform Tool}}
 
 
select the outline, hit control-a to select all its {{l|Handle|handles}} except the green position handle
 
 
drag the handle so that the arrow is centred around the green position handle
 
 
Add a {{l|Rotate Layer}} above the outline and region
 
 
{{l|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 ===
 
=== Make the Arrow Move and Rotate ===
  
Select the group layer by clicking it in the {{l|Layers Panel}}
+
# Select the Group Layer by selecting it in the {{l|Layers Panel}}.
 +
# Then:
 +
## select its green origin position {{l|Handle|handle}} by clicking on it in the Canvas window
 +
## while holding {{Shortcut|Ctrl}} select the Rotate Layer in the Layers Panel
 +
## while holding {{Shortcut|Ctrl}} select its blue rotation handle in the Canvas window
 +
#: At this point, there are 2 Layers selected and one handle from each of those 2 Layers selected.
 +
# Now, while holding {{Shortcut|Ctrl}} select also the curved Spline Layer (it should be the last Layer in the Layer Panel's list).
 +
# Right-click on the dotted line that indicates the position of the curved Spline, not on any handle, but on the dotted line between handles.
 +
# 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}} ]]
 +
#: 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. The handle is now constrained to the Spline and dragging it will also affect the rotation of the arrow.
 +
#: We can now animate the arrow.
 +
# Turn on {{l|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 {{c|File|Preview|}} to watch the animation.
  
select its green position handle by clicking on it in the canvas window
 
 
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
 
 
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 {{Shortcut|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 {{Literal|Link to Spline}}
 
[[Image:Spline-Link-to-0.63.06.png|frame|none]]
 
 
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 {{l|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 {{c|<Caret Menu>|<File>|Preview|}} to watch the animation.
 
  
 
== Results ==
 
== Results ==
Line 90: Line 74:
 
[[File:Arrow-follows-bline.gif|center|alt Following a Spline example]]
 
[[File:Arrow-follows-bline.gif|center|alt Following a Spline example]]
  
Synfig project : {{l|Media:Arrow-follows-bline.sifz‎|Arrow-follows-bline.sifz‎}}
+
Synfig project: {{l|Media:Arrow-follows-bline.sifz‎|Arrow-follows-bline.sifz‎}}
 +
 
  
 
== Controlling the linear velocity ==
 
== Controlling the linear velocity ==
  
By default, the arrow travels the whole spline with a constant velocity, independently of the spline structure.
+
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 {{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.
+
If you select the Group Layer and look at the Parameters Panel, you'll see that its Origin parameter is {{L|convert|converted}} to {{Literal|Spline Vertex}} type. This is done automatically when {{Literal|Link to Spline}} is executed.
 +
 
 +
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 segment then a bendy complex part, the arrow will move much faster along the straight segments (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 [http://www.youtube.com/watch?v=3PGXroxBcuo this demo].
 
For illustration of the "Homogenous" effect see [http://www.youtube.com/watch?v=3PGXroxBcuo this demo].
 +
 +
 +
== See also ==
 +
* Discussion on the forum: [https://forums.synfig.org/t/following-a-spline-serious-problem-and-frustration/9627 Following a spline: Serious problem and frustration]
 +
* Link to Spline command: {{l|Command:Link_to_Spline}}
 +
* A [https://youtu.be/d1hPxgq2qeU video tutorial] showing the steps of this page.

Latest revision as of 12:24, 1 April 2020

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

The tutorial is intended to provide a demonstration on how to use this feature.


Create the Animation

  • Create a new animation by selecting from the menu "File → New".


Create the Layers

First step, let's draw the Spline:

  1. Select the Spline Tool from the Toolbox:
    Spline-tool-0.63.06.png
  2. In the Tool Options Panel, enable only the Outline Layer type.
  3. Draw a Spline that you want the arrow to move along.
  4. Click the "Make Spline" icon in the bottom left of the Tool Options Panel to create the Spline.


Second step, let's draw the arrow:

  1. Select the Spline Tool, this time enabling "Create Outline" and "Create Region" Layer types:
    Spline-Tool-Options 0.63.06.png
  2. Draw an arrow (or any another arbitrary shape) pointing to the right side of the Canvas.
  3. Switch to the Transform Tool and select the Outline, press CtrlA to select all its handles except the green position handle.
  4. Drag the handles so that the arrow is centered around the green position handle.
  5. Add a Rotate Layer above the Outline and Region Layers.
  6. Group the Rotate, Outline, and Region Layers. At this point there are 2 top-level Layers:
    1. an Outline Layer
    2. a Group Layer containing the arrow and the Rotate Layer


Make the Arrow Move and Rotate

  1. Select the Group Layer by selecting it in the Layers Panel.
  2. Then:
    1. select its green origin position handle by clicking on it in the Canvas window
    2. while holding Ctrl select the Rotate Layer in the Layers Panel
    3. while holding Ctrl select its blue rotation handle in the Canvas window
    At this point, there are 2 Layers selected and one handle from each of those 2 Layers selected.
  3. Now, while holding Ctrl select also the curved Spline Layer (it should be the last Layer in the Layer Panel's list).
  4. Right-click on the dotted line that indicates the position of the curved Spline, not on any handle, but on the dotted line between handles.
  5. 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.
  6. Select just the Group Layer, and drag its green handle around. The handle is now constrained to the Spline and dragging it will also affect the rotation of the arrow.
    We can now animate the arrow.
  7. Turn on Animate Editing Mode by clicking the icon in the bottom right of the Canvas window:
    1. at time 0f, drag the Group Layer's green position handle to one end of the Spline
    2. at time 5s, drag the same position handle to the other end of the Spline
  8. Try "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, you'll see that its Origin parameter is converted to "Spline Vertex" type. This is done automatically when "Link to Spline" is executed.

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 segment then a bendy complex part, the arrow will move much faster along the straight segments (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 • русский