Squeak Class Documentation category index | class index  
 
ThreeDSParser
  category: Balloon3D-Import
  superclass: Object
  subclasses:

(c) 1996-97 Bert Freudenberg, neŽ Schönwälder, (bert@isg.cs.uni-magdeburg.de) University of Magdeburg, Germany.

Modified 1998 by Andreas Raab (Andreas.Raab@disney.com) for Squeak.

Class ThreeDSParser reads a 3DS File (AutoDesk 3D Studio's native format). It isn't a real parser at all, I chose this name for consistency with the other scene parser classes. For description of 3DS format I used "The Unofficial 3DStudio 3DS File Format v1.0" by Jeff Lewis and the "3ds_bin" by Jim Pitts et. al., see #chunkDocumentation on the Class side.

Instance Variables:
source <Stream> binary stream on source file
chunkPos <Integer> File position of current chunk
chunkID <Integer> ID of current cunk
chunkLen <Integer> Length of current chunk
indent <Integer | nil> If nil, no log is written. Otherwise the current nesting level.
informer <Block> A block taking the progress value while reading
classSpec <Dictionary | nil> Specification of the classes to construct.

Class Variables:
ChunkDescriptions <Dictionary of: ThreeDSChunkDescription>
For debugging only. ChunkDescriptions generated from the documentation
DefaultSpec <Dictionary | nil>
The default class specification to use.

instance methods
  accessing
  informer
informer:

  construction classes
  cameraClass
materialClass
meshObjectClass
pointLightClass
sceneClass
specAt:
specAt:ifAbsent:
splineVertexClass
spotLightClass
textureArrayClass
vertexArrayClass

  dispatching
  recognize:
recognize:as:
recognize:do:
recognize:do:inChunksUpTo:

  executing
  indexed:do:do:
indexed:do:do:do:
indexed:doBlocks:

  initialize-release
  classSpec:
parse:
parse:using:
parseFileNamed:
parseFileNamed:using:
parseStream:

  private
  chunkHeader
logUnreadBytes:
printChunkInfo

  private-dispatching
  dispatchID:in:
findID:in:
getSelectorFor:in:
makeResult:for:in:

  private-util
  chunkDescriptionFor:

  reading
  scene

  reading-keyframe
  keyframeData
keyframeHeader
node
nodeHeader
trackCString
trackCollect:
trackColor
trackFlag
trackFloat
trackRotation
trackVector

  reading-material
  materialColor
materialEntry
textureMap
textureVertices
verticalGradient

  reading-mesh
  camera
light
meshData
namedObject
smoothList
spot
triList
triMesh
vertexList

  reading-primitives
  cString
color24
colorFloat
container
flag
float
long
matrix
percentageChunk
short
twoFloats
twoLongs
twoShorts
twoVector3
uLong
uShort
vector3

class methods
  class initialization
  defaultSpec
defaultSpec:
initialize
initializeB3D

  instance creation
  parse:
parse:using:
parseFileNamed:
parseFileNamed:using:

  utilities
  chunkDescriptionFor:
chunkDescriptions
chunkDocumentation
clearChunkDescriptions
initializeChunkDescriptions

instance methods
  accessing top  
 

informer


 

informer:


  construction classes top  
 

cameraClass


 

materialClass


 

meshObjectClass


 

pointLightClass


 

sceneClass


 

specAt:


 

specAt:ifAbsent:


 

splineVertexClass


 

spotLightClass


 

textureArrayClass


 

vertexArrayClass


  dispatching top  
 

recognize:

Answer first item found


 

recognize:as:

Collect all items in a new resultCollectionClass


 

recognize:do:

Provide default end position


 

recognize:do:inChunksUpTo:

Scan chunks up to endPos, process those mentioned in dispatcherArray


  executing top  
 

indexed:do:do:

According to item's key evaluate one of the blocks with item's value


 

indexed:do:do:do:

According to item's key evaluate one of the blocks with item's value


 

indexed:doBlocks:

According to item's key evaluate one of the blocks with item's value


  initialize-release top  
 

classSpec:


 

parse:

Read the 3DS file from the given stream


 

parse:using:

Read the 3DS file from the given stream


 

parseFileNamed:

Read the 3DS file from the given stream


 

parseFileNamed:using:

Read the 3DS file from the given stream


 

parseStream:

Read the 3DS file from the given stream


  private top  
 

chunkHeader

Read header of a chunk, store in instance variables


 

logUnreadBytes:


 

printChunkInfo


  private-dispatching top  
 

dispatchID:in:

Look for id in dispatcher, and process it, if found


 

findID:in:

Return index of id in dispatcher, nil if not found


 

getSelectorFor:in:

Return method selector


 

makeResult:for:in:

Answer Association if needed


  private-util top  
 

chunkDescriptionFor:

Answer chunk description for id


  reading top  
 

scene

Whole file


  reading-keyframe top  
 

keyframeData

Subchunk of scene


 

keyframeHeader

Subchunk of keyframeData


 

node

Subchunk of keyframeData


 

nodeHeader

Subchunk of node


 

trackCString

Read keyframes defining a string (morph)


 

trackCollect:

Read keyframes, return Array with values of aBlock


 

trackColor

Read keyframes interpolating a color


 

trackFlag

Read keyframes for a flag (hide)


 

trackFloat

Read keyframes interpolating a float (hotspot, falloff, roll, etc.)


 

trackRotation

Read keyframes interpolating a rotation


 

trackVector

Read keyframes interpolating a vector (position, scale)


  reading-material top  
 

materialColor


 

materialEntry

Globally defined materials


 

textureMap


 

textureVertices

Subchunk of tri object


 

verticalGradient


  reading-mesh top  
 

camera

Subchunk of namedObject


 

light

Subchunk of namedObject


 

meshData

Subchunk of scene


 

namedObject

Subchunk of meshData


 

smoothList

Optional subchunk of faceList


 

spot

Subchunk of light


 

triList

Subchunk of triMesh


 

triMesh

Subchunk of namedObject


 

vertexList

Subchunk of triMesh


  reading-primitives top  
 

cString

Generic Subchunk containing a cstring


 

color24

Color from 3 bytes


 

colorFloat

Color from 3 floats


 

container

Generic container chunk


 

flag

Generic Subchunk -- if found, answer true


 

float

Generic Subchunk containing a float


 

long

Generic Subchunk containing a long


 

matrix

float matrix[4][3]


 

percentageChunk


 

short

Generic Subchunk containing a short


 

twoFloats

Generic Subchunk containing two floats


 

twoLongs

Generic Subchunk containing two longs


 

twoShorts

Generic Subchunk containing two shorts


 

twoVector3

Generic Subchunk containing two points


 

uLong

Generic Subchunk containing a long


 

uShort

Generic Subchunk containing a short


 

vector3

Generic Subchunk containing a vector


class methods
  class initialization top  
 

defaultSpec

The default spec is a dictionary with
#camera -> CameraClassName (e.g., #B3DCamera3DS)
#material -> MaterialClassName (e.g., #B3DMaterial3DS)
#meshObject -> MeshObjectClassName (e.g., #B3DObject3DS)
#pointLight -> PointLightClassName (e.g., #B3DPositionalLight)
#spotLight -> SpotLightClassName (e.g., #B3DSpotLight)
#scene -> SceneClassName (e.g., #B3DScene3DS)
#splineVertex -> SplineVertexClass (e.g., B3DSplineVertex3DS)
all responding to #from3DS: aDictionary and
#vertexArray -> VertexArrayClassName (e.g., #B3DVector3Array)
#textureArray -> TextureArrayClassName (e.g., #B3DTexture2Array)
for constructing large arrays of vertex / texture coordinates
(responding to the standard array messages #new: #at: and #at:put:)


 

defaultSpec:

ThreeDSParser defaultSpec


 

initialize

ThreeDSParser initialize


 

initializeB3D

ThreeDSParser initializeB3D


  instance creation top  
 

parse:

Answer a dictionary of name->RenderObject associations


 

parse:using:

Answer a dictionary of name->RenderObject associations


 

parseFileNamed:

Answer a dictionary of name->RenderObject associations


 

parseFileNamed:using:

Answer a dictionary of name->RenderObject associations


  utilities top  
 

chunkDescriptionFor:

Answer chunk description for id


 

chunkDescriptions


 

chunkDocumentation

From: The Unofficial 3DStudio 3DS File Format v1.0 by Jeff Lewis


 

clearChunkDescriptions

Reset Class variable ChunkDescriptions


 

initializeChunkDescriptions

Initialize Class variable ChunkDescriptions from the documentation