Class: Teien::LightObjectInfo

Inherits:
ObjectInfo show all
Defined in:
lib/teien/ui/std_objects/light_object_info.rb,
lib/teien/base_object/std_objects/light_object_info.rb

Constant Summary collapse

POINT =
Ogre::Light::LT_POINT
DIRECTIONAL =
Ogre::Light::LT_DIRECTIONAL
SPOTLIGHT =
Ogre::Light::LT_SPOTLIGHT

Instance Attribute Summary collapse

Attributes inherited from ObjectInfo

#use_physics

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, diffuse_color = Color.new(1.0, 1.0, 1.0), specular_color = Color.new(0.25, 0.25, 0), direction = Vector3D.new( -1, -1, -1 )) ⇒ LightObjectInfo

Returns a new instance of LightObjectInfo.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 15

def initialize(type,
               diffuse_color = Color.new(1.0, 1.0, 1.0),
               specular_color = Color.new(0.25, 0.25, 0),
               direction = Vector3D.new( -1, -1, -1 ))
  super()
  @usePhysics = false
  @type = type
  @diffuse_color = diffuse_color
  @specular_color = specular_color
  @direction = direction
end

Instance Attribute Details

#diffuse_colorObject

Returns the value of attribute diffuse_color.



11
12
13
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 11

def diffuse_color
  @diffuse_color
end

#directionObject

Returns the value of attribute direction.



13
14
15
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 13

def direction
  @direction
end

#specular_colorObject

Returns the value of attribute specular_color.



12
13
14
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 12

def specular_color
  @specular_color
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 10

def type
  @type
end

Class Method Details

.create_physics_object(obj, physics) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/teien/base_object/std_objects/light_object_info.rb', line 27

def self.create_physics_object(obj, physics)
  physics_object = PhysicsObject.new(physics)
  cShape = Bullet::BtSphereShape.new(0.1)
  inertia = Bullet::BtVector3.new()
  cShape.calculate_local_inertia(0, inertia)
  obj.physics_info = PhysicsInfo.new(0)
  physics_object.set_rigid_body(obj, cShape, inertia)
  return physics_object
end

.create_view_object(obj, view) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/teien/ui/std_objects/light_object_info.rb', line 7

def self.create_view_object(obj, view)
  entity = view.scene_mgr.create_light(obj.name)
  entity.set_type(obj.object_info.type)
  entity.set_diffuse_colour(obj.object_info.diffuse_color)
  entity.set_specular_colour(obj.object_info.specular_color)
  entity.set_direction(Vector3D.to_ogre(obj.object_info.direction))

  view_object = ViewObject.new(@view)
  view_object.entity = entity

  return view_object
end