RE: does the clamp function in MEL have an equivalent in XSI expressions?
| Date : Tue, 4 Oct 2005 12:15:12 -0400 |
| To : <XSI(at)Softimage.COM> |
| From : "Ian Stewart" <istewart(at)Softimage.COM> |
| Subject : RE: does the clamp function in MEL have an equivalent in XSI expressions? |
MIN(MAX( slider.kine.local.posy, 0 ),10)
-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM]On Behalf Of javier
Posted At: October 4, 2005 12:06 PM
Posted To: xsi
Conversation: does the clamp function in MEL have an equivalent in XSI expressions?
Subject: Re: does the clamp function in MEL have an equivalent in XSI expressions?
/* From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM]On Behalf Of javier
Posted At: October 4, 2005 12:06 PM
Posted To: xsi
Conversation: does the clamp function in MEL have an equivalent in XSI expressions?
Subject: Re: does the clamp function in MEL have an equivalent in XSI expressions?
10 minute clamp function for you
copy this (straigten out the SiAddCustomparam lines, my mail chopped thiem in pieces)
into a function called Clamp.js
put that function in Plugins for user or wrokgroupd, restart xsi or update plugins
and then you got your clamp
to see an example run the following lines, you will notice that i actually put a custom param for min and max so you can interactively modify it
NewScene()
CreatePrim("Cube", "MeshSurface", null, null);
posy = "cube.kine.local.posy"
minn = 0
maxx = 10
Clamp (0,10,posy)
*/
function XSILoadPlugin( in_reg )
{
in_reg.Author = "Javier";
in_reg.Name = "Clamp";
in_reg.Email = "";
in_reg.URL = "";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.RegisterCommand("Clamp","Clamp");
return true;
}
function XSIUnloadPlugin( in_reg )
{
strPluginName = in_reg.Name;
return true;
}
function Clamp_Init( ctxt )
{
var oCmd;
oCmd = ctxt.Source;
oCmd.Description = "";
oCmd.ReturnValue = true;
var oArgs;
oArgs = oCmd.Arguments;
oArgs.Add("minval",siArgumentInput);
oArgs.Add("maxval",siArgumentInput);
oArgs.Add("param",siArgumentInput);
return true;
}
function Clamp_Execute(minval,maxval,param)
{
var sOp = ClampOp_Update.toString();
var posy = Dictionary.GetObject(param);
if (!param){logmessage ("parameter "+param+" is not a valid parameter ,exiting",siError);}
if (!minval){minval = 0;}
if (!maxval){maxval = 0;}
var c_out = XSIFactory.CreateActiveXObject("XSI.Collection");
c_out.add(param);
var c_in = XSIFactory.CreateActiveXObject("XSI.Collection");
c_in.add(param)
var opClamp = AddScriptedOp (c_out, sOp ,c_in, "ClampOp", "Jscript",null);
SIAddCustomParameter(opClamp , "Clamp_Min", siDouble, minval, -1000000, 1000000, null, 5, Math.abs(10*minval)*-1, maxval, null, null);
SIAddCustomParameter(opClamp , "Clamp_Max", siDouble, maxval, -1000000, 1000000, null, 5, minval, Math.abs(10*maxval), null, null);
return opClamp;
}
function ClampOp_Update(ctx,Out,In){
var val = In.value;
var max = ctx.Clamp_Max.value;
var min = ctx.Clamp_Min.value;
if (min > max){ctx.Clamp_Min.value = max;}
if (val > max){val = max;}
if (val < min){val = min;}
Out.Value = val;
}
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: RE: Is anybody using the shrink wrap with new options to simulate skin over
- Next by Date: RE: Is anybody using the shrink wrap with new options to simulate skin over
- Previous by Thread: RE: Is anybody using the shrink wrap with new options to simulate skin over
- Next by Thread: RE: Is anybody using the shrink wrap with new options to simulate skin over
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |