Custom ANIM3DTRANS animation - working.
Posted: 19 Feb 2015, 11:26
Hi, as the title is stating, it is possible to use custom ANIM3DTRANS animation type.
You may ask: Why to use ANIM3DTRANS instead of ANIM3DFRAMES?
Well, ANIM3DFRAMES animation type is displaying the objects stored in the pie - one object for one frame. This means you have to model objects for every frame. (Or you use one object and animate the textures frame by frame)
ANIM3DTRANS however, lets you animate the object by changing the location, rotation and scale values of the objects. So you model them once and then animate them with much better control. Since you can define the number of frames, frame rate, and multiple objects, the animation can be smooth and good looking, with low resources usage.
So, i was using reverse engineering to understand how the animation is working, and to get the right measurement for dimensions and rotations. To get some results, I made custom objects - see rotation image attachment. -I have used the rotation data from oil derrick animation - the arrow was showing me how much degrees it rotates.
How does it work:
First, let’s go thought the animation file blderik.ani to understand the formats and limitations:
The file header is actually quite self-explanatory:
/* header format: anim3d [filename] [frames][framerate] [num objects] */
/* anim line: [frame] [x] [y] [z] [xrot] [yrot] [zrot][xscale] [yscale] [zscale] */
ANIM3DTRANS "BLDerik.pie" 25 15 3
This means that the animation format is ANIM3DTRANS, it is animating the "BLDerik.pie" it has 25 frames total, frame rate is 15 frames per second and number of animated objects is 3
Then the objects are defined: ANIMOBJECT 0 – that is targeting the LEVEL 1 in the pie. (: ANIMOBJECT 1 will target LEVEL 2 and so on…) The "DerrickBase" is just a description to reference the animated object.
The animation values have a strict order and character space they occupy:
[frame] [x] [y] [z] [xrot] [yrot] [zrot][xscale] [yscale] [zscale]
0 0 0 0 0 0 0 1000 1000 1000
1 0 0 0 0 0 0 1000 1000 1000
First there are two tabulators, than 3 characters for frame number, which theoretically should allow 999 frames maximum.
Than one tabulator and now the values - 8 characters for each x, y, z, xrot, yrot, zrot, xscale, yscale, zscale value. Since the values can be also negative defined by “-” minus sign it leaves 7 characters for each value, which theoretically should allow maximum 9999999 values. It is important to use the correct spacing - all values are aligned to the right in the 8 character space, so all remaining characters to the left have to be empty space “ ”. I recommend tools like notepad++ to check the structure.
Now the scale ratio.
Let me start with the rotation, since it is easy to explain. One degree of rotation equals 1000 value. (1° = 1000) I didn't test if you can go beyond 360° (360000), but I presume it is possible (for spiral ascending paths for example).
The scale can be translated to percent 100% equals to 1000. So 50% is 500 and so on …
The location (or size dimension) are little harder to explain.
If you are working with the blender PIE plugin, like I do, the default cube in new scene is 2 blender tiles big. One blender tile = 100000 value (or 0,1 blender tile = 10000 value).
If you don’t use blender, let me describe the oil derrick size. The Derick base size is 89062 by 60938 wz units.
(The “piston” moves on z axis to 29827 wz units on frame 12.)
I have imported the oil derrick pie to blender and manually entered the location, rotation and scale values for each frame.You can open the attached blender file and press Alt + A to see the animation.
I have tested custom animation, -it works, but manually editing the ani file takes lot of time. The best would be to have a export script that exports the values for each frame. I have googled and found a script for exporting the location for each key frame. I just added the rotation and scale properties:
import bpy
scn = bpy.context.scene
obj = bpy.context.active_object
for f in range(scn.frame_start, scn.frame_end+1):
# use frame_set() so that keyed values are updated
scn.frame_set(f)
print(scn.frame_current, obj.location, obj.rotation_euler, obj.scale)
This is the output:
0 <Vector (0.0000, 0.0000, 0.0000)> <Euler (x=0.0000, y=0.0000, z=0.0000), order='XYZ'> <Vector (1.0000, 1.0000, 1.0000)>
1 <Vector (0.0067, 0.0000, 0.0017)> <Euler (x=0.0000, y=-0.0117, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
2 <Vector (0.0268, 0.0000, 0.0071)> <Euler (x=0.0000, y=-0.0335, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
3 <Vector (0.0600, 0.0000, 0.0172)> <Euler (x=0.0000, y=-0.0755, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
4 <Vector (0.1058, 0.0000, 0.0337)> <Euler (x=0.0000, y=-0.1345, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
5 <Vector (0.1632, 0.0000, 0.0589)> <Euler (x=0.0000, y=-0.2103, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
6 <Vector (0.2305, 0.0000, 0.0956)> <Euler (x=0.0000, y=-0.3031, z=-0.0000), order='XYZ'> <Vector (1.0000, 1.0000, 1.0000)>
7 <Vector (0.2989, 0.0000, 0.1418)> <Euler (x=0.0000, y=-0.4030, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
….
First is location, than rotation and on the end scale. However the location requires one more decimal point, the rotation is in radians and not in degrees. I found the degree calculation http://blenderartists.org/forum/showthr ... alculation, but I don’t know how to incorporate it into the script.
So if there is someone that understand python language (not the real snake) - your help is wanted and welcomed to export the values. At least text containing location, rotation and scale for each frame in correct wz values would be awesome.
my best regards,
Astorian
You may ask: Why to use ANIM3DTRANS instead of ANIM3DFRAMES?
Well, ANIM3DFRAMES animation type is displaying the objects stored in the pie - one object for one frame. This means you have to model objects for every frame. (Or you use one object and animate the textures frame by frame)
ANIM3DTRANS however, lets you animate the object by changing the location, rotation and scale values of the objects. So you model them once and then animate them with much better control. Since you can define the number of frames, frame rate, and multiple objects, the animation can be smooth and good looking, with low resources usage.
So, i was using reverse engineering to understand how the animation is working, and to get the right measurement for dimensions and rotations. To get some results, I made custom objects - see rotation image attachment. -I have used the rotation data from oil derrick animation - the arrow was showing me how much degrees it rotates.
How does it work:
First, let’s go thought the animation file blderik.ani to understand the formats and limitations:
The file header is actually quite self-explanatory:
/* header format: anim3d [filename] [frames][framerate] [num objects] */
/* anim line: [frame] [x] [y] [z] [xrot] [yrot] [zrot][xscale] [yscale] [zscale] */
ANIM3DTRANS "BLDerik.pie" 25 15 3
This means that the animation format is ANIM3DTRANS, it is animating the "BLDerik.pie" it has 25 frames total, frame rate is 15 frames per second and number of animated objects is 3
Then the objects are defined: ANIMOBJECT 0 – that is targeting the LEVEL 1 in the pie. (: ANIMOBJECT 1 will target LEVEL 2 and so on…) The "DerrickBase" is just a description to reference the animated object.
The animation values have a strict order and character space they occupy:
[frame] [x] [y] [z] [xrot] [yrot] [zrot][xscale] [yscale] [zscale]
0 0 0 0 0 0 0 1000 1000 1000
1 0 0 0 0 0 0 1000 1000 1000
First there are two tabulators, than 3 characters for frame number, which theoretically should allow 999 frames maximum.
Than one tabulator and now the values - 8 characters for each x, y, z, xrot, yrot, zrot, xscale, yscale, zscale value. Since the values can be also negative defined by “-” minus sign it leaves 7 characters for each value, which theoretically should allow maximum 9999999 values. It is important to use the correct spacing - all values are aligned to the right in the 8 character space, so all remaining characters to the left have to be empty space “ ”. I recommend tools like notepad++ to check the structure.
Now the scale ratio.
Let me start with the rotation, since it is easy to explain. One degree of rotation equals 1000 value. (1° = 1000) I didn't test if you can go beyond 360° (360000), but I presume it is possible (for spiral ascending paths for example).
The scale can be translated to percent 100% equals to 1000. So 50% is 500 and so on …
The location (or size dimension) are little harder to explain.
If you are working with the blender PIE plugin, like I do, the default cube in new scene is 2 blender tiles big. One blender tile = 100000 value (or 0,1 blender tile = 10000 value).
If you don’t use blender, let me describe the oil derrick size. The Derick base size is 89062 by 60938 wz units.
(The “piston” moves on z axis to 29827 wz units on frame 12.)
I have imported the oil derrick pie to blender and manually entered the location, rotation and scale values for each frame.You can open the attached blender file and press Alt + A to see the animation.
I have tested custom animation, -it works, but manually editing the ani file takes lot of time. The best would be to have a export script that exports the values for each frame. I have googled and found a script for exporting the location for each key frame. I just added the rotation and scale properties:
import bpy
scn = bpy.context.scene
obj = bpy.context.active_object
for f in range(scn.frame_start, scn.frame_end+1):
# use frame_set() so that keyed values are updated
scn.frame_set(f)
print(scn.frame_current, obj.location, obj.rotation_euler, obj.scale)
This is the output:
0 <Vector (0.0000, 0.0000, 0.0000)> <Euler (x=0.0000, y=0.0000, z=0.0000), order='XYZ'> <Vector (1.0000, 1.0000, 1.0000)>
1 <Vector (0.0067, 0.0000, 0.0017)> <Euler (x=0.0000, y=-0.0117, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
2 <Vector (0.0268, 0.0000, 0.0071)> <Euler (x=0.0000, y=-0.0335, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
3 <Vector (0.0600, 0.0000, 0.0172)> <Euler (x=0.0000, y=-0.0755, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
4 <Vector (0.1058, 0.0000, 0.0337)> <Euler (x=0.0000, y=-0.1345, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
5 <Vector (0.1632, 0.0000, 0.0589)> <Euler (x=0.0000, y=-0.2103, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
6 <Vector (0.2305, 0.0000, 0.0956)> <Euler (x=0.0000, y=-0.3031, z=-0.0000), order='XYZ'> <Vector (1.0000, 1.0000, 1.0000)>
7 <Vector (0.2989, 0.0000, 0.1418)> <Euler (x=0.0000, y=-0.4030, z=-0.0000), order='XYZ'> <Vector (0.9990, 1.0000, 0.9990)>
….
First is location, than rotation and on the end scale. However the location requires one more decimal point, the rotation is in radians and not in degrees. I found the degree calculation http://blenderartists.org/forum/showthr ... alculation, but I don’t know how to incorporate it into the script.
So if there is someone that understand python language (not the real snake) - your help is wanted and welcomed to export the values. At least text containing location, rotation and scale for each frame in correct wz values would be awesome.
my best regards,
Astorian