• Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by Pryme8

  1. Got the chunking done. Now I really need to do calculations on the nearest point on the plane, I found this but I am such a lamen I have no clue what it is saying if anyone can translate?
  2. So it "works" but it crashes once it propagates out a little. I need an idea of how to establish which zones to build. Maybe like a max ring size instead of what I am doing now and have it only render out say 4 steps from the current zone the player is on? Just hoping for some alternative ideas. ^^ for a non crashing version without neighborhood checks. #EDIT# Also any math buffs wanna help me with how to do an equation to calculate the distance from the the outer closest edge point or center, which ever is closest. Not just the Center, or at least point me in the right direction?
  4. My bad, I miss read your first post! >_< I was rushing out the door to get to lunch, good thing adam knows what hes talking about!
  5. player = { mesh:player_box, speed: { f:0, s:0, u:0, } }; //PHYSICS START player_box.body = player_box.setPhysicsState(BABYLON.PhysicsImpostor.SphereImpostor, { mass: 1.0, friction: 0.0001, restitution: 0.0}); player_box.body.grounded = false; player_box.body.collisionResponse = 0; player_box.body.addEventListener("collide", function(e){ player_box.body.grounded = true; player_box.body.collisionResponse = 1; }); //CONTROLS keys = {}; keys.up = false, keys.down = false, keys.left = false, keys.right = false, = false, keys.w = false, keys.s = false, keys.a = false, keys.d = false, keys.ctrl = false; function onKeyDown(evt) { console.log(evt.keyCode); switch (evt.keyCode){ case 37: // left keys.left = true; break; case 39: //right keys.right = true; break; case 38: //up keys.up = true; break; case 40: //down keys.down = true; break; case 32: //space = true; break; case 87: //w keys.w = true; break; case 83: //s keys.s = true; break; case 65: //a keys.a = true; break; case 68: //d keys.d = true; break; case 17: //ctrl keys.ctrl = true; break; } } function onKeyUp(evt) { switch (evt.keyCode){ case 37: // left keys.left = false; break; case 39: //right keys.right = false; break; case 38: //up keys.up = false; break; case 40: //down keys.down = false; break; case 32: //space = false; break; case 87: //w keys.w = false; break; case 83: //s keys.s = false; break; case 65: //a keys.a = false; break; case 68: //d keys.d = false; break; case 17: //ctrl keys.ctrl = false; break; } } window.addEventListener("keydown", onKeyDown); window.addEventListener("keyup", onKeyUp); //console.log(player_box.body); //console.log(camera); settings = { accel : 1, speeds :{ normal :{ f: 50.0, b: -20.0, s: 30.0, }, run :{ f: 1.0, b: 0.45, s: 0.65, }, walk :{ f: 0.3, b: 0.1, s: 0.2, }, }, }; //CONTROL RESPONSE scene.registerBeforeRender(function(){ //console.log(player_box.position); if(player_box.body.collisionResponse){ player_box.body.grounded = true; player_box.body.velocity.y = 0; }else{ player_box.body.grounded = false; } if(player_box.body.grounded || gravity.y == 0){ if(keys.w){ if(player.speed.f < settings.speeds.normal.f){ player.speed.f += settings.accel; }else{ player.speed.f = settings.speeds.normal.f; } }else if(keys.s){ if(player.speed.f > settings.speeds.normal.b){ player.speed.f -= settings.accel; }else{ player.speed.f = settings.speeds.normal.b; } } if(keys.a){ if(player.speed.s > settings.speeds.normal.s*-1){ player.speed.s -= settings.accel; }else{ player.speed.s = settings.speeds.normal.s*-1; } } if(keys.d ){ if(player.speed.s < settings.speeds.normal.s){ player.speed.s += settings.accel; }else{ player.speed.s = settings.speeds.normal.s; } } if({ if(gravity.y != 0 && player_box.body.grounded){ player_box.body.collisionResponse = 0; var jumpVector = v3(0,6.5,0); player_box.applyImpulse(jumpVector, player_box.position); }else{ if(player.speed.u < -2){ player.speed.u -= settings.accel; }else{ player.speed.u = -2; } } } if(keys.ctrl){ if(gravity.y != 0 && player_box.body.grounded){ player.speed.f*=0.5; player.speed.s*=0.5; }else{ if(player.speed.u > 2){ player.speed.u += settings.accel; }else{ player.speed.u = 2; } } } player.speed.f*=0.82; player.speed.s*=0.82; player.speed.u*=0.82; if(player.speed.f<0.05 && player.speed.f > -0.05){ player.speed.f = 0; } if(player.speed.s<0.05 && player.speed.s > -0.05){ player.speed.s = 0; } var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y = 0; var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; var f_speed = 0, s_speed = 0, u_speed = 0; if(player.speed.f != 0){ f_speed = player.speed.f; } if(player.speed.s != 0){ s_speed = player.speed.s; } if(player.speed.u != 0){ u_speed = player.speed.u; } move = (forward.scale(f_speed)).subtract((right.scale(s_speed))).subtract(scene.activeCamera.upVector.scale(u_speed)); player_box.body.velocity.x = move.x; player_box.body.velocity.z = move.z; player_box.body.velocity.y = move.y; } if(keys.ctrl){ camera.position = v3(player_box.position.x,player_box.position.y+1,player_box.position.z); }else{ camera.position = v3(player_box.position.x,player_box.position.y+2,player_box.position.z); } This might be over kill... but this is a controller that I have used in the past. You need to get a forward vector and do something with that!
  6. What do you mean by tile-able noise? Do you want the noise to repeat? var x = (x/unitSize) - Math.Floor(x/unitSize); var z = (z/unitSize) - Math.Floor(z/unitSize); I just woke up so that math might be wrong but off the top of my head that sounds right to make it repeat. <- might have some info for you. If you just want infinite noise then you need to not use a texture map... just use my Das_Noise Lib and keep feeding it what ever coords you want it will go on for ever. var noise = new dN('Simple2' , 'testSeed', { frequency:1, amplitude:1, octave:1, persistence:1, scale:100, }); var vertexData = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); for (var i = 0; i < vertexData.length; i += 3) { var x = vertexData[i]+mesh.position.x, y = vertexData[i+1] ,z = vertexData[i+2]+mesh.position.z; var h= noise.getValue({x:x,y:z}); vertexData[i+1] = h*height; } mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, vertexData, 0, 0);
  7. what are you trying to do exactly?
  8. Dumb dah dumb dumb... sorry it was a long day...
  9. So if I make a canvas, and then convert its content to an Image am I able to assign it as lets say a diffuse texture? The above demo does not work, but that's the idea. Is this what Dynamic textures are for? If so then why does this not work:
  10. This demo is down, anywhere to look at it source code somewhere else? **EDIT** I found the source code on the github, but the demo still seems to be down.
  11. I am so close it hurts.... >_< I guess I need a new projection algorithm. ***Edit*** Gotta make some fixes to the positioning and then this should work. Ok now I am beating my head into a wall... everything works when its a cube, but the second I try to project into a sphere everything goes to shit... Cube: Sphere: If change the displace method to not be wrapped in a timeout, I get even more odd behavior. About to give up on this >_< and go back to texture synthesis scripts... rabble rabble rabble...
  12. Has anyone done this yet in babylon JS I see a couple of examples but none of the projects I can reference have worked out the camera height in the process or the blending between LOD layers. I am going to start trying to make a working example from the paper but would like to see how others have handled it. I have looked at and but both of these are limited to 2d measurements and because I am going to be doing this on a planetary level with Spherical displacement I need to go a step farther. Also I am wondering how I should handle the frustum calculations because in theory nothing on the backside of the planet will need to be rendered but how do I establish the "zone" is hidden on the other side of the planet?
  13. Cool, now I have to figure out why the positions of the meshs are coming up as 0,0,0... why would after I position the mesh/zones they have incorrect positions stored, but are appearing in the correct area? Ahh it was line 76... so baking the vertices sets the mesh position to 0,0,0. Is there a way to bake the vertices position, but keep the meshs position intact? <- @Deltakosh (if you have a moment)
  14. Ok now I just need to figure out why all the meshes are returning the same position.
  15. Ohh boy, things just got complicated! I gotta figure out how to get this to split down in the correct way now that its a sphere. I think I will hold off on the projection into a sphere until each quadtree leaf propagates into the correct area! Its getting close though... I need some help with my math: so for each polar face I have a normal vector so like for the "front" one it would be new BABYLON.Vector3(Math.PI*-0.5,0,0) which rotates the plane in the direction I need, but now I need to figure out how to include this in the placement of the LOD level up from the initial. I do not want to have to do any sort of logic loops to establish which direction the plane needs to move I ws hoping for some sort of tricky math. Like if my normal vector is the above one, convert it to var faceNorm = new BABYLON.Vector3(-1,0,0) and then apply that to the positioning calculation of this.children[0].mesh.position = this.mesh.position.clone().add(new BABYLON.Vector3(-this.children[0]._size*0.5,0,this.children[0]._size*0.5)); and have it be something like this.children[0].mesh.position = this.mesh.position.clone().add( (new BABYLON.Vector3(-this.children[0]._size*0.5,0,this.children[0]._size*0.5)).cross(faceNorm) ); Not sure if I was just speaking jibberish or if anyone gets what Im talking about. Also Im going to have to come up with a new calculation for projecting the quadleaves into a sphere correctly, but ill do that after I get their positioning correct. *UPDATE* I found a work around: now I need to figure out why my distance calculation is not working, it should not split the back and front poles that I have being displayed at the same time and in the same manor, so something is off on the position of the mesh or at least how I am referencing it. Fuuu this is becoming a headache.
  16. its not BJS but the math is the same. Ive used this same Math with an inertia based movement system to do a 3rd person follow cam, but you gotta understand the basics first.
  17. @jerome do you think I should displace the terrain prior to projecting it to a sphere, or apply the projection then displace the point by finding the vector angle of the point to the center of the planet and scaling it that way? Im just mulling over my options and what would be the best solution for the displacement on a planetary scale.
  18. all hail @RaananW
  19. tile-able noise ^_^, if you need help with it let me know. Its not an active project for me anymore, but I use it all the time for other projects so if there are any errors or requests let me know.
  20. yes, but there are restrictions. With an instance you can not assign a different material and do not have as much control over making it different then the original, but you can change its position and scaling which is what your interested in. A clone is a whole new unique geometry with its own draw calls.
  21. given the speed of bullets, I would use Delta method but instead of a "bullet" mesh use a really simple cylinder and a scale animation that "stretches" the cylinder in its local y or height direction. Then script up a custom shader for them to make them look more like tracers. Just a small bullet flying wont have the same effect.
  22. Terrain LOD yes Please @JohnK, @Wingnut <- You two should like this. Ill be doing the planetary version here sometime once I have a chance to sit and focus. You may have to refresh or hit run again till Das_Noise loads. *EDIT* Also I changed the title of this thread to match the method that I decided to go with for the LOD. I did not really understand CDLOD was moving the terrain not the camera, and that method does not work for what my final goal is. for a CDLOD solution @jerome above examples would work better.
  23. *UPDATE* MUAHAHAHA I have done it! var newLOD = this.level+1; was the problem line... I had var newLOD = this.level+=1; which broke all the calculations. Still a little glitchy, on the merging but I should be able to make this a working model now, it looks like it may be only able to go back one level of LOD at this time. But given the limited focus I have gotten to put on this its a start! *UPDATE* Fixed Now to do a Spherical Projection, and then implement my 3d Noise library to establish height maps.
  24. hopefully I figure out a good way to decide when to merge the meshes, and if I should dispose the larger LOD's from memory or not. I think I am going to have each zone have a prototype function to check if all of its children are out of range of the LOD layer, and if so re-enable the parent, and dispose all its children. I am having trouble with this... uhg In my mind this should work.
  25. Anyone have a better equation then this to figure out when to up the meshes LOD? Im using something like: var _d = Math.pow(minDistance, maxLOD - meshesLODLevel); if(_d > cameraDistance2Center){//split}else{//skip} but the numbers get really high really fast and are not what I want. @JohnK I like the idea of doing it as a Icosphere as well, but will prolly go with the normalized cube. This is so I can identify neighbors and make sure that I know when to use t-junctions for LOD changes. If you can figure out how to do it with an icosphere (which you might have already in your demos ill look when I can) then I will for sure just use that ^_^. *UPDATE* changed it to this: var _d = this.minDist*Math.pow(2 , this.maxLOD - zone.level); and I like it now I need to make it handle more then one level shift... if you move closer to the plane you will see it up its detail/split once. *UPDATE 2* now to handle zooming out!