Jump to content

adjusting variables in a multi-mesh skeleton object


TheComputerGuy
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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;				});
Link to comment
Share on other sites

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

 

example.jpg

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

try to adjust the position Y of eye and eye1.

  1. eye.position.y = -3;
  2. eye2.position.y = -3;
or
  1. eye.parent.position.y = -3;
  2. 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.
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...