Game Development Community

Moving sun around

by Ivan Mandzhukov · in Technical Issues · 09/21/2007 (2:43 am) · 11 replies

I've tried to change the "azimuth" parametar of the sun object via slider. But it doesn't work. the code fothe slider is :

function slider3()
{sun1.azimuth = slider3.value;
}

any ideas how to make it work? In fact when i change the value from the slider and press F11 to get in the workd editor inspector, when i press on the sun1 object in the tree the changes apply. but i want it to work from the GUI i have made(where the slider3 is situated). Please help!

#1
09/21/2007 (5:45 am)
@Metodi - Your function is actually right on, but there is a function called from the WorldEditor which applies the changes. This function occurs after you hit apply or switch the focus to another field.

To get this functionality, you'll need to call the "apply" function directly on the sun object in your slider3() method.
#2
09/21/2007 (6:08 am)
Appending to my previous post, I admit that I had to make one minor change in the source code, but I can't talk about it in a public forum or provide the code to a non-SDK owner.

There is probably another clever way to make this "apply" function fire, but I went for the quick and easy solution.
#3
09/21/2007 (6:52 am)
Ok, Michael, no problem, but i just wanted to tell you that i have tried to call the function behind the "apply" button on the right place in my function , but still no result.I think there is something that i miss. correct me if i am wrong but it seems that the problem is big.
#4
09/21/2007 (7:09 am)
What is the exact name of the function you called?
#5
09/21/2007 (7:31 am)
EWorldEditor.isDirty = true;inspector.setName(InspectorNameEdit.getValue());EWorldEditor.makeFirstResponder(true);

this is what apply button does from the inspector editor.
I have tried this :

function slider3()
{sun1.azimuth = slider3.value;
EWorldEditor.isDirty = true;inspector.setName(InspectorNameEdit.getValue());EWorldEditor.makeFirstResponder(true);
}

but it didn't work.
#6
09/21/2007 (2:12 pm)
Nice attempt, but this is not the function that needs to be called. I'll look into another possible solution, but so far the only way I know how to do this is in the engine. What I have done is exposed the engine function to script
#7
09/22/2007 (11:10 am)
Anyway still no result , if anyone has an idea how to do it , i'll be glad to hear it.
#8
09/22/2007 (11:24 am)
Yup, I've tried a few different things and can't seem to replicate this functionality in script without really fudging things up. I'm afraid this can only be done in the engine. Now, since you don't have the source code access, if you tell me what version of TGE you are using, I can send you an executable that WILL allow you to do this from script.

How does that sound?
#9
09/22/2007 (12:12 pm)
A similar thread:
www.garagegames.com/mg/forums/result.thread.php?qt=67180

However the solution requires access to the source.

Gabriel
#10
09/22/2007 (12:34 pm)
Sun.apply(); did the job !!!
anyway thanks to all of you, pals.
#11
09/22/2007 (12:35 pm)
Well whadd' ya' know. Last time I had to perform this operation Sun.apply() was not an exposed function. I had to do it manually myself. Certainly helpful =)