Class: MD2::Frame
- Inherits:
-
Object
- Object
- MD2::Frame
- Defined in:
- lib/md2/frame.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The name of this frame (string).
-
#normal_indices ⇒ Object
readonly
The indices of the normal vectors.
-
#scale ⇒ Object
readonly
Float containing X, Y, Z scale values.
-
#translation ⇒ Object
readonly
Float containing X, Y, Z translations.
-
#vertices ⇒ Object
readonly
The vertices for this frame.
Instance Method Summary collapse
-
#initialize(frame_data) ⇒ Frame
constructor
A new instance of Frame.
- #reduce ⇒ Object
Constructor Details
#initialize(frame_data) ⇒ Frame
Returns a new instance of Frame.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/md2/frame.rb', line 27 def initialize(frame_data) @scale = [] @translation = [] @vertices = [] @normal_indices = [] # 3 floats (scale), 3 floats (transl), 16 bytes (name), and variable num of unsigned chars (vertices) frame_data = frame_data.unpack("f3f3a16C*") 3.times { @scale << frame_data.shift } 3.times { @translation << frame_data.shift } @name = frame_data.shift.strip while !frame_data.empty? packed_vertex = MD2::Vertex.new(frame_data.shift, frame_data.shift, frame_data.shift) @vertices << unpack_vertex_data(packed_vertex) @normal_indices << frame_data.shift end end |
Instance Attribute Details
#name ⇒ Object (readonly)
The name of this frame (string)
9 10 11 |
# File 'lib/md2/frame.rb', line 9 def name @name end |
#normal_indices ⇒ Object (readonly)
The indices of the normal vectors.
15 16 17 |
# File 'lib/md2/frame.rb', line 15 def normal_indices @normal_indices end |
#scale ⇒ Object (readonly)
Float containing X, Y, Z scale values
3 4 5 |
# File 'lib/md2/frame.rb', line 3 def scale @scale end |
#translation ⇒ Object (readonly)
Float containing X, Y, Z translations
6 7 8 |
# File 'lib/md2/frame.rb', line 6 def translation @translation end |
#vertices ⇒ Object (readonly)
The vertices for this frame.
12 13 14 |
# File 'lib/md2/frame.rb', line 12 def vertices @vertices end |
Instance Method Details
#reduce ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/md2/frame.rb', line 17 def reduce { :name => name, :translation => @translation, :scale => @scale, :vertices => packed_vertices, :normal_indices => normal_indices.flatten } end |