teien 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/README.md +7 -5
  2. data/bin/teien +36 -37
  3. data/lib/teien/{smooth_mover.rb → action_model/smooth_moving.rb} +19 -3
  4. data/lib/teien/actor/actor.rb +21 -0
  5. data/{sample/actor/app/helpers/user_event.rb → lib/teien/actor/actor_event.rb} +41 -32
  6. data/lib/teien/actor/actor_factory.rb +20 -0
  7. data/lib/teien/actor/actor_info.rb +7 -0
  8. data/lib/teien/actor/actor_manager.rb +31 -0
  9. data/lib/teien/actor/actor_manager_proxy.rb +72 -0
  10. data/lib/teien/addon/addon.rb +25 -0
  11. data/lib/teien/{animation.rb → animation/animation.rb} +1 -0
  12. data/lib/teien/animation/animation_event.rb +17 -0
  13. data/lib/teien/animation/animation_manager.rb +23 -0
  14. data/lib/teien/animation/animation_manager_proxy.rb +27 -0
  15. data/lib/teien/application/application.rb +43 -0
  16. data/lib/teien/base_object/attachment_info.rb +15 -0
  17. data/lib/teien/{garden_object.rb → base_object/base_object.rb} +43 -52
  18. data/lib/teien/{event.rb → base_object/base_object_event.rb} +9 -12
  19. data/lib/teien/base_object/base_object_manager.rb +57 -0
  20. data/lib/teien/{garden_base.rb → base_object/base_object_manager_base.rb} +22 -31
  21. data/lib/teien/{proxy_garden.rb → base_object/base_object_manager_proxy.rb} +20 -62
  22. data/lib/teien/base_object/object_info.rb +21 -0
  23. data/lib/teien/{physics.rb → base_object/physics.rb} +4 -5
  24. data/lib/teien/{physics_info.rb → base_object/physics_info.rb} +1 -0
  25. data/lib/teien/base_object/physics_object_factory.rb +23 -0
  26. data/lib/teien/base_object/std_objects/box_object_info.rb +42 -0
  27. data/lib/teien/base_object/std_objects/capsule_object_info.rb +44 -0
  28. data/lib/teien/base_object/std_objects/cone_object_info.rb +41 -0
  29. data/lib/teien/base_object/std_objects/cylinder_object_info.rb +44 -0
  30. data/lib/teien/base_object/std_objects/floor_object_info.rb +45 -0
  31. data/lib/teien/base_object/std_objects/light_object_info.rb +40 -0
  32. data/lib/teien/base_object/std_objects/mesh_bb_object_info.rb +42 -0
  33. data/lib/teien/base_object/std_objects/mesh_object_info.rb +62 -0
  34. data/lib/teien/base_object/std_objects/sphere_object_info.rb +38 -0
  35. data/lib/teien/commands/browser_command.rb +46 -0
  36. data/lib/teien/commands/local_command.rb +21 -0
  37. data/lib/teien/commands/server_command.rb +39 -0
  38. data/lib/teien/commands/std_command.rb +71 -0
  39. data/lib/teien/core/client_network.rb +26 -0
  40. data/lib/teien/core/component_manager.rb +11 -0
  41. data/lib/teien/core/core_event.rb +7 -0
  42. data/lib/teien/core/dispatcher.rb +30 -0
  43. data/lib/teien/core/event_router.rb +116 -0
  44. data/lib/teien/core/launcher.rb +31 -0
  45. data/lib/teien/core/network.rb +28 -0
  46. data/lib/teien/{remote_info.rb → core/remote_info.rb} +6 -1
  47. data/lib/teien/core/server_network.rb +23 -0
  48. data/lib/teien/{tools.rb → core/tools.rb} +2 -2
  49. data/lib/teien/{camera.rb → ui/camera.rb} +1 -1
  50. data/lib/teien/{camera_mover.rb → ui/camera_mover.rb} +1 -2
  51. data/lib/teien/ui/std_objects/box_object_info.rb +29 -0
  52. data/lib/teien/ui/std_objects/capsule_object_info.rb +28 -0
  53. data/lib/teien/ui/std_objects/cone_object_info.rb +25 -0
  54. data/lib/teien/ui/std_objects/cylinder_object_info.rb +26 -0
  55. data/lib/teien/ui/std_objects/floor_object_info.rb +34 -0
  56. data/lib/teien/ui/std_objects/light_object_info.rb +23 -0
  57. data/lib/teien/ui/std_objects/mesh_bb_object_info.rb +24 -0
  58. data/lib/teien/ui/std_objects/mesh_object_info.rb +24 -0
  59. data/lib/teien/ui/std_objects/sphere_object_info.rb +26 -0
  60. data/lib/teien/{user_interface.rb → ui/user_interface.rb} +18 -13
  61. data/lib/teien/{view.rb → ui/view.rb} +42 -20
  62. data/lib/teien/ui/view_object.rb +142 -0
  63. data/lib/teien/ui/view_object_factory.rb +23 -0
  64. data/lib/teien/version.rb +1 -1
  65. data/lib/teien.rb +3 -78
  66. data/mods/actor/addons/sinbad/lib/sinbad/sinbad_info.rb +16 -0
  67. data/{sample/actor/app/helpers → mods/actor/addons/sinbad/lib}/sinbad/sinbad_state.rb +14 -39
  68. data/mods/actor/addons/sinbad/lib/sinbad.rb +180 -0
  69. data/mods/actor/apps/browser/browser_application.rb +185 -0
  70. data/mods/actor/apps/common/browser_event.rb +68 -0
  71. data/mods/actor/apps/server/server_application.rb +101 -0
  72. data/{sample/actor/app/ais → mods/actor/commands/ai}/actor_ai.rb +8 -3
  73. data/mods/actor/commands/ai_command.rb +20 -0
  74. data/{sample/actor/config → mods/actor/configs}/plugins.cfg +4 -4
  75. data/{sample/hello_garden/app/controllers/hello_garden_controller.rb → mods/hello_garden/apps/browser/browser_application.rb} +48 -25
  76. data/mods/hello_garden/apps/common/browser_event.rb +58 -0
  77. data/{sample/hello_garden/app/models/hello_garden_model.rb → mods/hello_garden/apps/server/server_application.rb} +35 -26
  78. data/teien.gemspec +3 -1
  79. metadata +114 -55
  80. data/lib/teien/ai.rb +0 -27
  81. data/lib/teien/controller.rb +0 -30
  82. data/lib/teien/dispatcher.rb +0 -22
  83. data/lib/teien/event_router.rb +0 -118
  84. data/lib/teien/garden.rb +0 -91
  85. data/lib/teien/model.rb +0 -34
  86. data/lib/teien/network.rb +0 -108
  87. data/lib/teien/object_info.rb +0 -192
  88. data/lib/teien/physics_object_factory.rb +0 -170
  89. data/lib/teien/synchronizer.rb +0 -26
  90. data/lib/teien/view_object.rb +0 -67
  91. data/lib/teien/view_object_factory.rb +0 -210
  92. data/sample/actor/app/controllers/actor_controller.rb +0 -182
  93. data/sample/actor/app/helpers/sinbad/sinbad.rb +0 -176
  94. data/sample/actor/app/models/actor_model.rb +0 -108
  95. data/sample/hello_garden/app/helpers/user_event.rb +0 -12
  96. /data/lib/teien/{animation_operator.rb → animation/animation_operator.rb} +0 -0
  97. /data/lib/teien/{physics_object.rb → base_object/physics_object.rb} +0 -0
  98. /data/lib/teien/{sky_dome.rb → base_object/sky_dome.rb} +0 -0
  99. /data/lib/teien/{ui_listener.rb → ui/ui_listener.rb} +0 -0
  100. /data/{sample/actor/config → mods/actor/configs}/resources.cfg +0 -0
  101. /data/{sample/hello_garden/config → mods/hello_garden/configs}/plugins.cfg +0 -0
  102. /data/{sample/hello_garden/config → mods/hello_garden/configs}/resources.cfg +0 -0
  103. /data/{sample → mods}/hello_garden/run +0 -0
