Reyhard/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search

Goals of this tutorial

In this tutorial you will learn about:

  • How to prepare prop in FBX format for Enfusion
  • How to import FBX into Workbench
  • How to configure new prop in Workbench
  • How to add procedural animation with sound & custom action to prop prefab
If you don't have any experience with Workbench yet, it is recommended to go through modded weapon tutorial to familiarize with some of the concepts present in the Workbench
📥
Sources files for this tutorial can be found on Arma Reforger Samples Github repository

Preparation

💬
Overview

Preparation phase consist of things like:

  • Preparing basic structure
  • Preparing mesh
  • Exporting mesh
It is recommend to read before FBX Import & Textures pages before proceeding.

Preparing structure

While keeping to official structure is not mandatory and there are no engine restrictions asset wise about it, it's recommended to follow guidelines listed here - Data (file) structure - to ensure that all automation plugins are parsing your assets correctly and make it later easy to navigate.

Therefore, your first task will be preparing following file structure

armareforger-new-prop-file-structure.png

Cutting object to parts

Portable desk source model contained all optional elements, like desk wing and lids, in single model. In Arma 3, subvariants of such assets would be created by hiding each element via model config animations. Something like that is no longer necessary nor recommended (hiding of mesh has some performance drawback) - instead, additional parts of the model can be either added by SlotManagerComponent  or through Hierarchy.

armareforger-new-prop-object-builder-parts.gif

In case of those asset, one wing (PortableDesk_01_wing.fbx) and one lid (PortableDesk_01_lid.fbx) should be moved to separate FBX files and then all of them should be removed from the main mesh (PortableDesk_01.fbx)

armareforger-new-prop-split-object.png

Adding sockets

armareforger-new-weapon-empty-create.png

Sockets are empty objects (in Blender nomenclature) which can be used to attach elements (prefabs) or actions to it. In Blender, such sockets can be added via Add→ Empty→ Plain Axis option.

It is quite important to properly orientate those empty objects since their position & rotation will be used in various systems, like in SlotManagerComponent for attaching various parts of rugged desk (this is covered in detail in later part of this tutorial).

At this stage, main, PortableDesk_01.fbx, file should have following sockets

  • socket_wing_01 & socket_wing_02 - for both wing models
  • socket_lid_01 & socket_lid_02 - for both lids

armareforger-new-prop-sockets-model.png

Then, PortableDesk_01_lid.fbx & PortableDesk_01_wing.fbx should have corresponding snappoints - i.e. snap_wing and snap_lid.

Those points would be used later to connect (aka snap) both models together so their position and orientation is extremely important!

armareforger-new-prop-snap-points.png

Setting skeleton & rigging mesh

This asset has six drawers which can be animated. In order to make those drawers animated, it is necessary to add proper skeleton to the model and then skin those movable selections to newly created bones.

armareforger-new-prop-blender-add-bone.png

In Blender, new armature can be easily created by adding new Single Bone in Add → Armature  menu when in Object Mode. This new bone can be called root and it will be serving as main bone of this skeleton.

Similar to sockets, orientation of bones is quite important for animation. Unlike in RV engine, animations are no longer using two vertices to create axis of transformation but instead rotation & position of bone is used to determine origin of animation.

Once root bone was created, it is possible to add bone for each of the drawers like on picture below.

armareforger-new-prop-blender-full-skeleton.png

Colliders & material names

armareforger-new-prop-blender-scene-colection.png

Colliders are special type of objects which are used to calculate various kinds of collisions - be it physic simulation or tracing of bullet penetration. There are few rules regarding those colliders and most of them listed on collider related segment of FBX Import page.

When importing asset from previous Arma game - like in this example - you are most likely going to have already convex components ready from Geometry, Fire Geometry, View Geometry or Geometry Physx LODs. If you are using P3D importer which is part of Enfusion Blender Tools, then those components will be automatically converted to trimesh colliders ( UTM_ prefix). Since trimesh colliders are not recommended for general collision, it might be wise to verify if object can be converted to trimesh.

