PDA

View Full Version : This makes LW crash whe cloning items..and more...



Red_Oddity
04-06-2004, 08:53 AM
This is a MotionModifier plugin that simply scales one object according to
the distance to another object (chosen in the settings of the plugin)

This plugin works people, trust me...it's not a virus or anything, it's just not
bugfree...so give it a go...

Just copy and paste the stuff between the code lines in a text editor and save
as scale2distance.ls and just install like you would any other plugin


This piece of code makes LW crash when cloning, but not always...

When the cloning did work, it behaves weird...
Both objects that contain this plugin (the original and the clone) loose their settings
and for some bizarre reason seem to be linked to eachother...when you change one thing
on one of the objects, the other picks up these changes aswell...
But, when you save and load the scene everything has been corrected...

Could anyone take a peek what it could be?

*note*
vBulletin sees dirty words everywhere, so the line that looks like:

ctlme****ems

should offcourse be:

ctl mesh items

but without the spaces




// Scale 2 Distance
// by Sven Neve aka Red_Oddity
//
// Does just what the name says
// Pick a mesh and fill in the values
//
//

@version 2.3
@script motion
@name Scale 2 Distance

var vPick = nil;
var vPickName = nil;
var vMin = 0.0;
var vMax = 1.0;
var vDist = 5.0;

create
{
setdesc("Scale2Distance : None");
}

process: ma, frame, time
{
if(vPickName != nil) //this checks wheter or not the plugin is being called after a load Scene
{ //If this is the case, the vPickName will contain a name and
vPick = Mesh(vPickName); //the plugin will Pick the objID that goes with the name.
vPickName = nil;
}

if(vPick)
{
vector1 = ma.get(WPOSITION,time); //This is how you get a vector from the object the plugin is on.
vector2 = vPick.getWorldPosition(time);//This is how you get a vector from the object you selected in the dropdown menu.
vectordistance = vmag(vector1 - vector2); // return the vector between both vectors

if (vectordistance < vDist)
{
scalemultiply = 1 - (vectordistance / vDist);//creates a multiplier (used for final object scale)
}
else
{
scalemultiply = 0;
}
scalereal = vMax - vMin;//This is done so it is possible to do a decent scale, the minimum value will be added later after the final scale formula.

scale = vMin + (scalereal * scalemultiply);//this is the formula...

ma.set(SCALING,<scale,scale,scale>);
// vstring = string(vectordistance)+" | "+string(scalemultiply)+" | "+string(scale);
// info(vstring);//for debugging purposes, is turned off now
info(vPick);
}
}

options
{
reqbegin("Scale 2 Distance by Sven Neve");
reqsize(320,160);

c1 = ctlme****ems("Distance to",vPick);
c2 = ctlnumber("Minimum Scale",vMin);
c3 = ctlnumber("Maximum Scale",vMax);
c4 = ctlnumber("Distance for MaxScale",vDist);

return if !reqpost();

vPick = getvalue(c1);
vMin = getvalue(c2);
vMax = getvalue(c3);
vDist = getvalue(c4);

reqend();

if (vPick == nil)
{
vTemp = "None";
}
else
{
vTemp = vPick.name;
}
setdesc("Scale2Distance : " + vTemp); //Writes info behind your plugin in the MO window
}

//this part here saves all used values into your Scene file and will be loaded
//next time you open your Scene file again.


load: what,io
{
if(what == SCENEMODE)
{
vPickName = io.read(); //Loads the objects name
vMin = number(io.read());
vMax = number(io.read());
vDist = number(io.read());
setdesc("Scale2Distance : " + vPickName);
}
}

save: what,io
{
if(what == SCENEMODE)
{
io.writeln(vPick!=nil?vPick.name:nil); //Saves away the objects name
io.writeln(vMin);
io.writeln(vMax);
io.writeln(vDist);
}
}

GregMalick
12-10-2004, 11:57 PM
Hey Sven,

I tried you code and it doesn't crash LW 8.01
It doesn't seem to crash in LW 7.5c either. :confused: had to get rid of that info() though.

I can't figure yours out - but I'm having a LW crash when cloning an object with an IA attached. -- funny thing is that if I open the panel before cloning, LS doesn't crash.

I've narrowed it down to 2 controls in a non-modal panel that use elements of an array as their default value. (either of them will cause a crash). Remove the controls and everythings is hunk-dory even if the panel isn't opened.

The controls types are ctlpopup() & ctlnumber().

very weird... open the panel & cloning works great.
open a saved scene but don't open the IA panel --- cloning crashes LW.



go figure :confused:

Red_Oddity
12-17-2004, 04:56 AM
I should take a peek at this script again someday :)

But right now i'm really really busy, and the first script i really want to finish it the MotionVecotr script i wrote...

Anyway, thanks for figuring some of this stuff out