index color value 2005-06-13 - By ozu's mailbot
Back <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> <pre style="margin-top: 0.5em;" class="js">According to people in the know at SOFTIMAGE, the secret formula to encode RGB values into the wireframe color integer is the following:
wirecolor is a 10bit <tt>BBBGGGRRR0</tt> value where the first 3 bits are the most significant (out of 8) bits of Blue <tt>BBB00000</tt>, Green <tt>GGG00000< /tt> and Red <tt>RRR00000</tt> respectively and the last bit is left unused.
<b>Convert RGB to wire color</b>. This is done by shifting the red, green and blue values 5 places to the right, keeping only the 3 leftmost bits and shifting right to the correct position for red green and blue respectively.
</pre> <div style="padding: 4px; margin-top: 0px; display: block;"> <pre style="margin-top: 0.5em;" class="js">function RGBToWire(r,g,b) { var red = ( ( r >> 5 ) & 7 ) << 1; var green = ( ( g >> 5 ) & 7 ) << 4; var blue = ( ( b >> 5 ) & 7 ) << 7; return ( red | green | blue ); }
var red = 224; var green = 96; var blue = 0;
var wire = RGBToWire(red, green, blue);
LogMessage( "("+ red +","+ green +","+ blue +") = "+ wire); </pre> </div> <b>Convert wire color to RGB</b>. This is done by applying the inverse transformation.<br> <tt>function WireToRGB( wire ) { <br> var color = new Object; <br> color.r = ( ( wire >> 1 ) & 7 ) << 5;<br> color.g = ( ( wire >> 4 ) & 7 ) << 5;<br> color.b = ( ( wire >> 7 ) & 7 ) << 5;<br> return color;<br> } <br> <br> var wire = 62;<br> var color = WireToRGB(wire);<br> LogMessage( wire +" = ("+ color.r +","+ color.g +","+ color.b +")" );</tt> <pre style="margin-top: 0.5em;" class="js">
</pre> <br> <br> <a class="moz-txt-link-abbreviated" href="mailto:fgiard@(protected)">fgiard @(protected)</a> wrote:<br> <blockquote cite="mid1118669017.42ad88da02723@(protected)" type="cite"> <pre wrap="">Hi everyone, is there a quick way to convert rgg to index? (I want to set wireframe according to bones rgb) thank you, -Francois Giard
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ This message was sent using IMP, the Internet Messaging Program.
--- Unsubscribe? Mail <a class="moz-txt-link-abbreviated" href="mailto:Majordomo @(protected)">Majordomo@(protected)</a> with the following text in body: unsubscribe xsi </pre> </blockquote> </body> </html> --- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|