Point to one object

From Synfig Studio :: Documentation
Jump to: navigation, search
m (Convert RHS subparameter)
(Create the objects to move)
Line 14: Line 14:
 
== Create the objects to move==
 
== Create the objects to move==
  
First lets create the fly. In this case I've drawn three regions emulating the two wings and the body. Once created with the BLine Tool, encapsulate them into a Paste Canvas Layer.
+
First lets create the fly. In this case I've drawn three Region layers emulating the two wings and the body. Once created with the BLine Tool, encapsulate them into a Paste Canvas Layer. It is '''very important''' that the fly has to be centered on the paste canvas layer's origin. Once encapsulated the fly layers, the created Paste Paste Canvas layer's Origin is at (0,0) so you have to move the fly layers BLines to be around the Paste Canvas Layer origin. To do that select all the fly layers, select all the ducks and move them to where the Paste Canvas Layer Origin parameter is (normally at (0,0)). Once done you can select only the Paste Canvas Layer and move it around by dragging its Origin's duck.  
  
Then create the Eye. To create it I simply create three Circle Layers: One black in the background (countour of the eyeball), one white in the middle (white eyeball) slightly smaller than the black one, and one smaller black for the pupil. Once created place them in that order and below the fly paste canvas layer.
+
Now create the Eye. To create it simply create three Circle Layers: One black in the background (contour of the eyeball), one white in the middle (white eyeball) slightly smaller than the black one, and one smaller black for the pupil. Once created place them in that order and below the fly paste canvas layer. Rename them properly.
  
 
Add a Solid Color layer for the background and move it down to the bottom.
 
Add a Solid Color layer for the background and move it down to the bottom.
  
We are ready to start to make the magik ;)
+
We are ready to start to make the magic ;)
  
It should look like this (I have a zoom to make a close up screenshot):
+
It should look like this (I have a zoom layer added to make a close up screen shot):
  
[[File:Canvas window Point to Object.png]] [[File:Point to Object layers.png]]  
+
[[File:Canvas window Point to Object.png]] [[File:Point to Object layers.png]]
  
 
== Export some parameters ==
 
== Export some parameters ==

Revision as of 12:11, 3 March 2012

Languages Language: 

English


Introduction

The object of this tutorial is that achieve that one object points to other regardless the movement of both objects. For this tutorial I've selected one moving eye following one mofing fly. This is the result you'll obtain:

Look-the fly!.gif

Create the objects to move

First lets create the fly. In this case I've drawn three Region layers emulating the two wings and the body. Once created with the BLine Tool, encapsulate them into a Paste Canvas Layer. It is very important that the fly has to be centered on the paste canvas layer's origin. Once encapsulated the fly layers, the created Paste Paste Canvas layer's Origin is at (0,0) so you have to move the fly layers BLines to be around the Paste Canvas Layer origin. To do that select all the fly layers, select all the ducks and move them to where the Paste Canvas Layer Origin parameter is (normally at (0,0)). Once done you can select only the Paste Canvas Layer and move it around by dragging its Origin's duck.

Now create the Eye. To create it simply create three Circle Layers: One black in the background (contour of the eyeball), one white in the middle (white eyeball) slightly smaller than the black one, and one smaller black for the pupil. Once created place them in that order and below the fly paste canvas layer. Rename them properly.

Add a Solid Color layer for the background and move it down to the bottom.

We are ready to start to make the magic ;)

It should look like this (I have a zoom layer added to make a close up screen shot):

Canvas window Point to Object.png Point to Object layers.png

Export some parameters

  • First go to the Paste Canvas layer that holds the fly and select the Origin parameter.
  • Right click it and select 'Export' and give the name of 'fly'.
  • Then go to the 'white' layer and the 'black' layer and select both at the same time. You can do this holding CTRL meanwhile you click on the layers. Once selected both, the paramters on the Parameter layer are slightly different. The common parameters are shown (in this case all them because the layers are the same type) but the parameters that have different values are greyed indicating that.
  • Do right click to the Origin parameter and select 'Link'. That would allow to move the origin of both circles as one.
  • Now select the 'white' layer.
  • Repeat the right click on the Origin parameter and you'll obtain other contextual menu.
  • Select 'Export' and name the value node to be 'origin'
  • Select the Radius parameter and do right click and select 'Export' and name it as 'white radius'.
  • Go to the 'pupil' layer and select the Radius parameter of the circle.
  • Right click and select 'Export'. Give the name of 'pupil radius'. It will be used later.

Convert pupil's Origin parameter

To make the pupil look at the fly where ever it be, we need to automatically move the pupil based on the fly movement and position. To do that we need to make some geometric work.

First let's convert the pupil's Origin parameter to Add convert type. To do that select the 'pupil' layer and at the Parameters Panel select the Origin parameter and do right click. At the contextual menu select 'Convert' and in the sub menu select 'Add'. This will add three sub parameters to the Origin parameter.

  • Origin
    • LHS
    • RHS
    • Scalar

LHS is for 'Left Hand Side' and RHS is for 'Right Hand Side'. In a addition the order of the elements is not important but for a subtraction it is important.

You can see those sub parameters by clicking on the triangle that appear near the Origin parameter on the left.

Now, we will connect the LHS sub parameter with the origin of the eye, so the position of the pupil is given by the sum of two vectors: the origin of the eye (LHS) and the vector from the eye's origin to the pupil's origin (RHS). To connect the LHS sub parameter first select the Children Panel and expand the Value Nodes list by clicking on the small triangle on the left of the 'Value Node' row. You'll see all the exported value nodes that we did on the previous section of the tutorial. Then select the 'origin' parameter. This would allow us to use it as the target for the subsequent 'Connect' actions. Go to the Parameters Panel again and do right click on the LHS sub parameter of the Origin parameter. Select 'Connect' from the contextual menu. It will connect the LHS parameter to the exported value node called 'origin' already selected on the children list. It should look like this:


Point to object Pupil Origin add.png

Convert RHS sub parameter

Notice that the sub parameter RHS represents the vector that goes from the eye's origin to the pupils's origin and precisely it is the vector that we want to point to the fly. To make it point to the fly we need to achieve two things:

1) The pupil should not go outside the white eye's radius. 2) The pupil should point to the fly in all moment. It will point to the fly if the direction of the vector from the eye's origin to the pupil's origin has the same direction than the vector that goes from the eyes' origin to the fly's position.

So we need to control the distance and the angle of the vector form the eye's origin to the pupil's origin (that is the RHS). To do this we will convert the RHS in a Radial composite:

Select the RHS sub parameter. Right click on it and select Convert and Radial Composite from the sub menu. It will provide two sub parameters:

  • RHS
    • Radius
    • Theta

Let's first handle the Radius sub parameter.


Languages Language: 

English