I believe jbw mentioned he developed some debugging script for setting the light position interactively. But I don't know if he's able to share it with the community.
It is no very big secret (and please don't expect too much).
I have started my adventure of adventures from the "wme_demo_3d" example, so:
- my script system is still similar to it
- you can apply my code to it and quickly see results
1. All my interactive debug extensions are called from infinite loop of
game_daemon.script by:
if (Game.DebugMode) Game.debugkeys();
This is deliberately limited to debug mode only.
2. The main code is placed in the
game.script:
method debugkeys()
{
var shift = Keyboard.IsKeyDown(VK_SHIFT); //-- it is smarter to check it once
//-- some stupid actions on some stupid keys, like:
if (Keyboard.IsKeyDown("0")) Game.QuitGame(); //-- exit without annoying dialogues ;-)
//-- and more, and more, and finally:
var max = 300; //-- reasonably big limit
var mod = max+max; //-- our numbers will be changed in circular manner with "modulo"
var inc = 10; //-- increment by tenths is precise enough
var chg = false; //-- no changes so far
if (shift) inc = mod-inc; //-- [Shift] key forces decrementing instead of incrementing
if (Keyboard.IsKeyDown("x") && (shlx != null)) { shlx = ((shlx+max+inc)%mod)-max; chg = true; }
if (Keyboard.IsKeyDown("y") && (shly != null)) { shly = ((shly+inc)%mod); chg = true; }
if (Keyboard.IsKeyDown("z") && (shlz != null)) { shlz = ((shlz+max+inc)%mod)-max; chg = true; }
if (chg) //-- we have changed something
{
actor.SetLightPosition(shlx, shly, shlz);
Game.Msg("shadow casting light:"+shlx+","+shly+","+shlz);
}
}
Keys 'x', 'y', 'z' leads to change light position toward X, Y or Z axis respectively (with 'Shift' in reverse direction).
Note that this is not 'click', but rather 'depress' handler, so values will be changed continously as long as we hold the key.
For X and Z the range -300..290 was good for me, and Y - 0..590 (negative Y makes no sense).
Checking for 'null' prevents unwanted action before initialization (see below).
3. Globals are placed in
base.inc:
global shlx;
global shly;
global shlz;
and initialized for each scene in
scene.script:
if (Scene.shlpos == null) //-- no scene's custom property named 'shlpos'?
{
shlx = -40; shly = 200; shlz = -40; //-- default for 'trinity'
}
else //-- get shadow light position from custom property
{
var tmp = new String(Scene.shlpos); tmp = tmp.Split();
shlx = ToInt(tmp[0]);
shly = ToInt(tmp[1]);
shlz = ToInt(tmp[2]);
}
actor.SetLightPosition(shlx, shly, shlz);
Current light position shows itself in debug message area on the screen - we can read it using eyes and keep it by pen-and-paper method ;-)
Catched numbers can be coded permanently as the 'shlpos' property of scene in the form of comma separated list.
I'm sorry for the extended delay, but I'm not reading posts here much frequently. If somebody wishes to get rapid answer please ask me by e-mail.