TomaszFurca Posted October 2, 2017 Share Posted October 2, 2017 Hi, I try to run animation of skeleton on my SPS, but i don't work. Simple code: let SPS = new BABYLON.SolidParticleSystem("SPS", scene); SPS.addShape(meshP, 50); let mesh = SPS.buildMesh(); mesh.material = meshP.material; mesh.skeleton = meshP.skeleton.clone("clonedSkeleton2"); SPS.afterUpdateParticles = function(start, stop, update) { mesh.skeleton.beginAnimation('Skill01', true); } SPS.initParticles(); SPS.setParticles(); Thanks for help Tom Quote Link to comment Share on other sites More sharing options...
Raggar Posted October 2, 2017 Share Posted October 2, 2017 I have limited knowledge of SPS(unfortunately), but could it be, that that piece of code gets called every frame? If that's the case, you won't see any difference as the animation gets restarted every ~16ms. Try using something like a boolean. isSPSPlaying = false; SPS.afterUpdateParticles = function(start, stop, update) { if(!isSPSPlaying){ mesh.skeleton.beginAnimation('Skill01', true); isSPSPlaying = true; } } I'm not sure of how you want your logic to work. But I do believe this could be the issue. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 2, 2017 Share Posted October 2, 2017 @jerome who is the king of SPS. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 3, 2017 Share Posted October 3, 2017 The SPS is a big updatable mesh whose the vertex positions are all updated each call to setParticles(). That means its whole geometry is supposed to change each frame with no other global coherence. Therefore it doesn't support the skeleton by default. Quote Link to comment Share on other sites More sharing options...
TomaszFurca Posted October 3, 2017 Author Share Posted October 3, 2017 So, using SPS i cannot run skeleton animation, because all meshes are one big mesh. Today i try to make my animation using another method. I will write new post in this topic. Thanks for help. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 3, 2017 Share Posted October 3, 2017 Actually, the SPS is a big mesh... nothing would prevent technically to use a skeleton. But, as all this mesh vertices are updated one by one by setParticles(), there's no guarantee that the skeleton coherence and organization is kept along (for sure, it isn't). Maybe managing by the hand each parts would work, no idea (except that this would be really complex to implement). Quote Link to comment Share on other sites More sharing options...
TomaszFurca Posted October 3, 2017 Author Share Posted October 3, 2017 I create my field of grain using instances, but perfomance would be better using SPS, but I cannot do that using SPS. let grain = self.game.factories['nature_grain'].createInstance('Grain', true); grain.scaling = new BABYLON.Vector3(1.3,1.3,1.3); grain.position = new BABYLON.Vector3(22.32,0,-103.46); grain.skeleton.beginAnimation('ArmatureAction', true); for (let i = 0; i < 1000; i++) { let offsetX = (Math.random() - 0.5) * 60; let offsetZ = (Math.random() - 0.5) * 10; let instance = grain.createInstance("instance" + i); instance.parent = grain; instance.skeleton = grain.skeleton; instance.position.x = offsetX; instance.position.z = offsetZ; } Effect like this: https://streamable.com/wxygk Quote Link to comment Share on other sites More sharing options...
Sebavan Posted October 3, 2017 Share Posted October 3, 2017 w00t, it looks really cool Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.