blog games developers documentation portfolio gallery



The ColladaImporter.cs contains 2 overloaded functions to import your Collada model:

GameObject Import(string colladaString)

This reads the colladaString and creates a GameObject (possibly with children) that has a MeshRenderer and a MeshFilter component added to it.

To obtain the mesh itself, you can access the MeshFilter component.

MeshFilter meshFilter = go.GetComponent();
Mesh mesh = meshFilter.mesh;

GameObject Import(string colladaString, Quaternion rotate, Vector3 scale, Vector3 translate)

The colladaString is imported and the vertices of the meshes are first rotated by "rotate", then scaled by "scale" and finally translated by "translate".
This is useful when the model does not have the Y-axis up (rotate x 270 degrees usually does the trick), or uses a different unit (centimeters, inches instead of meters). Or sometimes the center of the model (0,0,0) lies somewhere outside the model.

For an example of this, try to adjust the Example 7 in the demo. This is a poor model of a wine bottle, lying flat on the ground with a center about 500 meters away from the bottle and it has a very big scale. In the picture I rotated it 270 degrees, scaled it down, and lowered it.

follow us