Hi
I’m writting to you this email because i’ve got some trouble to create a script in unity 3d (version 5.3.4f1).
First i tried with assimpNet 3.0 (because i’veread that it works better) but when i try to get the tree structure of my ifc file, it doesn’t really work… the script give another tree structure (for exemple i get fiew nodes and then one node with 7 mesh but in the ifc file i have 2 nodes, the first one with 6 meshes and the second one with 1mesh) and then my meshes ind are not good so it doesn’t work…i can get the good meshes with other PostProcessSteps, but i’ve just one game object because of optimizeGraph.
So i tried with the assimpNet 3.3.1 (with the source code, i did the dll able to work with unity). But now i get another problem, when i tried to import my file with :
« Assimp.Scene model2 = import.ImportFile("sample02.ifc", PostProcessPreset.TargetRealTimeMaximumQuality); »
I get this error :
« AssimpException: Error importing file: The string "E-006,#14,$)" cannot be converted into a value.
Assimp.AssimpContext.ImportFile (System.String file, PostProcessSteps postProcessFlags)
ImportIFC.Start () (at Assets/Tests/ImportIFC/ImportIFC.cs:51) »
So the script find the file but can not read it…
I give you my source code and if you have any question, i’ll be really happy to answer to you :
My class to get the information :
« using UnityEngine;
using System.Collections;
using Assimp;
public class MainNodeIFC {
public string name;
public UnityEngine.Mesh[] meshes;
public MainNodeIFC[] children;
} »
My main code :
« public class ImportIFC : MonoBehaviour
{
//UsethisforinitializationvoidStart(){//usingassimpNet3.3.1AssimpContextimport=newAssimpContext();//usingassimpNet3.0//AssimpImporterimport=newAssimpImporter();import.SetConfig(newNormalSmoothingAngleConfig(66.0f));//usingassimpNet3.3.1Assimp.Scenemodel2=import.ImportFile("sample02.ifc",PostProcessPreset.TargetRealTimeMaximumQuality);print("rootNode name: "+model2.RootNode.Name);//usingassimpNet3.0//cangetgoodimportofmeshesbuterasethetreestructure/*Assimp.Scenemodel1=import.ImportFile(fileName,//PostProcessSteps.FindInstances|//Noeffect+slow?PostProcessSteps.FindInvalidData|PostProcessSteps.FlipUVs|PostProcessSteps.FlipWindingOrder|//PostProcessSteps.MakeLeftHanded|//AppearstojustmessthingsupPostProcessSteps.JoinIdenticalVertices|PostProcessSteps.ImproveCacheLocality|PostProcessSteps.OptimizeMeshes|PostProcessSteps.OptimizeGraph|//WilleliminatehelpernodesPostProcessSteps.RemoveRedundantMaterials|PostProcessSteps.Triangulate);*///usingassimpNet3.0//cangetthegoodtreestructurebutnotthegoodmeshes//Assimp.Scenemodel2=import.ImportFile(fileName,PostProcessPreset.TargetRealTimeMaximumQuality);//Assimp.Scenemodel2=import.ImportFile(fileName,PostProcessPreset.TargetRealTimeQuality);/*MainNodeIFCMainNode1=newMainNodeIFC();GameObjectgo1=newGameObject();go1.name=model1.RootNode.Name;ImportNode(model1.RootNode,MainNode1,model1,go1);*/MainNodeIFCMainNode2=newMainNodeIFC();GameObjectgo2=newGameObject();go2.name=model2.RootNode.Name;ImportNode(model2.RootNode,MainNode2,model2,go2);}//UpdateiscalledonceperframevoidUpdate(){}voidImportNode(NoderefNode,MainNodeIFCnewNode,Assimp.Scenemodel,GameObjectgo){if(refNode.HasChildren){//createnewarrayofnodechildrennewNode.children=newMainNodeIFC[refNode.ChildCount];print(" node: "+refNode.Name+" nombre d'enfant: "+refNode.ChildCount);print("type du node: "+refNode.GetType().ToString());for(inti=0;i<refNode.ChildCount;i++){//createthechildnodenewNode.children[i]=newMainNodeIFC();//createthegameobjectforthenodeGameObjectchildGo=newGameObject();MeshFiltermf=childGo.AddComponent(typeof(MeshFilter))asMeshFilter;MeshRenderermr=childGo.AddComponent(typeof(MeshRenderer))asMeshRenderer;childGo.transform.parent=go.transform;childGo.name=refNode.Children[i].Name;//SettransformAssimp.Vector3Dposition,scaling;Assimp.Quaternionrotation;refNode.Transform.Decompose(outscaling,outrotation,outposition);childGo.transform.localPosition=newVector3(position.X,position.Z,position.Y);childGo.transform.localRotation=newUnityEngine.Quaternion(rotation.X,rotation.Z,rotation.Y,rotation.W);childGo.transform.localScale=newVector3(scaling.X,scaling.Z,scaling.Y);//recursivemethodetogetallthechildrennodeImportNode(refNode.Children[i],newNode.children[i],model,childGo);}}if(refNode.HasMeshes){//createarrayofmeshesofthisnewNode.meshes=newUnityEngine.Mesh[refNode.MeshCount];print("final node : "+refNode.Name+"a comme enfant: "+refNode.MeshCount);print("type du node: "+refNode.GetType().ToString());//createthegameobjectforthemesh/**/for(inti=0;i<refNode.MeshCount;i++){GameObjectchildGo=newGameObject();MeshFiltermf=childGo.AddComponent(typeof(MeshFilter))asMeshFilter;MeshRenderermr=childGo.AddComponent(typeof(MeshRenderer))asMeshRenderer;childGo.transform.parent=go.transform;childGo.name=i.ToString();print("nb faces: "+model.Meshes[refNode.MeshIndices[i]].FaceCount);//settranformAssimp.Vector3Dposition,scaling;Assimp.Quaternionrotation;refNode.Transform.Decompose(outscaling,outrotation,outposition);childGo.transform.localPosition=newVector3(position.X,position.Z,-position.Y);childGo.transform.localRotation=newUnityEngine.Quaternion(rotation.X,rotation.Z,rotation.Y,rotation.W);childGo.transform.localScale=newVector3(scaling.X,scaling.Z,scaling.Y);List<Vector3>verticeTmp=newList<Vector3>();//getverticesfrommodelVector3VectTmp=newVector3();for(intj=0;j<model.Meshes[refNode.MeshIndices[i]].VertexCount;j++){VectTmp=newVector3(model.Meshes[refNode.MeshIndices[i]].Vertices[j].X,model.Meshes[refNode.MeshIndices[i]].Vertices[j].Z,model.Meshes[refNode.MeshIndices[i]].Vertices[j].Y);//warningaxeYetZinverseverticeTmp.Add(VectTmp);}//setnormal:actuallydoesn’twork/*varnorm=model.Meshes[refNode.MeshIndices[i]].HasNormals?model.Meshes[refNode.MeshIndices[i]].Normals[i]:newVector3D();vartexC=model.Meshes[refNode.MeshIndices[i]].HasTextureCoords(0)?model.Meshes[refNode.MeshIndices[i]].GetTextureCoords(0)[i]:newVector3D();vartan=model.Meshes[refNode.MeshIndices[i]].HasTangentBasis?model.Meshes[refNode.MeshIndices[i]].Tangents[i]:newVector3D();newNode.meshes[i].normals[0].x=norm.X;newNode.meshes[i].normals[0].y=norm.Y;newNode.meshes[i].normals[0].z=norm.Z;*///setverticesandtrianglenewNode.meshes[i]=newUnityEngine.Mesh();newNode.meshes[i].SetVertices(verticeTmp);newNode.meshes[i].triangles=model.Meshes[i].GetIndices();//drawthemeshmf.mesh=newNode.meshes[i];}}}
}
«
sorry for my english, i’m a frensh student working also.
Thanks for your attention !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I’m writting to you this email because i’ve got some trouble to create a script in unity 3d (version 5.3.4f1).
First i tried with assimpNet 3.0 (because i’veread that it works better) but when i try to get the tree structure of my ifc file, it doesn’t really work… the script give another tree structure (for exemple i get fiew nodes and then one node with 7 mesh but in the ifc file i have 2 nodes, the first one with 6 meshes and the second one with 1mesh) and then my meshes ind are not good so it doesn’t work…i can get the good meshes with other PostProcessSteps, but i’ve just one game object because of optimizeGraph.
So i tried with the assimpNet 3.3.1 (with the source code, i did the dll able to work with unity). But now i get another problem, when i tried to import my file with :
« Assimp.Scene model2 = import.ImportFile("sample02.ifc", PostProcessPreset.TargetRealTimeMaximumQuality); »
I get this error :
« AssimpException: Error importing file: The string "E-006,#14,$)" cannot be converted into a value.
Assimp.AssimpContext.ImportFile (System.String file, PostProcessSteps postProcessFlags)
ImportIFC.Start () (at Assets/Tests/ImportIFC/ImportIFC.cs:51) »
So the script find the file but can not read it…
I give you my source code and if you have any question, i’ll be really happy to answer to you :
My class to get the information :
« using UnityEngine;
using System.Collections;
using Assimp;
public class MainNodeIFC {
} »
My main code :
« public class ImportIFC : MonoBehaviour
{
}
«
sorry for my english, i’m a frensh student working also.
Thanks for your attention !
Hi,
I created an issue on our github-page:
https://github.com/assimp/assimp/issues/843
Please use this place to continue the dicsussion, thanks :-).
Kimmi
thanks