Class: Teien::BaseObjectManagerBase

Inherits:
Object
  • Object
show all
Includes:
Dispatcher
Defined in:
lib/teien/base_object/base_object_manager_base.rb

Overview

This is a top object of 3D world.

Direct Known Subclasses

BaseObjectManager, BaseObjectManagerProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dispatcher

#notify, #notify_reversely, #register_receiver

Constructor Details

#initializeBaseObjectManagerBase

script_klass

: set a user define class.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/teien/base_object/base_object_manager_base.rb', line 26

def initialize()
  super()

  puts "initialize base_object_manager_base"

  @event_router = Teien::get_component("event_router")
  @event_router.register_receiver(self)

  @physics = Physics.new(self)

  @objects = {}
  @object_num = 0

  @quit = false
  @debug_draw = false

  @resources_cfg = nil
  @plugins_cfg = nil

  # environment value
  @gravity = nil
  @ambient_light_color = nil
  @sky_dome = nil
end

Instance Attribute Details

#ambient_light_colorObject

Returns the value of attribute ambient_light_color.



21
22
23
# File 'lib/teien/base_object/base_object_manager_base.rb', line 21

def ambient_light_color
  @ambient_light_color
end

#gravityObject

Returns the value of attribute gravity.



20
21
22
# File 'lib/teien/base_object/base_object_manager_base.rb', line 20

def gravity
  @gravity
end

#objectsObject

Returns the value of attribute objects.



18
19
20
# File 'lib/teien/base_object/base_object_manager_base.rb', line 18

def objects
  @objects
end

#physicsObject

Returns the value of attribute physics.



17
18
19
# File 'lib/teien/base_object/base_object_manager_base.rb', line 17

def physics
  @physics
end

#plugins_cfgObject

Returns the value of attribute plugins_cfg.



15
16
17
# File 'lib/teien/base_object/base_object_manager_base.rb', line 15

def plugins_cfg
  @plugins_cfg
end

#resources_cfgObject

Returns the value of attribute resources_cfg.



14
15
16
# File 'lib/teien/base_object/base_object_manager_base.rb', line 14

def resources_cfg
  @resources_cfg
end

Instance Method Details

#check_collision(objectA, objectB) ⇒ Object



97
98
99
100
# File 'lib/teien/base_object/base_object_manager_base.rb', line 97

def check_collision(objectA, objectB)
  result = @physics.contact_pair_test(objectA.rigid_body, objectB.rigid_body)
  return result.collided?()
end

#create_object(name, object_info, physics_info = nil) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/teien/base_object/base_object_manager_base.rb', line 76

def create_object(name, object_info, physics_info = nil)
  if (@objects[name])
    #raise RuntimeError, "There is a object with the same name (#{obj.name})"
    puts "There is a object with the same name (#{name})"
    return @objects[name]
  else
    obj = BaseObject.new()
    obj.name = name
    obj.object_info = object_info
    obj.physics_info = physics_info

    obj.manager = self
    @objects[obj.name] = obj
    obj.id = @object_num
    @object_num += 1
    @physics.add_physics_object(obj)
    notify(:create_object, obj)
    return obj
  end
end

#quitObject

quit the current running process.



103
104
105
# File 'lib/teien/base_object/base_object_manager_base.rb', line 103

def quit()
  @quit = true
end

#set_ambient_light(color) ⇒ Object

set the ambient light of the world.

color

: set a color(Color).



66
67
68
69
# File 'lib/teien/base_object/base_object_manager_base.rb', line 66

def set_ambient_light(color)
  @ambient_light_color = color
  notify(:set_ambient_light, color)
end

#set_gravity(grav) ⇒ Object

set the gravity of the world.

grav

: set a vector(Vector3D) as the gravity.



56
57
58
59
# File 'lib/teien/base_object/base_object_manager_base.rb', line 56

def set_gravity(grav)
  @gravity = grav
  @physics.set_gravity(grav)
end

#set_sky_dome(enable, materialName, curvature = 10, tiling = 8, distance = 4000) ⇒ Object



71
72
73
74
# File 'lib/teien/base_object/base_object_manager_base.rb', line 71

def set_sky_dome(enable, materialName, curvature = 10, tiling = 8, distance = 4000)
  @sky_dome = SkyDome.new(enable, materialName, curvature, tiling, distance)
  notify(:set_sky_dome, enable, materialName, curvature, tiling, distance)
end