TheComputerGuy Posted October 25, 2014 Share Posted October 25, 2014 thank you in advance,I am trying to control through variables like position and scaling... a rigged character with multiple meshes in a ,babylon file,"which was exported with animations from blender". The model is made up of three base objects "Creature", "eye", and "eye2". i need to be able to control the three meshes togeither as a whole. here is a clip of my code refering to this....// Load character object BABYLON.SceneLoader.ImportMesh("", "models/", "creature.babylon", scene, function (meshes) { var c = meshes[0]; c.isVisible = true; c.scaling = new BABYLON.Vector3(0.1,0.1,0.1); c.position = new BABYLON.Vector3(0,3,0); //c.renderingGroupId = 2; c.checkCollisions = true; CREAT = c; }); window.addEventListener("keydown", function (evt) { switch (evt.keyCode) { case 67: createCreat(); break; default: break; } }); var createCreat = function () { var posX = LANES_POSITIONS[Math.random()]; var c2 = CREAT.clone(CREAT.name) c2.id = CREAT.name+(Creats.length+1); c2.isVisible = true; c2.position = new BABYLON.Vector3(Math.random() * 100- 50, 3, Math.random() * 100 - 50); };when i load this with the meshes[0] selection it only effects the eye... [1] = eye2... [2] = Creature... how can i select all 3 at once? i will need to be able to do this for the animation as well. ty for any help you can give. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 25, 2014 Share Posted October 25, 2014 If your object has a bone, you can attach the eyes to bones.Otherwise you can use parent to attach the eyes to the head. eye1.parent = c;eye2.parent = c; TheComputerGuy 1 Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 25, 2014 Author Share Posted October 25, 2014 it does have bones. but i didnt create the model myself and the way its setup made it harder to attach the eyes to the bones. I will try your alt option and see if that solves it. ty Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 25, 2014 Author Share Posted October 25, 2014 ok im getting an error "Uncaught ReferenceError: eye is not defined " on the line 71. How do i define the mesh eye from the babylon file?// Load character object BABYLON.SceneLoader.ImportMesh("", "models/", "creature.babylon", scene, function (meshes) { var c = meshes[0]; eye.parent = c; eye2.parent = c; c.isVisible = true; c.scaling = new BABYLON.Vector3(0.1,0.1,0.1); c.position = new BABYLON.Vector3(0,3,0); //c.renderingGroupId = 2; c.checkCollisions = true; CREAT = c; }); Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 25, 2014 Author Share Posted October 25, 2014 ok about got it i used...// Load character object BABYLON.SceneLoader.ImportMesh("", "models/", "creature.babylon", scene, function (meshes) { var c = meshes[2]; var eye = meshes[0]; var eye2 = meshes[1]; eye.parent = c; eye2.parent = c; c.isVisible = true; c.scaling = new BABYLON.Vector3(0.1,0.1,0.1); c.position = new BABYLON.Vector3(0,3,0); //c.renderingGroupId = 2; c.checkCollisions = true; CREAT = c; });this loads it in a group however in the code c.position = new BABYLON.Vector3(0,3,0); it moves the creature up three but... it moves the eyes up three seperately so the eyes end up 3 above the creature.. any help would be great. ty again Quote Link to comment Share on other sites More sharing options...
Xeonzinc Posted October 26, 2014 Share Posted October 26, 2014 My method for dealing with a similar model is to create a new mesh and just make the parent of all three imported meshes this new one. That way they can all be moved around independently within the new local space.units[1].model[0] = new BABYLON.Mesh("Soldier Model",scene);However, your problem could be solved by changing the position of eye and eye2. • eye/eye2 are attached to c, so any transformation of c will be reflected on eye/eye2 • A transformation on eye/eye2 will only affect that mesh. TheComputerGuy 1 Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 27, 2014 Author Share Posted October 27, 2014 My method for dealing with a similar model is to create a new mesh and just make the parent of all three imported meshes this new one. That way they can all be moved around independently within the new local space.units[1].model[0] = new BABYLON.Mesh("Soldier Model",scene);However, your problem could be solved by changing the position of eye and eye2. • eye/eye2 are attached to c, so any transformation of c will be reflected on eye/eye2 • A transformation on eye/eye2 will only affect that mesh. yes re-positioning the eyes does work for that problem ty for all the responses. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 27, 2014 Share Posted October 27, 2014 try to adjust the position Y of eye and eye1.eye.position.y = -3; eye2.position.y = -3;oreye.parent.position.y = -3; eye2.parent.position.y = -3;You should know that attaches an object relative to the pivot point of the target. so you must adjust the position of the object relative to attach this pivot point. You can also change your pivot point in your modeling software. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.