[Bf-committers] Vert colours returning incorrect values.
Ton Roosendaal
bf-committers@blender.org
Sun, 18 Jul 2004 13:08:22 +0200
Hi,
This is very confusing & weird code... and if you want to get help
finding a bug, we would need the full code. Including how you get to
print all of this.
This is a call I quickly wrote and checked it works:
void print_tface_colors(Mesh *me)
{
TFace *tf;
int a, b;
char *cp;
tf= me->tface;
if(tf== NULL) return;
for(b= me->totface; b>0; b--, tf++) {
for(a=0; a<4; a++) {
cp= (char *)(tf->col+a);
printf("%d %d %d %d\n", cp[0], cp[1], cp[2], cp[3]);
}
}
}
-Ton-
On Sunday, Jul 18, 2004, at 05:05 Europe/Amsterdam, Campbell Barton
wrote:
> Hi, Im writing some code that compares the vert colours of faces with
> eachother.
>
> The code dosent work beacure the colour values returned from the
> selected face colours is incorrect.
>
> eg, i have 9 white faces on a plane, and when I print the colour
> values is shows the last 2 faces to be a different colour.
>
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 255 255 255
> !Match Comparing 255 255 255 with 255 255 255 Comparing 255 255 255
> with 255 255 255 Comparing 255 255 255 with 255 255 255 Comparing 255
> 255 255 with 76 66 89
> Comparing 255 255 255 with 255 255 255 Comparing 255 255 255 with 255
> 255 255 Comparing 255 255 255 with 76 66 89 Comparing 255 255 255 with
> 63 128 0
> Comparing 255 255 255 with 255 255 255 Comparing 255 255 255 with 76
> 66 89 Comparing 255 255 255 with 63 128 0 Comparing 255 255 255 with 0
> 0 0
>
>
> Heres the code that assigns the colours
>
>
> var props
>
>
> /* Here are vars where we store the colours to compare */
> /* extract of an email from Ton and Douglas Toltzman What Ton is
> saying is that there are 4, 8 bit components stored in a 32
> bit, unsigned value. I'm not sure of the order of components, but if
> Ton
> says "ABGR", then I'd presume the following would be correct
> - Ton
> Colors are 'packed' in an int, denoting bytes for ABGR respectively.
> Put a char pointer to the color, and read the color components
> individually. Alpha is by default 255. */
> char *packed_color_array;
> /* face A- the active save */
> short redA1, greenA1, blueA1, redA2, greenA2, blueA2, redA3, greenA3,
> blueA3, redA4, greenA4, blueA4,
> redB1, greenB1, blueB1, redB2, greenB2, blueB2, redB3, greenB3,
> blueB3, redB4, greenB4, blueB4;
> ____________________
>
>
> /* make sure the face has at lease 3 point before we go on */
> foundActFace=1;
> /* face A- the active save */
> packed_color_array = (char *) &tface[0].col;
> redA1= packed_color_array[3];
> greenA1= packed_color_array[2];
> blueA1= packed_color_array[1];
> packed_color_array = (char *) &tface[1].col;
> redA2= packed_color_array[3];
> greenA2= packed_color_array[2];
> blueA2= packed_color_array[1];
> packed_color_array = (char *) &tface[2].col;
> redA3 = packed_color_array[3];
> greenA3 = packed_color_array[2];
> blueA3 = packed_color_array[1];
> if (mface->v4) {
> packed_color_array = (char *) &tface[3].col;
> redA4 = packed_color_array[3];
> greenA4 = packed_color_array[2];
> blueA4 = packed_color_array[1];
> }
>
> Could anybody tel me why Im not getting all 255,255,255?
> - Thanks
>
>
> --
> Campbell J Barton
>
> 133 Hope Street
> Geelong West, Victoria 3218 Australia
>
> URL: http://www.metavr.com
> e-mail: cbarton@metavr.com
> phone: AU (03) 5229 0241
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers@blender.org
> http://www.blender.org/mailman/listinfo/bf-committers
>
>
------------------------------------------------------------------------
--
Ton Roosendaal Blender Foundation ton@blender.org
http://www.blender.org