Results 1 to 5 of 5

Thread: water waves

  1. #1

    water waves

    using a plane 50x50 the waves are more precise . using the waves TBGL code by Petr as a base http://www.thinbasic.com/community/s...ow-to-get-this and the equation
    YY = 30*(Sin(gFrameTime/600+(x^2+z^2)/10))/(x^2 + z^2 + 1.0)
    we got strange interesting water waves.
    water.PNG

    attached the files: plane.M15, plane.obj, plane.mtl, water_waves.tbasic
    Attached Files Attached Files
    Last edited by primo; 15-03-2016 at 11:35.

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Superhypnotic! Thanks for sharing!

    The m15 mesh could be also created at run-time, this way:
    Function BuildPlane_AsM15(modelSlot As Long, width As Long, height As Long, detailStep As Single)   
      Long vertexCount = (width / detailStep + 1) * (height / detailStep + 1) * 4
      TBGL_m15InitModelBuffers modelSlot, vertexCount       
      TBGL_m15SetModelVertexcount(modelSlot, vertexCount)
              
      Single x, z
      Long index
      
      For x = -width / 2 To width / 2 Step detailStep
        For z = -height / 2 To height / 2 Step detailStep
          Incr index
          TBGL_m15SetVertexXYZ(modelSlot, index, x, 0, z)
                  
          Incr index
          TBGL_m15SetVertexXYZ(modelSlot, index, x+detailStep, 0, z)
                  
          Incr index
          TBGL_m15SetVertexXYZ(modelSlot, index, x+detailStep, 0, z+detailStep)
                  
          Incr index
          TBGL_m15SetVertexXYZ(modelSlot, index, x, 0, z+detailStep)        
          TBGL_m15SetVertexPStop(modelSlot, index, 1)
        Next
      Next  
      TBGL_m15SetVertexRGB(modelSlot, 1, index, 255, 255, 255)
    End Function
    
    So, instead of TBGL_m15LoadModel, you just call, for example:
    BuildPlane_AsM15(1, 20, 20, 0.5)
    

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Thanks for the example primo!
    Very nice also to change some parameter in formula to see wave behave.
    Maybe some UI with slider to change formula params in real time.

    Looking at .M15 files and their size ... maybe adding a native TBGL zLib functionality to open compressed files can save a lot of space.
    TBGL_m15LoadModel maybe can accept a ZIP file from which load compressed files.
    Or maybe accept M15 data from string buffer so user can load it from ZIP files using zLib functions.
    Just ideas
    Last edited by ErosOlmi; 16-03-2016 at 04:25.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    You are right Eros,

    m15 needs some care -it is a format I designed on high school .

    I am currently in process of refactoring the code in order to:
    - be able to dynamically create m15 models on the fly (without the need for tbgl_m15InitModelBuffers)
    - manipulate them in dotted way, like:
    Dim model as m15Model
    model.Vertex(1).Position.Set(1, 2, 3)
    
    - allow the loading from memory (with the possible ZIP compression)


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    thanks Eros , thanks Petr very much. i never saw a mesh made from rectangles, usually we see meshes from triangles. but i see you have used TBGL_m15SetVertexPStop to stop the polygon construction to a square. it seems this mesh produces a clean waves while the triangular mesh produces some chaotic waves. i have read before occasionally about these types of meshes but never saw one and i don't know yet if it can be recognized by the usual models viewers, in Other engine there is meshface(v1,v2,v3) but we can't add v4
    thanks again for this jewel.
    Last edited by primo; 16-03-2016 at 12:32.

Similar Threads

  1. computer water cooling
    By zak in forum Shout Box Area
    Replies: 0
    Last Post: 16-01-2012, 18:02
  2. The Moon is water free?
    By LanceGary in forum Shout Box Area
    Replies: 2
    Last Post: 09-08-2010, 10:18
  3. no water effect ;)
    By Lionheart008 in forum TBGL General
    Replies: 11
    Last Post: 09-05-2009, 09:54
  4. How to animate a water texture?
    By Michael Hartlef in forum TBGL module by Petr Schreiber
    Replies: 8
    Last Post: 24-10-2008, 19:48

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •