Blender game wave plug-in

Saturday , 4, July 2009 14 Comments

Blender GE wave plug-in provides ability to create and manage waves in realtime. It also supports floating objects on waves. To allow efficient calculation of waves it can use separate thread.


Wave plug-in was used in game Power of will.

Downloads

There are binaries for Blender 2.49a on Windows XP or Vista. Store it to game folder to install it.
Plug-in is published as open source with GPL. There are sources of plug-in.
Finally, there is demo with waves and floating object.

blendWave API

blendWave plug-in is specialized mesh manipulation tool providing realtime waves animation. It uses existing mesh, waves are created in object’s local XY plane. Plug-in creates circular waves. Each wave can have different parameters, these are set during wave creation and are valid until its end. When waves meet, their effects are added.

Class Waver

This class covers basic functionality of waves – calculates mesh animation for every vertex, stores waves and wave generators (emiters).
Class constructor has 3 parameters:

  • mesh – object of class KX_MeshProxy (got from game object using method getMesh());
  • materialID – material index to specify submesh used for animation, default is 0
  • useThread – separate thread for wave calculation, yes = 1, no = 0, default is 0. Doing calculation in separate thread improves performance, especially on multicore processors

Attributes:

  • emiters – list of wave emiters. This attribute can be set by a list of emiter objects and allows access to list items. Attribute doesn’t support list interface, so it’s not possible to add or delete items (it can be done by copying list to variable)

Methods:

  • update (actTime) – performs wave calculation and sets vertex positions for time provided as parameter
  • getPosNorm (posX, posY) – calculates position and normal vector for coordinates passed as parameters. Method returns two 3d vectors – the first is wave position, the second is normal vector. It can be used for simulation of floating objects
  • getForce (posX, posY) – calculates horizontal force caused by waves on specified coordinates. Method returns 2d force vector in XY plane, its value depends on wave direction, position and amplitude

Class Emiter

Objects of this class control waves creation and parameters of created waves. Emiter contains actual wave data and sets them to wave when it’s created.

Attributes:

  • position – emiter’s position relative to the center of the mesh to be waved. It’s 2D vector (without Z coordinate)
  • range – range of wave, distance from emiter how far wave reaches
  • length – length of wave from its front edge to back edge
  • speed – speed of wave from its origin, default value is 1.0
  • amplitude – wave height (applied together with wave envelope and its shape); default value is 1.0
  • frontEdge – size of front edge smoothing area. It adapts normals to provide smooth transition to wave normal vectors. Value must be in range <0.0, backEdge)
  • backEdge – size of back edge smoothing area. It adapts normals to provide smooth transition to wave normal vectors. Value must be in rangee (frontEdge, 1.0>
  • shape – defines shape of a wave. It’s a list of 2D points describing wave shape for points regularly destributes in range <0.0, 1.0). Default shape is sinusoid starting at lowest point (angle = Pi)
  • envelope – wave envelope defines height of wave as it spreads in its range. It’s a list of 2D points, where x coordinate defines distance from origin and y coordinate defines height of wave (together with amplitude)
  • repeat – bool value to specify, if creation of wave is automatically repeated

Methods:

  • createWave (pos) – creates wave with parameters set to emiter and distance from emiter center defined in parameter pos

14 thoughts on “ : Blender game wave plug-in”
  • mohd.itqan says:

    excellent thats exactly what i was looking for.
    hats off to the guy who developed it.

  • This is a good plugin. I have used it to provide waves for my buoyancy script.

  • amcam says:

    I can’t seem to get it to work. 2,49b

  • amcam says:

    Working well. Looks great.

  • amcam says:

    Is there a 2.5x version ?

    • admin says:

      Hi amcam, I have to find some free time to dive into 2.5 internals and find a way to make this plugin work. But I don’t think it’ll be soon. The sources are available so anybody can take a chance.

  • amcam says:

    Hi,
    I’d like to add an animated texture to show some surface waves, to make it look more realistic. I’ve built an 11 x 11 image to use as an animated texture (using Real Time Properties in the UV Editor). I can get your waves to work and I can get the animated texture to work separately, but I can’t get both working together. Is this even possible ?
    Can you help please ?

  • admin says:

    Hi amcam,
    I’ve tested it with no problems. I can upload video showing waves with animated texture.

  • amcam says:

    Thanks. I’d love to see it. I assume you’re using multitexture rather than GLSL ? As soon as I select “tile” under texture face, it stops the ani texture working with your waves.

  • admin says:

    Hi,
    I’ve added video with animated texture at the end of this article. I used GLSL materials in it, multitexture materials don’t work.

  • amcam says:

    Hi, I think you might have posted the wrong video. The latter looks the same as the first.

    I was trying to avoid GLSL to allow playing on a wider range of machines. GLSL worked OK for me too … the problem was just multitexture.

    There’s another 2.49 script by Martinsh on BlenderArtists that does displacement waves, foam plus an animated texture. Looks great but it’s GLSL also.

    I assume multitexture is limited to displacement waves and a fixed texture ?

  • admin says:

    Hi,
    you’re right. Animated texture just doesn’t work in multitexture mode.

  • amcam says:

    My mistake .. animated textures DO work in “texture face materials” mode (but not multitexture). They also work of course in GLSL.

    The approach for text face is described here:
    http://www.tutorialsforblender3d.com/GameDoc/Texture-Animate/Animate_Texture_Step_4.html

    This works fine on a flat plane.

    However, when applied to your displacement waves using texture face mode, it stops the waves working.

    However, I found that if tiling is not used, and the texture is extended across the whole image, it does work, although the texture is quite blurred.

    Any idea what is going on here ?

  • admin says:

    Hi, it works for me also in texture face materials mode. It’s necessary to switch Light on for all faces of mesh in Texture Face panel.

  • Please give us your valuable comment

    Your email address will not be published. Required fields are marked *