This shows you the differences between two versions of the page.
arma2:modeling:user_animation [2011-06-30 18:10] snakeman created user_animation initial page. |
arma2:modeling:user_animation [2016-10-03 12:39] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== User Animation Tutorial ====== | ||
- | Primary target - Vehicles | ||
- | |||
- | This tutorial is to show the basics of how to animate a section of a vehicle model with a USER action. Specific subject pictures are a aeroplane ramp, but any vehicle can have similar. | ||
- | |||
- | |||
- | ====== Model ====== | ||
- | |||
- | First thing that needs to be done is create the section to be animated (an access ramp in this case). | ||
- | |||
- | This section needs its own name in O2. "RAMP1" in this example. | ||
- | |||
- | This section needs to be created and named in every Resolution LOD as well as the Geometry LOD. | ||
- | |||
- | If someone is going to walk on this section, then it should also be created and named in the Roadway as well. | ||
- | |||
- | In the Memory LOD you need to create 2 points/vertexes that mimic the "hinge" point. The points form the line around which the ramp will rotate. | ||
- | |||
- | These 2 points need also to be named. "AXIS_RAMP1" in this case. | ||
- | |||
- | For the USER/Player to access the Action menu of the vehicle, we definite points or locations where the required action will appear in the player menu. | ||
- | |||
- | These User Action point(s) we name for our example "ACTION_RAMP1" | ||
- | |||
- | |||
- | ====== Model.cfg ====== | ||
- | |||
- | In the CFG Skeleton section of the model.cfg file you should add something like this; | ||
- | <code cpp> | ||
- | class CfgSkeletons | ||
- | { | ||
- | class Plane; | ||
- | class myPlaneBones: Plane | ||
- | { | ||
- | isDiscrete=1; | ||
- | skeletonInherit = ""; | ||
- | skeletonBones[]= | ||
- | { | ||
- | "RAMP1","", | ||
- | xxxxxx, xxxxx, | ||
- | etc etc | ||
- | </code> | ||
- | |||
- | Its important to have the ,"" bit, as this defines "ramp1" as being hinged off the ROOT or main part of the model. | ||
- | In the CFG Model section of the model.cfg you should add something like this; | ||
- | <code cpp> | ||
- | class CfgModels | ||
- | { | ||
- | class Plane; | ||
- | class NameofmyP3Dfile: Plane | ||
- | { | ||
- | sectionsInherit = ""; | ||
- | skeletonName = "myPlaneBones"; | ||
- | sections[] = {}; | ||
- | class Animations | ||
- | { | ||
- | class AnimateRAMP1 | ||
- | { | ||
- | type="rotation"; | ||
- | source="UserRamp1"; | ||
- | sourceAddress = "clamp"; | ||
- | selection="RAMP1"; | ||
- | axis="AXIS_RAMP1"; | ||
- | memory=1; | ||
- | angle0="rad 0"; | ||
- | angle1="rad 22"; | ||
- | minValue=0.000; | ||
- | maxValue=1.000; | ||
- | }; | ||
- | etc etc | ||
- | </code> | ||
- | |||
- | TIP: If you have saved the model.cfg in your addon project file, when you reopen your model in O2, in Buldozer you can use the middle mouse button and wheel to select/change/view the demo animation in action. | ||
- | |||
- | If the animation / ramp animations in the wrong direction, just change "rad 22" (which is 22 degrees) to "rad -22" | ||
- | |||
- | "UserRamp1" (the animation "Source") is defined (will be defined) in the config.cpp file. | ||
- | |||
- | |||
- | ====== Config.cpp ====== | ||
- | |||
- | Inside you CFGVehicle definition you need to have something like; | ||
- | <code cpp> | ||
- | class AnimationSources: AnimationSources | ||
- | { | ||
- | class UserRamp1 | ||
- | { | ||
- | source = "user"; | ||
- | animPeriod = 20; | ||
- | initPhase=0; | ||
- | }; | ||
- | }; | ||
- | </code> | ||
- | |||
- | The "UserRamp1" here must be the same name as used in the model.cfg as "source". | ||
- | |||
- | source: The controller is defined as a user animation. Always "user" in these cases. | ||
- | |||
- | animPeriod: The animation period used for this controller. In seconds. | ||
- | |||
- | initPhase: Initial phase / status when object is created. 0 = CLOSED or O2 default modeled state. | ||
- | |||
- | To create the pop-up menu near the vehicle that allows players to open or close the ramp, add code like this inside the CFGVehicle definition; | ||
- | <code cpp> | ||
- | class UserActions | ||
- | { | ||
- | class OpenRamp | ||
- | { | ||
- | displayName="Open Ramp"; | ||
- | position="ACTION_RAMP1"; | ||
- | onlyforplayer=0; | ||
- | radius=8; | ||
- | condition="(this animationPhase ""AnimateRAMP1"" == 0)"; | ||
- | statement="this animate [""AnimateRAMP1"",1];"; | ||
- | }; | ||
- | class CloseRamp | ||
- | { | ||
- | displayName="Close Ramp"; | ||
- | position="ACTION_RAMP1"; | ||
- | onlyforplayer=0; | ||
- | radius=8; | ||
- | condition="(this animationPhase ""AnimateRAMP1"" == 1)"; | ||
- | statement="this animate [""AnimateRAMP1"",0];"; | ||
- | }; | ||
- | }; | ||
- | </code> | ||
- | |||
- | ACTION_RAMP1 is the point(s) we named in the Memory LOD | ||
- | |||
- | AnimateRAMP1 is the same name we used in the CfgModel section of the model.cfg | ||
- | |||
- | "Open Ramp" and "Close Ramp" are exactly the menu actions the player will see. | ||
- | |||
- | RADIUS is the radius in meters around the ACTION_RAMP1 points that players will see the action in menu. |