Kilombo

Members
  • Content Count

    145
  • Joined

  • Last visited

Everything posted by Kilombo

  1. Good morning Delta, Well, the add in place should replace the original cords by new cords in each frame, right? What is happening is that it is concatenating the new vector to the old one in each frame. I'm not getting why.. Thanks,
  2. Well... I have different files. In the first one there's what i call the main engine, in the second one there's the units class, in mainengine i've got a start() function that has this line: selectedUnit[a].setVelocity(parseFloat(tempx), parseFloat(tempz), parseFloat(posix), parseFloat(posiz)); The selectedUnit is one array of Units that is runned by a for cicle, so that it can set each of the existent units movement and direction (it does a lot more things but it's not important now). What it counts is that the setVelocity receives has parameters the mouseX and mouseY (the mesh destination cordinates) and the initial mesh cords. The setVelocity method is like this: unit.prototype.setVelocity = function (targetx, targetz, posix, posiz){ this.destination = new BABYLON.Vector3(targetx,0,targetz); this.origin = new BABYLON.Vector3(posix,0,posiz); this.origin.x = posix; this.origin.z = posiz; this.movevector = this.destination.subtract(this.origin); this.movevector = this.movevector.normalize(); this.movevector = this.movevector.scale(0.2); if (this.mesh){this.updateMesh(this.mesh);} }; This method calls another one called updateMesh, there's this one: unit.prototype.updateMesh = function (mesh){ this.mesh = mesh; if (typeof(this.movevector) !== "undefined"){ if(this.movevector.length() > 0.09) { this.mesh.moveWithCollisions(this.movevector); } } this.mesh.rotation.y = this.getShipRotation(); this.mesh.position.y = 0; this.x = this.mesh.position.x; this.z = this.mesh.position.z; }; So... I made a lot of "console.log()" to almost all of the variables, and my first conclusion is that there's something wrong with this method "this.mesh.moveWithCollisions(this.movevector);". Because this results in a BABYLON Vector3 concatenation, instead of a subtraction in each of the coords position. Delta... Sorry for such a long post, but i hope i'm explaining my self a bit better this time. Thanks in advance for your help.
  3. hi delta, nice to see you. i'm not sure what you mean, what's the camera relation with it? if I comment out the movewithcollisions function, the camera stays in bounds and detects all the collisions. please try to explain a little further.
  4. Hello again, Anyone knows a possible reason to moveWithCollisions() concatenate the existing position with the subtracted vector, instead of in fact do a subtraction for each of the positions (x,y,z) ? Thanks in advance,
  5. Hello bbmario, good evening and welcome to the forum and to this community. There's already lot's of stuff available. Delta and Devrous made some really good videos, and that's a good place to start. http://www.microsoftvirtualacademy.com/training-courses/introduction-to-webgl-3d-with-html5-and-babylon-js You can also check the documentation in here: http://doc.babylonjs.com. Best regards, Kilombo
  6. Wing and Fenomas, Thank you both for your answers. I'll stick with checkcollisions (for now). I have to do further experiences and some small games/demos with it before implement it on my project. Anyway, I already found the answer to my problems. This demo: http://playground.babylonjs.com/#1NQTNE#11 is quite good. Although, I've got to tell you guys. When I first saw the documentation my first tought was that the moveWithCollisions(); function would make the ellipsoid move within the mesh, and not move the mesh by itself. With that said, i was moving the mesh both with translations and with moveWithCollisions(), of course it woudn't work... It still doesn't work, but at least i know where the problem is Thanks for the help guys. If i sortit out, I'll post the conclusions. Best regards, Kilombo
  7. Congrats Deltakosh. Please take all the time you need. Kids are the best thing in the world. Spend all the time you can with your litle girl. You sure deserve it (and she needs it ). Best regards, Kilombo
  8. Do you want to keep the mesh rotated in the world and trick the system so that he thinks that those are in fact 0,0,0 ?
  9. Hello Wingnut, Long time no see , Well i tried to implement Oimo.js without success, alot of problems appeared (ships dissapeared, planets falling off in deep space with gravity switched to zero, etc...), the thing is... this is one rts game in a 2D axis (X,0,Z) in a 3D world, not one rpg, so i was not really worried with physics, i thought that there wasn't a real advantage for this type of game, anyway, when i started applying Oimo, things started to really slow down, so i thought.. imbebed babylon.js collision system looks simple, dad72 example seems really simple to implement, so.. let's do it.. then this big issue appeared, i can't seem to understant how this function and parameter really work. Btw wing, what do you prefer, Oimo or cannon ? And do you know where to find some more complete tutorials? To implemet Oimo i had to fly around for a bunch of posts. Thanks in advance.
  10. Good afternoon DigitalHilson, I'm not really sure what the problem is, can you plz create on example in the playground? Or post some code ? About helping you to write your project... I think that if you post the doubts and problems that you find, everyone will try to help you out, no problem on that. Thanks.
  11. Good afternoon, I'm trying to implement mesh collisions instead of a physics system (turns out that it costs to much in performance and i don't have the time to implement it right now), at first look it looks simpler. Although... I wen't looking at the tutorial and at dad72 example, and I'm not beeing able to implement it. I don't understand the concept behind the moveWithCollisions function and the velocity vector3. In my game I don't have a velocity var, the player point and click and the ship moves to that place. So... If i understand the concept, I may adapt it. At first, i thought.. well, maybe the function will try to calculate the mesh destiny, so I directly putted de ship X and Z coordinates on the velocity vector3 and it didn't work. I pasted a bit of the code. Notice that selectedUnit[a].setVelocity(velocity); is calling the setVelocity method, this method calls moveWithCollisions with the velocit parameter. this is part of the units class and the selectedUnit is one array of Units Thanks in advance for the help. if ((posix!==0)&&(typeof(posix)!=="undefined")&&(isNaN(posix)===false)){ if (targetx === 0){ Number(targetx); targetx = Number(posix)+1; Number(targetz); targetz = Number(posiz)+1; } camera.target = new BABYLON.Vector3(posix,0,posiz); systems[0].calculateSunDistance(camera); //calculateSunDistance(systemB1,camera); systems[1].calculateSunDistance(camera); //calculateSunDistance(systemB2,camera); dx = targetx - posix; dz = targetz - posiz; rot = Math.atan2(dx, dz); len = Math.sqrt(dx * dx + dz * dz); if (len === 0) len = 1; dx = dx / len; dz = dz / len; if (rot!==0){ posfy = rot + Math.PI; } posfx = parseFloat(selectedUnit[a].getShipPosx()) + parseFloat(dx); posfz = parseFloat(selectedUnit[a].getShipPosz()) + parseFloat(dz); shiproty = posfy; shipx = Math.round(posfx, 1); shipz = Math.round(posfz, 1); shipid = selectedUnit[a].getShipId(); selectedUnit[a].setShipPos(shipx,shipz,shiproty); ship = selectedUnit[a]; //velocity = new BABYLON.Vector3(parseFloat(Math.sin(parseFloat(shiproty))) / 1, 0.5, parseFloat(Math.cos(parseFloat(shiproty))) / 1); velocity = new BABYLON.Vector3(parseFloat(shipx), 0.5, parseFloat(shipz)); //console.log(velocity); selectedUnit[a].setVelocity(velocity);
  12. Yap.. I do. Strange thing, If I put no mass on the planets they still stand, but if I put some mass, they just disappear.
  13. Well..i sorted out.. now the planets just fall of.... but they shouldn't cause i've set gravity to zero. Anyone knows why?
  14. Good afternoon everyone, For some reason, my planets function is giving me the error in the topic. Everything works right in the units class, but in planets is not working. And i can't seem to find the answer. Help wanted plz The console is returning "Uncaught TypeError: Cannot read property 'setPhysicsState' of undefined" in system.js line 104, is the one in bold. I'm trying to implement Oimo.js in my project btw. system.prototype.setPlanets = function (){ var temp = this; BABYLON.SceneLoader.ImportMesh(name, "Assets/babylonreadyfiles/", "planets.babylon", scenes[0], function(newMeshes) { newMeshes[0].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet1 = newMeshes[0]; var planet2 = newMeshes[1]; newMeshes[1].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet3 = newMeshes[2]; newMeshes[2].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet4 = newMeshes[3]; newMeshes[3].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet5 = newMeshes[4]; newMeshes[4].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet6 = newMeshes[5]; newMeshes[5].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet7 = newMeshes[6]; newMeshes[6].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet8 = newMeshes[7]; newMeshes[7].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet9 = newMeshes[8]; newMeshes[8].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); if (temp.planet1 === "planet1"){ planet1.scaling.x = 500; planet1.scaling.y = 500; planet1.scaling.z = 500; planet1.position.x = temp.posx/2; planet1.position.y = 5; planet1.position.z = temp.posz/2; planet1.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[0].checkCollisions = true; scenes[0].beginAnimation(planet1, 0, 100, true, 0.04); console.log(planet1); //planet1.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet1,temp.planetId1,"planet"); } if (temp.planet2 === "planet2"){ planet2.scaling.x = 300; planet2.scaling.y = 300; planet2.scaling.z = 300; planet2.position.x = temp.posx*(6/4); planet2.position.y = 5; planet2.position.z = temp.posz; planet2.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[1].checkCollisions = true; scenes[0].beginAnimation(planet2, 0, 100, true, 0.04); //planet2.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet2,temp.planetId2,"planet"); } if (temp.planet3 === "planet3"){ planet3.scaling.x = 750; planet3.scaling.y = 750; planet3.scaling.z = 750; planet3.position.x = temp.posx*(6/4); planet3.position.y = 5; planet3.position.z = temp.posz*(8/4); planet3.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[2].checkCollisions = true; scenes[0].beginAnimation(planet3, 0, 100, true, 0.04); // planet3.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet3,temp.planetId3,"planet"); } if (temp.planet1 === "planet4"){ planet4.scaling.x = 500; planet4.scaling.y = 500; planet4.scaling.z = 500; planet4.position.x = temp.posx/2; planet4.position.y = 5; planet4.position.z = temp.posz/2; planet4.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[3].checkCollisions = true; scenes[0].beginAnimation(planet4, 0, 100, true, 0.04); //planet4.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet4,temp.planetId1,"planet"); } if (temp.planet2 === "planet5"){ planet5.scaling.x = 300; planet5.scaling.y = 300; planet5.scaling.z = 300; planet5.position.x = temp.posx; planet5.position.y = 5; planet5.position.z = temp.posz*(7/4); planet5.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[4].checkCollisions = true; scenes[0].beginAnimation(planet5, 0, 100, true, 0.04); //planet5.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet5,temp.planetId2,"planet"); } if (temp.planet3 === "planet6"){ planet6.scaling.x = 750; planet6.scaling.y = 750; planet6.scaling.z = 750; planet6.position.x = temp.posx*(7/4); planet6.position.y = 5; planet6.position.z = temp.posz/2; planet6.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[5].checkCollisions = true; scenes[0].beginAnimation(planet6, 0, 100, true, 0.04); // planet6.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet6,temp.planetId3,"planet"); } if (temp.planet1 === "planet7"){ planet7.scaling.x = 500; planet7.scaling.y = 500; planet7.scaling.z = 500; planet7.position.x = temp.posx/2; planet7.position.y = 5; planet7.position.z = temp.posz/2; planet7.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[6].checkCollisions = true; scenes[0].beginAnimation(planet7, 0, 100, true, 0.04); //planet7.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet7,temp.planetId1,"planet"); } if (temp.planet2 === "planet8"){ planet8.scaling.x = 300; planet8.scaling.y = 300; planet8.scaling.z = 300; planet8.position.x = temp.posx; planet8.position.y = 5; planet8.position.z = temp.posz*(7/4); planet8.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[7].checkCollisions = true; scenes[0].beginAnimation(planet8, 0, 100, true, 0.04); //planet8.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet8,temp.planetId2,"planet"); } if (temp.planet3 === "planet9"){ planet9.scaling.x = 750; planet9.scaling.y = 750; planet9.scaling.z = 750; planet9.position.x = temp.posx*(7/4); planet9.position.y = 5; planet9.position.z = temp.posz/2; planet9.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[8].checkCollisions = true; scenes[0].beginAnimation(planet9, 0, 100, true, 0.04); // planet9.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet9,temp.planetId3,"planet"); } });};
  15. Yap... It worked. Thank you for the help. Do you know why ? What have changed ?
  16. No prob mate, here you go. //Criação de chão da base. var gmat = new BABYLON.StandardMaterial("gmat", scenes[1]); gmat.diffuseTexture = new BABYLON.Texture("Textures/Ground_1.jpg", scenes[1]); gmat.diffuseColor = new BABYLON.Color3(.15, .05, 0); var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "Textures/heightMap.png", 200, 200, 250, 0, 6, scenes[1], false); ground.material = gmat;
  17. Good evening everyone, long time no see. I've been away for a while, and didn't made many changes to my project. The first thing I made when i get my hands on, was to update to the latest release. Everything worked fine. But the images using "BABYLON.Mesh.CreateGroundFromHeightMap" changed, and lost some colors. Can some one give me a hand on this? The first image is relative to v1.12, the second is relative to v2.0. Thanks in advance.
  18. You where right (again), My exporter was version 1.1, i installed v1.2 and it didn't solved out
  19. Ok, latest update... The problem is not with locations. It worked out at first because i only tested with one mesh, when I put the others the problems subsists, the more meshes I load, the messier the problem is. I don't know why but it seems that babylon is mixing the textures and materials from one meshes to anothers
  20. Actually I'm using this: But it should be the same principle. It loads meshes ok, but not the textures. The funny thing it that works out with some meshes and with other doesn't. I have another class that has a method just like this one to load planets, and in there everything is ok. The only problem is with the ships. Now the funny part.. I wiped out the path, put everything in the root (jpg's plus babylon files) and it worked. BABYLON.SceneLoader.ImportMesh(name, "./Assets/babylonreadyfiles/", imageFileName, scenes[0], function(newMeshes) {
  21. Yap mate, you are right. I putted the rootUrl parameter, the mesh works but no textures, when i remove it and leave it on root it works. Now that's a messy bug, it's for sure too many files to keep on the main root folder Now.. it's a problem with the blender exporter or with the babylon sceneLoader? I'll take a look at sceneLoader and try to work it out. Thanks JCPalmer you saved my day, that was really helpfull.
  22. Yap, I can edit the file, but it seems that isn't the problem, cause everything seems ok, and the babylon file is in the same place has the jpg file. Must be something with the object it self, I must be doing something wrong, only don't know what
  23. Temechon it's probably right Is the man of the physics engines , If he says so, probably he's right
  24. Thanks for your answer Palmer. Yap this textures a file based, when you tell in the same directory that html file, you mean same directory has file.babylon right ?