|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.microcrowd.loader.java3d.max3ds.ChunkChopper
public class ChunkChopper
A singleton flyweight factory responsible for chopping the data up and sending it to the corresponding chunks(which are flyweights ala the flyweight pattern) for processing. This will sequentially read a 3ds file, load or skip chunks and subchunks and initialize the data for the chunks.
Retrieved data may be stored as state in the ChunkChopper
via pushData(java.lang.Object, java.lang.Object) for use by other chunks.
Features not supported; unknown chunks are skipped.
| Field Summary | |
|---|---|
static boolean |
debug
This should be turned on by Loader3DS to view debugging information. |
static Chunk |
debugChunk
Current chunk for which debugging info is viewed if debug == true |
| Constructor Summary | |
|---|---|
ChunkChopper()
private singleton constructor. |
|
| Method Summary | |
|---|---|
void |
addBehaviorNode(Behavior behavior)
Adds a behavior to the scene base. |
void |
addLightNode(Light light)
Adds a light to the scene base. |
void |
addObject(java.lang.String name,
TransformGroup group)
Adds a group to the choppers scene group and sets the current name and group. |
void |
addViewGroup(TransformGroup viewGroup)
Adds a camera transform to the scene base. |
Texture |
createTexture(java.lang.String textureImageName)
Loads the image to server as a texture. |
protected void |
debug(Chunk parentChunk,
int level,
java.lang.Integer chunkID,
long chunkLength,
int position,
long limit)
prints some handy information... |
void |
get(byte[] bytes)
Fills bytes with data from the chunk buffer. |
java.nio.ByteBuffer |
getByteBuffer(java.nio.channels.ReadableByteChannel channel,
int channelSize)
Allocates and loads a byte buffer from the channel |
byte[] |
getChunkBytes()
Reads a number of bytes corresponding to the number of bytes left in the current chunk and returns an array containing them. |
float |
getFloat()
reads a float from the chunkBuffer. |
TransformGroup |
getGroup()
Gets the group for the current object the chopper is working with. |
java.lang.Integer |
getID()
Gets the id of the current chunk. |
int |
getInt()
Reads an int and returns it |
KeyFramer |
getKeyFramer()
Gets the key framer chunk These should be their own objects instead of chunks. |
long |
getLong()
Gets a long from the chunk Buffer |
java.lang.Object |
getNamedObject(java.lang.String key)
Sets a named Object in the loader. |
TransformGroup |
getNamedTransformGroup(java.lang.String key)
Gets and cast the named object for the key provided. |
java.lang.String |
getObjectName()
Gets the name of the current object the chopper is working with. |
Point3f |
getPoint()
Reads 3 floats x,z,y from the chunkbuffer. |
int |
getShort()
Reads a short and returns it as a signed int. |
java.lang.String |
getString()
This reads bytes until it gets 0x00 and returns the corresponding string. |
int |
getUnsignedByte()
Reads a byte, unsigns it, returns the corresponding int. |
int |
getUnsignedInt()
Reads an int and returns it unsigned, any ints greater than MAX_INT will break. |
int |
getUnsignedShort()
Reads a short and returns it as an unsigned int. |
Vector3f |
getVector()
Reads 3 floats x,z,y from the chunkbuffer. |
boolean |
hasLights()
Returns true if there have been lights loaded. |
SceneBase |
loadSceneBase(java.io.InputStream inputStream,
Loader3DS loader,
int modelSize)
This sequentially parses the chunks out of the input stream and constructs the 3D entities represented within. |
protected void |
loadSubChunks(Chunk parentChunk,
int level)
The base class Chunk takes care of loading subchunks for all chunks types. |
java.lang.Object |
popData(java.lang.Object key)
Gets a datum that had been retrieved and stored via pushData(java.lang.Object, java.lang.Object) earlier and removes it. |
void |
pushData(java.lang.Object key,
java.lang.Object data)
Used to store data that may later be used by another chunk. |
void |
setDataMap(java.util.HashMap dataMap)
Sets the data map used to store values that chunks may need to retrieve later. |
void |
setNamedObject(java.lang.String key,
java.lang.Object value)
Sets a named object in the loader. |
void |
setObjectName(java.lang.String name)
Sets the name of the current object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean debug
public static Chunk debugChunk
| Constructor Detail |
|---|
public ChunkChopper()
| Method Detail |
|---|
public SceneBase loadSceneBase(java.io.InputStream inputStream,
Loader3DS loader,
int modelSize)
The first chunk is the main chunk (id=4D4D) and its length is always the length of the file. It only contains sub chunks. Other chunks may contain data, subchunks or both. If the format of a chunk is unknown skipped.
Subclasses of chunk will all automagically load the subchunks.
It is the programmers responsibility to ensure that the data
preceeding the subchunks is loaded or skipped as
required and that something useful is done with the data. If data from the
subchunks is needed in order to initialize components then that code should be
placed in Chunk.initialize(com.microcrowd.loader.java3d.max3ds.ChunkChopper). Otherwise the data may be dealt with in
Chunk.loadData(com.microcrowd.loader.java3d.max3ds.ChunkChopper). Also, if a chunk has data preceeding its subchunks
it communicates how many bytes long that data is by returning it from loadData.
This chopper reads a file in order from beginning to end
inputStream - the stream with the data to be parsed.loader - the loader that will be configured from the data.modelName - name of the model file for display purposes.modelSize - size in bytes of the file to read.
public java.nio.ByteBuffer getByteBuffer(java.nio.channels.ReadableByteChannel channel,
int channelSize)
throws java.io.IOException
channel - the file channel to load the data from
java.io.IOException
protected void loadSubChunks(Chunk parentChunk,
int level)
throws CannotChopException
pushData(java.lang.Object, java.lang.Object)
CannotChopExceptionpublic KeyFramer getKeyFramer()
public void addObject(java.lang.String name,
TransformGroup group)
the - name of the object to add which
will also be the current name of the object
the chopper is working with.group - the current group that the chopper
will be adding things too.public java.lang.String getObjectName()
public void setObjectName(java.lang.String name)
addObject(java.lang.String, TransformGroup)
name - the name that the current object should be set to.public TransformGroup getGroup()
public void pushData(java.lang.Object key,
java.lang.Object data)
key - the look up key.data - the data to store.public java.lang.Object popData(java.lang.Object key)
pushData(java.lang.Object, java.lang.Object) earlier and removes it.
key - the key used to store the datum earlier.
public void setNamedObject(java.lang.String key,
java.lang.Object value)
key - the key name of the objectvalue - the named Object.public boolean hasLights()
public void addBehaviorNode(Behavior behavior)
behavior - the behavior to add to the scene base.public void addLightNode(Light light)
light - the light to add to the scene base.public void addViewGroup(TransformGroup viewGroup)
viewGroup - the transform group to add as a view.public java.lang.Object getNamedObject(java.lang.String key)
key - the key used as the name for which the object will be returnedpublic TransformGroup getNamedTransformGroup(java.lang.String key)
public long getLong()
public int getShort()
public int getUnsignedShort()
public float getFloat()
public Vector3f getVector()
public Point3f getPoint()
public int getInt()
public int getUnsignedInt()
public int getUnsignedByte()
public byte[] getChunkBytes()
public void get(byte[] bytes)
bytes - the array to fill with data.public void setDataMap(java.util.HashMap dataMap)
dataMap - the hashmap that will be used to store
and retrieve values for use by chunks.public java.lang.String getString()
public java.lang.Integer getID()
short.public Texture createTexture(java.lang.String textureImageName)
textureImageName - name of the image that
is going to be set to be the texture.
protected void debug(Chunk parentChunk,
int level,
java.lang.Integer chunkID,
long chunkLength,
int position,
long limit)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||