Anim System Tutorial
Covered in this tutorial.
ini.ini | Main ini file template |
Main.pov | Main anim pov file |
Lastval.inc | Holds last values |
Startval.inc | Holds a set of start values |
inertia/Convel.inc | Converts velocity |
inertia/Inertia.inc | does the movement calculations |
Anim/Objects.inc | Holds a list of objects to be animated |
Anim/Moveobj.inc | Template for the controls to move an object |
Anims/Makeflc.bat | Batch file to create a flc using DTA |
Anims/Joinflc.bat | Batch file to join a flc using DTA |
Things that have to be set
Final_Frame | The number of frames in the total animation. This is calculated by - Anim length in secs* Frames per sec |
Subset_Start_Frame | For starting the rendering of an animation later through |
Subset_End_Frame | For ending the rendering early |
MainScene | The name of your main scene | ||||||||||||
secs | Length of animation in seconds. - Must be a whole number of frames.
eg
if anim to be around 25secs, and there are 16.67 frames/sec (1 frame every 3/50 of a second) then, 25*50 (number of points to be calculated) = 1250. 1250/3 (number of frames) = 416.66667 -> round to 417 frames 417*3 (number of points to be calculated) = 1251 1251/50 (length of animation) = 25.02secs |
||||||||||||
Frames | Number of frames per sec. Must divide evently into the res value. ie
Frames can equal Res/1, 2,3,4,5 etc
eg.
|
||||||||||||
fast | Use in your scene file to block out unnecessary detail. | ||||||||||||
res | The resolution of the calculations | ||||||||||||
Often | How often to save the object positions to a file for cacheing. ie if Often=20 then save every 20 calculations, so that it doesn't have to be recalculated | ||||||||||||
flight | Turn on flight path checking. Please use a #if(flight=off) ....... #end around your camera statement | ||||||||||||
ObjectPos | Set to the position var for your object. eg ObjectPos=Ship1Pos | ||||||||||||
Marker | How often to place a red marker in the flight path.
Also a green marker is placed at 10x marker. This value is how many calculations between each marker. If you make this value the same as the res value then you will get a red marker at 1 sec and a green at 10 sec intervals. |
||||||||||||
Jumpin | To let the calculations jump in part way through the animation. eg.
calculate to a point eg 10 secs time copy the section from lastval.inc for Time=9.20 and paste to Startval.inc Set Jumpin to true. Now the Startval.inc will be read and the calculations will go from that point. |
#include "Anim/your_object_movement_file.inc"
Can use the Time var to remove sections.
eg.
#if (Time <=7.0) // 7 secs
#include "Anim/Missile1.inc"
#end
and in your scene file
#if(Time<=7.0) // 7 secs
object {Missile1}
#end
Vars for the inertia system.
@obj@ is replaced with the name of you object.
@obj@Inertia | If to use inertial or non-inertial movement.
Inertial is the correct method as far as the equations of motion go, and is great for in space. Non-Inertial looks good for atmosphere movement, ie where friction has a part in the movement. |
@obj@Dir | Only used when inertia = true. Locks the direction of the acceleration to the rotation of the object. |
@obj@Acc | <heading,pitch,size>. The Acceleration of the object. If in non-inertial mode then only the size part is used. |
@obj@Vel | <heading,pitch,size>. The object's velocitiy. If using non-inertial mode then only the size compent is used. |
@obj@Pos | <x,y,z>. The position of the object. To use in your scene -> object {thing translate thing.Pos} |
@obj@Rot | <bank,heading,pitch>. The rotations of the object. To use in your scene -> object {thing rotate thingRot*<1,0,1> rotate thingRot*<0,1,0> translate thingPos} |
@obj@Rotch | <bank/sec,heading/sec,pitch/sec>. The changes in rotation in
degrees per sec.
For inertial movement I find the I only change the bank, and pitch and set the heading to = -thingRot.x. Ie the objects current bank. |
In this tutorial we will go from nothing to a simple and object and camera flying around a small landscape.
1) Now the AnimSystem expects.
Object 1.
Lets have a simple paper place style object to fly arund with.
Now because of how the AnimSystem axis are used we will design the object so that it starts pointing in the +x direction with +y up and +z to the left.
* Note: If an object has been designed in a different direction, axis then do some initial rotations to the object first to make it point correctly.
Our Object.
Side:
Top:
Back:
We will make this up in three sections.
1. Wing
This will be made up of three boxs, so, Create a new file called paper.inc and type in;
#declare value=sqrt(2)/2 #declare Mid= difference { difference { box { <-1.5,-value,-value> <1.5,value,value> rotate <45,0,0> translate <0,-1,0>} box { <-2,-value,-value> <2,value,value> rotate <45,0,0> translate <0,-.9,0>} translate <-1.5,2,0> rotate <0,0,18.43> } box { <-5,0,-5> <5,2,5>} }
2. Mid
#declare value=sqrt(2)/2 #declare Mid= difference { difference { box { <-1.5,-value,-value> <1.5,value,value> rotate <45,0,0> translate <0,-1,0>} box { <-2,-value,-value> <2,value,value> rotate <45,0,0> translate <0,-.9,0>} translate <-1.5,2,0> rotate <0,0,18.43> } box { <-5,0,-5> <5,2,5>} }
3. thing
#declare Plane= union { object {wing} object {wing scale <1,1,-1>} object {Mid } translate <2,0.5,0> pigment {color White} }
OK. Thats the paper plane done. Now for the landscape. We will use the land.gif picture as a height field.
Create a new file called land.inc and type in;
#declare land = height_field { gif "land.gif" water_level .05 // smooth texture { pigment { gradient y color_map { [0.0 color Blue] [0.05 color Yellow] [0.2 color Brown] [0.4 color Green] [0.9 color White] [1.0 color White] } } finish {ambient .2} } scale <2000,256,2000> translate <-1000,-26,-1000> }
Now by using Height Field Lab 0.84 with the land.gif, we are going to get so heights on the height field.
Land.gif is 117x88 pixels in size
First lets find some places on the gif for some buildings.
Name | X | Y | X | Y | PovX | PovY | PovY |
a | 20% | 20% | 23 | 18 | .197 | .205 | .4627 |
b | 25% | 70% | 29 | 62 | .248 | .705 | .1412 |
c | 27% | 76% | 32 | 67 | .274 | .761 | .1647 |
d | 45% | 60% | 53 | 53 | .453 | .602 | .2078 |
e | 53% | 28% | 62 | 25 | .530 | .284 | .4118 |
f | 68% | 12% | 80 | 11 | .684 | .125 | .3294 |
g | 85% | 20% | 99 | 18 | .864 | .205 | .3451 |
h | 76% | 78% | 89 | 69 | .761 | .784 | .2078 |
Name | old Z | X | 1-Z | Y | X | Y | Z |
a | .205 | .197 | .795 | .4627 | -606 | 91 | 590 |
b | .705 | .248 | .295 | .1412 | -504 | 9 | -410 |
c | .761 | .274 | .239 | .1647 | -452 | 15 | -522 |
d | .602 | .453 | .398 | .2078 | -94 | 26 | -204 |
e | .284 | .530 | .716 | .4118 | 60 | 78 | 432 |
f | .125 | .684 | .875 | .3294 | 368 | 57 | 750 |
g | .205 | .846 | .795 | .3451 | 692 | 61 | 590 |
h | .784 | .761 | .216 | .2078 | 522 | 26 | -568 |
By using the above x,y,z points we can create some buildings.
Create a new file called building.inc and type in;
//Building.inc //a -606,91,590 box { <-600,91,580> <-620,200,600> pigment {color rgb <1,0,0>}} //b -504,9,-410 cylinder { <-504,9,-410> <-504,80,-420> ,10 pigment {color rgb <1,.5,.5>}} //c -452,15,-522 box {<-440,15,-510> <-460,120,-540> pigment {color rgb <1,1,.5>}} //d -94,26,-204 cylinder { <-94,26,-204> <-94,150,-204>,15 pigment {color rgb <.3,1,.7>}} //e 60,78,432 cylinder { <60,78,432> <60,250,432>,10 pigment {color rgb <1,1,1>}} //f 368,57,750 cylinder { <368,57,750> <368,300,750>,10 pigment {color rgb <1,1,0>}} //g 692,61,590 cylinder { <692,61,590> <692,220,590>,8 pigment {color rgb <0,1,1>}} //h 522,26,-568 box { <500,26,-550> <540,80,-580> pigment {color rgb <1,1,0>}} cylinder { <522,78,-568> <522,180,-568>,8 pigment {color rgb <1,0,1>}}
Now to put it all together in a POV file.
Create a new file called tut.pov and type in;
//Tut.pov #include "colors.inc" #include "paper.inc" #include "land.inc" #include "building.inc" // Set a color of the background (sky) background { color red 0.1 green 0.3 blue 0.8 } object {land} camera { location <0,100,-10> direction <0,0,2> look_at <0,100,0> } object {Plane pigment {color rgb <1,1,1>} rotate <0,0,0> rotate <0,-90,0> translate <0,100,0> } light_source { <0,100,-10> color rgb <1,1,1>}
Have a test render.
3) Now to create the Animation
To Start with we will use the Flight option and only declare the movement for the plane first. The Flight option will create a flight path going around the landscape, so we can make sure the object won't go through the landscape.
Step.1
Create a folder/directory called tutanim.
Copy from the AnimSys directoru all of the folders and files, so you end up with.
tutanim anim moveobj.inc Objects.inc anims makeflc.bat joinflc.bat inertia convel.inc system.inc t ini.ini main.pov
Copy from the tut directory, where the Paper plane and landscape were designed.
building.inc land.gif land.inc paper.inc tut.pov
Step.2
Rename ini.ini to tutanim.ini.
Edit tutanim.ini
Do a search for ??? File: Tutanim.ini Set the Final_Frame = 1 Set the Subset_Start_Frame = 1 Set the Subset_End_Frame = 1 Width = 320 Height = 240
Edit Main.pov
Again search for ???
Change; MainScene = "tut.pov" secs = 10 <-- the length of this anim approx Frames = 2 fast = true flight = on Jumpin = false Search for objectPOS objectPOS = planePos
Edit tut.pov
place a #if(fast=false) .... #end around #include "land.inc" and object {land} place a #if(flight=false)... #end around the camera statment and the object {Plane .....}
Edit Anim/Objects.inc
Change the line that reads,
#include "Anim/???.inc" to #include "Anim/plane.inc"
Copy Anim/moveobj.inc to Anim/plane.inc
Edit Anim/plane.inc
First do a Global search and replace from @obj@ to plane
We are not going to set some default values for the object,
Go down to the default section. Hint search for [sec1]
Set planeInertia = false. Use the non-interial system. ie the acceleration and velocity are now just scalars.
Set planeDir = true. To lock the acceleration to the objects direction.
Set planeRotCh = <0,0,0>. As a default we don't want the direction of the plane to change.
Set planeAcc = <0,0,0>. As a default we don't want the plane to accelerate.
Not to set the start values for the object.
Go down to Initial Values. Search for [sec2]
set planePos = <800,100,0>. Initial position.
set planeRot = <0,-90,0>. Initial rotation. Point in the +z direction
set planeVel = <0,0,150>. Initial Velocity of 150 units/sec
Remove the next lines down to the #break, as these aren't being changed from the defaults.
They are;
// only have to use the ConvertVel if @obj@Vel size <> 0 and using inertial system #declare Vel=@obj@Vel #include "inertia/ConvertVel" #declare @obj@Vel=Vel #declare @obj@Inertia = true // True/False #declare @obj@Dir = false // If the object acceleratiuon is in the direction of the object #declare @obj@Acc =<0,0,0> // Heading,Pitch,Size in units/sec^2
Now move down to [sec3]
Change the line #range (part, ) to #range (part,3). ie what to do for the time from 1 frame to 3 secs.
set planeRotCh = <0,0,0>. No Rotations.
Delete the other lines down to the #break.
Now when we changed Main.pov we set our length (secs) = 10, so we now have to define the time from 3 to 10 secs.
Move down to [sec4]
Change the line #range( , ) to #range (3,6). ie what to do between the time 3 and 6 secs. The duration of the section = 3 secs.
set planeRotCh = <20,-planeRot.x,0>
Delete the other lines down to the #break. This will give us a slow turn to the left.
To know by how much this effects things, it works like this.
Take the current Rotation and add on 1/res of RotCh. Which in this case is 1/50 of RotCh. So it comes out as;
Time | RotCh | Rot |
3 | 20,0,0 | 0.4,0,0 |
3.02 | 20,0.4,0 | 0.8,0.008,0 |
3.04 | 20,0.8,0 | 1.2,0.024,0 |
3.06 | 20,1.2,0 | 1.6,0.048,0 |
3.08 | 20,1.6,0 | 2,0.08,0 |
3.10 | 20,2,0 | 2.4,0.12,0 |
Etc.
Now copy the last #range .... #break group for time 3 -> 6 and paste below it, so you end up with;
#range(3,6) #declare planeRotCh = <20,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break #range(3,6) #declare planeRotCh = <20,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break #end
Change the second #range(3,6) to #range(6,10), so that this defines the time from 6 to 10.
Set the planeRotCh = <0,-planeRot.x,0>
Save the file.
Now we will go and do a test flight path render.
Run pov with the tutanim.ini
eg, povray tutanim.ini
Now you can see a white line with green and red blobs. The bottom most green blob is the Time=0, iw the start. Each Red blob from there is at 1 sec intervals with the last green blob for Time=10. At Time=6 the plane has reached the top of the curve so at that point we will flatten out the wings and start a turn to the right.
So re-edit the plane.inc,
Move down to the #range(6,10) section
Change the planeRotCh to <-30,-planeRot.,x,0>
Now Render again.
Now you can see from the flight path that the plane didn't immediately turn right. This is because it is already turning left and the plane has to first level out and then turn to the right.
Also at Time=10, the plane is heading for a block so to change this lets change the #range(6,10) section to read;
#declare planeRotCh=<-50,planeRot.x,0>
Now if we render again right from the start then it will again take ~ 1 min to render (on a 486x100). But if you look at the flight path you will notice that the values for a time <6 haven''t changed, and in the Lastval.inc is a set of values that specify a time close to 6.
So open up the Lastval.inc file. Go down the file until Time = just less than 6.00. I get 5.60. Take the values for the Tme=5.60 and copy to a new file called Startval.inc in the same directory as tutanim.ini.
The lines copied should be;
#declare Time=5.60 #declare planePos=<663.98170,100.00000,793.93549> #declare planeRot=<52.00000,-157.08000,0.00000> #declare planeVel=<0.00000,0.00000,150.00000>
Edit the file Main.pov and set Jumpin = true
Now render. This time it took me ~30 secs.
This gets us round but the plane looks like it might go a biut close to the top block. So lets change the
#range(6,10) #declare planeRotCh = <-50,-planeRot.x,0> #break #range(6,7) #declare planeRotCh = <-30,-planeRot.x,0> #break #range(7,10) #declare planeRotCh = <-50,-planeRot.x,0> #break
Re-render to see what that looks like.
Now I have worked out the rotations needed all the way up 10 secs. They are;
#range(6,7 ) #declare planeRotCh = <-30,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break #range(7,8 ) #declare planeRotCh = <-50,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break #range(8,9 ) #declare planeRotCh = <-25,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break #range(9,10 ) #declare planeRotCh = <45,-planeRot.x,0> // Bank,Heading,Pitch in degrees / sec #break
This looks like;
The rest of the animation for an object is just a collection of what has already been done.
Here are the rest for plane.inc
#range(10,11) // StartTime,EndTime #declare planeRotCh =<11,-planeRot.x,0> // The Rotation changes #declare planeAcc =<0,0,70> #break #range(11,15) // StartTime,EndTime #declare planeRotCh =<0,-planeRot.x,0> // The Rotation changes #break #range(15,16) // StartTime,EndTime #declare planeRotCh =<12,-planeRot.x,0> // The Rotation changes #break #range(16,18) // StartTime,EndTime #declare planeRotCh =<0,-planeRot.x,0> // The Rotation changes #declare planeAcc =<0,0,-40> #break #range(18,23) // StartTime,EndTime #declare planeRotCh =<0,-planeRot.x,0> // The Rotation changes #break #range(23,25) // StartTime,EndTime #declare planeRotCh =<90,0,45> // The Rotation changes #declare placeAcc =<0,0,100> #break
Now as the motion is now defined up to time 25 , edit Main.pov and change secs=25
Change the Jumpin=false to render to whole path.
And now to define the camera.
Search for objectPOS. Set objectPOS = cameraPos
Go to the end of the file and add in the line
#include "Anim/camera.inc"
Do a Global search and replace @obj@ to camera.
Search for [sec1]
Set cameraInertia = false.
Set cameraDir = true
Set cameraRotCh = <0,0,0>
Set cameraAcc = <0,0,0>
Add in the line #declare cameraLook = planePos
This is to make the camera always follow where every the plane goes.
Search for [sec2]
Set cameraPos = <600,100,750>. This is up by the first block.
Set cameraRot = <0,0,0>. Doesn't matter what it is as the cameraLook will be used instead.
Set cameraVel = <0,0,0>. Don't want the camera to move.
Remove the next lines down to the #break.
Search for [sec3]
change the #range(part, ) to #range(10,11)
Add in the line #declare cameraPos=<100,100,500>
This makes the camera jump to that position at time 10.
Remove all of the next lines down to the #break
Search for [sec4]
change the #range( , ) to #range(13,14)
Add in the line #declare cameraPos = <-700,100,50>
Remove all of the next lines down to the #break
Copy the last #range...#break section and paste below itself.
change the #range(13,14) to #range(22,22)
Change the cameraPos to <-600,100,-527>
The camera.inc sections should look like this;
//[sec1] #declare cameraDir =true // true or false #declare cameraRotCh =<0,0,0> // The Rotation changes #declare cameraInertia = false // true or false #declare cameraAcc = <0,0,0> // Heading,Pitch,Size #declare cameraLook = planePos // Controls #switch(Time) // The current time #case(0) //[sec2] // Initial values #declare cameraPos = <600,100,750> // x,y,z #declare cameraRot = <0,0,0> // Bank,Heading,Pitch #declare cameraVel = <0,0,0> // Heading,Pitch,Size #break //[sec3] #range(10,11) // StartTime,EndTime #declare cameraPos = <100,100,500> #break //[sec4] #range(13,14) // StartTime,EndTime #declare cameraPos = <-700,100,50> #break #range(22,22) // StartTime,EndTime #declare cameraPos = <-600,100.00000,-527> #break #end
Now go and do a render.
Each of the four spots define where the camera is going to go.
Now to finally have a look from the camera's point of view of the animation.
1.
Edit Main.pov
Change the Frames = 2. For two frames / sec
Change the flight = false
Edit tut.pov
Change the object {plane .... to read;
object {Plane pigment {color rgb <1,1,1>} finish {ambient .5} scale 4 rotate planeRot*<1,0,1> rotate planeRot*<0,1,0> translate planePos }
Change the camera definition to read;
camera { location cameraPos direction <0,0,4> look_at cameraLook }
Now edit tutanim.ini
Now the length of the anim is 25secs, and there are 2 frames per sec, therefore there are 50 frames to render.
Set the Final_Frame = 50
Set the Subset_Start_Frame=1
Set the Subset_End_Frame = 50
Set the Width = 80
Set the Height = 64
Render and wait quite a while. 486-100 ~ 4:36.
To create the animation use what is approprite for your system.
For dos/Win95/Win3.11 goto the dos prompt.
(Win95 - Start/Programs/MS-Dos)
(Win3.11 - Main/Msdos)
CD whereever the tutanim directory is.
CD anims
makeflc fr 9 500 test01. This uses DTA, so you need that in your path.
dfv test01 to show the anim.
To see the animation better try ->
Edit Main.pov
Set Frames = 50/3
Number of frames is going to be 25*50/3 = 416.6667 so round up to 417
Set secs = (417*3)/50=25.02
Set fast=false
Edit tutanim.ini
Set Final_Frame=417
Set Subset_End_Frame=417
Set Width = 320
Set Height = 240
Wait a REALLY LONG TIME... ~~ Time for a Pentium 100 = 8 Hours.
That is how to create an animation using the Anim System. Have a look at the Shipanim and Shark examples also, to see how they work.
Fran.