Jump to content

Imported File Hierarchy


Recommended Posts

This is likely answered elsewhere, I just can't find it! 

My problem is that I'm importing an obj file. I get back a list of meshes including some names listed as "groupXXXXXXX" (where x's are numbers). Unfortunately, the mesh hierarchy appears very flat. When I import the same OBJ in other programs like Unity, it understands the hierarchy and treats single objects comprised of multiple meshes as a single object. I've tried invoking the getChildMeshes property and get a 0 length array, the parent getter is undefined. I know I can parent things manually once my meshes are loaded, but I'd like to load arbitrary OBJ files, and I can't find anything where I have info regarding the scene hierarchy.

Can anyone tell me what I need to look into for this grouping/hierarchy info?


Link to comment
Share on other sites

I believe I'm totally wrong about the premise for this question for what its worth. I'm still stumped, but it's not a hierarchy thing. I'm just getting "extra" meshes. The raw obj file has 4 sets of data under 2 names, and they look duplicated. The Babylon v2 editor somehow understands it contains only 1 object, but the loader gives back 4 meshes. Other more complex OBJ files I have, have way more meshes than I expect, and I think it's a similar problem. I should probably be ignoring meshes somehow, and I'm still investigating the details. Simpler OBJ files are fine - these ones I'm trying are saved from Google Poly

Link to comment
Share on other sites

Hi @benforreal

You are correct all meshes loaded can be accessed from a single 'flat' array in the loader's callback,
however, parent/child relations should still be there.

Example, If your file has three meshes & mesh 0 is parent of both mesh 1 & mesh 2;

// Callback
var parent = newMeshes[0] // parent
var childA = newMeshes[1] // child
var childB = newMeshes[2] // child

// But
parent ._children[0] should return childA
parent ._children[1] should return childB

aswell as the array returned by parent.getChildMeshes() should contain childA & childB

If the parent/child relations isn't there, then there's (mostlikely) something wrong in the obj file.

Link to comment
Share on other sites

Thanks much for the reply @aweirdo and @sebavan Sorry for the delay, I'm new to the forum and thought I'd get notifications for replies (I'll need to look for this).

Anyway - I'm realizing that you're correct. My OBJ file really doesn't have a hierarchy. I went in and looked at it raw after I posted this. That said, the Babylon editor renders it correctly as one node in the scene graph. Other programs do as well. I'm wondering if theres additional logic/relationships that I'm somehow missing. 

Also....I think Google Blocks generated files could be just messy.

thanks again! 

*turns notify me of replies on*


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...