Collada BIM model import and distinguish its elements

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Collada BIM model import and distinguish its elements

Post by emadof85 »

Hello Dears
I'm new here, but I'm using this amazing game engine "Irrlicht" to visualize my 3D BIM Model into it
what I've done till now is export my model as collada file (.dae), then loaded into irrlicht using irrlicht source code.
Now I'm trying to distinguish each element of the model such as the wall, or the door but I can't find how to do this in irrlicht since loading the model is as the following:
I want someone to help me doing this in irrlicht and I'll be appreciated

Code: Select all

 
static void Main(string[] args)
        {
            DriverType driverType = DriverType.OpenGL;
            IrrlichtDevice device = IrrlichtDevice.CreateDevice(driverType, new Dimension2Di(840, 680));
            if (device == null)
                return;
 
            device.SetWindowCaption("Hello World! - Irrlicht Engine Demo");
 
            VideoDriver driver = device.VideoDriver;
            
            SceneManager smgr = device.SceneManager;
            GUIEnvironment gui = device.GUIEnvironment;
 
            gui.AddStaticText("Hello World! This is the Irrlicht Software renderer!",
                new Recti(10, 10, 260, 22), true);
 
            smgr.Attributes.SetValue(SceneParameters.COLLADA_CreateSceneInstances, true);
            AnimatedMesh mesh = smgr.GetMesh("test.dae");
            AnimatedMeshSceneNode node = smgr.AddAnimatedMeshSceneNode(mesh);
CameraSceneNode camera = smgr.AddCameraSceneNodeFPS(null, 100, .01f);
            camera.Position = new Vector3Df(0, 2, 0);
            camera.Target = new Vector3Df(-200f, 0f, -100f);
            device.CursorControl.Visible = false;
            int lastFPS = -1;
 
            while (device.Run())
            {
                driver.BeginScene(true, true, new Color(100, 101, 140));
 
                smgr.DrawAll();
                gui.DrawAll();
 
                driver.EndScene();
                int fps = driver.FPS;
                if (lastFPS != fps)
                {
                    device.SetWindowCaption(String.Format(
                        "Movement example - Irrlicht Engine [{0}] fps: {1}",
                        driver.Name, fps));
 
                    lastFPS = fps;
                }
            }
 
 
            device.Drop();
        }
 
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada BIM model import and distinguish its elements

Post by CuteAlien »

Hi, welcome to the forum. No problem as you didn't know yet - but please don't cross-post when you don't get answer in the future. We will remove such posts (as it makes it harder to keep track of answers when people start writing into 2 posts at the same time about the same topic). We read all posts - when there is no answer it's usually because it's not a trivial problem so people don't know the answer immediately.

Did you check if node-names contain some useful information? Would be the first I'd check - and I think Collada passes on some infos by that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Re: Collada BIM model import and distinguish its elements

Post by emadof85 »

Thanks for the reply, and I'm sorry for posting in two form; now I know the rules.
But actually node name is return nothing and what I need is to get children nodes of the root node ScenNode after get a mesh of a collada file but it return null:

Code: Select all

 
DriverType driverType = DriverType.OpenGL;
            IrrlichtDevice device = IrrlichtDevice.CreateDevice(driverType, new Dimension2Di(840, 680));
            if (device == null)
                return;
 
            VideoDriver driver = device.VideoDriver;
            
            SceneManager smgr = device.SceneManager;
            GUIEnvironment gui = device.GUIEnvironment;
 
            smgr.Attributes.SetValue(SceneParameters.COLLADA_CreateSceneInstances, true);
            AnimatedMesh mesh = smgr.GetMesh("test.dae");
            AnimatedMeshSceneNode node = smgr.AddAnimatedMeshSceneNode(mesh);
            SceneNode[] nodes = node.Children;
 
What I'm missing or is loading collada file into mesh give only one node as a whole scene?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada BIM model import and distinguish its elements

Post by CuteAlien »

Yeah - collada-loader is a little hacky. I guess it started out as mesh-loader probably. But the meshloader can only load 1 mesh exactly. If you use to load a complete scene then it will just put all the nodes of the collada file in the scenemanager.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Re: Collada BIM model import and distinguish its elements

Post by emadof85 »

we know that collada consists of many geometries and each geometry contains mesh
how i can select a mesh by using ray from camera ??????????
i need it to catch some parts of model to show properties of selected mesh

for example :my project loads a callada model which represents a building sand i want to navigate through it and select some parts like doors or walls >>>>
how?
please help :cry: :cry: :cry: :cry: :cry: :cry:
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada BIM model import and distinguish its elements

Post by CuteAlien »

It's hard to say more than I already did without knowing your scene. It might be exported as 1 mesh or as many meshes which are now in different nodes. If you have one mesh there's not much you can do. If you have several nodes then you can find those - and have to figure out how to give them names before export (Irrlicht imports node-names).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Re: Collada BIM model import and distinguish its elements

Post by emadof85 »

here is my collada file just the visual scene which I think is the most important type for my question:

Code: Select all

 
<library_visual_scenes>
    <visual_scene id="1170233280" name="Revit_scene">
      <node id="1346730160" name="Generic - 8"">
        <instance_geometry url="#geom-1350755952">
          <bind_material>
            <technique_common>
              <instance_material target="#1170234516-material" symbol="1170234516" />
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
      <node id="1346730640" name="Generic - 8"">
        <instance_geometry url="#geom-1351049248">
          <bind_material>
            <technique_common>
              <instance_material target="#1170234516-material" symbol="1170234516" />
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
      <node id="1182589376" name="Generic - 8"">
        <instance_geometry url="#geom-1274656272">
          <bind_material>
            <technique_common>
              <instance_material target="#1170234516-material" symbol="1170234516" />
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#1170233280" />
  </scene>
 
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada BIM model import and distinguish its elements

Post by CuteAlien »

In this case the Irrlicht scene-nodes should have the id's from above as name I think.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

Re: Collada BIM model import and distinguish its elements

Post by emadof85 »

Thank you I got it solved.
As you say all nodes are stored in the scene manager object:

Code: Select all

 
smgr.RootNode.Children[0].Children[0].Visible = false;
string name = smgr.RootNode.Children[0].Children[0].Name;
 
Post Reply