Community Forum

Min Clip Distance

Forum Overview >> Scripting

CategoryScripting
Created10.05.2012 12:28


Milan Lekše (Unknown) 10.05.2012 12:33
I would like to use Min Clip Distance, but works only in Giants editor - not working in game, what to do, or how to enable it in game...

Or help me with a script to be called onCreate, and when player distance is less then Min Clip Distance to be object visibility=false

Thanks to all...


Christian Ammann - GIANTS Software 11.05.2012 00:07
Hi Milan,

Min Clip is not supported in LS11. You have to wait for LS13.

Best,
Chris

Milan Lekše (Unknown) 12.05.2012 18:59
Christian I could not wait so I write this mod-script to be called width extraSourceFiles - please check it for some faster or easier way to determinate some variables

If some one need it copy from bellow

--------------------------------------------------------------------------------------------------------------------------------
-- MinClipDistances
-- Script for MinClipDistance
--
-- Autor Milan Lekše
-- Last Edit 12/05/2012
--
-- Usage:
-- In editor select object You want to be hiden when you are near it, an add user attribute:
-- name="MinClipDistance" type="float" value="175"
-- name="onCreate" type="scriptCallback" value="MinClipDistance.OnCreate"
-- float value is value in meters when object hide
--

MinClipDistance = {}

local MinClipDistance_mt = Class(MinClipDistance)

function MinClipDistance:onCreate(id)
table.insert(g_currentMission.updateables, MinClipDistance:new(id))
end

function MinClipDistance:new(id, customMt)

local instance = {}
if customMt ~= nil then
setmetatable(instance, customMt)
else
setmetatable(instance, MinClipDistance_mt)
end

instance.objectId = id

instance.posX, instance.posY, instance.posZ = getWorldTranslation(instance.objectId)
instance.MinClipDistance =Utils.getNoNil(getUserAttribute(instance.objectId, "MinClipDistance"), 175.0) -- TODO read from map if is possible not from user atributes

return instance
end

function MinClipDistance:update(dt)
local ax,ay,az = nil, nil, nil
local bx,by,bz = nil, nil, nil
local distance = 10000

-- TODO find better way to determinate player position on foot or in wehicle
-- in vehicle
if g_currentMission.controlledVehicle then
ax,ay,az = getWorldTranslation(g_currentMission.controlledVehicle.rootNode)
end
-- on foot
if g_currentMission.player.rootNode and (ax == nil or ay == nil or az == nil) then
ax,ay,az = getWorldTranslation(g_currentMission.player.rootNode)
end

bx,by,bz = self.posX, self.posY, self.posZ

if ax ~= nil and ay ~= nil and az ~= nil and bx ~= nil and by ~= nil and bz ~= nil then
distance = Utils.vector2Length(bx-ax, bz-az)
if distance < self.MinClipDistance then
setVisibility(self.objectId, false)
else
setVisibility(self.objectId, true)
end
end
end


function MinClipDistance:deleteMap()
end

function MinClipDistance:mouseEvent(posX, posY, isDown, isUp, button)
end

function MinClipDistance:keyEvent(unicode, sym, modifier, isDown)
end

function MinClipDistance:delete()
end

function MinClipDistance:draw()
end

OnCreate = MinClipDistance.onCreate
--------------------------------------------------------------------------------------------------------------------------------



Note: Log in to post. Create a new account here.