Quantcast
Channel: Second Life – Austin Tate's Blog
Viewing all articles
Browse latest Browse all 281

OAR Converter with glTF

$
0
0

OAR Converter can take an OpenSimulator Archive (OAR) and from it create textures, meshes and terrain suitable to import into a Unity or Unreal Engine scene. It can use Collada (DAE), OBJ or glTF formats. This blog post covers use converting an OpenSim OAR to glTF for use via Unity. It describes OAR Converter 1.8.* an update in September 2024 to replace the earlier versions 1.7.0 from June 2024 and 1.0.6 from 2013-2017. See this earlier blog post for information on using the Collada format as the instructions are unchanged.

From Unity a range of virtual world or virtual reality experiences can be created. The converter has been created by Fumikazu Iseki (Avatar: @Fumi.Hax – @fumi_hax) and his colleagues at the Network Systems Laboratory of Tokyo University of Information Sciences (TUIS) in Japan with support from Austin Tate at the University of Edinburgh.

This blog post is provided for convenience and using content from the original TUIS OAR Converter Japanese Web Site and GitHub for OARConv which should be considered definitive.

Unity Base Project with glTFast

Create an Unity project including the glTFast package as a basis for using OAR Converter with glTF. To install the Unity glTFast package, follow these steps:

  1. In your Unity project, go to Windows > Package Manager.
  2. On the status bar, select the Add (+) button.
  3. From the Add menu, select Add + package by name. Name and Version fields appear.
  4. In the Name field, enter com.unity.cloud.gltfast
  5. Select Add.
  6. The Editor installs the latest available version of the package and any dependent packages.

Note that items in your project can be exported to glTF by selecting the item(s) you wish to export and right click on that or choose from menu Assets > Export glTF > choose .glb or .gltf.

It is suggested that you use GLTF format rather than GLB as the imported size of the project may be larger with GLB as textures cannot (currently anyway) be shared between separate GLB meshes. Also GLB mesh import to the hierarchy of a Unity scene may stall/hang due to heavy use of textures. You can sometime get round this by not adding all the GLB meshes to the scene in one go.

OAR Converter with Windows UI – Quick Start

OAR Converter for Windows User Interface

For straightforward conversions, simply follow these steps:

  1. Use “Tools” -> “Output Format” and “Tools” -> “Settings” to check output for UNITY is selected and if necessary change the output format to GLTF or GLB.
  2. Place your OpenSim OAR file in a suitable directory.
  3. Run the OAR Converter and using “File” -> “Open OAR File” select the OAR file you wish to convert. This will create a directory called OAR_ with the unpacked contents of the OAR file ready for conversion.
  4. Now select “File” -> “Convert Data” from the OAR Converter File menu. This will create a directory called GLTF_ (or GLB_) with the converted content in it.
  5. The converted objects are placed in three directories: Solids contains objects which which have colliders; Phantoms (objects with no collider); and Terrains.
  6. The Textures sub-directories within a for GLB_ conversion are not actually needed for use in Unity since GLB has the textures embedded but is provided for convenience. It may be deleted or not imported to Unity if you wish.

Import to Unity3D

You could follow the video instructions in this video by Fumikazu Iseki.

https://blackjack.nsl.tuis.ac.jp/video/close/03056f6c-062a-431d-853e-cad40ee90b14/OARConvWin-1.8.2_unity.mp4

The video gives an example of converting an OpenSim OAR, conversion to GLTF and importing the contents and merging that with a Unity project/scene including adding the required glTFast library and Editor scripts, and adding a sample water surface. Importing the included “UnityChan” character avatar is also shown.

Unity - OAR Conversion - OpenVCE Unity - OAR Conversion - Oil Rig

Import to Unity – Quick Start

  1. Ensure you add relevant parts of the contents of the “Unity” folder in the OAR Converter distribution into your Unity project, adding Editor/GLTFAutoCollider.cs and Editor/SetLocationByParameter.cs at least. Editor/SelectOARShader.cs is not used for GLTF/GLB imports.
  2. In your Unity project add an empty game object at 0,0,0 and name it (e.g.) the same as your OpenSim region name. Under this add three empty game objects named Solids, Phantoms and Terrains
  3. Drag the GLTF_ (or GLB_) folder in its entirety onto the Unity “Project” (Assets) panel.
  4. Select all the objects in the Solids directory of this directory and drag them onto the “Solids” game object in the Unity “Hierarchy” panel.
  5. Select all the objects in the Phantom directory and drag them onto the “Phantoms” game object in the Unity “Hierarchy” panel.
  6. Select all the objects in the Terrains directory and drag them onto the “Terrains” game object in the Unity “Hierarchy” panel.
  7. Look at the imported objects and if you see any that are not correctly textured (usually showing as magenta coloured items) perform an “Assets” -> “Reimport All” to fix that.
    Materials may be Magenta Coloured Materials after Reimport All
  8. Optional: Add a water layer at 0,20,0. 20 is sea level in OpenSim. [Instructions in video].
  9. Optional: Add a ThirdPartyController/Avatar to be able to run the scene and move through the contents. [Instructions in <video].

Project Base for OAR Converter Projects

Once you have successfully tried a conversion and understand the elements, you may wish to create a base for any future OAR conversion… which can include all the steps except for the drag and drop in of the actual DAE converted content. Do this yourself to incorporate the very latest OAR Converter content, scripts and Unity assets. You can if you wish save this as a “unitypackage” to incorporate into future Unity projects.

For convenience my own base project is available at http://www.aiai.ed.ac.uk/~ai/unity/oarconv/ (file: Unity-OAR-Converter-Base.unitypackage). This can be loaded into a “New Project” made in Unity 6000.0 onwards. I use the 3D Template with the “Built-in Render Pipeline”. It provides Mixamo Xbot and Ybot avatars along with UnityChan movement animations and avatars linked cameras.
Unity OAR Converter - Base Project

After that you can make a copy of the base project you created, or create a new unity project and ensure that the glTFast package is included as described above. Then you can import the unitypackage as a base, and then drag the OAR Converter produced “GLTF_” (or “GLB_”) directory into the Unity Project Assets area, add the GLTF/Solids folder assets and those in the GLTF/Phantoms and GLTF/Terrain folders to the hierarchical view panel. Adjust the position of the chosen avatar and attached camera to suit the region, save the project, save the scene, and you should be good to go.


Notes on OAR Converter for glTF/glb in Unreal Engine by Fumi Iseki (To Be Tided Up)

for UE5
– UE 5.3/5.4 can also drag & drop as-is (.gltf, .glb files only)
— Check the “Combine Static Meshes” checkbox in the “Static Mesh” section when importing.
— If the “Are you sure you want to override asset Message” dialog box pops up frequently during import, hold down the ESC key (there may be another solution).
– Do not use the OARSelectMaterial plugin, as it does not work properly.
– When importing glTF/glb files with skeleton information, UE5 does not follow the glTF2.0 standard (*). In this case, OARConverter outputs a glTF/glb file that does not conform to the glTF2.0 standard in order to ensure that UE5 reads the data.
— (*) In glTF 2.0, matrix property is not required or should be ignored if skin property exists in node data, but in UE5, matrix property is required (depending on model structure) even if skin property exists.
— If you want to get the same general glTF/glb files with skeleton information, please output those for Unity.


Viewing all articles
Browse latest Browse all 281

Trending Articles