Convert dae to scn at runtime in iOS

Is there a utility to convert Colada (dae) files to SceneKit Scene files (scn) at run-time in iOS. If not, is there a utility that converts a dae file into a scn file in MacOS for users who do not have XCode.

Hi diamondminder,


You can easily create a utility yourself as a macOS app project.


First load a DAE file from the file system using SCNScene's init(url:options:) together with NSOpenPanel's urls property.


Then save as an SCN file using NSKeyedArchiver's archiveRootObject(scnScene, toFile: aFile)


You can use NSSavePanel to handle the file system to allow the user to choose a write destination.

Hi ksigiscar@cmc ,



I'm stuck at this issue , could you help me to understand what you wrote above ? Or is there any latest solution of this problem ?

To Convert DAE to SCN Using Terminal You need: Xcode To Be Installed On Your Mac, You Don't Need to Run It we gonna use scntool command line from Xcode app

Now Open Terminal

1- Set The scntool to be Called From Anywhere 

export PATH="/Applications/Xcode.app/Contents/Developer/usr/bin"

2- Change Your Directory To where The DAE and The Resources are My Folder named Export

cd THE_LOCATION_OF_YOUR_DAE_FILE

Example cd /Users/YOURHOME/Desktop/Export

3- Use scntool to convert it like that (INPUT and OUTPUT is names of the file)

The dot at the end of the command line is very important it means you will set resources to same location 

scntool --convert INPUT.dae --format scn --output OUT.scn --asset-catalog-path .

Example:

scntool --convert ISS.dae --format scn --output ISS.scn --asset-catalog-path .

If you don’t set the —asset-catalog-path . You will have no materials 

By comparing 2 Output files, one with correct conversion and the other without 

You will notice a missing line “path”, this line “path”, tells the SCN file to search the materials in the correct location 

Mistaken Out.scn

	},

	{	"$class" = :false;

		NS.keys = ( :false );

		NS.objects = ( :false );

	},

	"AMS02Coil.png",

	{	"$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" );

		"$classname" = "NSMutableDictionary";

	},

Correct Out.scn File

	},

	{	"$class" = :false;

		NS.keys = ( :false );

		NS.objects = ( :false );

	},

	"path",

	"AMS02Coil.png",

	{	"$classes" = ( "NSMutableDictionary", "NSDictionary", "NSObject" );

		"$classname" = "NSMutableDictionary";

	},

List Of scntool Command Options (I Got It From This Location 

https://gist.github.com/matux/4a30c4b4b29d636fe6847b6a3234bc4f)

$ xcrun scntool --verbose

| Current SceneKit version is 4.560000

| Running scntool (compiled on Jul  1 2018 01:01:55)

usage: scntool --convert file --format format [--output file]

--convert: File to convert. Formats found to be supported: com.apple.scenekit.scene (scn), com.apple.scenekit.scene.zip (scnz), com.apple.scenekit.particlesystem (.scnp), org.khronos.collada.digital-asset-exchange (.dae), c3d, bplist

--format: Format to convert to. Formats found to be supported: scn, c3d, dae.

--output: Destination path and filename.

-c (--compress)

-d (--decompress)

--uncompress

--copy

--target-platform=

--target-version=

--target-build-dir=

--asset-catalog-path

--resources-path-prefix

--resources-folder-path=

--force-y-up: Some documents use different up axis. When enabled, objects in a scene are converted to the Y-up orientation.

--force-interleaved: Because most geometries use more than one geometry source and the GPU typically uses data from multiple sources together, you can achieve better rendering performance for custom geometries by interleaving the vertex data for multiple semantics in the same array.

--prefer-compressed-textures: Use this option to prefer KTX, ASTC and PVRTC to other file formats. When enabled, if an image is referenced by a scene and exists within the asset catalog with the same name and the .astc or .pvrtc file extension, the compressed version will be used by SceneKit.

--verbose: Always use verbose to get pretty error messages. With --verbose: scntool: error: No file at path /path/to/model/file.scn Same error, without --verbose:

Convert dae to scn at runtime in iOS
 
 
Q