public FBXScenePtr(FBXScenePtr other) : this(FBXImporterUnmanagedPINVOKE.new_FBXScenePtr__SWIG_2(FBXScenePtr.getCPtr(other)), true) { if (FBXImporterUnmanagedPINVOKE.SWIGPendingException.Pending) { throw FBXImporterUnmanagedPINVOKE.SWIGPendingException.Retrieve(); } }
public static GameObject Import(string modelPath) { Debug.LogFormat("import {0}", modelPath); if (!File.Exists(modelPath)) { Debug.LogErrorFormat("Import {0} failed, file not exist.", modelPath); return(null); } if (Path.GetExtension(modelPath).ToLower() == ".fbx") { FBXScenePtr scene = fbxImporter.ImportFile(modelPath); if (scene != null && !scene.IsNull()) { return(CreateGameObject(modelPath, scene)); } else { Debug.LogWarningFormat("{0} scene is empty", modelPath); } } else { Debug.LogErrorFormat("Not support file format {0}", Path.GetExtension(modelPath)); } return(null); }
static GameObject CreateGameObject(string modelPath, FBXScenePtr scene) { // get unity scale factor and scale to meter for Unity float unitScaleFactor = 1.0f / scene.GetGlobalSettings().GetUnitScaleFactor(); FBXModelPtr model = scene.GetModel(); if (model == null) { return(null); } // skip scene root if only one node under root, same as Unity does if (model.GetChildCount() == 1) { model = model.GetChild(0); } GameObject ret = CreateGameObject(modelPath, model, unitScaleFactor, null, Vector3.zero); if (ret != null) { ret.gameObject.name = Path.GetFileNameWithoutExtension(modelPath); ret.gameObject.transform.localPosition /= unitScaleFactor; ret.gameObject.transform.localScale /= unitScaleFactor; } return(ret); }
public FBXScenePtr ImportFile(string path) { FBXScenePtr ret = new FBXScenePtr(FBXImporterUnmanagedPINVOKE.FBXImporter_ImportFile(swigCPtr, path), true); return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FBXScenePtr obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public FBXScenePtr Create() { FBXScenePtr ret = new FBXScenePtr(FBXImporterUnmanagedPINVOKE.FBXScenePtr_Create(swigCPtr), true); return(ret); }