• Content count

  • Joined

  • Last visited

  1. Tnx for your answer deltakosh (and great work, keep on ). Have to try to let this work on rotation matrices and not single variables in the mesh, but seems the right way
  2. Hi all, is there a way to interpolate actual bone rotation to have a "smooth" transition until it returns to rest pose? Explaining better: I can set rest pose on a bone by doing: mesh.skeleton.bones[19].setRotationMatrix(mesh.skeleton.bones[19].getRestPose().getRotationMatrix()) but obviously there's no transition between two poses by this way. How to interpolate along N steps between the two rotation matrices? Tnx
  3. Wow tnx adam, I see your PG working, but I've always the same problem using a very similar code: first click works, then terrain becomes unselectable (and I noticed that also boundingBox disappears). Quite strange, i can't explain myself. I try to upload here an example, if someone wants to give a check and report me what's wrong... http://yorke.altervista.org/webgl/Provaanim2.htm Many thanks Cheers
  4. Many tnx for your reply adam, you've always a solution for everything Following your suggestions solves the terrain creation problem, but now i've problems "interacting" with the terrain by the mouse. Let me explain: with a terrain created with CreateGroundFromHeightMap() I could by example raise terrain faces at mouseclicks using VertexBuffer: var pickInfo=window.engine.scenes[0].pick(offsetX, offsetY); var mesh = pickInfo.pickedMesh; var faceID = pickInfo.faceId; var indices = mesh.getIndices(); var vertices = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); //Raise the height of vertices in this face id vertices [indices[faceID*3]*3+1]+=1; vertices [indices[faceID*3+1]*3+1]+=1; vertices [indices[faceID*3+2]*3+1]+=1; mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, vertices,true,true); Now i've problems doing this: this code runs well only for the first time I click the terrain, from the second time the mesh seems to become "invisible" to mouse clicks (but it's still visible on screen). It seems that mesh.updateVerticesData() breaks something in the mesh structure... Any ideas?
  5. Re-up this thread: i'm having problems using function CreateGroundFromHeightMap with a buffer containing elevation data, rather than using a .png. I'm using babylon 2.5. I've not problems creating the terrain with a png: var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "perlin.png", 1000, 1000, 100, -10, 10, newScene, false); But when I try to use as elevation buffer an array containing one million (1000*1000) integers in the range 0-255: var vertexData = BABYLON.VertexData.CreateGroundFromHeightMap(1000, 1000, 100, -10, 10, perlinbuffer, 1000, 1000); vertexData.applyToMesh(ground, false); I obtain empty structures. Also if I put in firebug only the latter part BABYLON.VertexData.CreateGroundFromHeightMap(1000, 1000, 100, -10, 10, perlinbuffer, 1000, 1000) the result are empty arrays for positions[], indices[], normals[] and uvs[]. I'm I calling that function in a wrong way or with wrong parameters?
  6. Sorry I managed by myself, I was not multiplying by 3 in the positions array, so I was accessing wrong array cells arr[indices_array[faceID*3]*3+1]+=1; arr[indices_array[faceID*3+1]*3+1]+=1; arr[indices_array[faceID*3+2]*3+1]+=1; Tnx
  7. Hi all, sorry if this may seem to be a stupid question but i'm struggling about that... I'm trying to raise only y coordinates of the vertices of a mesh face when I click on it. I retrieve the face id: faceID = window.engine.scenes[0].pick(offsetX, offsetY).faceId; Then I get indices: var indices_array = mesh.getIndices(); I get vertices positions array: var arr = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); But something goes wrong when I try to increment y coordinates of the three vertices: arr[indices_array[faceID*3]+1]+=1; arr[indices_array[faceID*3+1]+1]+=1; arr[indices_array[faceID*3+2]+1]+=1; mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, arr,true,true); It seems that with those formulas i'm picking the wrong vertices from face ids... What's wrong there? Tnx, cheers
  8. Woah just what I needed Awesome adam, the latter PG made things very more clear to me with your explanation about resetting bone and re-applying rotations vs rotating by deltas on previous frame. Also I was totally missing rotations' order. Putting it at work: still many thanks, you saved me a huge waste of time!
  9. Many thanks to both of you for your good hints. I'm taking a look at the second PG posted by adam. After some tests on that PG, it seems to me that calling three times bone.rotate() on local axes and ZXY order is equivalent to setYawPitchRoll(Y,X,Z), which is also equivalent to multiplying quaternions (no order needed in this case). Am i wrong? Maybe the problems I noticed could be caused by the fact that I was calling bone.rotate() in YXZ order, I'm just verifying
  10. Hi all, I lurked some topics related to bones and their rotation but didn't find a clear solution to my problem, so I try to expose it. I'm trying to find the best way to compose rotation of bone on all 3 local axes. In my simulation, i rotate manually the bones of a human rigged model to match desired poses. Everything works fine when a bone rotates only around one local axis (x, y or z), but if I have to compose rotations and rotate, by example, a bone 90° around original x axis and 90° around original z axis, the results are not the ones I expected. E.g: bone.rotate(BABYLON.Axis.X,Math.PI/2, BABYLON.Space.LOCAL); bone.rotate(BABYLON.Axis.Z,Math.PI/2, BABYLON.Space.LOCAL); gives different results than bone.rotate(BABYLON.Axis.Z,Math.PI/2, BABYLON.Space.LOCAL); bone.rotate(BABYLON.Axis.X,Math.PI/2, BABYLON.Space.LOCAL); So what's the best way to compose rotations on 3 bone axes? Using quaternions and multiplying 3 rotation matrixes with the initial quaternion? Thus I'd like to write a sort of function rotateBone(bone, x, y, z) that rotates a bone of x degrees around its original X axis, y axis and z axis, where x, y, and z are expressed in radians [0 - 6.28] (or degrees [0 - 360])
  11. Tnx jerome, I just saw some playgrounds of yours about facets and collision and they're really impressive. So let me understand better: With: yourMesh.intersectsMesh(theParticle, true); I have the coordinates of the impact point on the mesh, that come from the particle coordinates. How can I use this coordinate to retrieve the mesh's hit facet index inside the mesh tree structure?
  12. Thanks for your kind suggestions, i'll give it a try this evening and report the results. I've another question on the same subject (collision between solid particle and mesh): are there any functions that can give you the normal of the mesh face hit by the particle? I mean: I surely know the vector that gives me the direction of the particle bullet, but no one grants me that the mesh face hit is normal to that vector (e.g. a sideswiped mesh). Many thanks yet!
  13. Hi all, my first post here. I'm learning babylon.js after having worked in three.js and I must say that I love this framework, many thanks to its creators for such a professional production. Actually I'm experiencing a little problem with collision detection between particles "fired" from a SolidParticleSystem and a mesh: I can trigger the collision between the particle and the mesh using particle.intersectsMesh(window.engine.scenes[0].meshes[15]) but intersectMesh() seems to become true when collision occurs with mesh's BoundingBox, which is way too approximate when I use a human mesh. Is there a way to calculate the exact point of collision from particle to mesh? I thought i could fire a BABYLON.Ray when intersectMesh() becomes true and retrieve the "real" intersection with mesh, is this a good approach or you think it can be done better? Are there any examples of using Babylon.Ray to retrieve exact intersection with a mesh? Thanks to all