teien 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.md +11 -6
  2. data/bin/teien +16 -2
  3. data/lib/teien/ai.rb +27 -0
  4. data/lib/teien/animation.rb +34 -0
  5. data/lib/teien/animation_operator.rb +6 -0
  6. data/lib/teien/controller.rb +30 -0
  7. data/lib/teien/dispatcher.rb +22 -0
  8. data/lib/teien/event.rb +60 -0
  9. data/lib/teien/event_router.rb +118 -0
  10. data/lib/teien/garden.rb +60 -172
  11. data/lib/teien/garden_base.rb +117 -0
  12. data/lib/teien/garden_object.rb +119 -136
  13. data/lib/teien/model.rb +34 -0
  14. data/lib/teien/network.rb +108 -0
  15. data/lib/teien/object_info.rb +21 -0
  16. data/lib/teien/physics.rb +47 -39
  17. data/lib/teien/physics_object.rb +57 -0
  18. data/lib/teien/physics_object_factory.rb +170 -0
  19. data/lib/teien/proxy_garden.rb +118 -0
  20. data/lib/teien/remote_info.rb +20 -0
  21. data/lib/teien/sky_dome.rb +15 -0
  22. data/lib/teien/smooth_mover.rb +31 -42
  23. data/lib/teien/synchronizer.rb +26 -0
  24. data/lib/teien/tools.rb +30 -2
  25. data/lib/teien/user_interface.rb +58 -5
  26. data/lib/teien/version.rb +1 -1
  27. data/lib/teien/view.rb +52 -33
  28. data/lib/teien/view_object.rb +67 -0
  29. data/lib/teien/view_object_factory.rb +210 -0
  30. data/lib/teien.rb +62 -14
  31. data/sample/actor/app/ais/actor_ai.rb +112 -0
  32. data/sample/actor/app/controllers/actor_controller.rb +182 -0
  33. data/sample/actor/app/helpers/sinbad/sinbad.rb +176 -0
  34. data/sample/actor/app/helpers/sinbad/sinbad_state.rb +224 -0
  35. data/sample/actor/app/helpers/user_event.rb +75 -0
  36. data/sample/actor/app/models/actor_model.rb +108 -0
  37. data/sample/actor/config/plugins.cfg +19 -0
  38. data/sample/actor/config/resources.cfg +24 -0
  39. data/sample/hello_garden/app/controllers/hello_garden_controller.rb +90 -0
  40. data/sample/hello_garden/app/helpers/user_event.rb +12 -0
  41. data/sample/{standalone/hello_garden/hello_garden.rb → hello_garden/app/models/hello_garden_model.rb} +29 -83
  42. data/sample/{standalone/hello_garden → hello_garden/config}/plugins.cfg +0 -0
  43. data/sample/{standalone/hello_garden → hello_garden/config}/resources.cfg +0 -0
  44. data/sample/hello_garden/run +6 -0
  45. data/teien.gemspec +2 -1
  46. metadata +52 -15
  47. data/lib/teien/light_object.rb +0 -36
  48. data/lib/teien/object_factory.rb +0 -308
  49. data/sample/standalone/hello_garden/run +0 -5