If you are using Blender, there is small handy tool to assist you with assigning correct game materials & layer presets on colliders - more details about can be found on Arma_Reforger:Enfusion_Blender_Tools:_Objects_Tools.

In this sample, rugged desk uses simple box mesh, so usage of UBX_ prefix is recommended.

Next thing when it comes to configuration of colliders is configuration of Layer Preset. This is done through usage custom property (details about adding that property can be found on following FBX Import page). For simple prop like this one, layer preset should be set to PropFireView. If you have multiple colliders, you have to add that property to each of them!

After layer preset is set, it is time for setting Game Material. This is done by assigning to collider a material with specific name and again, details of naming are described on FBX Import page. For this example prop, Plastic_6mm game materials is used, since it is assumed that single wall is 3mm thick and due to to geometry is a simple box, those walls are counted twice.

Below is screen showing Game Materials & Layer Presets selection menu from Enfusion Blender Tools. Using this simple tool it is possible to easily select desired game material and layer preset, which will be automatically. Please note that before using that feature it is necessary to sort objects and setup plugin correctly.

armareforger-new-prop-blender-game-materials.png


FBX export settings

Most of the general rules can be found on FBX Import page . In principle, when exporting from i.e. 3DS Max, you have to make sure that you are exporting in binary format in version 2014/2015. Furthermore, Triangulation & Preserve Edge Orientation should be turned off.

Blender wise, there are 3 most important things to keep in mind when exporting FBX

1. Object Types:

For animated object like this prop, you need to have checked on at least:

Empty - handles all snap points

Armature - exports skeleton of your weapon

Mesh - self explanatory

armareforger-new-weapon-export-blender2.png
2. Custom Properties:

Without this option all custom properties like LayerPresets would be lost!

3. Leaf bones:

Leaf bones are completely unnecessary in Enfusion and it's better to have that option turned off


Preparing textures

When importing textures of weapon from previous Real Virtuality games like Arma 3 there is no real automated or simple method of conversion spec-gloss textures to PBR (Physicial Based Rendering) Metal Rough ones - current industry standard. Therefore in most cases it's much easier to do textures from scratch in i.e. Substance Painter.

There are tons of materials on the internet how to create proper PBR texture and it's highly recommend to search for it via some popular search engines. More information about maps and textures used by Reforger can be found on Arma_Reforger:Textures page

For this asset, assuming that Substance Painter is used, it is recommended to use one of the shared export profiles - Arma Reforger - BCR + NMO, which should create textures compatible with Reforger.


Importing & registering new model

