Remapping Data Function

Remapping Data Function

noah1211football
Enthusiast Enthusiast
1,590 Views
5 Replies
Message 1 of 6

Remapping Data Function

noah1211football
Enthusiast
Enthusiast

Hello, Looking for the Mel command to remap or scale a number...can't seem to find this command anywhere. To be more clear, I have a variable that I want remapped to a different high/low bound. Seems like maya should have this, I know there is the remap value node, but is there not a quick math function in MEL?

 

Thanks,

Noah

0 Likes
Accepted solutions (1)
1,591 Views
5 Replies
Replies (5)
Message 2 of 6

jmreinhart
Advisor
Advisor

It sounds like you just need the functionality of the setRange node not the remapValue node.

You can find that function on the setRange nodes documentation:

https://download.autodesk.com/us/maya/2011help/Nodes/setRange.html

OutValue = Min + (((Value-OldMin)/(OldMax-OldMin)) * (Max-Min))

The remapValue node does not have simple function because of the spline/linear options for each key and the fact that is a piecewise function. 

0 Likes
Message 3 of 6

noah1211football
Enthusiast
Enthusiast
I should've clarified more. I'm looking to use a remap function for setting
per particle attributes within nparticles, so the node editor won't be able
to do this. Is there a function that could do this for nparticles?

Noah
0 Likes
Message 4 of 6

muir.j
Contributor
Contributor

Are you mapping from one particle attribute to another?
Quick and dirty way would be just a particle expression and put your remap function in that or a call to it.

0 Likes
Message 5 of 6

noah1211football
Enthusiast
Enthusiast
Not looking to remap from one attribute to another. Looking to perform the
calculation for every particle. I'm trying to do some steering effects with
particles and have their acceleration slow to zero as their distance from
the goal point decreases I'd like to be able to scale the
acceleration multiplier by distance to point. Hopefully I'm being clear
with this. Perhaps the quick and dirty way would work, but I am not really
understanding what you mean by writing a call to do this

Thanks again for the help

Noah
0 Likes
Message 6 of 6

muir.j
Contributor
Contributor
Accepted solution

Here you go - just make an emitter and add color for the following expression to work.  If you make a dynamic particle expression it will affect every particle - just make sure you select RunBeforeDynamics.

 

 

 

$myPoint = <<0,0,0>>;

$pos = nParticleShape1.position;

$dist = sqrt(($myPoint.x - $pos.x) * ($myPoint.x - $pos.x) + ($myPoint.y - $pos.y) * ($myPoint.y - $pos.y) + ($myPoint.z - $pos.z) * ($myPoint.z - $pos.z));  
$dist = $dist/100;
nParticleShape1.rgbPP = <<$pos.x/100,$pos.y/100,$pos.z/100>>;
nParticleShape1.acceleration = <<1,$dist * 100,0>>;

 

 

 

0 Likes