Class: Lightwave::LightwaveObject::GeomLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/lightwave.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scene, strio) ⇒ GeomLayer

Returns a new instance of GeomLayer.



423
424
425
426
427
428
429
430
# File 'lib/lightwave.rb', line 423

def initialize(scene, strio)
  strio.read(4) # discard number and flags for now
  @pivot = strio.read_vector
  @name = strio.read_string
  @parent = strio.eof? ? nil : strio.read_u2
  @points = []
  @uvmaps = {}
end

Instance Attribute Details

#childrenObject

Not actually used here. Used by the lw2xaml code.



363
364
365
# File 'lib/lightwave.rb', line 363

def children
  @children
end

#hiddenObject

boolean



354
355
356
# File 'lib/lightwave.rb', line 354

def hidden
  @hidden
end

#maxObject

Bounding box points.



359
360
361
# File 'lib/lightwave.rb', line 359

def max
  @max
end

#minObject

Bounding box points.



359
360
361
# File 'lib/lightwave.rb', line 359

def min
  @min
end

#morphsObject

Returns the value of attribute morphs.



362
363
364
# File 'lib/lightwave.rb', line 362

def morphs
  @morphs
end

#nameObject

Label



356
357
358
# File 'lib/lightwave.rb', line 356

def name
  @name
end

#numberObject

an ID



353
354
355
# File 'lib/lightwave.rb', line 353

def number
  @number
end

#parentObject

Another layer number or nil.



357
358
359
# File 'lib/lightwave.rb', line 357

def parent
  @parent
end

#pivotObject

Vector of the layer origin



355
356
357
# File 'lib/lightwave.rb', line 355

def pivot
  @pivot
end

#pointsObject

Returns the value of attribute points.



358
359
360
# File 'lib/lightwave.rb', line 358

def points
  @points
end

#polygonsObject

Returns the value of attribute polygons.



360
361
362
# File 'lib/lightwave.rb', line 360

def polygons
  @polygons
end

#uvmapsObject

Returns the value of attribute uvmaps.



361
362
363
# File 'lib/lightwave.rb', line 361

def uvmaps
  @uvmaps
end

Instance Method Details

#read_bbox(strio) ⇒ Object



377
378
379
380
# File 'lib/lightwave.rb', line 377

def read_bbox(strio)
  @min = strio.read_vector
  @max = strio.read_vector   
end

#read_morph(strio) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/lightwave.rb', line 400

def read_morph(strio)
  @morphs ||= {}
  dimension = strio.read_u2
  name = strio.read_string
  map = {}
  while !strio.eof?
    index = strio.read_vx
    vector = []
    dimension.times do vector << strio.read_float end
    map[@zero_offset + index] = vector
  end
  @morphs[name] = map
end

#read_points(strio) ⇒ Object



381
382
383
384
385
386
# File 'lib/lightwave.rb', line 381

def read_points(strio)
  @zero_offset = @points.length
  while !strio.eof?
    @points << strio.read_vector
  end
end

#read_polygons(strio) ⇒ Object



373
374
375
376
# File 'lib/lightwave.rb', line 373

def read_polygons(strio)
  @polygons ||= Polygons.new
  @polygons << strio
end

#read_ptag(strio) ⇒ Object



364
365
366
367
368
369
370
371
372
# File 'lib/lightwave.rb', line 364

def read_ptag(strio)
  type = strio.read_type
  while !strio.eof?
    vertex_id = strio.read_vx
    tag_id = strio.read_u2
    @polygons.latest[vertex_id].surface_id = tag_id
    @polygons.surface_groups[tag_id] << @polygons.latest[vertex_id]
  end
end

#read_uvmap(strio) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/lightwave.rb', line 387

def read_uvmap(strio)
  @uvmaps ||= {}
  dimension = strio.read_u2
  name = strio.read_string
  map = {}
  while !strio.eof?
    index = strio.read_vx
    vector = []
    dimension.times do vector << strio.read_float end
    map[@zero_offset + index] = vector
  end
  @uvmaps[name] = map
end

#read_vmap(strio) ⇒ Object



413
414
415
416
417
418
419
420
421
422
# File 'lib/lightwave.rb', line 413

def read_vmap(strio)
  type = strio.read_type
  case type
  when 'TXUV'
    read_uvmap(strio)
  when 'MORF'
    read_morph(strio)

  end
end