Class: MD2

Inherits:
Object
  • Object
show all
Includes:
Sizes
Defined in:
lib/md2.rb,
lib/md2/normals.rb

Defined Under Namespace

Modules: Errors Classes: Command, Frame, Header, Normals, Triangle, Vertex

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ MD2

Returns a new instance of MD2.



25
26
27
# File 'lib/md2.rb', line 25

def initialize(path)
  load(path)
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



18
19
20
# File 'lib/md2.rb', line 18

def base_path
  @base_path
end

#framesObject (readonly)

Returns the value of attribute frames.



18
19
20
# File 'lib/md2.rb', line 18

def frames
  @frames
end

#gl_commandsObject (readonly)

Returns the value of attribute gl_commands.



18
19
20
# File 'lib/md2.rb', line 18

def gl_commands
  @gl_commands
end

#headerObject (readonly)

Returns the value of attribute header.



17
18
19
# File 'lib/md2.rb', line 17

def header
  @header
end

#skinsObject (readonly)

Returns the value of attribute skins.



18
19
20
# File 'lib/md2.rb', line 18

def skins
  @skins
end

#texcoordsObject (readonly)

Returns the value of attribute texcoords.



18
19
20
# File 'lib/md2.rb', line 18

def texcoords
  @texcoords
end

#trianglesObject (readonly)

Returns the value of attribute triangles.



18
19
20
# File 'lib/md2.rb', line 18

def triangles
  @triangles
end

Instance Method Details

#to_jsonObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/md2.rb', line 29

def to_json
  raise "Can't convert to json unless you've already activated the 'json' gem!" if !defined?(JSON)
  
  {
    :header => @header,
    :frames => @frames.collect { |f| f.reduce },
    :triangles => @triangles,
    :texcoords => @texcoords,
    :skins => @skins,
    :gl_commands => @gl_commands,
    :base_path => @base_path
  }.to_json
end