com.sun.j3d.utils.geometry.compression
Class CommandStream

java.lang.Object
  extended by com.sun.j3d.utils.geometry.compression.CommandStream

 class CommandStream
extends java.lang.Object

This class is used to build the bit-level compression command stream which is the final result of the compression process. It defines the bit representations of the compression commands and provides a mechanism for the interleaving and forwarding of command headers and bodies required by the geometry compression specification.


Field Summary
private  int bitOffset
           
private  int byteOffset
           
private  byte[] bytes
           
(package private) static int COLOR_TABLE
           
private  long lastBody
           
private  int lastBodyLength
           
(package private) static int MESH_B_R
           
(package private) static int NORMAL_TABLE
           
(package private) static int POSITION_TABLE
           
(package private) static int SET_COLOR
           
(package private) static int SET_NORM
           
(package private) static int SET_STATE
           
(package private) static int SET_TABLE
           
(package private) static int V_NO_OP
           
(package private) static int VERTEX
           
 
Constructor Summary
CommandStream()
          Create an empty CommandStream with a default initial size.
CommandStream(int initSize)
          Create an empty CommandStream with the given initial size.
 
Method Summary
private  void addByte(int b, int bitCount)
           
(package private)  void addCommand(int header, int headerLength, long body, int bodyLength)
          Add a compression command to this instance.
private  void addLong(long l, int bitCount)
           
(package private)  void clear()
          Mark the CommandStream as empty so that its storage will be reused.
(package private)  void end()
          Add a no-op and the last command body.
(package private)  int getByteCount()
          Get the number of bytes in the compression command stream.
(package private)  byte[] getBytes()
          Get the bytes composing the compression command stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_NORM

static final int SET_NORM
See Also:
Constant Field Values

SET_COLOR

static final int SET_COLOR
See Also:
Constant Field Values

VERTEX

static final int VERTEX
See Also:
Constant Field Values

MESH_B_R

static final int MESH_B_R
See Also:
Constant Field Values

SET_STATE

static final int SET_STATE
See Also:
Constant Field Values

SET_TABLE

static final int SET_TABLE
See Also:
Constant Field Values

V_NO_OP

static final int V_NO_OP
See Also:
Constant Field Values

POSITION_TABLE

static final int POSITION_TABLE
See Also:
Constant Field Values

COLOR_TABLE

static final int COLOR_TABLE
See Also:
Constant Field Values

NORMAL_TABLE

static final int NORMAL_TABLE
See Also:
Constant Field Values

bytes

private byte[] bytes

byteOffset

private int byteOffset

bitOffset

private int bitOffset

lastBody

private long lastBody

lastBodyLength

private int lastBodyLength
Constructor Detail

CommandStream

CommandStream()
Create an empty CommandStream with a default initial size.


CommandStream

CommandStream(int initSize)
Create an empty CommandStream with the given initial size.

Parameters:
initSize - initial capacity of CommandStream in bytes
Method Detail

clear

void clear()
Mark the CommandStream as empty so that its storage will be reused.


addCommand

void addCommand(int header,
                int headerLength,
                long body,
                int bodyLength)
Add a compression command to this instance.

A compression command includes an 8-bit header and can range up to 72 bits in length. The command with the maximum length is a 2-bit color command with a 6-bit tag in the header, followed by four 16-bit color components of data.

A subcommand is either a position, normal, or color, though in practice a position subcommand can only be part of a vertex command. Normal and color subcommands can be parts of separate global normal and color commands as well as parts of a vertex command.

A subcommand includes a 6-bit header. Its length is 2 bits less than the length of the corresponding command.

Parameters:
header - contains compression command header bits, right-justified within the bits of the int
headerLength - number of bits in header, either 8 for commands or 6 for subcommands
body - contains the body of the compression command, right-justified within the bits of the long
bodyLength - number of bits in the body

addByte

private void addByte(int b,
                     int bitCount)

addLong

private void addLong(long l,
                     int bitCount)

end

void end()
Add a no-op and the last command body. Pad out with additional no-ops to a 64-bit boundary if necessary. A call to this method is required in order to create a valid compression command stream.


getByteCount

int getByteCount()
Get the number of bytes in the compression command stream.

Returns:
size of compressed data in bytes

getBytes

byte[] getBytes()
Get the bytes composing the compression command stream.

Returns:
reference to array of bytes containing the compressed data


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.