PDA

View Full Version : Displacement Maps



GregMalick
03-06-2004, 11:05 PM
OK... I'm just trying to go through the tutorial and learn how to use displacement maps. I actually cutNpasted the following code from the LScript User manual (p.71-72). I then loaded a cube (as suggested) into Layout. As soon as I load the displacement script, the info box start flashing and LW crashes.:eek:

here's the code.... Can anybody tell me what's wrong?

@warnings
@version 2.3
@script displace
@name Splat

// Global variables.
splatValue = 0;

create
{
setdesc("Splat!");
}

newtime: id, frame, time
{
info("newTime: id: ", id, " frame: ",frame, " time: ", time);
}

process: da
{
// da is the Displacement Map Object Agent passed
// from Layout.
info("process: ", da.oPos[1]);
}

options
{
}

#lwrs_web
03-12-2004, 10:51 AM
Use the Diagnostic Window instead of info (or write debug info to a file).
In such callbacks you should return as fast as possible, because it may be called thousands of times per second.
Especially avoid things like opening requesters or things that are out of context and take long time to return.



@warnings
@version 2.3
@script displace
@name Splat

// Global variables.
splatValue = 0;
diag;
pnum;

create
{
setdesc("Splat!");
diag = Diagnostic();
diag.showonwrite = false;
pnum=0;
}

newtime: id, frame, time
{
diag.post("newTime: id: ", id, " frame: ",frame, " time: ", time);
pnum=0;
}

process: da
{
if(pnum>10)
{
return;
}
pnum++;
diag.post("process: ", da.oPos[1]);
}

options
{
diag.show(true);
}

GregMalick
03-12-2004, 11:16 AM
Thanks lwrs. You are a champion!
And you are absolutely right... the info() statement brings down LW.

I can't tell you how many hours I puzzled over this.

Someone (with contact) should suggest that they rewrite the examples in their reference materials so they actually work. But I'm not holding out much hope. It's just great that we have LScript at all.

mahalo,