Importing and registering of new model is quite simple and this involves following steps:

  • Locating FBX file that you wish to convert in Resource Browser
  • Clicking on that FBX with RMB and then selecting "Register and Import" option from the context menu
  • From pop up menu with title Register Resource (File(s), select  "as Model" option

After that, conversion of FBX into XOB will begin and depending on complexity of the model it might take some time. In case of that simple prop.

Once model is imported, a new XOB should appear in Resource Browser - this file can be now opened in new Resource Manager tab for preview and game related parameters tweaking by double clicking with Left Mouse Button on it.

armareforger-new-prop-register-fbx.gif

While Workbench still supports relative paths for materials, this method is discouraged and should not be used.
Both Layer Preset and Game Material can be changed in Import Settings window, although it is recommended to have that stored in model itself. Otherwise you might loose your data if colliders are changed (by f.e. renaming of objects).


While Workbench still supports relative paths for materials, this method is discouraged and should not be used.

Import settings

If everything went fine, main Resource Manager window should look like that:

armareforger-new-prop-imported-model-xob.png

On the right side of the viewport, there is a panel where you can select between two tabs:

  • Details - shows various statistics (i.e. vertex, face or face count) and informations about  materials, colliders, skeleton or LODs present in the imported model. This tab is by default selected when opening new model.
  • Import Settings - in this tab it is possible to modify how FBX is imported to the game and it is possible to modify transformation, materials, physics or other misc parameters here.

After briefly checking if model has correct number of LOD (levels of details) and it looks visually fine, it's time to move to Import Settings tab, where there are couple important things to set.

Physics setup

After initial import was done it's time to make sure that materials & colliders are using proper materials & colliders.  If it fails to find such texture, new dummy material (see area marked in orange on screen below) will be created in data folder next to the FBX model.

If everything was setup correctly in Blender, imported model should already have one collider imported with correctly assigned Layer Preset (PropFireView) and Surface Properties (plastic_3mm.gamemat). Otherwise, here is the list of some common issues:

Geometry Params list is empty

If both Colliders array in Details and Geometry Params array in Import Settings are empty, check for following errors:

  1. Check if objects which are supposed to be colliders have correct prefix - i.e. UBX, UCX, etc. See FBX Import page for more information
  2. Check Console Log if there are no errors regarding convexity or shape of the collider. See FBX Import page for more information

Wrong Game Material

If impact effect on the asset are using default dirt impact effects or following error appears in console

RESOURCES : GetResourceObject @"{411A617924FC3D61}Assets/Props/Military/Camps/PortableDesk_01/PortableDesk_01.xob"
RESOURCES (E): Wrong&patched resource GUID in @"Assets/Props/Military/Camps/PortableDesk_01/PortableDesk_01.xob" for property UBX_Component01 resource name @"Plastic_6m.gamemat"
RESOURCES : GetResourceObject @"{D4D49F200A5937E1}Plastic_6m.gamemat"
RESOURCES (E): Failed to open

then check for following errors:

  1. Make sure in 3D software of your choice that material assigned to collider is correctly named, i.e. Plastic_6mm_6A7CBD6BBCFC5148 - see Game Material section of FBX Import page.
Keep in mind that changes to materials or layer presets in FBX are only imported if Geometry Params list is empty. See FBX Import - Game Materials pagefor more information

Wrong Layer Preset

If you see warning triangle Colliders section of Details tab or All interaction layers used error, then check for following things:

  1. Make sure that collider has correct Layer Preset assigned
  2. Make sure that Custom Properties option is checked in FBX export settings

armareforger-new-weapon-collider-errors.png

Changing parameters

If for some reason you don't want to touch FBX and want to change Layer Preset or assigned game materials in Workbench itself, then it is possible to do that by manipulating Layer Preset & Surface Properties parameters in Physics section of Import Settings tab. Changes to those parameters require usage of Reimport resource button - otherwise information stored in XOB would not be updated. This method is not recommended though.

armareforger-new-prop-import-change-params.gif

Skeleton & Hierarchy

In case of models with skeleton (Armature) it is quite important to check Export Skinning option in Miscellaneous section of Import Settings.

Since Rugged Desk is supposed to have six animated drawers, it is important to enable that option and then reimport the model via Reimport resource (PC) button.

armareforger-new-prop-export-skinning.png

If skeleton was imported correctly', Details tab' in right section of the Resource Manger view port should show some non zero number in Bones section. In case of Rugged Desk, this object should have 6 skinned bones, 4 sockets and one dummy hierarchy element (root), which should be visible as Bones (6 + 5). First number in the bracket indicates number of skinned bones and 2nd one indicates of empty bones (either bones which are not skinned to anything or empty objects)

armareforger-new-prop-skeleton-full-imported.png

For Rugged Desk wing & lid it is possible to just use Export Scene Hierarchy - this should allow to use empty objects created before for snapping purposes.

Importing textures

By default, Workbench importer will create new materials (emats) using MatPBRBasic shader in Data folder next to the imported model, based on material names located in FBX. If material suitable for the mesh already exist somewhere in available projects, it is possible to change linked material by changing elements in Material Assigns located in Visual section of Import Settings - this option will be later used for Portable Desk lid & wing, which share same materials.

Once those materials are ready, you can use same procedures as the ones described on Sample Modded Weapon - Documentation - Creating New Materials page.

Adding basic configuration

💬
Overview

Following topics will be covered in this paragraph

  • Creating prefab
  • Basic asset configuration

Creating prefab

Prefabs for props can be prepared in multiple ways and it also depends on amount of functions that are planned to be added to such asset.

In general, it is recommend to use one of those two prefabs as a base:

Since this sample is planned to have destruction, Destructible_Props_Base.et prefab can be used as a base.

In this article, Enfusion links are used. With those links it is possible to open specific resource just by simply clicking on that link. Enfusion links has to be manually activated in Workbench options (Workbench -> Options -> Workbench -> Register "enfusion://" protocol) before it can be used]

