Class: Lightwave::LightwaveObject::Scene

Inherits:
ChunkReader show all
Defined in:
lib/lightwave.rb

Instance Attribute Summary collapse

Attributes inherited from ChunkReader

#errors

Instance Method Summary collapse

Methods inherited from ChunkReader

chunk_map, #make_defaults, #process_tags, set_chunk_length

Constructor Details

#initialize(string) ⇒ Scene

Returns a new instance of Scene.



476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/lightwave.rb', line 476

def initialize(string)
  init_lists

  ext_reader = LightwaveStringIO.new(string)
  discard, reader = ext_reader.read_chunk
  @type = reader.read_type

  @current_layer = VCR.new 

  super(reader)
  read_scene_bbox
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



466
467
468
# File 'lib/lightwave.rb', line 466

def method_missing(sym, *args, &block)
  @current_layer.send(sym, *args, &block)
end

Instance Attribute Details

#clipsObject

Returns the value of attribute clips.



446
447
448
# File 'lib/lightwave.rb', line 446

def clips
  @clips
end

#current_layerObject

Returns the value of attribute current_layer.



445
446
447
# File 'lib/lightwave.rb', line 445

def current_layer
  @current_layer
end

#descriptionObject

Returns the value of attribute description.



448
449
450
# File 'lib/lightwave.rb', line 448

def description
  @description
end

#filenameObject

Returns the value of attribute filename.



439
440
441
# File 'lib/lightwave.rb', line 439

def filename
  @filename
end

#iconObject

Returns the value of attribute icon.



444
445
446
# File 'lib/lightwave.rb', line 444

def icon
  @icon
end

#layersObject

list of layers



442
443
444
# File 'lib/lightwave.rb', line 442

def layers
  @layers
end

#maxObject

Returns the value of attribute max.



449
450
451
# File 'lib/lightwave.rb', line 449

def max
  @max
end

#minObject

Returns the value of attribute min.



449
450
451
# File 'lib/lightwave.rb', line 449

def min
  @min
end

#surfacesObject

Returns the value of attribute surfaces.



443
444
445
# File 'lib/lightwave.rb', line 443

def surfaces
  @surfaces
end

#tagsObject

list of strings



441
442
443
# File 'lib/lightwave.rb', line 441

def tags
  @tags
end

#textObject

Returns the value of attribute text.



447
448
449
# File 'lib/lightwave.rb', line 447

def text
  @text
end

#typeObject

Version



440
441
442
# File 'lib/lightwave.rb', line 440

def type
  @type
end

Instance Method Details

#init_listsObject



469
470
471
472
473
474
475
# File 'lib/lightwave.rb', line 469

def init_lists 
  @errors = []
  @layers = []
  @surfaces = {} 
  @tags = []
  @clips = {}
end

#read_clip(strio) ⇒ Object



498
499
500
# File 'lib/lightwave.rb', line 498

def read_clip(strio)
  @clips[strio.read_u4] = Clip.new(strio)
end

#read_layer(strio) ⇒ Object



501
502
503
504
505
506
507
508
# File 'lib/lightwave.rb', line 501

def read_layer(strio)
  new_layer = GeomLayer.new(self,strio)
  if @current_layer.respond_to? :play_back_to
    @current_layer.play_back_to new_layer
  end
  @layers << new_layer
  @current_layer = new_layer
end

#read_scene_bboxObject



488
489
490
491
492
493
494
495
496
497
# File 'lib/lightwave.rb', line 488

def read_scene_bbox
  @min = @layers[0].min.dup
  @max = @layers[0].max.dup
  @layers.each do |layer|
    (0..2).each do |i|
      @min[i] = layer.min[i] < @min[i] ? layer.min[i] : @min[i]
      @max[i] = layer.max[i] > @max[i] ? layer.max[i] : @max[i]
    end
  end
end

#read_surface(strio) ⇒ Object



509
510
511
512
513
# File 'lib/lightwave.rb', line 509

def read_surface(strio)
  s = Surface.new(strio)
  @surfaces[s.name] = s
 # @errors += s.errors
end