Jump to content

Recommended Posts

Posted

This is my current cluttered script for the ocean object, but I see no trace of wavescale, wfreq or wlength in my sbx, so the ocean is always default between loads. (im a totally newbie on this so any help is appreciated smile.png )

 

How can I persist my settings in the sbx ? Say if I cange wfreq in the dialog

 

require("scripts/class")
require("scripts/math/math")
local class=CreateClass(...)
function class:InitDialog(grid)
self.super:InitDialog(grid)
group=grid:AddGroup("Ocean")
group:AddProperty("wavescale",PROPERTY_FLOAT,"0,20,2","Wave Scale")
group:AddProperty("wlength",PROPERTY_FLOAT,"0,2,2","Wave Length")
group:AddProperty("wspeed",PROPERTY_FLOAT,"0,1,2","Wave Speed")
group:AddProperty("wfreq",PROPERTY_FLOAT,"0,10,2","Wave Frequency")
group:AddProperty("bumpscale",PROPERTY_FLOAT,"0,10,2","Surface Bump")
--group:AddProperty("camerarange",PROPERTY_VEC2,"","Camera range")
--group:AddProperty("backgroundmode",PROPERTY_CHOICE,"None,Solid,Skybox","Background")
--group:AddProperty("backgroundcolor",PROPERTY_COLOR,"","Background color")
--group:AddProperty("skymaterial",PROPERTY_FILE,"Material Files (*.mat):mat","Skybox")
--group:AddProperty("fogmode",PROPERTY_BOOL,"","Distance fog")
--group:AddProperty("fogcolor",PROPERTY_COLOR,"1","Fog color")
--group:AddProperty("fogrange",PROPERTY_VEC2,"","Fog range")
--group:AddProperty("fogangle",PROPERTY_VEC2,"","Fog angle")
--group:AddProperty("gravityforce",PROPERTY_VEC3,"","Gravity")
--group:AddProperty("Saturation",PROPERTY_FLOAT,"0,2,1")
--group:AddProperty("Brightness",PROPERTY_FLOAT,"0,2,1")
--group:AddProperty("Contrast",PROPERTY_FLOAT,"0,2,1")
--group:AddProperty("cullrange",PROPERTY_VEC3,"","Cull range")
--group:Expand(1)
end
function class:CreateObject(model)
local object=self.super:CreateObject(model)
object.model = model
object.wavescale =1
object.wlength = 0.75
object.wspeed = 0.025
object.wfreq= 1
object.bumpscale = 1

function object:SetKey(key,value)
 if key=="wavescale" then
  self.wavescale = tonumber(value)
elseif key=="wlength" then
  self.wlength = tonumber(value)
elseif key=="wspeed" then
  self.wspeed = tonumber(value)
elseif key=="wfreq" then
  self.wfreq = tonumber(value)
elseif key=="bumpscale" then
  self.bumpscale = tonumber(value)
 end
end
function object:GetKey(key,value)
 if key=='wavescale' then
  return tonumber(self.wavescale)
	   elseif key=="wlength" then
  return tonumber(self.wlength)
	   elseif key=="wspeed" then
  --Notify(tonumber(self.wspeed))
  return tonumber(self.wspeed)
	   elseif key=="wfreq" then
  return tonumber(self.wfreq)
	   elseif key=="bumpscale" then
  --Notify(tonumber(self.bumpscale))
  return tonumber(self.bumpscale)
 end
end
function object:UnlockKeys(model)
 self:Refresh()
end

function object:Init()
 --self:Refresh()
end
function object:Refresh()
 if fw~=nil then
 local mat=LoadMaterial("abstract::rock1.mat")
 local shader=GetMaterialShader(mat)
 SetShaderFloat(shader,"wscale",self.wavescale)
 SetShaderFloat(shader,"wlength",self.wlength)
 SetShaderFloat(shader,"wspeed",self.wspeed)
 SetShaderFloat(shader,"wfreq",self.wfreq)
 SetShaderFloat(shader,"bumpscale",0.1)
 object:SetKey( "wavescale", self.wavescale )
 end
end

function object:needsUpdate()
 self:Refresh()
end

function object:Reset()
 self:Refresh()
end

function object:Free(model)
 self.super:Free()
end

object:Init()

end

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...