PDA

View Full Version : Help with colorAtPoint expressioin


misterwolfy
11-13-2010, 05:51 AM
string $cubes2[] = `ls -type transform "gridCube*"`;
for( $each in $cubes2) {
float $u = `getAttr($each + ".translateX")`;
float $v = `getAttr($each + ".translateZ")`;
float $capValueF[] = `colorAtPoint -o RGB -u (($u+40)/80) -v (($v+40)/80) file1`;
setAttr ($each + ".scaleY") (($capValueF[0]+$capValueF[1]+$capValueF[2])*10);
setAttr ($each + "Lam.incandescenceR") $capValueF[0];
setAttr ($each + "Lam.incandescenceG") $capValueF[1];
setAttr ($each + "Lam.incandescenceB") $capValueF[2];
}
flushUndo;


This expression watches the value of colorAtPoint, it cycles through a grid of cubes, and takes the value as interpreted in texture's UV space, and applies it to the scaleY of the cube. Easier to just watch the a video.

youtube video (http://www.youtube.com/watch?v=_r-5UfwR444)

The only problem is that it does not evaluate correctly when rendering. It just renders the same frame over and over again. While if I bake the animation, it will work fine, but baking takes a long time and crashes Maya often. Also the baked file is rather large.

Is there a better way to do this?

Thanks!!

YourDaftPunk
11-14-2010, 12:39 AM
The reason your bake takes so long is that you are calling colorAtPoint in a loop every frame. You should call it once, read in as many pixels as required into an array, then inside the for() loop you should grab the value in the pixel array as needed.

This is also something SOuP would do better:
http://petershipkov.com/development/SOuP/SOuP.htm

misterwolfy
11-14-2010, 05:05 AM
Cool, SOuP looks like an amazing tool set. Thanks!

Does this mean that I need to create two expressions? One runtime, to set the values at each frame, and one creation, to declare the variables = to colorAtPoint? When I pull the "getAttr colorAtPoint" out of the expression I get a variable not declared error.

CGTalk Moderation
11-14-2010, 05:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.