querying object material color

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 09 September 2005   #1
Lightbulb querying object material color

Hi to all:-)

anyone knows how to read the RGB values of a lambert shader on a simple sphere??? I want to query them to be able to extract & control the red channel only..any ideas???
 
Old 09 September 2005   #2
{
  	// create a Lambert + SG
  	string $lamb = `shadingNode -asShader lambert` ;
  	sets -renderable true -noSurfaceShader true -empty -name ($lamb + "SG");
  	connectAttr -f ($lamb + ".outColor") ($lamb + "SG.surfaceShader") ;
  
  	// assign it a greenish color
  	setAttr ($lamb + ".color") -type double3 .133 .55 .123 ;
  
  	// query the color
  	// note: when you setAttr on a color you set 3 floats
  	// so this needs to be a float-array!
  	float $col[] = `getAttr ($lamb + ".color")`  ;
  	
  	// now see what we got:
  	print ("R: \<" + $col[0] + "\>\n") ;
  	print ("G: \<" + $col[1] + "\>\n") ;
  	print ("B: \<" + $col[2] + "\>\n") ;
  	// et voilá!
  	// hope it helps!
  }
 
Old 09 September 2005   #3
=== variable declarations =========================================
   string $inputNodes[],$selObj[];
   string $curObj,$shadingNode;
   float $redVal;
   vector $nodeColor;
   //==================================================  ============
   
   $redVal = 0.5;                                           //this will be yr red value,btwn 0 - 1
   $selObj = `ls -sl`;                                      //get current selection
   $selObj = `listRelatives -s $selObj[0]`;           //get shapeNode of current selection
   $selSG = `listConnections -t shadingEngine $selObj`;  //get name of shader engine
   $inputNodes = `listConnections -s 1 -d 0 $selSG`;      //get material name 
   $shadingNode = $inputNodes[0];
   
   $nodeColor = `getAttr ($shadingNode + ".color")`;      //get color of material name
   setAttr ($shadingNode + ".color") $redVal ($nodeColor.y) ($nodeColor.z);  //assign it
 
 
Old 09 September 2005   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:39 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.