Santiago3D Posted August 14, 2017 Share Posted August 14, 2017 Hello, I am learning Leadwerks, and for that I am doing a little game of a boat. All my programming experience is with Blitz3D, and now I decided to migrate my projects to Leadwerks. I could already make the boat sail, rotate the turret, raise the cannon and shoot cubes. Now I would like to know how I can modify my water MESH, I want to move its vertices to generate a wave effect. Is there any example of a SCRIPT to control the position of the vertices of a mesh? Sorry for the way I write, I'm using google translate. Regards! Santiago Quote Link to comment Share on other sites More sharing options...
tjheldna Posted August 15, 2017 Share Posted August 15, 2017 Shadmar did a leaf/foliage shader which would do what you require I think, with his permission i'll post it. 1 Quote Link to comment Share on other sites More sharing options...
Santiago3D Posted August 15, 2017 Author Share Posted August 15, 2017 Hi, thanks, achieve using the Help move the vertices using a script. I move the vertices, I had to reduce the amount of vertices since vertex moving vertex seems to be a slow process. Q1. If I did this using a shader would it be faster? Q2. Something I must be doing wrong, since I get an error the minute I run the application, surely I am accumulating memory somewhere and I do not know where. I share the Script on the water mesh to see if they help me find what is wrong. function Script:Start() surface = self.entity:GetSurface(0) end Script.wave_vel = .1 --float "Wave Speed" function Script:UpdateWorld() for v=0, surface:CountVertices()-1 do local position = surface:GetVertexPosition(v) local color = surface:GetVertexColor(v) --float position.z = Math:Sin((position.x*position.y)+Time:GetCurrent()*self.wave_vel) color.r = 100-position.z*.2 color.g = 110-position.z*.2 color.b = 120-position.z*.2 surface:SetVertexPosition(v,position) surface:SetVertexColor(v,color) end end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 15, 2017 Share Posted August 15, 2017 Doing this per update cycle is rather expensive. This is where shaders come in to play. Quote Link to comment Share on other sites More sharing options...
shadmar Posted August 18, 2017 Share Posted August 18, 2017 You can easily just mod the vertex shader to this with no overhead. .z Something like : modelvertexposition.z = sin((modelvertexposition.x*modelvertexposition.y)+currenttime*.001); Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Santiago3D Posted August 25, 2017 Author Share Posted August 25, 2017 Thanks Shadmar, , I'll try it! 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.