petemac

Members
  • Content Count

    20
  • Joined

  • Last visited

  1. Thank you deltakosh! I played around with your scene and indeed it does work with moveWithCollisions I investigated further in my scene and found that I missed the second parameter of swordMesh.attachToBone(myMesh.skeleton.bones[7]); changed it to: swordMesh.attachToBone(myMesh.skeleton.bones[7],myMesh); and it worked!
  2. I tried attaching swordMesh to mymesh skeleton bone: swordMesh.attachToBone(myMesh.skeleton.bones[7]); then moving myMesh with: forwards = new BABYLON.Vector3(parseFloat((Math.sin(myMesh.rotation.y)) / speedCharacter) * scene.getAnimationRatio(), 0, parseFloat((Math.cos(myMesh.rotation.y)) / speedCharacter) * scene.getAnimationRatio());myMesh.moveWithCollisions(forwards); however the swordMesh does not follow. Also the swordmesh looks like the normals have been flipped around.I can see the inside of the sword.
  3. Does it work with moveWithCollisions?
  4. Has anyone figured out how to do this? Maybe?: http://www.html5gamedevs.com/topic/17135-create-bone-animation-programatically/?hl=programatically Hmm, I understand it, but when I try to implement it, it doesnt work, gets caught up on .value and .value.m.
  5. I figured it out. scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, function (){ani = 1;});works correctly. This will allow you to see what animation frame you are on: var anim = scene.getAnimatableByTarget(myMesh.skeleton);var currentFrame = anim._animations[0].currentFrame;
  6. Hello Everytime I try to do something at the end of my animation with onAnimationEnd, it happens at the start of my animation or it doesnt work at all. I try to alert at the end of my animation in this example below and I get the alert as soon as the animtion starts playing instead. var ani = 0;var sceneready = false;var playable = false;BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human25.babylon", scene, function (newMeshes, skeleton) { });scene.executeWhenReady(function (){sceneready = true;});function theendani(){ani = 1;}scene.registerBeforeRender(function () {if(sceneready){myMesh = scene.getMeshByName("HumanMale");myMesh.position = new BABYLON.Vector3(0, 1, 0);sceneready = false;playable = true;}if(playable){if(ani == 0){//All of these play the animation once but do not trigger the ani = 1 at the end of the animation//For some reason I am getting the alert right when the animation starts//I realize they are commented out I tried each of these individually:ani = 5; // So it doesnt call beginanimation again.//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, ani = 1);//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, ani = false);//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, theendani());//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, onAnimationEnd(){ani = 1;});//scene.beginAnimation(myMesh.skeleton, 85, 105, false, 1.0, onAnimationEnd(ani = 1));//ive also tried setting the animation to loop = true and it still triggers onanimationend at the start of my animation and then just loops the animation}if(ani == 1){//scene.stopAnimation(myMesh.skeleton);//scene.beginAnimation(myMesh.skeleton, 1, 85, false, 1.0);alert("end");ani = 2;}}}Also how do you tell what frame the animation is on? Custom time tracker? For example if I wanted onAnimationEnd to be called at frame 99 of my animation.
  7. Thank you! Using mesh.computeBonesUsingShaders = false works perfectly! However, I am curious. If I have a mesh with 30 bones, but 31 bones puts me over the limit by 1 bone. Will two seperate mesh with 30 bones put me over the limit for shader uniforms?
  8. I thought that might be the problem, is there a onloadfinish function of some sorts I can incorporate to this? //example?//function onload(){BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) { scene.beginAnimation(newMeshes[1].skeleton, 2, 70, 1.0, true); });//}myMesh = scene.getMeshByName("HumanMale");myMesh.position = new BABYLON.Vector3(0, 1, 0);
  9. But then I cant use myMesh outside of: BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) {});and thats the point, im trying to access and manipulate newMeshes and skeleton outside of that function.
  10. Hello Does mobile safari have a limit of bones per mesh? When I load a mesh with 30 bones from blender, it loads and displays fine. However when I add one more bone and load the mesh with 31 bones it doesnt display on screen. Ive tried numerous times with different models and no luck. The mesh still displays perfectly in Google Chrome on my laptop. It also displays perfectly in sandbox on my laptop. Is there some sort of limitation on safari mobile? The Iphone6? Babylon?
  11. //character BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) { scene.beginAnimation(newMeshes[1].skeleton, 2, 70, 1.0, true); });Above shows my mesh and the animation works. //character BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) { scene.beginAnimation(newMeshes[1].skeleton, 2, 70, 1.0, true); });myMesh = scene.getMeshByName("HumanMale");myMesh.position = new BABYLON.Vector3(0, 1, 0);Above my page doesnt load, just get a white screen. The problem lies with accessing the mesh and changing it, what ever and when ever I try something it doesnt load the page. Ive tried with numerous different models and blender files, attempted many different ways of trying to access and change the mesh outside the callback function. Always results with the page being white and the rest of my script not executing. This is my blender model showing the naming is correct:
  12. Using double quotes didnt work either : myMesh = scene.getMeshByName("HumanMale");myMesh.position = new BABYLON.Vector3(0, 1, 0);I still get a blank page. I did this: myMesh = scene.getMeshByName("HumanMale");//myMesh.position = new BABYLON.Vector3(0, 1, 0);The page loaded fine. But of course then I didnt change the position.
  13. I believe I tried that before, however I was probably doing it incorrectly Do you use the mesh name how it is named in blender? For example: BABYLON.SceneLoader.ImportMesh("thischaractername", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) {}myMesh = scene.getMeshByName('thischaractername');myMesh.doStuffWithMe;I just tried this and it did not work: I got a blank page. BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) { scene.beginAnimation(newMeshes[1].skeleton, 2, 70, 1.0, true); });var myMesh = scene.getMeshByName('HumanMale');myMesh.position = new BABYLON.Vector3(0, 1, 0);"HumanMale" is the name of the mesh I have exported from blender to a human24b.babylon.
  14. Thank you. Ive never really had trouble accessing variables I initalized outside a function and set inside a function, only in this specific case with (newmesh and skeleton) in the callback function; For example var a;blah();function blah(){a = 1;}print(a);//prints 1If im not mistaken, " ( if(m && s){...} )" only checks to see if they exist. What is the correct way to access newmesh and skeleton outside the callback function? Ive tried the var m;var s;BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) {m = newMeshes[0];s = newMeshes[0].skeleton;});m.position = new BABYLON.Vector3(0, 1, 0);scene.beginAnimation(s, 2, 70, 1.0, true);and it did not work. Does it not work because it hasnt been loaded before I ask for it to change position and animate? will changing it to this work?: var m;var s;BABYLON.SceneLoader.ImportMesh("", "firstpersongame/", "human24b.babylon", scene, function (newMeshes, skeleton) {m = newMeshes[0];s = newMeshes[0].skeleton;});if(m&&s){m.position = new BABYLON.Vector3(0, 1, 0);scene.beginAnimation(s, 2, 70, 1.0, true);}