..submesh access

Hello

Greetings to everybody my friends. I hope you all doing well. I would like to ask a question regarding access to submesh.
Lets assume that i have one OBJ file, called Dude. Dude consists of individual parts such as :
-Head
-Right Hand
-Left Hand
-Torso
-Right Leg
-Left Leg
Mentioned parts are named same way as its show on list.

Now, lets assume that I have loaded Dude.OBJ as follows:

Spatial DUDE=assetManager.loadModel(“Models/Dude.OBJ”); .
ROOT_NODE.attachChild(DUDE);

…now, if i want to access lets say, Right Hand, i should do this:

Geometry Right_Hand=(Geometry) ROOT_NODE.getChild(“Right Hand”);

…from here I should be able to rotate, move or whatever i want, with accessed sub mesh, which is in this case Right_Hand.

Is this correct?

No, as right hand is a child of dude, you should call dude.getChild(“Right Hand”). To do so, you first have to cast Dude to a Node though.

…hmm…but, isn’t DUDE already child of ROOT_NODE, therefore, all children of DUDE are children of ROOT_NODE ? …or i misunderstanding concept of parenting??

Sure, but which DUDE?

Better to search the node where you know you will already find it rather than the whole scene.

Why does the spoiler tag not work here :frowning:

There is only one DUDE

1 Like

There are many "DUDE"s… but there is only one “the dude”. :slight_smile:

1 Like

…then, this suppose to be a proper way, please ?? …

Spatial DUDE=assetManager.loadModel(“Models/Dude.OBJ”); ***
DUDE.setName(“I AM DUDE”);
ROOT_NODE.attachChild(DUDE);

Node DUDENode=(Node) ROOT_NODE.getChild(“I AM DUDE”);
Geometry Right_Hand=(Geometry) DUDENode.getChild(“Right Hand”);

Well, that goes through a lot of work to do a relatively simple thing.

Node dude = (Node)assetManager.loadModel("Models/Dude.OBJ");
Geometry rightHand=(Geometry)dude.getChild("Right Hand");

…I did try that before, and i’m receiving error, as it is shown on link…

http://s28.postimg.org/47hco5xvh/msg.png

DUDE’s a Geometry :open_mouth:

…i think i deserve massive beating or something…if assetManager.loadModel() is returning Spatial, and it seems to be that way according to documentation, then, im casting spatial to a node as requested, then why that line crashing program?? I have commented everything else, so only this line is left, where program is crashing…

The spatial is not a Node, its a Geometry, there is no sub-spatials.

…so i assume that what mr. pspeed posted is correct, then why doesn’t work…im kind a lost now…can anyone post short code where things should be up to specification, because, im truly lost now…I have file dude.obj, inside that file are several individual 3D objects named as i have mentioned in my initial post. So, how to access each of them. I will truly appreciate to see solution, up to specification because, it seems im just plain stupid and cant get this thing up and running…sigh…

If they have the same material there is only one when imported.
The importer batches all stuff with the same material.
Obj is only usefull for static stuff.

I thought you’d loaded it in scene composer and already knew that it was multiple objects or that you’d actually tried the other code that you made. Too many assumptions. I’ll be sure not to make those assumptions when answering your posts in the future and figure you’ve only done the minimum exploration on your end.

So, yeah, as others have said. Your loaded model does not have ‘submeshes’… it’s just one Geometry.

TO be honest, that the obj importer batches by default is kinda a “feature” by it’s own. No other importer does that.

…well…as i said…i deserve some beating…it appears to be, as suggested, actual material issue…basically i just created simple scene in 3dsMax, and exported as .obj, but without any materials/textures on individual objects inside 3d file…problem is solved by proper export…my sincere apology for everybody involved in reply, as i asked question, without been prepared…im going to toilet and be ashamed for next 30 minutes :slight_smile: