Jump to content

Recommended Posts

Posted

 

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

Battelship2.JPG

Posted


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

0FC1E65A3AE4C2EB3BFD6204573E94B0B2A03058

battleship3.JPG

Posted

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);

 

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

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.

×
×
  • Create New...