public FbxConverter(out AssimpSharp.Scene scene, Document doc) { this.Doc = doc; this.NodeNames = new Dictionary<string, bool>(); this.RenamedNodes = new Dictionary<string, string>(); this.Result = scene = new AssimpSharp.Scene(); // animations need to be converted first since this will // populate the node_anim_chain_bits map, which is needed // to determine which nodes need to be generated. ConvertAnimations(); ConvertRootNode(); if (doc.Settings.ReadAllMaterials) { // unfortunately this means we have to evaluate all objects foreach(var v in doc.Objects) { var ob = v.Value.Get(); if (ob == null) { continue; } var mat = ob as Material; if (mat != null) { if (!MaterialsConverted.ContainsKey(mat)) { ConvertMaterial(mat, null); } } } } TransferDataToScene(); }
/// <summary> /// Constructor for a specific scene to export /// </summary> public XFileExporter(AssimpSharp.Scene scene, IOSystem iosystem, string path, string file) { //Properties = Properties; IOSystem = iosystem; Path = path; File = file; Scene = scene; SceneOwned = false; End = "\n"; WriteFile(); }
public void SetUp() { var assimpNetimporter = new Assimp.AssimpContext(); Assimp.LogStream.IsVerboseLoggingEnabled = true; var logger = new Assimp.ConsoleLogStream(); logger.Attach(); assimpNetScene = assimpNetimporter.ImportFile(filename); logger.Detach(); var assimpSharpImporter = new AssimpSharp.FBX.FBXImporter(); assimpSharpScene = new AssimpSharp.Scene(); assimpSharpScene = assimpSharpImporter.ReadFile(filename); }
void TestXFile(string file, string dir) { var path = Path.Combine(dir, file); var stopwatch = new Stopwatch(); stopwatch.Start(); LoadAssimpNetScene(path); stopwatch.Stop(); var netTime = stopwatch.ElapsedMilliseconds; stopwatch.Restart(); var assimpSharpImporter = new AssimpSharp.XFile.XFileImporter(); var assimpSharpScene = new AssimpSharp.Scene(); assimpSharpImporter.InternReadFile(path, assimpSharpScene); stopwatch.Stop(); var sharpTime = stopwatch.ElapsedMilliseconds; Console.WriteLine(" {0,4} | {1,5} | {2,5} | {3}", "x", netTime, sharpTime, file); }
private void loadBtn_click(object sender, EventArgs e) { if (fileOpen.ShowDialog() == DialogResult.OK) { //Get the path of specified file FBXfilePath = fileOpen.FileName; } bool simpleFormat = false; // flipped if simpleFormat is detected. fbx = assimpSharpImporter.ReadFile(FBXfilePath); int materialCount = fbx.Materials.Count; int textureCount = 0; int mastervertCount = 0; int masterfaceCount = 0; int surfacevertCount = 0; int surfacefaceCount = 0; int masterObjectCount = 0; AssimpSharp.Node masterNode = fbx.RootNode.FindNode("Course Master Objects"); if (masterNode == null) { simpleFormat = true; } else { simpleFormat = false; } AssimpSharp.Node pathNode = fbx.RootNode.FindNode("Course Paths"); AssimpSharp.Mesh countObj = null; int sectionCount = 0; for (int searchSection = 1; ; searchSection++) { AssimpSharp.Node searchNode = fbx.RootNode.FindNode("Section " + searchSection.ToString()); if (searchNode != null) { sectionCount++; } else { break; } } // // Textures // textureArray = mk.loadTextures(fbx); materialCount = textureArray.Length; // // Course Objects // Surface Map // if (simpleFormat == false) { masterObjects = mk.loadMaster(fbx, textureArray); masterObjectCount = masterObjects.Length; surfaceObjects = mk.loadCollision(fbx, sectionCount, textureArray, simpleFormat); sectionList = mk.loadSection(fbx, sectionCount, masterObjects); } else { masterObjects = mk.createMaster(fbx, sectionCount, textureArray); masterObjectCount = masterObjects.Length; surfaceObjects = mk.loadCollision(fbx, sectionCount, textureArray, simpleFormat); sectionList = mk.automateSection(sectionCount, surfaceObjects, masterObjects, fbx); } // // Section Views // countBox.Text = sectionCount.ToString(); surfcountBox.Text = sectionCount.ToString(); for (int currentChild = 0; currentChild < masterObjects.Length; currentChild++) { masterBox.Items.Add(masterObjects[currentChild].objectName); } for (int currentIndex = 0; currentIndex < surfaceObjects.Length; currentIndex++) { surfaceobjectBox.Items.Add(surfaceObjects[currentIndex].objectName); } for (int currentSection = 0; currentSection < sectionCount; currentSection++) { surfsectionBox.Items.Add("Section " + (currentSection + 1).ToString()); sectionBox.Items.Add("Section " + (currentSection + 1).ToString()); } for (int surfacematerialIndex = 0; surfacematerialIndex < surfaceType.Length; surfacematerialIndex++) { surfmaterialBox.Items.Add(surfaceTypeID[surfacematerialIndex].ToString("X") + "- " + surfaceType[surfacematerialIndex]); } foreach (var viewstring in viewString) { viewBox.Items.Add(viewstring); } for (int materialIndex = 0; materialIndex < materialCount; materialIndex++) { if (textureArray[materialIndex].texturePath != null) { if (textureArray[materialIndex].textureClass == -1) { MessageBox.Show("Warning! Texture wrong dimensions -" + textureArray[materialIndex].textureName + "- Height: " + textureArray[materialIndex].textureHeight + " Width: " + textureArray[materialIndex].textureWidth); textureBox.Items.Add("UNUSABLE " + materialIndex.ToString() + " - " + textureArray[materialIndex].textureName); } else { textureBox.Items.Add("Material " + materialIndex.ToString() + " - " + textureArray[materialIndex].textureName); } textureCount++; } else { MessageBox.Show("Warning! Material " + fbx.Materials[materialIndex].Name + " does not have a diffuse texture and cannot be used."); textureArray[materialIndex].textureName = fbx.Materials[materialIndex].Name; textureBox.Items.Add("UNUSABLE " + materialIndex.ToString() + " - " + textureArray[materialIndex].textureName); } } viewBox.SelectedIndex = 0; mcountBox.Text = materialCount.ToString(); tcountBox.Text = textureCount.ToString(); textureBox.SelectedIndex = 0; lastMaterial = 0; objcountBox.Text = surfaceCount.ToString(); MessageBox.Show("Finished Loading .FBX"); loaded = true; sectionBox.SelectedIndex = 0; compilebtn.Enabled = true; mvertBox.Text = mastervertCount.ToString(); mfaceBox.Text = masterfaceCount.ToString(); mobjectbox.Text = masterObjectCount.ToString(); }