Hey, I have a scene with 2 houses, a straight road (made of 2 straight road objects going on the Z axis) and 2 footpath objects on either side of the straight road. Here is the code
[java]
Spatial house = assetManager.loadModel(“Models/House/House.mesh.xml”);
house.setLocalTranslation(new Vector3f(-6.0f, 0.0f, 0.0f));
Spatial house2 = assetManager.loadModel(“Models/House/House.mesh.xml”);
house2.setLocalTranslation(new Vector3f(6.0f, 0.0f, -7.0f));
Spatial road = assetManager.loadModel(“Models/Road/Road.mesh.xml”);
Spatial road2 = assetManager.loadModel(“Models/Road/Road.mesh.xml”);
road2.setLocalTranslation(new Vector3f(0.0f, 0.0f, -10.0f));
Spatial footpath = assetManager.loadModel(“Models/Footpath/Footpath.mesh.xml”);
footpath.setLocalTranslation(new Vector3f(0.0f, 0.0f, 0.0f));
footpath.rotate(0.0f, 180*FastMath.DEG_TO_RAD, 0.0f);
Spatial footpath2 = assetManager.loadModel(“Models/Footpath/Footpath.mesh.xml”);
footpath2.setLocalTranslation(new Vector3f(0.0f, 0.0f, 0.0f));
rootNode.attachChild(house);
rootNode.attachChild(house2);
rootNode.attachChild(road);
rootNode.attachChild(road2);
rootNode.attachChild(footpath);
rootNode.attachChild(footpath2);
[/java]
The houses and the road are all perfectly positioned but the footpaths do something weird. When they are set to 0, 0,0 they actually appear not in the center of the scene but 2 units to the right on the X axis and if I rotate one of the footpaths by 180 degrees on the Y axis it ends up 2 units to the left on the X axis.
The footpath is only 1 unit in Blender. I am thinking that it might have somethig to do with using a mirror modifier in Blender. I applied the modifier and turned the 2 footpaths into seperate objects before I exported it though so I don’t know whats going on especially since the rest of my objects are in the correct place.
Any help would be appreciated thanks.
The mesh of your road is off. The center is outside the mesh. Probably when you open the street in your editor its also not at 0/0/0
Thanks for the reply.
I also put a 1, 1, 1 blue box at Vector3f.ZERO so I know where the center is and the box is right in the middle of the X axis on the road so the road seems to be fine and the houses are positioned at the correct distance on either side of the blue box.
Any other ideas?
It’s not the road that’s off… it’s the paths. It sounds from your description like they have a built in two unit translation.
On Blender there is 4 units between the 2 footpaths. The road takes up 4 units on the X axis, 2 on either side and then footpaths are in the next unit on either side. When I put the footpath at 0, 0 , 0 in jME it end up in the place that it is in in Blender.
Im convinced it has something to do with me using a mirror modifier on the X axis because it only happens with the footpath spatials.
Has anyone else experienced this before?
@metallicalive said:
When I put the footpath at 0, 0 , 0 in jME it end up in the place that it is in in Blender.
Thats what we try to tell you, thats the normal behavior. You move the vertices in blender, the object stays at 0/0/0.
@normen said:
Thats what we try to tell you, thats the normal behavior. You move the vertices in blender, the object stays at 0/0/0.
Is that because of the mirror modifier because if I put a house at 0, 0, 0 or a road at 0, 0, 0 they go to the center of the scene.
I just created an object in Blender with the same dimensions as the other footpath and same scale and when I export it and set it at 0, 0 ,0 it actually goes to 0, 0, 0 in the scene, not like the other footpath and this goes to 0, 0, 0 everytime no matter what position I exported it from Blender in.
I think the exporter does something weird tot he mesh.xml file if a mirror modifier was used in Blender. Is there a workaround for this because using the mirror modifier is really handy.
:facepalm: Look. You make a new object in blender, its being put in at 0/0/0. You go to edit mode to modify its vertices and move them two units to the right. The objects center still is at 0/0/0 but now its mesh is off by two units. When you rotate the object around its center the street obviously moves like the blade of a helicopters rotor. For the other model, you probably moved the object in blender so the geometry created from that also gets that location and not just its mesh.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:scenegraph_for_dummies