Class: Lightwave::LightwaveObject::GeomLayer
- Inherits:
-
Object
- Object
- Lightwave::LightwaveObject::GeomLayer
- Defined in:
- lib/lightwave.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Not actually used here.
-
#hidden ⇒ Object
boolean.
-
#max ⇒ Object
Bounding box points.
-
#min ⇒ Object
Bounding box points.
-
#morphs ⇒ Object
Returns the value of attribute morphs.
-
#name ⇒ Object
Label.
-
#number ⇒ Object
an ID.
-
#parent ⇒ Object
Another layer number or nil.
-
#pivot ⇒ Object
Vector of the layer origin.
-
#points ⇒ Object
Returns the value of attribute points.
-
#polygons ⇒ Object
Returns the value of attribute polygons.
-
#uvmaps ⇒ Object
Returns the value of attribute uvmaps.
Instance Method Summary collapse
-
#initialize(scene, strio) ⇒ GeomLayer
constructor
A new instance of GeomLayer.
- #read_bbox(strio) ⇒ Object
- #read_morph(strio) ⇒ Object
- #read_points(strio) ⇒ Object
- #read_polygons(strio) ⇒ Object
- #read_ptag(strio) ⇒ Object
- #read_uvmap(strio) ⇒ Object
- #read_vmap(strio) ⇒ Object
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
#children ⇒ Object
Not actually used here. Used by the lw2xaml code.
363 364 365 |
# File 'lib/lightwave.rb', line 363 def children @children end |
#hidden ⇒ Object
boolean
354 355 356 |
# File 'lib/lightwave.rb', line 354 def hidden @hidden end |
#max ⇒ Object
Bounding box points.
359 360 361 |
# File 'lib/lightwave.rb', line 359 def max @max end |
#min ⇒ Object
Bounding box points.
359 360 361 |
# File 'lib/lightwave.rb', line 359 def min @min end |
#morphs ⇒ Object
Returns the value of attribute morphs.
362 363 364 |
# File 'lib/lightwave.rb', line 362 def morphs @morphs end |
#name ⇒ Object
Label
356 357 358 |
# File 'lib/lightwave.rb', line 356 def name @name end |
#number ⇒ Object
an ID
353 354 355 |
# File 'lib/lightwave.rb', line 353 def number @number end |
#parent ⇒ Object
Another layer number or nil.
357 358 359 |
# File 'lib/lightwave.rb', line 357 def parent @parent end |
#pivot ⇒ Object
Vector of the layer origin
355 356 357 |
# File 'lib/lightwave.rb', line 355 def pivot @pivot end |
#points ⇒ Object
Returns the value of attribute points.
358 359 360 |
# File 'lib/lightwave.rb', line 358 def points @points end |
#polygons ⇒ Object
Returns the value of attribute polygons.
360 361 362 |
# File 'lib/lightwave.rb', line 360 def polygons @polygons end |
#uvmaps ⇒ Object
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 |