Jump to content

Waterplane hide/unhide


Michael Betke
 Share

Recommended Posts

I'm looking for a script which hides/unhides the waterplane. I had it but overwrote it by accident after and sync... ;)

It added just a hide/unhide checkbox to the properties so I'm able to edit the underwater zone in a nice way.

 

Maybe someone can resent it to me or tell me what I have to add. :)

Pure3d Visualizations Germany - digital essences

AAA 3D Model Shop specialized on nature and environments

Link to comment
Share on other sites

I personally never have seen a waterplane script posted here that has this feature, but this is how I would do it.

 

require("scripts/class")

local class=CreateClass(...)

function class:InitDialog(grid)
self.super:InitDialog(grid)
local group=grid:AddGroup("Water")
group:AddProperty("submersioncolor",PROPERTY_COLOR,"","Submersion Color")
group:AddProperty("Softness",PROPERTY_FLOAT,"0,50")
group:AddProperty("Visibility",PROPERTY_VEC2)
group:AddProperty("Amplitude",PROPERTY_FLOAT,"0,16")
group:AddProperty("WaveSpeed",PROPERTY_FLOAT,"0,10","Wave speed")
group:AddProperty("ShowWater", PROPERTY_BOOL)
group:Expand(1)	
end

function class:CreateObject(model)
local object=self.super:CreateObject(model)
object.height=model.mat.ty

object.submersioncolor=Vec4(0.5,0.5,0.5,1.0)
object.softness=1
object.visibility=Vec2(0,20)
object.amplitude=1
object.wavespeed=1

object.model:SetKey("submersioncolor","128,128,128,255")
object.model:SetKey("softness","1.0")
object.model:SetKey("visibility","0,20")
object.model:SetKey("amplitude","1.0")
object.model:SetKey("wavespeed","1.0")
object.model:SetKey("ShowWater","1")

function object:Refresh()
	if fw~=nil then
		fw.renderer:SetWater(self.showwater)
		fw.renderer:SetWaterHeight(self.height)
		fw.renderer:SetWaterColor(self.model.color,self.submersioncolor)
		fw.renderer:SetWaterSoftness(self.softness)
		fw.renderer:SetWaterVisibility(self.visibility.x,self.visibility.y)
		fw.renderer:SetWaterAmplitude(self.amplitude)	
		fw.renderer:SetWaterWaveSpeed(self.wavespeed)		
	end
end

function object:UpdateMatrix()
	self.height=self.model.mat.ty
	self:Refresh()
end

function object:UnlockKeys(model)
	object:Refresh()
end

function object:SetKey(key,value)
	if key=="softness" then
		self.softness=tonumber(value)
	elseif key=="submersioncolor" then
		self.submersioncolor=StringToColor(value)
	elseif key=="visibility" then
		self.visibility=StringToVec2(value)
	elseif key=="wavespeed" then
		self.wavespeed=tonumber(value)
	elseif key=="showwater" then
		self.showwater=tonumber(value)
	elseif key=="amplitude" then
		self.amplitude=tonumber(value)
	elseif key=="position" then
		local t
		t=StringToVec3(value)
		self.height=t.y
		return self.super:SetKey(key,value)
	else
		return self.super:SetKey(key,value)
	end
	return 1
end

function object:Free()
	local model,object
	self.class:RestoreDefaults()
	for model,object in pairs(self.class.instances) do
		if object~=self then
			object:Refresh()
			break
		end
	end
	self.super:Free()
end

object:Refresh()
end

function class:RestoreDefaults()
if fw~=nil then
	fw.renderer:SetWater(0)
	fw.renderer:SetWaterHeight(0.0)
	fw.renderer:SetWaterColor(Vec4(1,1,1,1),Vec4(0.5,0.5,0.5,1.0))
	fw.renderer:SetWaterSoftness(1.0)
	fw.renderer:SetWaterVisibility(0,50)
	fw.renderer:SetWaterAmplitude(1.0)
	fw.renderer:SetWaterWaveSpeed(1.0)
end
if fw.renderer.waterpatch~=nil then
	fw.renderer.waterpatch:SetParent(nil,1)
end	
end

function class:Free()
self:RestoreDefaults()
self.super:Free()
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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.

 Share

×
×
  • Create New...