Module: Shattered::View::ClassMethods

Defined in:
lib/shattered_view/shattered_view.rb

Instance Method Summary collapse

Instance Method Details

#light(name, type = nil, options = {}) ⇒ Object

Any view can create a light.

There are 4 types of possible lights.
 Ambient Light - this type of light lights everything in the scene equally.
 Example:   light :sun, :ambient => [1,1,1]

 Point Light - this type of light emanates from a point in space and lights all 
             directions equally.
 Example:  light :fireplace, :position => [0,-5,20], :diffuse => [1,0.5,0.5], :specular => [1,0,0], :attenuation => [8000,0,4,0.3]  
 Parameters:
 position:: the x,y,z position or vector position
 diffuse:: the r,g,b value of the diffuse color 
 specular:: the r,g,b value of the specular color
 attenuation::  arguments are range, constant, linear, quadratic 
   range is how far the light will extend
   constant 	The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation
   linear 	The linear factor in the attenuation formula: 1 means attenuate evenly over the distance
   quadratic 	The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula.

 Directional Light - this light is like the positional light, except instead of position it has only direction
 Example:  light :sun, :direction => [0,-1,-1], :diffuse => [1,1,1], :specular => [1,1,1]
 direction::  the direction light emanates from
 other:: same as point light above.

 Note: The following type of light is not currently implemented in shattered.
 Spotlight - this light has both a direction and a position, as well as other factors.
 Example:  light :flashlight...


58
59
60
# File 'lib/shattered_view/shattered_view.rb', line 58

def light(name, type = nil, options = {})
  before_init_call :dsl_create, :metalight, name, type, options
end

#mesh(name, options = {}) ⇒ Object

Meshes are the foundation for your world.

They tie in to Ogre’s .mesh file format, and display a 3d object onto the screen.

class DirtyRubyView
  mesh "dirty_ruby", :position => v(0,0,1)
end


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

def mesh(name, options = {})
	before_init_call :dsl_create, :mesh, name, options
end