Jump to content

santarcade

Members
  • Content Count

    23
  • Joined

  • Last visited

About santarcade

  • Rank
    Member

Contact Methods

  • Twitter
    santarcade

Recent Profile Visitors

1026 profile views
  1. Hey @leechii, here it is a sample I used on a ribbon, creating a linear gradient via UVs: http://www.babylonjs-playground.com/#1YHPOU#7 It can take an input color or sample the passed texture (for that uncomment lines 67 and 68). Applied to you shape it looks like this: http://www.babylonjs-playground.com/#1YHPOU#9 My goal was to make a fadeout near the head and tail of my shape, probably you will want to adapt the code to blend between two colors. Best, santarcade
  2. I didn't know too about update-able vertex color and uvs. Lovely discovery that should be added in the docs and tutorials maybe. To achieve something similar, I did write a custom shader! Thank you!
  3. Ok, I should have fixed the things pointed out by @Deltakosh. Now the engine is properly deterministic, same scene with same inputs evolves in the same manner over different browsers and platform. I tested on MacOS, Linux, Windows, iOS, Android on different platforms and browsers, and I only got minor differences caused by floating point rounding (past the 11th decimal position). A truncation of floating point values at a good decimal position should be enough to guarantee a good screening of this problem: in my case this will be directly workaround by periodical re-sync of game state.
  4. Ok, I made a PR for this. To explain the change briefly, this new feature can be enabled with: this.engine = new BABYLON.Engine(theCanvas, true, { deterministicLockstep: true, lockstepMaxSteps: 4 }); This way, the scene will render quantizing physics and animation steps by discrete chunks of the timeStep amount, as set in the physics engine. For example: let physEngine = new BABYLON.CannonJSPlugin(false); newScene.enablePhysics(this.gravity, physEngine); physEngine.setTimeStep(1/60); With the code above, the engine will run discrete steps at 60Hz (0.01666667s) and, in case
  5. Hello, the game I'm currently working on will be multi-player and needs to show replays. Instead of snapshotting complete game states, I would like to have a deterministic engine, so supplying the same initial state and the same inputs should result in same state evolutions over time. To achieve this, I need physics and animations to be frame-rate independent and to be in sync with each other. The idea is quantize the state execution time, by updating the game state at a fixed frequency, keeping an accumulator so to carry over exceeding time to the next frame update (the code would be
  6. Hi guys, I tested even OimoJS and my conclusion is that there is definitively something wrong with physics in version 2.4. Check this demo up: http://www.babylonjs-playground.com/#2B84TV#5 The timeStep in Oimo is inconsistent: so fast to the point that after a few bounces on the plane, the sphere will pass through it. I tried to check the code, but could not find a reason for this: any idea? The only consistent version seems to be the first commented line: var physEngine = new BABYLON.CannonJSPlugin(true); Joez
  7. I've been playing even with setting different timeSteps: if useDeltaForWorldStep is true, after a while it seems the world simulation losses sync (I guess the accumulator jumps in, feeling the need to recover steps). So far, I have been able to achieve a stable and consistent results changing the line with this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta*(this._fixedTimeStep/(1/60)) : 0, 3); Does it make sense to you? Best, Joez
  8. Hi RaananW, you are right: the speed increase factor is not directly 1 thousand. I wrote some trajectory prediction code to estimate when a body launched with given velocity will hit the ground. If I keep just delta, the collision will be matching the prediction. If I keep delta*1000, the body will hit the ground way earlier than expected (physics is altered). This is indeed seen in the playground: same forces on same bodies end up in two different behaviors. What do you think? Thank you, Joez
  9. Hi Deltakosh, I double checked: OimoJSPlugin does not have the useDeltaForWorldStep parameter. I created a small playground that shows the issue: http://www.babylonjs-playground.com/#2B84TV#4 I dug a little in the code, and in addition, I think that this accumulator done with time delta, could suffer on another bug when setting a different timeStep via setTimeStep(timeStep). Best, Joez
  10. Hi guys, I upgraded to BabylonJS 2.4 and I think I've found a bug on the CannonJS plugin. It's line 32 of babylon.cannonJSPlugin.ts: this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta * 1000 : 0, 3); If I leave the default _useDeltaForWorldStep set to true, the game runs 1000 faster than normal, if I set it to false it works fine. By removing the delta*1000 works as expected, resulting in this patch: this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3); I can't do a PR at the moment, so I'm writing here... but I
  11. Ok, I will try to extract an example as soon as I can. Thanks so far!
  12. Deltakosh! Thank you very much for the reply: this is exactly what I ended up coding, a skeleton visualizer and a bone matrix updater. Turned out, my calculations were correct the problem I experienced instead was related to how I override bone matrixes while an animation is playing: basically when calculating how to dynamically adjust the rotation of a bone, I was using theBone.getWorldMatrix() but the resulting matrix was not up-to-date. So my bone adjustment looked wrong, while it was just the matrix that was out-dated: so a small function such as this one https://github.com/BabylonJS
  13. Hi guys, after beating my head against this for a while, I came to the conclusion that I need a break and possibly some support. I want to calculate the position of theObject mesh in the local space of theBone which is attached to theMesh. The code I write for it is: // combine the bone World Matrix with the transform of the mesh var boneInverse = theBone.getWorldMatrix().multiply(theMesh.getWorldMatrix()); boneInverse.invert(); // calculate object position relative to the bone joint console.log('object world position: '+objectMesh.position); var relPos = BABYLON.Vector3.T
  14. Hi guys, I am experiencing an issue in doing something that I thought to be pretty easy: I need the equivalent of lookAt for bones, since I plan to move the eyes of a rigged character via bones. So I created a test rig in blender and tried to workout the code to properly rotate the bones to lookAt a given target and… I failed. I attached a screenshot showing the blend file in Blender. Babylon file: https://www.dropbox.com/s/fu5fgl5zckqh5dh/testeyes.babylon?dl=1 Blend file: https://www.dropbox.com/s/ybo93nll7na7zyj/testeye.blend?dl=1 Playground demo: http://www.babylonjs-playground.com/#1
×
×
  • Create New...