What 3D model formats are supported by ARKit? - swift

What 3D model formats are supported by ARKit?
Does someone know all supported formats for using in ARKit, and which format Xcode can export to use in app?

DAE and OBJ/MTL are automatically supported, in the sense that you can just drop the files in the .scnassets folder and it will handle them for you. Personally, I had fewer issues with OBJ/MTL but I'm not well versed in 3D.
The documentation for Model I/O states that you can import 3D assets from the following files
The set of supported formats includes Alembic (.abc), Wavefront Object
(.obj), Polygon (.ply), and Standard Tessellation Language (.stl).
Additional formats may be supported as well.
I've not worked with this framework though, so can't tell you how well does it work with ARKit.
And you may want to have a look at AssimpKit which allows to export several formats to .scn SceneKit scenes

ARKit 6.0
ARKit itself doesn't read any 3D formats. Only rendering engines can do it.
SceneKit and RealityKit frameworks are satellites of ARKit, so they can read in poly geometry supporting several popular 3D file formats at the moment. If SceneKit or RealityKit can't read a file, you can covert it using usdzconvert Terminal command into USDZ.
Collada's Digital Asset Exchange .dae (SceneKit)
Pixar's Zipped Universal Scene Description .usdz (SceneKit and RealityKit)
Pixar's ASCII Universal Scene Description .usda (needs conversion)
Pixar's Binary Universal Scene Description .usd and .usdc (needs conversion)
Reality Composer format .rcproject (RealityKit)
Reality Composer format .reality (works faster in RealityKit)
Wavefront Object .obj along with material .mtl (needs conversion)
Alembic Interchange File Format .abc (needs conversion)
Polygon File Format .ply (needs conversion)
Autodesk Filmbox Format .fbx (needs conversion)
Graphics Library Transmission Format .glTF (needs conversion)
Stereolithography File Format .stl (needs conversion)
Native Scene Format .scn (SceneKit)
The best way to use those formats is to initialize SCNScene from MDLAssset like this:
import SceneKit.ModelIO
guard let url = Bundle.main.url(forResource: fileName, withExtension: "usdz")
else {
fatalError()
}
let mdlAsset = MDLAsset(url: url)
let scene = SCNScene(mdlAsset: mdlAsset)

The full set of file types documented as supported by the Model I/O framework can be found here:
https://developer.apple.com/documentation/modelio/mdlasset/1391813-canimportfileextension
The set of supported extensions and formats includes:
.abc Alembic
.usd, .usda, .usdc Universal Scene Description
.usdz Universal Scene Description (Mobile)
.ply Polygon
.obj Wavefront Object
.stl Standard Tessellation Language
Additional formats may be supported as well.
It looks like Apple's new preferred file type for ARKit on iOS (as of iOS 12) is their own usdz:
https://developer.apple.com/augmented-reality/quick-look/

Related

Import 3D model to Xcode with its nodes

I have 3D Models which have many parts and are designed by some 3D editors such as: AutoCad, Blender...
Those 3D Models are combined many parts, so I want to import them to Xcode with same parts, then add Node to each part.
I want to interact with each part in ScenceView.
3D model from:
https://drive.google.com/file/d/11MccUtXd61wDWQldMTleotvg_yoHnzWP/view?usp=sharing
As i can see on the link provided by you, the 3D model is available in FBX and OBJ formate. for using in Xcode you can try using following steps.
Convert your model into DAE or .SCN formate. (you can use Blender) .DAE and .SCN formate contains all the nodes in a single file.
import your Model with associate texture folder in the art.scnassets folder.
Load and use your model.

FBX Import At Runtime

I did many tests to import FBX at runtime in unity and I'm testing more. The FBX file has to be in ASCII format when imported. It needs to export to ASCII from 3dsMax or Maya. ASCII FBX file has bigger size depending on the file.
On the other hand, the binary FBX format has a smaller size compared to ASCII.
My script works with ASCII FBX (for most models). It uses a parse method to read all the plain text, including vertices, triangles and normals in a FBX file and constructs the mesh in GameObjects.
The problem is size of model and speed of import. Asset Bundles is not a good solution.
If anyone knows a method to import BINARY FBX at RUNTIME please share your knowledge. Also, if you know how to deserialize binary fbx to ASCII FBX in Unity at runtime please let me know.
I need to deserialize FBX from Binary to ASCII. Because this is a reduced version.
If I understood correctly your problem is that the game stuck while you are importing the FBX.
Have you tried to use a Coroutines?
Coroutine will execute parallel to your update function so it won't get stuck in the middle of the execution.
If you only have 1 FBX it won't be faster unless you divide the work into multiple coroutines (be careful with the performance).

How to create a DAE file to use in SceneKit?