In general, it is possible to create new inherited prefab in two ways:

No matter what method was picked, it is recommended to create base prefab for props, which might have some variants. In this tutorial Portable Desk have 3 texture variants prepared, so such base class will be more than welcome.

In this case, new prefab, which inherits from Destructible_Props_Base.et , should be called PortableDesk_01_Base.et

Final step in initial configuration  will be assigning previously imported mesh. This can be done by simply assigning Rugged Desk XOB into Object property of MeshObject component in PortableDesk_01_Base.et prefab.

armareforger-new-prop-desk-prefab.png

If change was applied to MeshObject component of prefab instance, don't forget to press Apply to prefab button and then save currently loaded world!

Creating texture variants

armareforger-new-prop-prefab-material-assign.png

Since this assets is supposed to have three color variants, new prefab variants have to be prepared

  1. Create new prefabs, inheriting from PortableDesk_01_Base.et,  either via World Editor viewport drag and drop method or via Inherit Prefab action available in Resource Browser attached to World Editor
  2. Once new prefabs are created, open them and one by one, change assigned materials in Materials array inside MeshObject component to appropriate material created before.
  3. Apply changes to the prefabs if changes were applied to entity instance, otherwise (if hierarchy tree was used) this step can be skipped
  4. Permanently save changes to the prefabs by either saving current world or, if in prefab edit mode, save the prefab directly.

In the end, following files should be present in next to the PortableDesk_01_Base.et

  • PortableDesk_01_Black.et
  • PortableDesk_01_Olive.et
  • PortableDesk_01_Sand.et


Creating prefabs for smaller parts

armareforger-new-prop-prefab-variants-list.png

Procedure described above should be also applied to lid and wing prefabs so they have base prefab (inheriting from Destructible_Props_Base.et ) and color variants. Those prefabs should be really simple at this stage so MeshObject and RigidBody components which they inheriting from Destructible_Props_Base should be enough.

In the end, following set of prefabs should be created

  • PortableDesk_01_wing_base.et
    • PortableDesk_01_wing_Black.et
    • PortableDesk_01_wing_Olive.et
    • PortableDesk_01_wing_Sand.et
  • PortableDesk_01_lid_base.et
    • PortableDesk_01_lid_Black.et
    • PortableDesk_01_lid_Olive.et
    • PortableDesk_01_lid_Sand.et


Creating prop variants

In order to create a variant of Portable Rugged Desk with for instance both wings and lids attached, it is possible to utilize SlotManagerComponent to attach additional elements. Before going any further though, it is recommend to start with creating a new base prefab - PortableDesk_01_Base_Full.et - which will serve as a base asset  with all additions attached. Since the core of the desk remains the same, this new base prefab should inherit from PortableDesk_01_Base.et

Once base prefab is there, follow below steps to :

  • Add new SlotManagerComponent via + Add Component button
  • Select SlotManagerComponent and add new element to Slots array by clicking on plus sign on the right side of that property
    • Select EntitySlotInfo from the list that appeared
    • Type new name of that slot. For instance slot for wing can be called Wing_L
    • In Wing_L element, locate Pivot ID property and select socket_wing_01 from the list
    • In Child Pivot ID type name of the snap point which is located in the mesh - in this case it is called snap_wing
    • In Prefab property, assign prefab which you want to use - in this case it will be PortableDesk_01_Base_Wing.et

This procedure should be repeated for the rest of the slots - Wing_R, Lid_1 & Lid2. In case the prefabs from the slots are incorrectly attached, please make sure that orientation of sockets and snap points is correct. Otherwise, the new PortableDesk_01_Base_Full.et should look like that:

