Class: MD2::Header
- Inherits:
-
Object
- Object
- MD2::Header
- Defined in:
- lib/md2/header.rb
Constant Summary collapse
- LENGTH =
The length of an MD2 header is fixed.
68
- MD2_IDENT =
The magic number that all MD2 headers start with. This is equal to “IDP2” in bytes.
((?2.ord<<24) + (?P.ord<<16) + (?D.ord<<8) + ?I.ord)
- MD2_VERSION =
The MD2 file format version. This is always 8.
8
Instance Attribute Summary collapse
-
#eof_offset ⇒ Object
readonly
Returns the value of attribute eof_offset.
-
#frame_count ⇒ Object
readonly
Returns the value of attribute frame_count.
-
#frame_data_offset ⇒ Object
readonly
Returns the value of attribute frame_data_offset.
-
#frame_size ⇒ Object
readonly
Returns the value of attribute frame_size.
-
#gl_command_count ⇒ Object
readonly
Returns the value of attribute gl_command_count.
-
#gl_command_offset ⇒ Object
readonly
Returns the value of attribute gl_command_offset.
-
#skin_count ⇒ Object
readonly
Returns the value of attribute skin_count.
-
#skin_height ⇒ Object
readonly
Returns the value of attribute skin_height.
-
#skin_name_offset ⇒ Object
readonly
Returns the value of attribute skin_name_offset.
-
#skin_width ⇒ Object
readonly
Returns the value of attribute skin_width.
-
#texture_coord_count ⇒ Object
readonly
Returns the value of attribute texture_coord_count.
-
#texture_coord_offset ⇒ Object
readonly
Returns the value of attribute texture_coord_offset.
-
#triangle_count ⇒ Object
readonly
Returns the value of attribute triangle_count.
-
#triangle_offset ⇒ Object
readonly
Returns the value of attribute triangle_offset.
-
#vertex_count ⇒ Object
readonly
Returns the value of attribute vertex_count.
Instance Method Summary collapse
-
#initialize(file) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(file) ⇒ Header
Returns a new instance of Header.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/md2/header.rb', line 16 def initialize(file) header = file.sysread(LENGTH).unpack("i17") raise MD2::Errors::InvalidFile, "Header identifier did not match" unless header.shift == MD2_IDENT raise MD2::Errors::InvalidVersion, "File format version mismatch" unless header.shift == MD2_VERSION @skin_width = header.shift @skin_height = header.shift @frame_size = header.shift @skin_count = header.shift @vertex_count = header.shift @texture_coord_count = header.shift @triangle_count = header.shift @gl_command_count = header.shift @frame_count = header.shift @skin_name_offset = header.shift @texture_coord_offset = header.shift @triangle_offset = header.shift @frame_data_offset = header.shift @gl_command_offset = header.shift @eof_offset = header.shift end |
Instance Attribute Details
#eof_offset ⇒ Object (readonly)
Returns the value of attribute eof_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def eof_offset @eof_offset end |
#frame_count ⇒ Object (readonly)
Returns the value of attribute frame_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def frame_count @frame_count end |
#frame_data_offset ⇒ Object (readonly)
Returns the value of attribute frame_data_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def frame_data_offset @frame_data_offset end |
#frame_size ⇒ Object (readonly)
Returns the value of attribute frame_size.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def frame_size @frame_size end |
#gl_command_count ⇒ Object (readonly)
Returns the value of attribute gl_command_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def gl_command_count @gl_command_count end |
#gl_command_offset ⇒ Object (readonly)
Returns the value of attribute gl_command_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def gl_command_offset @gl_command_offset end |
#skin_count ⇒ Object (readonly)
Returns the value of attribute skin_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def skin_count @skin_count end |
#skin_height ⇒ Object (readonly)
Returns the value of attribute skin_height.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def skin_height @skin_height end |
#skin_name_offset ⇒ Object (readonly)
Returns the value of attribute skin_name_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def skin_name_offset @skin_name_offset end |
#skin_width ⇒ Object (readonly)
Returns the value of attribute skin_width.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def skin_width @skin_width end |
#texture_coord_count ⇒ Object (readonly)
Returns the value of attribute texture_coord_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def texture_coord_count @texture_coord_count end |
#texture_coord_offset ⇒ Object (readonly)
Returns the value of attribute texture_coord_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def texture_coord_offset @texture_coord_offset end |
#triangle_count ⇒ Object (readonly)
Returns the value of attribute triangle_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def triangle_count @triangle_count end |
#triangle_offset ⇒ Object (readonly)
Returns the value of attribute triangle_offset.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def triangle_offset @triangle_offset end |
#vertex_count ⇒ Object (readonly)
Returns the value of attribute vertex_count.
11 12 13 |
# File 'lib/md2/header.rb', line 11 def vertex_count @vertex_count end |