data/lib/teien/model.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'teien'
2
-
3
- module Teien
4
-
5
- class Model
6
- @@models = Array.new
7
- @@loaded_models = Array.new
8
-
9
- @garden = nil
10
-
11
- def initialize(garden)
12
- @garden = garden
13
- @garden.register_receiver(self)
14
-
15
- =begin
16
- # set config files.
17
- fileDir = File.dirname(File.expand_path(__FILE__))
18
- @garden.plugins_cfg = "#{fileDir}/plugins.cfg"
19
- @garden.resources_cfg = "#{fileDir}/resources.cfg"
20
- =end
21
- end
22
-
23
- def self.inherited(klass)
24
- @@models.push(klass)
25
- end
26
-
27
- def self.load(garden)
28
- @@models.each {|ctl|
29
- @@loaded_models.push(ctl.new(garden))
30
- }
31
- end
32
- end
33
-
34
- end
data/lib/teien/network.rb DELETED
@@ -1,108 +0,0 @@
1
- require 'teien/remote_info'
2
-
3
- module Teien
4
-
5
- class Network < EM::Connection
6
- @@connected_clients = Hash.new
7
- @@garden = nil
8
-
9
- def initialize(garden)
10
- @@garden = garden
11
- end
12
-
13
- def self.connected_clients
14
- @@connected_clients
15
- end
16
-
17
- def post_init
18
- puts "A client has connected."
19
- @@connected_clients[self] = RemoteInfo.new(self)
20
- @@garden.receive_event(Event::ClientConnected.new, self)
21
- end
22
-
23
- def unbind
24
- puts "A client has unbinded."
25
- @@garden.receive_event(Event::ClientUnbinded.new, self)
26
- @@connected_clients.delete(self)
27
- end
28
-
29
- include EM::P::ObjectProtocol
30
-
31
- def receive_object(obj)
32
- @@garden.receive_event(obj, self)
33
- end
34
-
35
- def self.send_all(obj)
36
- @@connected_clients.each_value { |c|
37
- c.connection.send_object(obj)
38
- }
39
- end
40
- end
41
-
42
- =begin
43
- class ServerNetwork < EM::Connection
44
- @@connected_clients = Array.new
45
-
46
- def initialize(event_router)
47
- @event_router = event_router
48
- @event_router.register_receiver(Event::ToControllerGroup, self)
49
- end
50
-
51
- def receive_event(event)
52
- send_all(event)
53
- end
54
-
55
- def post_init
56
- puts "A client has connected."
57
- @@connected_clients.push(self)
58
- @event_router.notify(Event::ClientConnected.new)
59
- end
60
-
61
- def unbind
62
- puts "A client has unbinded."
63
- @@connected_clients.delete(self)
64
- end
65
-
66
- include EM::P::ObjectProtocol
67
-
68
- def receive_object(obj)
69
- @event_router.notify(obj)
70
- # puts "A object is received"
71
- # obj.print
72
- end
73
-
74
- def send_all(obj)
75
- @@connected_clients.each { |c|
76
- c.send_object(obj)
77
- }
78
- end
79
- end
80
-
81
- class ClientNetwork < EM::Connection
82
- def initialize(event_router)
83
- @event_router = event_router
84
- @event_router.register_receiver(Event::ToModelGroup, self)
85
- end
86
-
87
- def receive_event(event)
88
- send_object(event)
89
- end
90
-
91
- def connection_completed
92
- puts "The connection is completed."
93
- end
94
-
95
- def unbind
96
- puts "The connection is closed."
97
- end
98
-
99
- include EM::P::ObjectProtocol
100
-
101
- def receive_object(obj)
102
- @event_router.notify(obj)
103
- end
104
- end
105
-
106
- =end
107
-
108
- end
@@ -1,192 +0,0 @@
1
- module Teien
2
-
3
- class LightObjectInfo
4
- POINT = Ogre::Light::LT_POINT
5
- DIRECTIONAL = Ogre::Light::LT_DIRECTIONAL
6
- SPOTLIGHT = Ogre::Light::LT_SPOTLIGHT
7
-
8
- attr_accessor :type
9
- attr_accessor :diffuse_color
10
- attr_accessor :specular_color
11
- attr_accessor :direction
12
-
13
- def initialize(type,
14
- diffuse_color = Color.new(1.0, 1.0, 1.0),
15
- specular_color = Color.new(0.25, 0.25, 0),
16
- direction = Vector3D.new( -1, -1, -1 ))
17
- @type = type
18
- @diffuse_color = diffuse_color
19
- @specular_color = specular_color
20
- @direction = direction
21
- end
22
- end
23
-
24
- class MeshBBObjectInfo
25
- attr_accessor :mesh_path
26
- attr_accessor :size # Loading mesh only: bounding box size
27
- attr_accessor :scale # Loading mesh only: scales mesh
28
- attr_accessor :view_offset # Loading mesh only: offset of Mesh
29
- attr_accessor :view_rotation # Loading mesh only: rotation offset of Mesh
30
- attr_accessor :physics_offset # Loading mesh only: offset of collision Box
31
- attr_accessor :material_name
32
-
33
- def initialize(mesh_path, size, scale = Vector3D.new(1, 1, 1),
34
- view_offset = Vector3D.new(0, 0, 0),
35
- view_rotation = Quaternion.new(0, 0, 0, 1.0),
36
- physics_offset = Vector3D.new(0, 0, 0))
37
- @size = size
38
- @mesh_path = mesh_path
39
- @scale = scale
40
- @view_offset = view_offset
41
- @view_rotation = view_rotation
42
- @physics_offset = physics_offset
43
- @material_name = nil
44
- end
45
- end
46
-
47
- class MeshObjectInfo
48
- attr_accessor :mesh_path
49
- attr_accessor :scale # Loading mesh only: scales mesh
50
- attr_accessor :view_offset # Loading mesh only: offset of Mesh
51
- attr_accessor :view_rotation # Loading mesh only: rotation offset of Mesh
52
- attr_accessor :physics_offset # Loading mesh only: offset of collision Box
53
- attr_accessor :material_name
54
-
55
- def initialize(mesh_path, scale = Vector3D.new(1, 1, 1),
56
- view_offset = Vector3D.new(0, 0, 0),
57
- view_rotation = Quaternion.new(0, 0, 0, 1.0),
58
- physics_offset = Vector3D.new(0, 0, 0))
59
- @mesh_path = mesh_path
60
- @scale = scale
61
- @view_offset = view_offset
62
- @view_rotation = view_rotation
63
- @physics_offset = physics_offset
64
- @material_name = nil
65
- end
66
- end
67
-
68
- class FloorObjectInfo
69
- attr_accessor :width
70
- attr_accessor :height
71
- attr_accessor :depth
72
- attr_accessor :num_seg_x
73
- attr_accessor :num_seg_y
74
- attr_accessor :u_tile
75
- attr_accessor :v_tile
76
- attr_accessor :material_name
77
-
78
- def initialize(width, height, depth = 0.5, num_seg_x = 1, num_seg_y = 1, u_tile = 1.0, v_tile = 1.0)
79
- @width = width
80
- @height = height
81
- @depth = depth
82
- @num_seg_x = num_seg_x
83
- @num_seg_y = num_seg_y
84
- @u_tile = u_tile
85
- @v_tile = v_tile
86
- @material_name = nil
87
- end
88
- end
89
-
90
- class BoxObjectInfo
91
- attr_accessor :size
92
- attr_accessor :num_seg_x
93
- attr_accessor :num_seg_y
94
- attr_accessor :num_seg_z
95
- attr_accessor :u_tile
96
- attr_accessor :v_tile
97
- attr_accessor :material_name
98
-
99
- def initialize(size, num_seg_x = 1, num_seg_y = 1, num_seg_z = 1, u_tile = 1.0, v_tile = 1.0)
100
- @size = size
101
- @num_seg_x = num_seg_x
102
- @num_seg_y = num_seg_y
103
- @num_seg_z = num_seg_z
104
- @u_tile = u_tile
105
- @v_tile = v_tile
106
- @material_name = nil
107
- end
108
- end
109
-
110
- class SphereObjectInfo
111
- attr_accessor :radius
112
- attr_accessor :num_rings
113
- attr_accessor :num_segments
114
- attr_accessor :u_tile
115
- attr_accessor :v_tile
116
- attr_accessor :material_name
117
-
118
- def initialize(radius, num_rings = 16, num_segments = 16, u_tile = 1.0, v_tile = 1.0)
119
- @radius = radius
120
- @num_rings = num_rings
121
- @num_segments = num_segments
122
- @u_tile = u_tile
123
- @v_tile = v_tile
124
- @material_name = nil
125
- end
126
- end
127
-
128
- class CapsuleObjectInfo
129
- attr_accessor :radius
130
- attr_accessor :height
131
- attr_accessor :num_rings
132
- attr_accessor :num_segments
133
- attr_accessor :num_seg_height
134
- attr_accessor :u_tile
135
- attr_accessor :v_tile
136
- attr_accessor :material_name
137
-
138
- def initialize(radius, height, num_rings = 8, num_segments = 16, num_seg_height = 1, u_tile = 1.0, v_tile = 1.0)
139
- @radius = radius
140
- @height = height
141
- @num_rings = num_rings
142
- @num_segments = num_segments
143
- @num_seg_height = num_seg_height
144
- @u_tile = u_tile
145
- @v_tile = v_tile
146
- @material_name = nil
147
- end
148
- end
149
-
150
- class ConeObjectInfo
151
- attr_accessor :radius
152
- attr_accessor :height
153
- attr_accessor :num_seg_base
154
- attr_accessor :num_seg_height
155
- attr_accessor :u_tile
156
- attr_accessor :v_tile
157
- attr_accessor :material_name
158
-
159
- def initialize(radius, height, num_seg_base = 16, num_seg_height = 1, u_tile = 1.0, v_tile = 1.0)
160
- @radius = radius
161
- @height = height
162
- @num_seg_base = num_seg_base
163
- @num_seg_height = num_seg_height
164
- @u_tile = u_tile
165
- @v_tile = v_tile
166
- @material_name = nil
167
- end
168
- end
169
-
170
- class CylinderObjectInfo
171
- attr_accessor :radius
172
- attr_accessor :height
173
- attr_accessor :capped
174
- attr_accessor :num_seg_base
175
- attr_accessor :num_seg_height
176
- attr_accessor :u_tile
177
- attr_accessor :v_tile
178
- attr_accessor :material_name
179
-
180
- def initialize(radius, height, capped = true, num_seg_base = 16, num_seg_height = 1, u_tile = 1.0, v_tile = 1.0)
181
- @radius = radius
182
- @height = height
183
- @capped = capped
184
- @num_seg_base = num_seg_base
185
- @num_seg_height = num_seg_height
186
- @u_tile = u_tile
187
- @v_tile = v_tile
188
- @material_name = nil
189
- end
190
- end
191
-
192
- end
@@ -1,170 +0,0 @@
1
- require 'teien/garden_object'
2
-
3
- module Teien
4
-
5
- class PhysicsObjectFactory
6
- def initialize(physics)
7
- @physics = physics
8
- end
9
-
10
- def create_object(obj)
11
- case obj.object_info
12
- when LightObjectInfo
13
- return create_light_object(obj)
14
- when FloorObjectInfo
15
- return create_floor_object(obj)
16
- when BoxObjectInfo
17
- return create_box_object(obj)
18
- when SphereObjectInfo
19
- return create_sphere_object(obj)
20
- when CapsuleObjectInfo
21
- return create_capsule_object(obj)
22
- when ConeObjectInfo
23
- return create_cone_object(obj)
24
- when CylinderObjectInfo
25
- return create_cylinder_object(obj)
26
- when MeshBBObjectInfo
27
- return create_meshBB_object(obj)
28
- when MeshObjectInfo
29
- return create_mesh_object(obj)
30
- else
31
- puts "Error: passed no supported object_info."
32
- return nil
33
- end
34
- end
35
-
36
- def create_light_object(obj)
37
- physics_object = PhysicsObject.new(@physics)
38
- cShape = Bullet::BtSphereShape.new(0.1)
39
- inertia = Bullet::BtVector3.new()
40
- cShape.calculate_local_inertia(0, inertia)
41
- physics_object.set_rigid_body(obj, cShape, inertia)
42
- return physics_object
43
- end
44
-
45
- #
46
- # Floor Object
47
- #
48
-
49
- # Setting a collision shape and a rigid body of Bullet.
50
- def create_floor_object(obj)
51
- physics_object = PhysicsObject.new(@physics)
52
- cShape = Bullet::BtBoxShape.new(Vector3D.new(obj.object_info.width,
53
- obj.object_info.depth,
54
- obj.object_info.height))
55
- physics_object.set_rigid_body(obj, cShape,
56
- Vector3D.new(0, 0, 0),
57
- Vector3D.new(0.0, -obj.object_info.depth, 0.0))
58
- return physics_object
59
- end
60
-
61
- #
62
- # Box Object
63
- #
64
-
65
- def create_box_object(obj)
66
- physics_object = PhysicsObject.new(@physics)
67
- cShape = Bullet::BtBoxShape.new(Vector3D.new(obj.object_info.size.x,
68
- obj.object_info.size.y,
69
- obj.object_info.size.z))
70
- inertia = Bullet::BtVector3.new()
71
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
72
- physics_object.set_rigid_body(obj, cShape, inertia)
73
- return physics_object
74
- end
75
-
76
- #
77
- # Sphere Object
78
- #
79
-
80
- def create_sphere_object(obj)
81
- physics_object = PhysicsObject.new(@physics)
82
- cShape = Bullet::BtSphereShape.new(obj.object_info.radius)
83
- inertia = Bullet::BtVector3.new()
84
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
85
- physics_object.set_rigid_body(obj, cShape, inertia)
86
- return physics_object
87
- end
88
-
89
- #
90
- # Capsule Object
91
- #
92
-
93
- def create_capsule_object(obj)
94
- physics_object = PhysicsObject.new(@physics)
95
- cShape = Bullet::BtCapsuleShape.new(obj.object_info.radius,
96
- obj.object_info.height)
97
- inertia = Bullet::BtVector3.new()
98
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
99
- physics_object.set_rigid_body(obj, cShape, inertia)
100
- return physics_object
101
- end
102
-
103
- #
104
- # Cone Object
105
- #
106
-
107
- def create_cone_object(obj)
108
- physics_object = PhysicsObject.new(@physics)
109
- cShape = Bullet::BtConeShape.new(obj.object_info.radius, obj.object_info.height)
110
- inertia = Bullet::BtVector3.new()
111
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
112
- physics_object.set_rigid_body(obj, cShape, inertia,
113
- Vector3D.new(0, obj.object_info.height / 2, 0))
114
- return physics_object
115
- end
116
-
117
- #
118
- # Cylinder Object
119
- #
120
-
121
- def create_cylinder_object(obj)
122
- physics_object = PhysicsObject.new(@physics)
123
- cShape = Bullet::BtCylinderShape.new(Bullet::BtVector3.new(obj.object_info.radius,
124
- obj.object_info.height / 2,
125
- obj.object_info.radius))
126
- inertia = Bullet::BtVector3.new()
127
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
128
- physics_object.set_rigid_body(obj, cShape, inertia)
129
- return physics_object
130
- end
131
-
132
- #
133
- # MeshBB Object
134
- #
135
-
136
- def create_meshBB_object(obj)
137
- physics_object = PhysicsObject.new(@physics)
138
- cShape = Bullet::BtBoxShape.new(obj.object_info.size)
139
- inertia = Bullet::BtVector3.new()
140
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
141
- physics_object.set_rigid_body(obj, cShape, inertia, obj.object_info.physics_offset)
142
- return physics_object
143
- end
144
-
145
- #
146
- # Mesh Object
147
- #
148
-
149
- # This method needs the obj.entity to create a collision shape.
150
- # So it's not support to use this method on server(physics only) currently.
151
- def add_mesh_object(obj)
152
- physics_object = PhysicsObject.new(@physics)
153
- strider = Teienlib::MeshStrider.new(obj.entity.get_mesh().get())
154
- cShape = Bullet::BtGImpactMeshShape.new(strider)
155
- cShape.set_local_scaling(Bullet::BtVector3.new(obj.object_info.scale.x,
156
- obj.object_info.scale.y,
157
- obj.object_info.scale.z))
158
- cShape.instance_variable_set(:@strider, strider) # prevent this from GC.
159
- cShape.post_update()
160
- cShape.update_bound()
161
- inertia = Bullet::BtVector3.new()
162
- cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
163
- physics_object.set_rigid_body(obj, cShape, inertia,
164
- obj.object_info.physics_offset)
165
- return physics_object
166
- end
167
- end
168
-
169
-
170
- end
@@ -1,26 +0,0 @@
1
- module Teien
2
-
3
- class Synchronizer
4
- def initialize(garden, sync_period)
5
- @garden = garden
6
- @garden.register_receiver(self)
7
- @sync_period = sync_period
8
- @sync_timer = sync_period
9
- end
10
-
11
- def setup(garden)
12
- end
13
-
14
- def update(delta)
15
- @sync_timer += delta
16
- if (@sync_timer > @sync_period)
17
- @garden.notify_objects()
18
- @sync_timer = 0
19
- end
20
- end
21
-
22
- def add_actor(actor)
23
- end
24
- end
25
-
26
- end
@@ -1,67 +0,0 @@
1
- require "teien/animation_operator.rb"
2
-
3
- module Teien
4
-
5
- class ViewObject
6
- # Ogre3D accessor
7
- ## center of view objects(sceneNode) and kept to equal with the rigid_body position.
8
- attr_accessor :pivot_scene_node
9
- attr_accessor :scene_node
10
- attr_accessor :entity
11
- attr_accessor :animation_operators
12
-
13
- def initialize(view)
14
- @view = view
15
- @pivot_scene_node = nil
16
- @scene_node = nil
17
- @entity = nil
18
- @animation_operators = Hash.new
19
- end
20
-
21
- def finalize()
22
- @pivot_scene_node.remove_child(@scene_node)
23
- @view.scene_mgr.destroySceneNode(@scene_node)
24
- @view.scene_mgr.get_root_scene_node.remove_child(@pivot_scene_node)
25
- @view.scene_mgr.destroySceneNode(@pivot_scene_node)
26
- @view.scene_mgr.destroyEntity(@entity)
27
- end
28
-
29
- def update_animation(delta, animation)
30
- animation.operators.each_pair{|key, value|
31
- unless @animation_operators[key]
32
- @entity.get_skeleton().set_blend_mode(animation.blend_mode)
33
- ani_ope = AnimationOperator.new(@entity)
34
- ani_ope.init(value.name, value.loop)
35
- @animation_operators[key] = ani_ope
36
- end
37
-
38
- if (value.name != @animation_operators[key].name ||
39
- value.loop != @animation_operators[key].loop)
40
- @animation_operators[key].play(value.name, value.loop)
41
- end
42
- @animation_operators[key].add_time(delta * value.speed)
43
- }
44
- end
45
-
46
- #
47
- # The offset changes the local position of the created scene_node in Object.
48
- #
49
- def set_scene_node(entity, offset = Vector3D.new(0, 0, 0), rotate = Quaternion.new(0, 0, 0, 1.0))
50
- if (@pivot_scene_node == nil)
51
- @pivot_scene_node = @view.scene_mgr.get_root_scene_node().create_child_scene_node()
52
- end
53
- @scene_node = @pivot_scene_node.create_child_scene_node(Vector3D.to_ogre(offset),
54
- Quaternion.to_ogre(rotate))
55
- @pivot_scene_node.instance_variable_set(:@child, @scene_node) # prevent this from GC.
56
-
57
- if entity
58
- @scene_node.attach_object(entity)
59
- @entity = entity
60
- end
61
-
62
- return @scene_node
63
- end
64
-
65
- end
66
-
67
- end