Jump to content
metaldc4life

Adding GodRays

Recommended Posts

Hi,

I was needing help with this script for godrays please..

 

camera->SetKeyValue("godray_pos", std::string(Vec3(-x, -y, -z)));

 

I get the error below:

 

 

"C:/Users/Gaming Rig/Documents/Leadwerks/Projects/MyGame/scripts/godrays.lua" : 1 : '=' expected near '-'

Share this post


Link to post

That is C++ code, you are using Lua.

 

Changing -> to : fixes your initial error, but you'll get another error once it gets to std::string

 

I haven't seen the god ray script but I think this is what you need:

camera:SetKeyValue("godray_pos", Vec3(-x, -y, -z));

Share this post


Link to post

well, I tried it and I got this:

 

"C:/Users/Gaming Rig/Documents/Leadwerks/Projects/MyGame/scripts/godrays.lua" : 1 : attempt to index global 'camera' (a nil value)

Share this post


Link to post

I think I'm starting to understand a little now and if my theory is correct, the reference would be in the player script and I would use this line somehow:

self.camera = self.Camera

 

but how would I implement it into this script properly?

 

camera:SetKeyValue("godray_pos", Vec3(-x, -y, -z));

Share this post


Link to post

You can attach this to your directional light as a script to get the correct calculations :

 

function Script:Start()

 

self.world=World:GetCurrent()

if self.camera==nil then

for i=0,self.world:CountEntities()-1 do

if self.world:GetEntity(i):GetClass()==Object.CameraClass then

self.camera=self.world:GetEntity(i)

tolua.cast(self.camera,"Camera")

System:Print(self.world:GetEntity(i):GetClassName())

break

end

end

end

 

if self.camera then

local light=self.entity

self.dir = Vec3(light.mat.k.x,light.mat.k.y,light.mat.k.z):Normalize()

--sun raw position is then:

self.sunrawpos=Vec3(-self.dir.x,-self.dir.y,-self.dir.z)

self.camera:SetKeyValue("godray_pos",self.sunrawpos:ToString())

end

end

Share this post


Link to post

got it working!

thanks!

do you happen to know how to adjust the x, y axis on the mouse because I have this water script that I downloaded from klepto that I attached to the player but it won't let me look up or down.. it prevents me from looking up or down...

Thanks again!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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