Jump to content

How to make a wave animation on a plane


elkyu
 Share

Recommended Posts

Hi, 
I have a plane composed of faces (triangles).
 
I would like to create an animation like this one :
 
 
For the moment, I can make that with babylon :
 
 
(hide the editor to see in full screen, it's better)
 
I tried to adapt the seenjs's code for my Babylon animation but it doesn't work like i would like.
 
Can you help me to realize this animation ?
Link to comment
Share on other sites

http://www.html5gamedevs.com/topic/13258-animate-or-morph-mesh-dynamically/  This should work.  :)

I played with AltReality's 1AVEYO series...  with solid and wire frame grounds converted to flat shaded.  Strange, but fun!

http://playground.babylonjs.com/#1AVEYO#18

Update:  I think this is a memory leaker... at least in my FF 39.

Link to comment
Share on other sites

Hey again!

 

It seems to me you have two issues with your PG:

- your camera is... weird. Why an ortho camera? The camera in the example you provided is certainly not an orthographic one. Also it seems your camera's rotation center is way off the plane.

- you will need some sort of random noise to achieve a similar effect (random wave amplitude varying over time). BJS does not provide such utility, so you'll have to borrow from somewhere else or code it yourself.

 

Simplex and Perlin noise are the most common noise algorithms. Many JS libraries exist for these. I personally used this one with much success: http://pastebin.com/vmxkDDgF

Link to comment
Share on other sites

A thought from a non-programmer. Could you use a shader to accomplish this?

 

Ground distorting shader

 

From a few minutes tinkering, the crucial part that influences the geometry with time is line 19 of the vertex shader.

 

Could substituting the appropriate math at line 19 create the kind of effect you want?

 

cheers, gryff :)

Link to comment
Share on other sites

- your camera is... weird. Why an ortho camera? The camera in the example you provided is certainly not an orthographic one. Also it seems your camera's rotation center is way off the plane.

 

I use an ortho camera because I have some other mesh behind and i need that there is no gap between these mesh.

 

 

Wow, thanks for your help, i will look at all of that, and try to do my animation. And great job adam !

 

I'll keep you informed of my progress

Link to comment
Share on other sites

 
No my problem is not to get a fix camera.

My problem is that behind my mesh, i put an image. I create a "hole" in my mesh and we can see the image through this hole.

The problem is that with the 3D, a standard camera will create a gap between the mesh and the image. We can settle that with an ortho camera (another way ?), tell me if i'm wrong but ..
Like this  :

37cc596e56.png

But when I put the camera in ortho, the animation is almost not visible.
I want this animation in full screen (scene) and without gap between the mesh and what is behind : #19 #CG2MJ#19
it looks like what I want

Another problem, to put well my image in the hole's center (I put the image in the same time as the "hole" creation, not before), I get all the vertex of the faces which composed the "hole", I search the extremity of each side, and I calculate the middle with that. But I thinks that there is a better solution to do that, no ?
Link to comment
Share on other sites

You can use Rendering Groups to make sure that one mesh is displayed before the other, no matter what their relative positions are: http://doc.babylonjs.com/page.php?p=25100

 

This way, you won't need to put the image in the hole far away from the ondulating plane. Maybe that will solve your gaps problem?

 

Your method for finding the center of a face looks good to me. You can even use this to find the center of several faces, for example if you want to remove a full square instead of just a triangle.

Link to comment
Share on other sites

A sprite will be rendered on top of everything else, so not really. I'd say a simple plane with the texture on!

 

EDIT: actually you can also force a sprite to be rendered behind your plane with the renderingGroup property, so it's up to you!

Link to comment
Share on other sites

I'm not sure to understand about the renderingGroup.

 

Does the defined value to the renderingGroup of a mesh will define which one we'll see above the other, where as both have the same Y position ?

 

Or it will define the apparition order of the meshs ?

Link to comment
Share on other sites

But my mesh (with the animation) hasn't a hole at the beginning of my animation. I create the "hole" after a few seconds and i put the image in the same time. So in this case I think the rendering group is useless, no ?  

 

Several "hole" will be create and for each hole there is another image, I can't put the images at the beginning, they will be superimposed on and if there are many, this may slow the animation.

Link to comment
Share on other sites

oh, I tried with picture.width & picture.height but the result is very weird 

 

But the image still stay a square with this method. Is it possible to apply a precise size in width and height ?

 

maybe there is another way than a sprite to put the image in the scene, which is more practical for set a custom size ?

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...