armareforger-new-prop-prefab-slot-manager.png

Beside using SlotManagerComponent, it is also possible to utilize hierarchy. This is especially useful when you for instance want to create a mini composition out of prefab, like add a telephone, some notebooks or ashtrays to it. After adding Hierarchy component to both parent and children prefab, it is even possible to utilize Pivot ID to snap prefabs to desired place. There is no way to define Child Pivot ID using that method though and thats why SlotManagerComponent was used here.

Principles of adding entity to prefab are described on Prefabs Basics page

armareforger-new-prop-prefab-add-hierarchy.gif


Adding procedural animation

💬
Overview

Following topics will be covered in this paragraph

  • Creating basic procedural animation
  • Applying animation to the asset
Before proceeding further it is recommend to make yourself familiar with Procedural Animation Editor documentation & Procedural Animation Editor tutorial.

Creating new procedural animation project

armareforger-new-prop-procedural-animation-new-project.png

armareforger-new-prop-procedural-animation-create-project.png

First step in creation of new procedural animation project would be launching of Procedural Animation Editor. After that, new project can be created by navigating to File → New → Project... ( alternatively, Ctrl + ⇧ Shift + N shortcut can be used) in order to create new Procedural Animation Project. Procedural Animation Project is quite similar in purpose to animation definitions in Real Virtuality Model Config but with much better signal processing (more about it next chapter).

Once that step is completed, a new pop up window will appear asking for save location. In Arma Reforger, asset specific procedural animations are stored next to the model somewhere in inside Asset folder structure. Common animations, like turrets or wheel animations which are used by multiple vehicles, are located in Anims/Proc folder.

Here, situation is quite simplified and Rugged Desk animations are assumed to be specific to this asset and are placed in Assets/Props/Military/Camps/PortableDesk_01/Anims/ folder.


Creating new procedural animation signal

Once new Procedural Animation Project is created, it is possible to populate it with actual data. First step towards this goal would be creating new signal. To differentiate it from Audio Editor signals, Procedural Animation Editor signals have .siga extension.

Signals are quite essential part of procedural animation since they are controlling how signals from scripted or engine events are processed. For those familiar with Real Virtuality Engine, signals are somewhat similar in their purpose to source parameter in Model Config - this time though it is possible to do much more complex processing of signals like mixing values, non linear movement and mixing two or more signals together.


Setting  up signal

To create new signal, click with Left Mouse Button on Signal button located in the top bar of Procedural Animation Editor. After clicking on that, a new pop up window should appear, asking for a location and name of new signal. By default, that Create Signal window should suggest same name (different extension is used - siga) and folder as Procedural Animation Project is using and in case of simple animations like this one, this is a correct solution.

After confirming filename and location, new signal should be created on drive. This new signal file should be also automatically added to current Procedural Animation project - if not, then it might be necessary to drag that new signal to the main window.

armareforger-new-prop-procedural-animation-create-signal.gif

At minimum, signal should contain Input and Output node and those can be added by clicking with Left Mouse Button on Input and Output buttons respectively in the top section of main window. At this point, it is possible to simply connect Out connector from Input node to In connector from Output node and such signal would already work. However, beauty of Procedural Animator Editor lies in nodes that can be used to process the signal and therefore, Smoother node will be added in this signal project to, as name suggest, smooth the signal.

Same as with the Input and Output nodes, Smoother can be simply added by clicking on Smoother button in top section of main window.

Once that newly created node is present in the window, it is possible to connect Out' from Input node with In from Smoother node'. Similar thing should be done with Output node where its In connector should be linked with Out connector of Smoother node.

armareforger-new-prop-procedural-animation-adding-smoother.gif

armareforger-new-prop-procedural-animation-smoother-settings.png

With those nodes being properly connected, now it's time to adjust behavior of Smoother node itself. To do so, click on it and navigate to Item detail window and go to Data section over there.

