Notifications
Clear all

[Closed] set range node

hay everyone,
im wondeing if anyone can tell me if such thing exists in max or similar to it. In maya there is set range node. Besically what it does is, it take values and then turns them into different specified by user values. For example if you have value min = 0.124925 and max value = 1.412 you can set this value to be 0.0 to 1.0
Thanks.

7 Replies

If you are scripting, shouldn’t be too hard to do yourself. For example:

fn range number minimum maximum = (
if number < minimum then 0
else if number > maximum then 1
else (number - minimum) / (maximum - minimum) 
)

then pass it values to check in the form ‘number to check, minimum number, maximum number’, and it will return you the number from 0 to 1 that that number is. Remember to pass it a float though, or it will always be 0 or 1, never in the middle.

Try:


range 9.0 5.0 10.0

Shouldn’t be too hard for you to write a reverse of this to go the other direction.

What Morbid Angel is asking for is not quite as simple as what you’re offering, F_N. What is needed is a function to re-map a value from one range to another. I’m not very gifted at algebra, so the expression in the following function could probably be simplified, but it does work:

fn remap v min max target_min target_max =
(
	v /= 1.0--ensure a float value
	start_rng = max - min
	end_rng = target_max - target_min
	return (((v - min) * end_rng) / start_rng) + target_min
)

v is the value you want to remap, min and max are the range you’re mapping from, target_min and target_max are the range you’re mapping to. Test it on some known values, e.g.: remap 5 0 10 0 1 should return 0.5. The good thing about this function is that you can use it both ways – remap 0.5 0 1 0 10 would return 5.0.

Make sense?

RH

Ahh, I see. I thought he wanted everything mapped to be from 0 to 1. Thanks LF!

well im new to script and is not so easy for me to pick it apart altho i do see what you mean

what im trying to do, and perhaps it doesnt work for me because of that is im trying to make manipulator control mix value of mixMap. So, where in manipulator 0 -1 = mix value 0.0 =100.0, but what I want is to mix several maps one after another. So if I could define that mixMap 1 has range from 0-1, mixMap 2 range 2-3 and so on…

I’m not exactly sure what you are getting at, but it sounds beyond my skills anyways. I’m new to maxscript too. Sorry!

If I understand what your needs are, this function should do the trick.

fn RoundNumber val=
(
	local rNum
	num = mod val 1
 
	if num >= .5 then
	(
		 rNum = ceil val
	)
 
	else
	(
		 rNum = floor val
	)
)
 
j = RoundNumber 1.6 -- Insert any value here

-Jon

P.S. If anyone could tell me how to use the code brackets button it would be appreciated. I had to copy/paste an existing post and hack this together

If I understand your needs this function should do the trick:


fn RoundNumber val =

(

local rNum

num = mod val 1

if num >= .5 then

(

[indent]rNum = ceil val

)

else

(

rNum = floor val

)

[/indent])

Hope this helps,

-Jon