How do you create a .dae file from a 3D model? I've created a 3D model from a drone areal mapping and now have a very large file I can import in to Photoshop, but I can't figure out how to create a .dae file I can use in SceneKit.
The default game example for Xcode has a SceneKit that shows a rotating aircraft, and the asset is a .dae file, but I don't see any documentation on how to create one of those from a 3D model, and how to correctly apply a texture to it.
To create a 3D model and export it as a Collada .dae file you can use any of the following 3D authoring tools: Autodesk Maya, Blender, Autodesk 3dsMax, The Foundry Modo, Maxon Cinema 4D, SideFX Houdini, etc. The simplest way is to use a non-commercial student version of Autodesk Maya 2022. It's free. You can download it from HERE.
There are countless examples in YouTube how to model and uv-map in Maya software. Look at this example of UV-mapping in Maya. So, when your 3D model (and its UV-texture) is ready for use, you can export it as one of the four formats supported by SceneKit:
animated Collada DAE
animated Pixar USDZ (for iOS 12 and higher)
animated Autodesk FBX
single-frame Sony Alembic
single-frame Wavefront OBJ
In Maya Export Type for your 3D geometry must be DAE_FBX export:
A texture for you model (square UV-mapping 1K or 2K) you can export as JPEG or PNG file. It may look like this:
This UV-square-texture you must assign to a Diffuse slot of properties in Lighting Model (shader) in Show the Material Inspector.
And here's some Swift code if you wanna make it programmatically:
let scene = SCNScene(named: "art.scnassets/mushroom.scn")!
let mushroom = scene.rootNode.childNode(withName: "mushroom",
recursively: true)!
let mushroomMaterial = SCNMaterial()
mushroomMaterial.diffuse.contents = UIImage(named: "mushroom.png")
P.S. Working with Pixar's USDZ file format:
If you need a .usdz for your 3D scene, you can convert .usda using the following command in Terminal:
usdzconvert file.usda
Here you can read about usdzconvert command.

To convert 3d model from obj,3ds to .ac file format

I am having a 3d model of a car in .3ds format.I want to convert .3ds/.obj files into .ac format. Is there any tool to do this?
Here's one solution.
Blender (http://www.blender.org/) can open .3DS and .OBJ formats.
File Formats
Blender comes packed with import/export support for many different programs.
3D
3D Studio (3DS), COLLADA (DAE), Filmbox (FBX), Autodesk (DXF),
Wavefront (OBJ), DirectX (x), Lightwave (LWO), Motion Capture (BVH),
SVG, Stanford PLY, STL, VRML, VRML97, X3D.
And this AC3D Exporter plugin for Blender will allow you to export to .AC.
Export selected meshes to AC3D's .ac file format.

XNA 4: import FBX problem

I have a problem with importing 3D model from FBX file.
Source model contains 575 objects + 1 camera and looks like this: http://habreffect.ru/files/23d/542fa7f67/source_model.png
In XNA prepared with content pipeline model contains 82 meshes, and 576 bones.
So, when I draw my model, I see only part of source model. Result picture like following:
http://habreffect.ru/files/28a/6e61c0215/Result_view.png
My drawing code:
GraphicsDevice.Clear(Color.CornflowerBlue);
Matrix[] transforms = new Matrix[_model.Bones.Count];
_model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (var mesh in _model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.LightingEnabled = true;
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] * _world;
effect.View = _view;
effect.Projection = _proj;
}
mesh.Draw();
}
base.Draw(gameTime);
How can I get all 575 meshes in my Model instance in XNA?
Thanks!
UPD: I tried to import my FBX model to 3ds max, select all meshes and use "Export selected". Result FBX file is 11x bigger. Then I add it as content to XNA project, loaded model contains all 575 meshes, and it rendered correctly.
Unfortunately, this manual converting method don't suit me - I need to render varied fbx models from mutable repository.
So, what FBX file are "good" for XNA content processor (I use XNA 4)?
So, on MSDN I found that FbxImporter designed to work with 2006.11 version of FBX format.
Recently Autodesk released FBX Converter 2012.1, which contains other tools, like FBX Eplorer, FBX Viewer.
FBX explorer can show structure of FBX file, and I compare exported from 3D MAX file, and source FBX file. They have different internal format. I tried to make following conversion: FBX -> Collada -> FBX, and the result FBX file contains similar to exported from MAX data structure.
So, I simply add the result FBX to Content of my XNA app, and it's rendered well :)
Another way to make it work is to use Autodesk FBX SDK to manually read model, and draw it in XNA.
Conclusion:
XNA FbxImporter correct work doesn't depend on version (2006, 2011, etc) and form (binary, ascii) of FBX file. Internal FBX data structure much more important.
To make FBX "readable" for XNA Importer you can use double conversion like FBX -> Collada -> FBX
You also can use FBX SDK to manually load data from FBX
Open the 3d model in latest 3dx max 2012 and export it in .fbx format. This .fbx is loaded properly with the xna model loader. While exporting you can even embed the resources, so you dont have to add textures to it through XNA.
You are using instancing in 3DS MAX. This isn't supported directly by XNA.
You have to draw the mesh for each instance bone yourself.
Ideally you would instead use DirectX instancing to draw each mesh once per bone in a single Draw() call.
But you have to roll your own code to do that, by converting the bones into instance vertices.
By default XNA only supports the most basic operations.