public void importmodel() { //string fileName = "F:/UNITY stuff/FlexHub/FlexHub_parts/FBX-Parts_FlexHub/Part_72.fbx"; allnodes.Clear(); //Create a new importer importer = new AssimpImporter(); // create an importer instance //importer.SetConfig (new con) model = importer.ImportFile(filetoImport //import the specified file //PostProcessSteps.JoinIdenticalVertices | //PostProcessSteps.FindInvalidData | //PostProcessSteps.RemoveRedundantMaterials | //PostProcessSteps.FixInFacingNormals ); Debug.Log(model.RootNode.Name + "\n" + "-----------------------------"); // get the root node name MasterNode = model.RootNode; // get the master node of the scene meshesinmodel = model.Meshes; GameObject gobject = convertNodes(MasterNode); // call the function and pass the resulting GO to a new GO importer.Dispose(); // diacard the importer when importing is done }
public void importmodel() { //string fileName = "F:/UNITY stuff/FlexHub/FlexHub_parts/FBX-Parts_FlexHub/Part_72.fbx"; allnodes.Clear(); //Create a new importer AssimpImporter importer = new AssimpImporter(); // create an importer instance //importer.SetConfig (new con) Scene model = importer.ImportFile(filetoImport, //import hte specified file PostProcessSteps.JoinIdenticalVertices | PostProcessSteps.FindInvalidData | PostProcessSteps.RemoveRedundantMaterials | PostProcessSteps.FixInFacingNormals ); Debug.Log(model.RootNode.Name + "\n" + "-----------------------------"); // get the root node name MasterNode = model.RootNode; // get the master node of the scene GameObject gobject = convertNodes(MasterNode); // call the function and pass the resulting GO to a new GO //int count = gobject.transform.childCount; //for(int i = 0; i < count; i++) //{ // Transform obj = gobject.transform.GetChild(i); // Debug.Log(obj.name); //} importer.Dispose(); // diacard the importer when importing is done }
public void importmodel() { //string fileName = "F:/UNITY stuff/FlexHub/FlexHub_parts/FBX-Parts_FlexHub/Part_72.fbx"; allnodes.Clear(); //Create a new importer importer = new AssimpImporter(); // create an importer instance //importer.SetConfig (new con) model = importer.ImportFile(filetoImport, //import the specified file //PostProcessSteps.JoinIdenticalVertices | PostProcessSteps.Triangulate | //very important PostProcessSteps.FindInvalidData | PostProcessSteps.RemoveRedundantMaterials ); Debug.Log(model.RootNode.Name + "\n" + "-----------------------------"); // get the root node name MasterNode = model.RootNode; // get the master node of the scene //meshesinmodel = model.Meshes; Debug.Log("No.Of Meshes in the model : " + model.MeshCount + "\n" + "-----------------------------"); //foreach (Assimp.Mesh m in meshesinmodel) //{ // Debug.Log("Polygon type: " +m.PrimitiveType); // /*************************************************************************************/ // Debug.Log("No. Vertices in this mesh: " +m.VertexCount); // verticesinmesh = m.Vertices; // for (int y = 0; y < verticesinmesh.Length; ++y) // { // Debug.Log ("vertex " + (y+1) + " is " + verticesinmesh[y]); // } // Debug.Log("No.Vertices detected in this mesh: " +verticesinmesh.Length); // /*************************************************************************************/ // Debug.Log("Faces in this mesh: " + m.FaceCount); // facesinmesh = m.Faces; // foreach (Assimp.Face f in facesinmesh) // { // faceindices = f.Indices; // for (int x = 0; x < faceindices.Length; ++x) // { // Debug.Log(faceindices[x]); // } // Debug.Log("Length of the face indeces array: "+faceindices.Length); // } // Debug.Log("No.Faces detected in this mesh: " + facesinmesh.Length); //} GameObject gobject = convertNodes(MasterNode); // call the function and pass the resulting GO to a new GO importer.Dispose(); // diacard the importer when importing is done }
public void LoadScene() { AssimpImporter importer = new AssimpImporter(); LogStream logstream = new LogStream(delegate(String msg, String userData) { Console.WriteLine(msg); }); importer.AttachLogStream(logstream); m_scene = importer.ImportFile(Path.Combine(m_scenePath, m_sceneFileName)); // Oslobadjanje resursa koriscenih za ucitavanje podataka o sceni. importer.Dispose(); }
/// <summary> /// Ucitavanje podataka o sceni iz odgovarajuceg fajla. /// </summary> public void LoadScene() { // Instanciranje klase za ucitavanje podataka o sceni. AssimpImporter importer = new AssimpImporter(); // Definisanje callback delegata za belezenje poruka u toku ucitavanja podataka o sceni. LogStream logstream = new LogStream(delegate(String msg, String userData) { Console.WriteLine(msg); }); importer.AttachLogStream(logstream); // Ucitavanje podataka o sceni iz odgovarajuceg fajla. m_scene = importer.ImportFile(Path.Combine(m_scenePath, m_sceneFileName)); // Oslobadjanje resursa koriscenih za ucitavanje podataka o sceni. importer.Dispose(); }
private static void BuildMesh(D3D10.Device d, string meshArgs) { string name = meshArgs.Split(',')[0]; InputElement[] layout = (InputElement[])typeof(MeshInputElements10).GetField(meshArgs.Split(',')[1]).GetValue(typeof(MeshInputElements10)); string fileName = ConfigurationSettings.AppSettings["ExportsFolder"] + name; AssimpImporter importer = new AssimpImporter(); LogStream logstream = new LogStream(delegate(String msg, String userData) { Console.WriteLine(msg); }); importer.AttachLogStream(logstream); importer.Scale = 0; importer.XAxisRotation = 0; importer.YAxisRotation = 0; importer.ZAxisRotation = 0; importer.VerboseLoggingEnabled = true; importer.RemoveConfigs(); Scene model = importer.ImportFile(fileName, PostProcessSteps.CalculateTangentSpace // calculate tangents and bitangents if possible | PostProcessSteps.JoinIdenticalVertices // join identical vertices/ optimize indexing CAUSES A PROBLEM //| PostProcessSteps.ValidateDataStructure // perform a full validation of the loader's output | PostProcessSteps.ImproveCacheLocality // improve the cache locality of the output vertices | PostProcessSteps.RemoveRedundantMaterials // remove redundant materials //| PostProcessSteps.FindDegenerates // remove degenerated polygons from the import CAUSES A PROBLEM //| PostProcessSteps.FindInvalidData // detect invalid model data, such as invalid normal vectors | PostProcessSteps.GenerateUVCoords // convert spherical, cylindrical, box and planar mapping to proper UVs | PostProcessSteps.TransformUVCoords // preprocess UV transformations (scaling, translation ...) //| PostProcessSteps.FindInstances // search for instanced meshes and remove them by references to one master //| PostProcessSteps.LimitBoneWeights // limit bone weights to 4 per vertex | PostProcessSteps.OptimizeMeshes // join small meshes, if possible; | PostProcessSteps.GenerateSmoothNormals // generate smooth normal vectors if not existing | PostProcessSteps.Triangulate // triangulate polygons with more than 3 edges | PostProcessSteps.SortByPrimitiveType // make 'clean' meshes which consist of a single typ of primitives | PostProcessSteps.FlipUVs // common DirectX issue (Xna also) | PostProcessSteps.FixInFacingNormals | PostProcessSteps.MakeLeftHanded | PostProcessSteps.FlipWindingOrder ); MeshHelper.BuildMeshTextures(d, model); Mesh3D m = MeshHelper.LoadFromFile(d, model, layout); importer.Dispose(); Stream stream = File.Open(ConfigurationSettings.AppSettings["ExportsFolder"] + name.Replace(".X", ".mesh"), FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); if (m != null) { bFormatter.Serialize(stream, m); } stream.Close(); }