Code34/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
(delete useless link)
(Animation page - original)
Line 1: Line 1:
[[Category:Sandbox]]
[[Image:AnimatedDoors.jpg|right|thumb|200px|Car with animated doors & trunk]]
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).


{{TOC|side}}
Complex animations for soldier's movements for example are a [[Rtm_%28Animation%29_File_Format | different issue]] altogether...


[[Arma 3 Apex]] introduces new main menu defined in the RscDisplayMain ressource.


[[File:a3 mainMenu.jpg|512px]]
To create a model animations, these are the requirements:


== World Scene ==
Create the movable object in the [[LOD#.3CResolution.3E | ResolutionLOD]] and give it a name.<br>
World scene is a scenario shown behind main menu when a specific terrain is loaded and [[Arma_3_Startup_Parameters#Game_Loading_Speedup|-skipIntro]] is not used. If you're playing on Altis and leave to main menu, Altis scene will be used.
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 scene must be defined in an addon either in the terrain configuration or later by overwriting the existing configurations.
In the [[Config.cpp]] for your model you need to define two classes: Animations & UserActions.<br>
The Animations class defines ''how'' the object moves, and the UserActions class defines ''when'' it moves.


=== Guidelines ===
By default, the scene uses a camera but any scriptable system can be used, such as OGV videos.
* All content of the scenario should be placed in the ''Intro'' [[Eden_Editor:_Scenario_Phases|phase]].
* The scene should work on 16:9 screen. Multiple monitors doesn't need to be considered, as the main menu shows a grey background there.


For a better player experience, the scene should meet following criteria:
The following example is for an object that has been named 'door', which turns around an axis named 'door axis'.
* Lower performance makes navigating the menu uncomfortable.
The 'action point' (the position the player has to be close to, in order to be able to activate this animation) is called 'doorbell'.
* Low [[setViewDistance|view distance]] (~200 m) is recommended.
* Avoid Camera looking down or towards sloped terrain, so the view distance is not as apparent.
* Avoid Unlit night scenes (dark menus on dark scene don't look well).
* Avoid Bad weather (hides shadows).


=== Configuration for Stratis terrain ===
config.cpp (must be binarized)
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
class CfgPatches {
class Animations
class mainmenu {
units[] = {};
weapons[] = {};
requiredVersion = 0.1;
requiredAddons[] = {"A3_Data_F_Enoch_Loadorder"};
};
};
class CfgWorlds
{
class CAWorld;
class Stratis : CAWorld
{
cutscenes[] = {"MyWorldScene"}; // Class names of used scenes. When more than one is present, the system will pick one randomly.
};
initWorld = "Stratis";
demoWorld = "Stratis";
};
class CfgMissions
{
{
class Cutscenes
class MoveDoor
{
{
class MyWorldScene // Class referenced in 'cutscenes' property in CfgWorlds
type = "rotation"; // always "rotation"
{
animPeriod = 1; // how long it takes for the movevement to finish
directory = "MyAddon\MyScene.Stratis"; // Path to scenario with the scene
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>
=== Default Scenario with camera ===
<ol>
<li>Open [[Eden Editor]] on the desired terrain</li>
<li>Switch to ''Intro'' [[Eden_Editor:_Scenario_Phases|phase]] and place a player character (the system will not work without a player!)</li>
<li>Save the scenario using the name defined by ''directory'' property in config (''MyScene.MyWorld'' in our example)</li>
<li>Open scenario folder (''Scenario > Open Scenario Folder'')</li>
<li>Create '''initIntro.sqf''' file, it will be run automatically at the scene start</li>
<li>Copy the code below to the file
<syntaxhighlight lang="cpp">
[
//--- Underwater plane
{
["InitDummy",["Stratis",[1445.92,4802.16,-4.05235],140.191,0.27,[-9.09091,-10.4773],2.74605,0,1049.08,0.00329716,1,1.10852,-0.157568,1.23792]] call bis_fnc_camera;
setviewdistance 200;
},
//--- Aegis
{
["InitDummy",["Stratis",[2622.76,580.76,16.5994],25.2349,0.53,[-44.4346,0],0,0,526.374,0.00669019,1,1,0,1]] call bis_fnc_camera;
}
] call BIS_fnc_initWorldScene;</syntaxhighlight>
The script will automatically add a subtle vignette and play main menu theme repeatedly.
</li>
<li>Replace scenes in the [[Array|array]] with your scenes captured by [[Arma 3: Splendid Camera]]. Make sure to use "InitDummy" [[String|string]] at the beginning. The example currently uses two Stratis scenes, you replace them with as many scenes as you wish.
* Optionally, add assets to the scene in the editor if needed (e.g., soldiers walking around, parked vehicles, etc.)</li>
<li>Move the scenario folder to your addon folder (as defined by ''directory'' property in config; ''MyAddon\MyScene.Stratis'' in our example)</li>
</ol>
== Spotlight ==
Three large square buttons in the middle of the main menu are spotlight buttons. While the left and right ones are hard-coded, the middle one can be used by any mod-maker.
It's possible to define a list of spotlights, with the system picking randomly from them every time the menu refreshes (i.e., startup or returning from sub-menu).


=== Configuration ===
class UserActions
<syntaxhighlight lang="cpp">
class CfgMainMenuSpotlight // RscDisplayMain >> Spotlight works but is considered obsolete since SPOTREP #00064
{
{
class CoopCampaign
class OpenDoor // action to open the door
{
text = "Coop Campaign"; // Text displayed on the square button, converted to upper-case
textIsQuote = 1; // 1 to add quotation marks around the text
picture = "\a3\Ui_f\Data\GUI\Rsc\RscDisplayMain\spotlight_1_apex_ca.paa"; // Square picture, ideally 512x512
video = "\a3\Ui_f\Video\spotlight_1_Apex.ogv"; // Video played on mouse hover
action = "ctrlactivate ((ctrlparent (_this select 0)) displayctrl 101);"; // Code called upon clicking, passed arguments are [<button:Control>]
actionText = $STR_A3_RscDisplayMain_Spotlight_Play; // Text displayed in top left corner of on-hover white frame
condition = "true"; // Condition for showing the spotlight
};
class AnotherCoopCampaign
{
{
text = "Another Coop Campaign";
displayName = "Open Door"; // string that's displayed in the action menu
picture = "\a3\Ui_f\Data\GUI\Rsc\RscDisplayMain\spotlight_1_eastwind_ca.paa";
position = "doorbell"; // name of the 'action point'
action = "ctrlactivate ((ctrlparent (_this select 0)) displayctrl 149);";
radius = 1.5; // how close the player has to be see this action
actionText = $STR_A3_RscDisplayMain_Spotlight_Play;
condition = "this animationPhase ""MoveDoor"" < 0.5"; // check whether the door has moved already
condition = "isKeyActive 'FinishedCoopCampaign';";
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 JoinServer
class CloseDoor // action to close the door
{
{
text = "Splendid Server";
displayName = "Close Door";
picture = "my_mod\data\spotlight.paa";
position = "doorbell";
action = "connectToServer ['127.0.0.1', 2302, '']";
radius = 1.5;
actionText = "Join the Splendid Server";
condition = "this animationPhase ""MoveDoor"" < 0.5";
condition = "true";
statement = "this animate[""MoveDoor"", 0]";
onlyForPlayer = true;  
};
};
};
};
Line 123: Line 57:




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

Revision as of 08:24, 19 February 2021

Car with animated doors & trunk

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 different issue altogether...


To create a model animations, these are the requirements:

Create the movable object in the ResolutionLOD and give it a name.
If the animation would affect the ( Fire) GeometryLOD, copy the selection into those LODs as well.
In the MemoryLOD define the rotational axis via two vertexes. Select both of those points and give them a name.
Still in the 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.
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'. The 'action point' (the position the player has to be close to, in order to be able to activate this animation) is called 'doorbell'.

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; 
	};
};