blog games developers documentation portfolio gallery

More in this category:

SimpleCollada

Import COLLADA models into Unity3D at runtime. SimpleCollada provides the tools to let users upload 3D models and use them in your game.

Supports multiple meshes:


If you have multiple meshes in 1 collada file they are all imported as GameObjects that are children of the first mesh in the Collada file. The translations, scales, rotations and matrix translations are read from the "library_visual_scenes" entry in your Collada file. Empty gameobjects like lights and cameras are not imported.

Supports submeshes:


If a mesh has multiple materials, each material will have its own submesh.

The Collada specifications entail more than just vertices and normals, but this importer is called "SimpleCollada" for a reason. It imports vertices, normals, 1 uv map, and triangles. (polygons are automatically converted to triangles). This means that material properties, rig definitions, skinned meshes and animations (among whatever else is enclosed in your collada file) are not imported.

The demo scene that is included allows you to download any Collada model and import it. It has sliders to adjust the rotation, scale and position of the mesh and gives a good idea of how to use the importer. You can also run the demo here.

To obtain the SimpleCollada package, go to the Unity Asset Store The SimpleCollada package also contains the SimpleXML package.

To use SimpleCollada in your Unity project, you need to have the files ColladaImporter.cs, CollectionExtensions.cs and StringExtensions.cs somewhere in your project folder.

Some code examples:

// import a Collada string
myGameObject = ColladaImporter.Import(colladaString);

// If model has Z up and uses inches as unit
myGameObject = ColladaImporter.Import(
colladaString,
Quaternion.Euler(270,0,0), // rotate over X
new Vector3(0.0254f, 0.0254f, 0.0254f), // scale down
Vector3.zero); // no translation













follow us