@@ -1,308 +0,0 @@
1
- require 'teien/garden_object'
2
-
3
- module Teien
4
-
5
- class ObjectFactory
6
- def initialize(garden)
7
- @garden = garden
8
- end
9
-
10
- def create_object(name, object_info, physics_info)
11
- case object_info
12
- when FloorObjectInfo
13
- return create_floor_object(name, object_info, physics_info)
14
- when BoxObjectInfo
15
- return create_box_object(name, object_info, physics_info)
16
- when SphereObjectInfo
17
- return create_sphere_object(name, object_info, physics_info)
18
- when CapsuleObjectInfo
19
- return create_capsule_object(name, object_info, physics_info)
20
- when ConeObjectInfo
21
- return create_cone_object(name, object_info, physics_info)
22
- when CylinderObjectInfo
23
- return create_cylinder_object(name, object_info, physics_info)
24
- when MeshBBObjectInfo
25
- return create_meshBB_object(name, object_info, physics_info)
26
- when MeshObjectInfo
27
- return create_mesh_object(name, object_info, physics_info)
28
- else
29
- puts "Error: passed no supported object_info."
30
- end
31
- end
32
-
33
- private
34
-
35
- def create_floor_object(name, object_info, physics_info)
36
- obj = GardenObject.new(@garden)
37
- obj.name = name
38
- obj.object_info = object_info
39
- obj.physics_info = physics_info
40
-
41
- unless @garden.is_server
42
- # Setting an entity and a node of Ogre3d.
43
- normal = Ogre::Vector3.new(0, 1, 0)
44
- up = Ogre::Vector3.new(0, 0, 1)
45
- Ogre::MeshManager::get_singleton().create_plane(name,
46
- Ogre::ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
47
- Ogre::Plane.new(normal, 0),
48
- object_info.width * 2.0,
49
- object_info.height * 2.0,
50
- object_info.num_seg_x,
51
- object_info.num_seg_y,
52
- true, 1,
53
- object_info.u_tile,
54
- object_info.v_tile, up)
55
- entity = @garden.view.scene_mgr.create_entity(name, name)
56
- entity.set_cast_shadows(true)
57
- entity.set_material_name(object_info.material_name)
58
- node = obj.create_scene_node(entity)
59
- end
60
-
61
- # Setting a collision shape and rigid body of Bullet.
62
- cShape = Bullet::BtBoxShape.new(Vector3D.new(object_info.width, object_info.depth, object_info.height))
63
- rb = obj.create_rigid_body(0, cShape, Vector3D.new(0, 0, 0), Vector3D.new(0.0, -object_info.depth, 0.0))
64
- rb.set_angular_factor(physics_info.angular_factor)
65
- rb.set_restitution(physics_info.restitution)
66
- rb.set_friction(physics_info.friction)
67
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
68
-
69
- @garden.add_object(obj)
70
-
71
- return obj
72
- end
73
-
74
- def create_box_object(name, object_info, physics_info)
75
- obj = GardenObject.new(@garden)
76
- obj.name = name
77
- obj.object_info = object_info
78
- obj.physics_info = physics_info
79
-
80
- unless @garden.is_server
81
- gen = Procedural::BoxGenerator.new()
82
- gen.set_size_x(object_info.size.x * 2.0)
83
- gen.set_size_y(object_info.size.y * 2.0)
84
- gen.set_size_z(object_info.size.z * 2.0)
85
- gen.set_num_seg_x(object_info.num_seg_x)
86
- gen.set_num_seg_y(object_info.num_seg_y)
87
- gen.set_num_seg_z(object_info.num_seg_z)
88
- gen.set_utile(object_info.u_tile).set_vtile(object_info.v_tile).realize_mesh(name)
89
- entity = @garden.view.scene_mgr.create_entity(name)
90
- entity.set_cast_shadows(true)
91
- entity.set_material_name(object_info.material_name)
92
- node = obj.create_scene_node(entity)
93
- end
94
-
95
- cShape = Bullet::BtBoxShape.new(Vector3D.new(object_info.size.x, object_info.size.y, object_info.size.z))
96
- inertia = Bullet::BtVector3.new()
97
- cShape.calculate_local_inertia(physics_info.mass, inertia)
98
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
99
- rb.set_angular_factor(physics_info.angular_factor)
100
- rb.set_restitution(physics_info.restitution)
101
- rb.set_friction(physics_info.friction)
102
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
103
-
104
-
105
- @garden.add_object(obj)
106
-
107
- return obj
108
- end
109
-
110
- def create_sphere_object(name, object_info, physics_info)
111
- obj = GardenObject.new(@garden)
112
- obj.name = name
113
- obj.object_info = object_info
114
- obj.physics_info = physics_info
115
-
116
- unless @garden.is_server
117
- gen = Procedural::SphereGenerator.new()
118
- gen.set_radius(object_info.radius)
119
- gen.set_num_rings(object_info.num_rings)
120
- gen.set_num_segments(object_info.num_segments)
121
- gen.set_vtile(object_info.u_tile).set_vtile(object_info.v_tile).realize_mesh(name)
122
- entity = @garden.view.scene_mgr.create_entity(name)
123
- entity.set_cast_shadows(true)
124
- entity.set_material_name(object_info.material_name)
125
- node = obj.create_scene_node(entity)
126
- end
127
-
128
- cShape = Bullet::BtSphereShape.new(object_info.radius)
129
- inertia = Bullet::BtVector3.new()
130
- cShape.calculate_local_inertia(physics_info.mass, inertia)
131
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
132
- rb.set_angular_factor(physics_info.angular_factor)
133
- rb.set_restitution(physics_info.restitution)
134
- rb.set_friction(physics_info.friction)
135
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
136
-
137
-
138
- @garden.add_object(obj)
139
-
140
- return obj
141
- end
142
-
143
- def create_capsule_object(name, object_info, physics_info)
144
- obj = GardenObject.new(@garden)
145
- obj.name = name
146
- obj.object_info = object_info
147
- obj.physics_info = physics_info
148
-
149
- unless @garden.is_server
150
- gen = Procedural::CapsuleGenerator.new()
151
- gen.set_radius(object_info.radius).set_height(object_info.height)
152
- gen.set_num_rings(object_info.num_rings)
153
- gen.set_num_segments(object_info.num_segments)
154
- gen.set_num_seg_height(object_info.num_seg_height)
155
- gen.set_vtile(object_info.u_tile).set_vtile(object_info.v_tile).realize_mesh(name)
156
- entity = @garden.view.scene_mgr.create_entity(name)
157
- entity.set_cast_shadows(true)
158
- entity.set_material_name(object_info.material_name)
159
- node = obj.create_scene_node(entity)
160
- end
161
-
162
- cShape = Bullet::BtCapsuleShape.new(object_info.radius, object_info.height)
163
- inertia = Bullet::BtVector3.new()
164
- cShape.calculate_local_inertia(physics_info.mass, inertia)
165
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
166
- rb.set_angular_factor(physics_info.angular_factor)
167
- rb.set_restitution(physics_info.restitution)
168
- rb.set_friction(physics_info.friction)
169
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
170
-
171
-
172
- @garden.add_object(obj)
173
-
174
- return obj
175
- end
176
-
177
- def create_cone_object(name, object_info, physics_info)
178
- obj = GardenObject.new(@garden)
179
- obj.name = name
180
- obj.object_info = object_info
181
- obj.physics_info = physics_info
182
-
183
- unless @garden.is_server
184
- gen = Procedural::ConeGenerator.new
185
- gen.set_radius(object_info.radius).set_height(object_info.height)
186
- gen.set_num_seg_base(object_info.num_seg_base).set_num_seg_height(object_info.num_seg_height)
187
- gen.set_utile(object_info.u_tile).set_vtile(object_info.v_tile).realize_mesh(name)
188
- entity = @garden.view.scene_mgr.create_entity(name)
189
- entity.set_cast_shadows(true)
190
- entity.set_material_name(object_info.material_name)
191
- node = obj.create_scene_node(entity)
192
- end
193
-
194
- cShape = Bullet::BtConeShape.new(object_info.radius, object_info.height)
195
- inertia = Bullet::BtVector3.new()
196
- cShape.calculate_local_inertia(physics_info.mass, inertia)
197
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, Vector3D.new(0, object_info.height / 2, 0))
198
- rb.set_angular_factor(physics_info.angular_factor)
199
- rb.set_restitution(physics_info.restitution)
200
- rb.set_friction(physics_info.friction)
201
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
202
-
203
-
204
- @garden.add_object(obj)
205
-
206
- return obj
207
- end
208
-
209
- def create_cylinder_object(name, object_info, physics_info)
210
- obj = GardenObject.new(@garden)
211
- obj.name = name
212
- obj.object_info = object_info
213
- obj.physics_info = physics_info
214
-
215
- unless @garden.is_server
216
- gen = Procedural::CylinderGenerator.new
217
- gen.set_radius(object_info.radius).set_height(object_info.height).set_capped(object_info.capped)
218
- gen.set_num_seg_base(object_info.num_seg_base).set_num_seg_height(object_info.num_seg_height)
219
- gen.set_utile(object_info.u_tile).set_vtile(object_info.v_tile).realize_mesh(name)
220
- entity = @garden.view.scene_mgr.create_entity(name)
221
- entity.set_cast_shadows(true)
222
- entity.set_material_name(object_info.material_name)
223
- node = obj.create_scene_node(entity, Vector3D.new(0, -object_info.height / 2, 0))
224
- end
225
-
226
- cShape = Bullet::BtCylinderShape.new(Bullet::BtVector3.new(object_info.radius,
227
- object_info.height / 2,
228
- object_info.radius))
229
- inertia = Bullet::BtVector3.new()
230
- cShape.calculate_local_inertia(physics_info.mass, inertia)
231
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
232
- rb.set_angular_factor(physics_info.angular_factor)
233
- rb.set_restitution(physics_info.restitution)
234
- rb.set_friction(physics_info.friction)
235
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
236
-
237
- @garden.add_object(obj)
238
-
239
- return obj
240
- end
241
-
242
- def create_meshBB_object(name, object_info, physics_info)
243
- obj = GardenObject.new(@garden)
244
- obj.name = name
245
- obj.object_info = object_info
246
- obj.physics_info = physics_info
247
-
248
- unless @garden.is_server
249
- entity = @garden.view.scene_mgr.create_entity(name, object_info.mesh_path)
250
- entity.set_cast_shadows(true)
251
- entity.set_material_name(object_info.material_name) if object_info.material_name
252
- node = obj.create_scene_node(entity, object_info.view_offset, object_info.view_rotation)
253
- node.set_scale(object_info.size.x * object_info.scale.x,
254
- object_info.size.y * object_info.scale.y,
255
- object_info.size.z * object_info.scale.z)
256
- end
257
-
258
- cShape = Bullet::BtBoxShape.new(object_info.size)
259
- inertia = Bullet::BtVector3.new()
260
- cShape.calculate_local_inertia(physics_info.mass, inertia)
261
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, object_info.physics_offset)
262
- rb.set_angular_factor(physics_info.angular_factor)
263
- rb.set_restitution(physics_info.restitution)
264
- rb.set_friction(physics_info.friction)
265
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
266
-
267
- @garden.add_object(obj)
268
-
269
- return obj
270
- end
271
-
272
- def create_mesh_object(name, object_info, physics_info)
273
- obj = GardenObject.new(@garden)
274
- obj.name = name
275
- obj.object_info = object_info
276
- obj.physics_info = physics_info
277
-
278
- unless @garden.is_server
279
- entity = @garden.view.scene_mgr.create_entity(name, object_info.mesh_path)
280
- entity.set_cast_shadows(true)
281
- entity.set_material_name(object_info.material_name) if object_info.material_name
282
- node = obj.create_scene_node(entity, object_info.view_offset)
283
- node.set_scale(object_info.scale.x, object_info.scale.y, object_info.scale.z)
284
- strider = Teienlib::MeshStrider.new(entity.get_mesh().get())
285
- cShape = Bullet::BtGImpactMeshShape.new(strider)
286
- cShape.set_local_scaling(Bullet::BtVector3.new(object_info.scale.x,
287
- object_info.scale.y,
288
- object_info.scale.z))
289
- cShape.instance_variable_set(:@strider, strider) # prevent this from GC.
290
- cShape.post_update()
291
- cShape.update_bound()
292
- inertia = Bullet::BtVector3.new()
293
- cShape.calculate_local_inertia(physics_info.mass, inertia)
294
- rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, object_info.physics_offset)
295
- rb.set_angular_factor(physics_info.angular_factor)
296
- rb.set_restitution(physics_info.restitution)
297
- rb.set_friction(physics_info.friction)
298
- rb.set_damping(physics_info.linear_damping, physics_info.angular_damping)
299
- end
300
-
301
- @garden.add_object(obj)
302
-
303
- return obj
304
- end
305
- end
306
-
307
-
308
- end
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- FILE_PATH=`dirname "$0"`
4
- teien $FILE_PATH/hello_garden.rb
5
-