Code34/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
(Animation page - original)
(describe differents ways to create animation, add examples)
Line 1: Line 1:
[[Image:AnimatedDoors.jpg|right|thumb|200px|Car with animated doors & trunk]]
There are two ways to create animations:
This articles talks about simple, single-p3d animations, where parts of a model rotate around an axis (like a car door, or a tank turret).


Complex animations for soldier's movements for example are a [[Rtm_%28Animation%29_File_Format | different issue]] altogether...
* about vehicles or objects, you will have to use [[Model Config]].
* about characters, animals, then you have to use a [[CfgMoves Config Reference]].


The difference between the two methods is that the config model permits simple animations (like rotations around axes), while the other method permits more complex animations (with states) described in a [[Rtm_%28Animation%29_File_Format | RTM]] file.


To create a model animations, these are the requirements:
[[Image:AnimatedDoors.jpg|right|thumb|200px|Car with animated doors & trunk]]


Create the movable object in the [[LOD#.3CResolution.3E | ResolutionLOD]] and give it a name.<br>
=== Quick start: Model Config example ===
If the animation would affect the ([[LOD#Fire_Geometry | Fire]])[[LOD#Geometry | GeometryLOD]], copy the selection into those LODs as well.<br>
This example talks about simple, single-p3d animations, where parts of a model rotate around an axis (like a car door, or a tank turret).
In the [[LOD#Memory | MemoryLOD]] define the rotational axis via two vertexes. Select both of those points and give them a name.<br>
Still in the [[LOD#Memory | MemoryLOD]] create a single vertex (this will be the 'action point') and give it a name.


In the [[Config.cpp]] for your model you need to define two classes: Animations & UserActions.<br>
To create a model animations, there are requirements:
The Animations class defines ''how'' the object moves, and the UserActions class defines ''when'' it moves.
# Create the movable object in the [[LOD#.3CResolution.3E | ResolutionLOD]] and give it a name.<br>
# If the animation would affect the ([[LOD#Fire_Geometry | Fire]])[[LOD#Geometry | GeometryLOD]], copy the selection into those LODs as well.<br>
# In the [[LOD#Memory | MemoryLOD]] define the rotational axis via two vertexes. Select both of those points and give them a name.<br>
# Still in the [[LOD#Memory | MemoryLOD]] create a single vertex (this will be the 'action point') and give it a name.


The following example is for an object that has been named 'door', which turns around an axis named 'door axis'. The 'action point' (the position the player has to be close to, in order to be able to activate this animation) is called 'doorbell'. In the [[Config.cpp]] for your model you need to define two classes: Animations & UserActions. The Animations class defines ''how'' the object moves, and the UserActions class defines ''when'' it moves.


The following example is for an object that has been named 'door', which turns around an axis named 'door axis'.
=== config.cpp ===
The 'action point' (the position the player has to be close to, in order to be able to activate this animation) is called 'doorbell'.
<syntaxhighlight lang="cpp">
class CfgModels {
class door {
class Animations
{
class MoveDoor
{
type = "rotation"; // always "rotation"
animPeriod = 1; // how long it takes for the movevement to finish
selection = "door"; // the name of the moving object
axis = "door axis"; // the name of the axis
angle0 = 0; // the start angle
angle1 = -2.0; // the end angle, in radians (= degrees/57.3 = degrees * 180/pi)
};
};


<syntaxhighlight lang="cpp">
class UserActions
class Animations
{
{
class OpenDoor // action to open the door
class MoveDoor
{
{
displayName = "Open Door"; // string that's displayed in the action menu
type = "rotation"; // always "rotation"
position = "doorbell"; // name of the 'action point'
animPeriod = 1; // how long it takes for the movevement to finish
radius = 1.5; // how close the player has to be see this action
selection = "door"; // the name of the moving object
condition = "this animationPhase ""MoveDoor"" < 0.5"; // check whether the door has moved already
axis = "door axis"; // the name of the axis
statement = "this animate[""MoveDoor"", 1]"; // and if not, then start the animation
angle0 = 0; // the start angle
onlyForPlayer = true; // requirement by ArmA - presumably defines if AI can/cannot open doors etc
angle1 = -2.0; // the end angle, in radians (= degrees/57.3 = degrees * 180/pi)
};
class CloseDoor // action to close the door
{
displayName = "Close Door";
position = "doorbell";
radius = 1.5;
condition = "this animationPhase ""MoveDoor"" < 0.5";
statement = "this animate[""MoveDoor"", 0]";
onlyForPlayer = true;
};
};
};
};
};
};
</syntaxhighlight>


class UserActions
=== Quick start: CfgMoves example ===
This example describes an anim of holding rifle with one hand with the other hanging on the side. You are able to shoot in this position. It lasts for 5 seconds and returns to default pose (Weapon Raised Standing position).
 
To create a CfgMoves animations, there are requirements:
# Create your animation file with an external tool like Blender
# Export it to RTM file format
# Prepare an addon with your P3D file and RTM anim
 
The config file of your addon must describes the animations in the Cfgmoves section. In the case of our example, it is useless to use an RTM file because Arma's animations are used.
 
=== config.cpp ===
<syntaxhighlight lang="cpp">
class CfgMovesBasic; // Reference CfgMovesBasic.
class CfgMovesMaleSdr: CfgMovesBasic // Override CfgMovesMaleSdr
{
{
class OpenDoor // action to open the door
skeletonName="OFP2_ManSkeleton";
gestures="CfgGesturesMale";
class States
{
{
displayName = "Open Door"; // string that's displayed in the action menu
class AmovPercMstpSrasWrflDnon;
position = "doorbell"; // name of the 'action point'
class MyAnimation : AmovPercMstpSrasWrflDnon
radius = 1.5; // how close the player has to be see this action
{
condition = "this animationPhase ""MoveDoor"" < 0.5"; // check whether the door has moved already
looped = 0;  
statement = "this animate[""MoveDoor"", 1]"; // and if not, then start the animation
speed = -5;  
onlyForPlayer = true; // requirement by ArmA - presumably defines if AI can/cannot open doors etc
file = "\myAddons\myAnimation";
canBlendStep = 0;
minPlayTime= 0.95;  
InterpolateTo[] =  
{
"AmovPercMstpSrasWrflDnon", 0.5 
};
};
};
};
class CloseDoor // action to close the door
};
{
displayName = "Close Door";
position = "doorbell";
radius = 1.5;
condition = "this animationPhase ""MoveDoor"" < 0.5";
statement = "this animate[""MoveDoor"", 0]";
onlyForPlayer = true;
};
};
</syntaxhighlight>
</syntaxhighlight>


{{GameCategory|ofp|Modelling}}
{{GameCategory|ofp|Modelling}}
{{GameCategory|ofpe|Modelling}}
{{GameCategory|ofpe|Modelling}}
{{GameCategory|arma1|Addon Editing}}
{{GameCategory|arma1|Addon Editing}}

Revision as of 08:26, 19 February 2021

There are two ways to create animations:

The difference between the two methods is that the config model permits simple animations (like rotations around axes), while the other method permits more complex animations (with states) described in a RTM file.

Car with animated doors & trunk

Quick start: Model Config example

This example talks about simple, single-p3d animations, where parts of a model rotate around an axis (like a car door, or a tank turret).

To create a model animations, there are requirements:

  1. Create the movable object in the ResolutionLOD and give it a name.
  2. If the animation would affect the ( Fire) GeometryLOD, copy the selection into those LODs as well.
  3. In the MemoryLOD define the rotational axis via two vertexes. Select both of those points and give them a name.
  4. Still in the MemoryLOD create a single vertex (this will be the 'action point') and give it a name.

The following example is for an object that has been named 'door', which turns around an axis named 'door axis'. The 'action point' (the position the player has to be close to, in order to be able to activate this animation) is called 'doorbell'. In the Config.cpp for your model you need to define two classes: Animations & UserActions. The Animations class defines how the object moves, and the UserActions class defines when it moves.

config.cpp

class CfgModels {
	class door {
		class Animations
		{
			class MoveDoor
			{
				type = "rotation";	// always "rotation"
				animPeriod = 1;		// how long it takes for the movevement to finish
				selection = "door";	// the name of the moving object
				axis = "door axis";	// the name of the axis
				angle0 = 0;			// the start angle
				angle1 = -2.0;		// the end angle, in radians (= degrees/57.3 = degrees * 180/pi)
			};
		};

		class UserActions
		{
			class OpenDoor // action to open the door
			{
				displayName = "Open Door";	// string that's displayed in the action menu
				position = "doorbell";		// name of the 'action point'
				radius = 1.5;				// how close the player has to be see this action
				condition = "this animationPhase ""MoveDoor"" < 0.5";	// check whether the door has moved already
				statement = "this animate[""MoveDoor"", 1]";			// and if not, then start the animation
				onlyForPlayer = true;		// requirement by ArmA - presumably defines if AI can/cannot open doors etc
			};
			class CloseDoor // action to close the door
			{
				displayName = "Close Door";
				position = "doorbell";
				radius = 1.5;
				condition = "this animationPhase ""MoveDoor"" < 0.5";
				statement = "this animate[""MoveDoor"", 0]";
				onlyForPlayer = true; 
			};
		};
	};
};

Quick start: CfgMoves example

This example describes an anim of holding rifle with one hand with the other hanging on the side. You are able to shoot in this position. It lasts for 5 seconds and returns to default pose (Weapon Raised Standing position).

To create a CfgMoves animations, there are requirements:

  1. Create your animation file with an external tool like Blender
  2. Export it to RTM file format
  3. Prepare an addon with your P3D file and RTM anim

The config file of your addon must describes the animations in the Cfgmoves section. In the case of our example, it is useless to use an RTM file because Arma's animations are used.

config.cpp

class CfgMovesBasic; // Reference CfgMovesBasic. 
class CfgMovesMaleSdr: CfgMovesBasic // Override CfgMovesMaleSdr
{
	skeletonName="OFP2_ManSkeleton"; 
	gestures="CfgGesturesMale"; 
	class States
	{
		class AmovPercMstpSrasWrflDnon;
		class MyAnimation : AmovPercMstpSrasWrflDnon
		{
			looped = 0; 
			speed = -5; 
			file = "\myAddons\myAnimation"; 
			canBlendStep = 0; 
			minPlayTime= 0.95; 
			InterpolateTo[] = 
			{
				"AmovPercMstpSrasWrflDnon", 0.5  
			};
		};
	};
};