Hi Andrew,

We went through this when we were first adding byte color support into
Java 3D.  On the surface it looks like java can't handle unsigned byte
data, but it actually can with the help of appropriate masks and casts.
This little programs shows how:

public class ByteTest
{
   public static void main(String[] args)
   {
       byte[] bytes = new byte[256];
       int[] ints = new int[256];
       int i;

       for (i=0; i<256; i++) {
           bytes[i] = (byte)i;
           ints[i] = (bytes[i]&0xff);
           System.out.println("Byte: " + bytes[i] + " => " + ints[i]);
       }
   }
}

As the loop runs, you will notice that the byte array thinks it goes from
0=>127 then from -128=>-1.  However, the integer array goes from 0=>255
as expected.  By using this, you can represent unsigned byte data in java.

Having said that, it looks like our GeometryInfo code is not masking correctly
during conversion, so it is broken.  I know our GeometryArray objects do it
correctly.

Doug Twilleager
Java 3D Team


> MIME-Version: 1.0
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
> Subject: [JAVA3D] Bug in GeometryInfo with byte[] colors >= 128???
> To: [EMAIL PROTECTED]
>
>
>   In a GeometryInfo object, if I setColors3(byte[]), values above 127 don't
seem to appear. Values from 0-127 do. But RGB colors are represented by a
3-tuple each of whose components are in the range [0,255].
>   I didn't see this in Sun's list of bugs.
>   Has anyone else encountered this behavior?
>   If this is a bug in the library rather than my application, could it be
related to Java's inability to represent logically unsigned values as physically
unsigned types?
>
>
================================================================================
> Andrew R. Thomas-Cramer
> Home: [EMAIL PROTECTED]    http://www.execpc.com/~artc/
> Work: [EMAIL PROTECTED]                                608.287.1043
>
> "Your quote here."
> -- Bjarne Stroustrup, "The C++ programming language," chapter 13: "Templates".
>
================================================================================

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to