3d model parts location

First of I work with anim8tor and export all my models in 3ds.



  Ok my question is … how do I get the location of a certain part of my model??



  For example … I have a model of a house … this house has four walls named wall1, wall2 ect. Now in jme I want to access these walls so that I can apply some physics to them … I've tried using …



Node.getChild("wall1").getWorldTranslation().x



but the x location of this child is  0.0 … which is actually the origin of the whole model, how do I reference the parts of the model only so they may be moved, rotated, scaled ect. ??



I can get access to the part using Node.getChild("wall1")  but its always off center because of its location withing the model how do I get around this ??

thanks but as I started to look into it it seems there is no class to load an obj file … is there one available like load3ds or do I have to convert all obj file to jme??

this is for .obj models but the system is the same:

http://www.jmonkeyengine.com/forum/index.php?topic=12366.msg91758#msg91758

there seems to be an issue with the code snip-it I got from the link you supplied …



TriMesh t = obj.getChild(…);

t.setModelBound(new BoundingBox());

t.updateModelBound(),

System.err.println(t.getCenter());



  First off the compiler is telling me that getCenter() is not a method of TriMesh … so whats up with that? Second what type in the above code is obj … I can't cast from Node to TriMesh, and Spatial does not have a getChild method.



There has to be a way to do what I want to do … my models are made from many separate peaces all relative to the x,y,z of the whole model, this seems to be a very simple thing to figure out but  at the moment it eludes me and its keeping me from moving on with my project.  These objects reside in 3d space somewhere … how do I locate there x,y,x??



And as I asked above is there a loadObj methode like the load3ds one … or do I have to convert all obj to jme format??

phmenard said:

And as I asked above is there a loadObj methode like the load3ds one ... or do I have to convert all obj to jme format??


Even if you had to convert form .obj to .jme first you would have to load the .obj model for that, wouldn't you?  :P

I just posted the link with the snippet above so you can look at smth similar, and <sarcasm>I'm sorry I didn't run the snippet through the compiler first.</sarcasm>

Once more without the bugs you get when you write into a simple TextField:


TriMesh t = someTriMeshYouLoadedAndWantToGetThePositionOf; // can be an imported .obj, .3ds or even .jme
// although most imported models are a Node with various TriMeshes attached to it
t.setModelBound(new BoundingBox());
t.updateModelBound(),
System.err.println(t.getModelBound().getCenter())



If its a Node you can cast your Spatial to a Node and retrieve the TriMesh child with getChild(N). (<sarcasm>Please replace the "N" parameter with the number of the child you want to retrieve.</sarcasm>)

You can find most of the loaders for the various model formats in the package com.jmex.model.converters

Again there is no methode getModelBound() for type TriMesh, this seems to be way more complicated then it should be.

phmenard said:

Again there is no methode getModelBound() for type TriMesh.


Yes there is, Geometry defines it and TriMesh extends Geometry. I take it you looked in the source code of TriMesh itself. Just in case you are new to the concept of Object Oriented Programming, i strongly suggest you learn that first, since it is vital when using this engine.

If this is not working at all maybe you should post some more sourcecode for us to work with, provided you change the tone in which you talk to people that are trying to solve YOUR problems.

Sorry if I seemed like I Had an attitude … that's not the case at all. I appreciate all the help I get from this forum.



  I know the concept of OPP … that's not the issue … here is the code I am using …



private ModelLoader3DS loader = new ModelLoader3DS();
model = loader.load3ds("bin/models/test.3ds");

TriMesh child = (TriMesh) ((Node) model).getChild(1); // can be an imported .obj, .3ds or even .jme
// although most imported models are a Node with various TriMeshes attached to it
child.setModelBound(new BoundingBox());
child.updateModelBound();
System.err.println(child.getModelBound().getCenter()); // the compiler keeps telling me there is no method getModelBound for type TriMesh

ok then,



two things come to my mind:

  1. make sure the right TriMesh (com.jme.scene.TriMesh) was imported
  2. Let the compiler clean the whole workspace (in Eclipse "Project - clean - Clean all projects")



    This issue is not about jme, the sourcecode compiles and is correct (for jme 2.0 on my end and for jme 1.0 as well i guess).



    I have never seen the ModelLoader3DS class and it doesn't exist in jme.

ok com.jme.scene.TriMesh is my import … I also cleand the project.



  The class ModelLoader3DS is a class I got from a book I read a while ago … its load3ds(…) method loads and returns the model as a Spatial with all textures if they are available.



  What do ya think is going on … and why do ya think I can't get access to the getModelBound().getCenter() methods??



 

ok … I'm getting closer now, I can now find the center of any part of my model … I Had to use this …



child.getWorldBound().getCenter()



rather than …



child.getModelBound().getCenter()



  But now the question is why does the model move position after I apply my physics??? After  20 seconds the objects is added to a DynamicPhysicsNode which cause it to fall to the ground from what ever height it is at … so the DynamicPhysicsNode now is place where it should be (the center of the mesh which is a sub mesh of the whole model) but it pushes the actual mesh off to the side so now the physics node is where it should be but the model representing the physics node is offset from my center … hmmm stumped again? Any ideas on why this is happening?