How do I move all the meshes, keeping them locally in their position relative to the scene, but moving the absolute position of everything to my terrain? ( where my player is )
This is how I usually solve this. I am not sure if this is best practice though.
var mesh = BABYLON.SceneLoader.ImportMesh("", "scenes/", "mdl_roterBaron_v064_awhg.babylon", scene, function (newMeshes) {
for (mesh in newMeshes){
newMeshes[mesh].scaling = new BABYLON.Vector3(1, 1, 1);
newMeshes[mesh].position = new BABYLON.Vector3(0,1,0);
}
});
this is a bit different because this is a scene that has local positions that need to be saved. I don’t want their position to all be exactly the same. A thought I had would be to put a dummy mesh in the middle of the scene, give it a name then reference it in my code, find the difference between all the other meshes position and the center dummy mesh(origin of scene) and then set the position of the center dummy mesh and apply the base difference of the positions to the meshes locally to the center dummy mesh.
When I do incremental position deduction (mesh.position.x -= 10;) it works as intended for meshes that don’t have a rotation. But meshes with rotations and its position will not move as intended. Is their a way to move a mesh with the offset of a rotation in case it has one?
and look at line 28, the rabbit has been reduced in scale to give it an appropriate size relative to the dude. Comment out line 28 and see what happens.
Changes in scale will also affect relative positioning.
I did not create the meshes, I don’t think its a scaling issue? If I deduct all positioning from a static number, majority of the props move properly, its the ones that have rotation that go out of wack. I am not doing any manual scaling, and the scene looks proportional to my player.