Logo Search packages:      
Sourcecode: java3ds-fileloader version File versions  Download package

void com::microcrowd::loader::java3d::max3ds::ChunkChopper::loadSubChunks ( Chunk  parentChunk,
int  level 
) throws CannotChopException [inline, protected]

The base class Chunk takes care of loading subchunks for all chunks types. It occurs as follows:

  1. The chunk id (short) is read
  2. The chunk length(int) is read
  3. A subchunk is looked up from the map of publish subchunk types of the current chunk.
  4. If it isn't found during the lookup it is skipped.
  5. Otherwise it is requested to pushData
  6. The return value, if there is one, is used to determine where its next subchunk is. A return value of 0 signifies that the next subchunk is nigh.
  7. The chunk's subchunks are then loaded.
  8. The chunks initialize method is called.

Definition at line 196 of file ChunkChopper.java.

References debug.

Referenced by loadSceneBase().

    {
        level++;
        while(chunkBuffer.hasRemaining())//hasRemaining() evaluates limit - position.
        {
            chunkID         = new Integer(chunkBuffer.getShort());
            Chunk chunk     = parentChunk.getSubChunk(chunkID);

            int currentChunkLength     = chunkBuffer.getInt() - 6;  //length includes this 6 byte header.
            int finishedPosition       = chunkBuffer.position() + currentChunkLength;
            int previousLimit          = chunkBuffer.limit();
            chunkBuffer.limit(chunkBuffer.position() + currentChunkLength);

            if(debug) {
                debug(parentChunk, level, chunkID, currentChunkLength, chunkBuffer.position(), chunkBuffer.limit());
            }
            if(chunk != null && currentChunkLength != 0) {
                try {
                    chunk.loadData(this);
                }
                catch(BufferUnderflowException e){
                    chunkBuffer.position(finishedPosition);
                    chunkBuffer.limit(previousLimit);
                    throw new CannotChopException(" tried to read too much data from the buffer. Trying to recover.", e);
                }
                try {
                    if(chunkBuffer.hasRemaining()) {
                        loadSubChunks(chunk, level);
                    }
                    chunk.initialize(this);
                }
                catch(CannotChopException e){
                    logger.log(Level.SEVERE, chunk.toString() + "Trying to continue");
                }
            } 

            chunkBuffer.position(finishedPosition);
            chunkBuffer.limit(previousLimit);
        }
    }


Generated by  Doxygen 1.6.0   Back to index