JackFalcon

Physics of a Fish.

Recommended Posts

Blend meshs and or a rig with animations.

I would do blend meshes, and have like a sin or cos algorithm that is based off of fish speed and make it bounce between 3 mesh variants: idle, maxleft, maxright.

Sorry I'm at work and this is rushed hope that makes since

 

Share this post


Link to post
Share on other sites

UPDATE:

image.png.d7a9a57fcc8a62c4646ada5734e807a9.png

Ready to wiggle....

            var createAFish = function () {
                var aBox = BABYLON.Mesh.CreateBox("box", 1, scene);
                aBox.position = new BABYLON.Vector3(0,1,1);
                var aSphere = BABYLON.MeshBuilder.CreateSphere('', {diameter: 1}, scene);
                aSphere.position = new BABYLON.Vector3(0,1,0);
                var aRect = BABYLON.Mesh.CreateBox("box", 1, scene);
                aRect.scaling = new BABYLON.Vector3(0.2,0.6, 1);
                aRect.position = new BABYLON.Vector3(0,1,-1);
            }

Will it work? We'll see!

 

Share this post


Link to post
Share on other sites
13 minutes ago, aFalcon said:

Yes - collision detection.

@BitOfGold oh really? Hmmm... vertex shader, didn't think of that. Interesting...

 @Pryme8 -> really gr8!

Double-likes (tomorrow)... and how did you do that? <looking>

Thank you for intro to 

_blend
 
Wow!

Keep in mind that is really rudimentary and can be done in a way better manor, but that can serve as an example to make something cool.

If you really want to make it sing, a animation blending algorithm needs to be implemented which will smooth all this up.

Share this post


Link to post
Share on other sites

^_^, I was thinking about this the other day... and I think @BitOfGold was on the right path wanting to do it with a shader.

I was thinking you could do a sin algo to displace the vertices from a point on the fish (behind the head) and use a texture weightmap to control the intensity in locations.

Share this post


Link to post
Share on other sites

Hey yeah, you nailed it @Pryme8, here's low-fidelity solution (for now, until morphin-power-ranger skills gained...):

                scene.registerBeforeRender(function() {
                        wiggleSpeed1+=0.18;
                        body.position.x += (Math.sin(wiggleSpeed1)*0.025);
                        head.lookAt(merphbugbody.position)
                        tail.lookAt(merphbugbody.position)
                    }
                });

https://www.babylonjs-playground.com/#PHMP7X

Oh, but sine displacement, cool... yeah?

Share this post


Link to post
Share on other sites

@aFalcon

http://pryme8.github.io/fish/

All this needs is the weight map, and then to shift the sin oscillation down the fish instead of keeping it in place. 
@BitOfGold <- ALL GPU just for you buddy <3

And there are definitively some fixes that need to happen because as this is it "stretches" the fish, so the displacement side to side needs to have a displacement forward as well to make it look like the fish is swishing and not just magically making new skin.

A fade of the intensity of the sin wave from the head is needed as well.


*edit* 
Added the fade from the head, and made some adjustments.  Now I need to make the sin wave "move" down the fish instead of just oscillate.

@jerome or @NasimiAsl how would I make the sin do that?  Im kinda drawing a blank, I was thinking maybe just adding a offset to the position (using the same time algo) that is then moded into range?

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.