class MyFilePostprocessor extends AssetPostprocessor {
function OnPreprocessModel () {
// Set imported models to scale 1.
// Disable swap UV channels.
var modelImporter : ModelImporter = (assetImporter as ModelImporter);
modelImporter.globalScale = 1.0;
modelImporter.swapUVChannels = false;
}
function OnPostprocessModel ( object : GameObject ) {
FixMaxImport ( object );
}
function FixMaxImport ( object : GameObject ) {
// Unrotate root transform.
object.transform.rotation = Quaternion.identity;
// Get all meshes and unrotate them.
var meshFilters : MeshFilter[] = object.GetComponentsInChildren.< MeshFilter > ();
for ( var j : int = 0; j < meshFilters.length; j++ ) {
FixMesh ( meshFilters[j].sharedMesh );
}
}
function FixMesh ( mesh : Mesh ) {
var resetTransform : Quaternion = Quaternion.Euler ( -90.0, 0.0, 0.0 );
var newMeshVertices : Vector3[] = new Vector3[mesh.vertexCount];
var newMeshNormals : Vector3[] = new Vector3[mesh.vertexCount];
for ( var i : int = 0; i < mesh.vertexCount; i++ ) {
newMeshVertices[i] = resetTransform * mesh.vertices[i];
newMeshNormals[i] = resetTransform * mesh.normals[i];
}
mesh.vertices = newMeshVertices;
mesh.normals = newMeshNormals;
mesh.RecalculateBounds ();
}
}
This should unrotate all models that don't have animation on import.
I've tried fixing skeletal animation - got somewhere close on very simple rigs - but it's far harder to fix... the maths and internal workings is a little beyond me.
Also, I have some Unity related tutorials (mostly shader stuff) up on my blog; http://www.farfarer.com/blog/ - might come in handy for some.
Hope we don't get in trouble for posting this here as well but we're very happy to announce that Amplify Shader Editor now supports the new Unity 2018 Substance Plugin. Manipulating Substances via shader is a great way to tweak your assets without needing to recalculate them.
Check out our ASE Polycount Threadfor additional information, we look forward to any questions or feedback.
Replies
nah, jus kiddin'
also: monster's solution to the FBX scale import problem:
and the last thing: the axis problem: did anyone ever get rid of it?
http://feedback.unity3d.com/forums/15792-unity/suggestions/210672-fbximporter-correct-orientation-and-without-game
I've tried fixing skeletal animation - got somewhere close on very simple rigs - but it's far harder to fix... the maths and internal workings is a little beyond me.
Also, I have some Unity related tutorials (mostly shader stuff) up on my blog; http://www.farfarer.com/blog/ - might come in handy for some.
DOWNLOAD
The Unity 5.0 pre-order beta is available only to Unity 5 pre-order customers and Unity Pro subscribers.
DOWNLOAD - http://unity3d.com/unity/beta/5.0?utm_source=marketo&utm_medium=email&utm_campaign=5x_open_beta_phase_2_offline_preorder_2014&mkt_tok=3RkMMJWWfF9wsRoguKnIZKXonjHpfsXw6O07BPbv3sYw3mx7dMXLZRe62IEXEYc8ZuGVCAw5N801kF4VI9OmMdEVrA%3D%3D
https://www.assetstore.unity3d.com/en/#!/content/9180
https://www.assetstore.unity3d.com/en/#!/content/13238
Hope we don't get in trouble for posting this here as well but we're very happy to announce that Amplify Shader Editor now supports the new Unity 2018 Substance Plugin. Manipulating Substances via shader is a great way to tweak your assets without needing to recalculate them.
Check out our ASE Polycount Thread for additional information, we look forward to any questions or feedback.
Thanks!
This thread was last active 2018.