Fade In Time & Type will correspond to opening of drawer and Fade Out Time & Type to closing of drawer. In this case, Fade In Time was set to 700 and Type was set to S-curve (See {{Wikipedia|Sigmoid function) - this should give it quite nice & natural motion. Closing of the drawer should behave more like you slam it so that's why Power of 2 was selected in Fade Out Type drop-down list.

At later stage, once scripted user action are configured, it might be wise to play with those parameters in-game and observe what kind of results you can get by changing time or type of fade effect.

Once first set of Input, Smoother & Output nodes is completed, it is now possible to create rest of the signals for all separate drawers. This could be achieved in two ways:

  1. By repeating whole procedure and manually adding Input, Smoother & Output nodes and then, adjusting content of Smoother node
  2. By using copy and paste procedure

Naturally, since all those signals are supposed to work almost exactly the same, using copy paste procedure is recommend way of dealing with rest of the signal.

To copy paste nodes, simply click and then hold Left Mouse Button and select all nodes that you want copy. If everything was done correctly, nodes should have now golden stroke around them. After that, use Ctrl + C combination to copy files and then use Ctrl + V combo to paste those nodes under the cursor. Voila, now this action has to be repeated till signal project has 6 sets of Input, Smoother & Output nodes.

Aligning and grouping nodes

Both Procedural Animation Editor and Audio Editor offers way to adjust position of the nodes making it look more pleasant and aesthetical. This is done by selecting multiple nodes and then clicking on of them with RMB and then, selecting one of the alignment options from the context menu. It is also possible to catch few nodes in a single group by selecting Group option but again - this option has purely aesthetical function.
armareforger-new-prop-procedural-animation-align-nodes.gif

Last step in setting up signal will be changing of Name property in all Signal nodes. This Name property will be later used to link script source to signal, therefore, some reasonable name should be picked - in case of that project all Input nodes were named Drawer 1 to Drawer 6. Names of rest of the nodes is not important but it is usually quite helpful to maintain some reasonable names - especially with Output nodes - since it helps with navigation and understanding of project that you are working on.

In the end, you should end up with following setup in Procedural Animation Signal

armareforger-new-prop-procedural-animation-signal-ready.png

Setting up Procedural Animation Project

After signal is configured, it is possible to proceed further with Procedural Animation Project itself. To put in motion things, nodes are required. 

The goal here would be to make drawers move. To achieve that goal, let's take a look   Motion of the drawer is quite simple and simple translation could be used. In Procedural Animation Editor, this translates into following procedure:

  • Add TranslateMake node and connect signal from Signal node to Z axis of that newly created item
    • Select TranslateMake node that was just created and in Item detail window, navigate to axis parameter in Data section - over there change the value to -0.5 (meters)- that will be the maximal movement of the bone.
  • Create TranslateSet node and connect TranslateMake node to translation input on TranslateSet
  • Create Bone node and connect it to In input in TranslateSet

armareforger-new-prop-procedural-animation-setting-pap.gif

Those actions should be repeated for all 6 drawers present in that model -  similar to signal setup, it is possible to utilize copy paste process to speed up whole procedure. In the end, Procedural Animation Project should look like that:

armareforger-new-prop-procedural-animation-pap-ready.png


Previewing animation

After adding nodes, drawer animations should be already in working state but without any means to test it, it is rather hard to verify if the motion is fully correct. To preview those animations, it will be necessary to set up few things.

Previewing animations which have smoother node is only working in 0.9.6 version of Workbench and beyond

In View window, located by default in right section of Procedural Animation Editor, it is possible to quickly preview animation that is currently developed. To do so, follow below steps:

armareforger-new-prop-procedural-animation-setting-preview.gif

  • Click on Select Model button (in 0.96 version this button is replaced by icon) and in pop up window select preview model (in this case it will be PortableDesk_01.xob)
  • On all Bone nodes that were previously created, go to Item detail window and over there, pick from Bone name list correct bone for particular signal
    • For example Drawer 1 signal should use Drawer_1 bone
  • Select signal node in the main window
  • In Item detail window, expand one of the inputs (f.e. Input1) in Inputs section and try to manipulate ValRT - either with mouse or by typing the value

Adding scripted action