teien 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ class GardenObject < Bullet::BtMotionState
41
41
 
42
42
  @rigid_body = nil
43
43
  @transform = Bullet::BtTransform.new()
44
- @transform.setIdentity()
44
+ @transform.set_identity()
45
45
  @acceleration = Vector3D.new(0, 0, 0)
46
46
 
47
47
  @maxHorizontalVelocity = 0
@@ -53,12 +53,12 @@ class GardenObject < Bullet::BtMotionState
53
53
  #
54
54
  def create_scene_node(entity, offset = Vector3D.new(0, 0, 0), rotate = Quaternion.new(0, 0, 0, 1.0))
55
55
  if (@pivot_scene_node == nil)
56
- @pivot_scene_node = @garden.view.scene_mgr.getRootSceneNode().createChildSceneNode()
56
+ @pivot_scene_node = @garden.view.scene_mgr.get_root_scene_node().create_child_scene_node()
57
57
  end
58
- @scene_node = @pivot_scene_node.createChildSceneNode(Vector3D.to_ogre(offset), Quaternion.to_ogre(rotate))
58
+ @scene_node = @pivot_scene_node.create_child_scene_node(Vector3D.to_ogre(offset), Quaternion.to_ogre(rotate))
59
59
  @pivot_scene_node.instance_variable_set(:@child, @scene_node) # prevent this from GC.
60
60
  if entity
61
- @scene_node.attachObject(entity)
61
+ @scene_node.attach_object(entity)
62
62
  @entity = entity
63
63
  end
64
64
  return @scene_node
@@ -71,9 +71,9 @@ class GardenObject < Bullet::BtMotionState
71
71
  # puts "offset(#{offset.x}, #{offset.y}, #{offset.z})"
72
72
  @pivot_shape = Bullet::BtCompoundShape.new
73
73
  localTrans = Bullet::BtTransform.new
74
- localTrans.setIdentity()
75
- localTrans.setOrigin(offset)
76
- @pivot_shape.addChildShape(localTrans, shape)
74
+ localTrans.set_identity()
75
+ localTrans.set_origin(offset)
76
+ @pivot_shape.add_child_shape(localTrans, shape)
77
77
  @shape = shape
78
78
  @rigid_body = @garden.physics.create_rigid_body(mass, self, @pivot_shape, inertia)
79
79
  end
@@ -83,7 +83,7 @@ class GardenObject < Bullet::BtMotionState
83
83
  end
84
84
 
85
85
  def set_activation_state(state)
86
- @rigid_body.setActivationState(state)
86
+ @rigid_body.set_activation_state(state)
87
87
  end
88
88
 
89
89
 
@@ -92,9 +92,9 @@ class GardenObject < Bullet::BtMotionState
92
92
  # ==== Args
93
93
  # [aPos: Vector3D]
94
94
  def set_position(aPos)
95
- @pivot_scene_node.setPosition(aPos.x, aPos.y, aPos.z) unless @garden.is_server
96
- @transform.setOrigin(Bullet::BtVector3.new(aPos.x, aPos.y, aPos.z))
97
- @rigid_body.setCenterOfMassTransform(@transform) if (@rigid_body != nil)
95
+ @pivot_scene_node.set_position(aPos.x, aPos.y, aPos.z) unless @garden.is_server
96
+ @transform.set_origin(Bullet::BtVector3.new(aPos.x, aPos.y, aPos.z))
97
+ @rigid_body.set_center_of_mass_transform(@transform) if (@rigid_body != nil)
98
98
  end
99
99
 
100
100
  # Set a linear velocity.
@@ -103,7 +103,7 @@ class GardenObject < Bullet::BtMotionState
103
103
  # [aVel: Vector3D]
104
104
  def set_linear_velocity(aVel)
105
105
  @rigid_body.activate(true)
106
- @rigid_body.setLinearVelocity(aVel)
106
+ @rigid_body.set_linear_velocity(aVel)
107
107
  end
108
108
 
109
109
  # Set an angular velocity.
@@ -111,7 +111,7 @@ class GardenObject < Bullet::BtMotionState
111
111
  # ==== Args
112
112
  # [vel: Vector3D]
113
113
  def set_angular_velocity(vel)
114
- @rigid_body.setAngularVelocity(vel)
114
+ @rigid_body.set_angular_velocity(vel)
115
115
  end
116
116
 
117
117
  # Set a max horizontal velocity.
@@ -136,22 +136,22 @@ class GardenObject < Bullet::BtMotionState
136
136
  end
137
137
 
138
138
  def set_gravity(grav)
139
- @rigid_body.setGravity(grav)
139
+ @rigid_body.set_gravity(grav)
140
140
  end
141
141
 
142
142
  def set_rotation(quad)
143
- transform = @rigid_body.getCenterOfMassTransform()
144
- transform.setRotation(quad)
145
- @rigid_body.setCenterOfMassTransform(transform)
143
+ transform = @rigid_body.get_center_of_mass_transform()
144
+ transform.set_rotation(quad)
145
+ @rigid_body.set_center_of_mass_transform(transform)
146
146
  end
147
147
 
148
148
  def set_collision_filter(filter)
149
- @garden.physics.dynamicsWorld.removeRigidBody(@rigid_body)
150
- @garden.physics.dynamicsWorld.addRigidBody(@rigid_body, filter.group, filter.mask)
149
+ @garden.physics.dynamicsWorld.remove_rigid_body(@rigid_body)
150
+ @garden.physics.dynamicsWorld.add_rigid_body(@rigid_body, filter.group, filter.mask)
151
151
  physics_info.collisionFilter = filter
152
152
  end
153
153
 
154
- def setWorldTransform(worldTrans)
154
+ def set_world_transform(worldTrans)
155
155
  # puts "setWorldTransform"
156
156
 
157
157
  if (@mode == MODE_FREE)
@@ -159,8 +159,8 @@ class GardenObject < Bullet::BtMotionState
159
159
  # puts "origin(#{pos.x}, #{pos.y}, #{pos.z})"
160
160
 
161
161
  @transform = Bullet::BtTransform.new(worldTrans)
162
- newPos = @transform.getOrigin()
163
- newRot = @transform.getRotation()
162
+ newPos = @transform.get_origin()
163
+ newRot = @transform.get_rotation()
164
164
  # puts "newRot(#{id}: #{newRot.x}, #{newRot.y}, #{newRot.z}, #{newRot.w})"
165
165
  # puts "newPos(#{id}: #{newPos.x}, #{newPos.y}, #{newPos.z})"
166
166
 
@@ -169,43 +169,43 @@ class GardenObject < Bullet::BtMotionState
169
169
  end
170
170
 
171
171
  unless @garden.is_server
172
- @pivot_scene_node.setPosition(newPos.x, newPos.y, newPos.z)
173
- @pivot_scene_node.setOrientation(newRot.w, newRot.x, newRot.y, newRot.z)
172
+ @pivot_scene_node.set_position(newPos.x, newPos.y, newPos.z)
173
+ @pivot_scene_node.set_orientation(newRot.w, newRot.x, newRot.y, newRot.z)
174
174
  end
175
175
  end
176
176
  end
177
177
 
178
- def getWorldTransform(worldTrans)
178
+ def get_world_transform(worldTrans)
179
179
  # puts "getWorldTransform"
180
180
  end
181
181
 
182
182
  def get_activation_state()
183
- @rigid_body.getActivationState()
183
+ @rigid_body.get_activation_state()
184
184
  end
185
185
 
186
186
  def get_mass()
187
- return 1.0 / @rigid_body.getInvMass()
187
+ return 1.0 / @rigid_body.get_inv_mass()
188
188
  end
189
189
 
190
190
  def get_inv_mass()
191
- return @rigid_body.getInvMass()
191
+ return @rigid_body.get_inv_mass()
192
192
  end
193
193
 
194
194
  def get_collision_mask()
195
- @rigid_body.getBroadphaseHandle().m_collisionFilterMask
195
+ @rigid_body.get_broadphase_handle().m_collisionFilterMask
196
196
  end
197
197
 
198
198
  def get_position()
199
- newPos = @transform.getOrigin()
199
+ newPos = @transform.get_origin()
200
200
  return newPos
201
201
  end
202
202
 
203
203
  def get_linear_velocity()
204
- return @rigid_body.getLinearVelocity()
204
+ return @rigid_body.get_linear_velocity()
205
205
  end
206
206
 
207
207
  def get_angular_velocity()
208
- return @rigid_body.getAngularVelocity()
208
+ return @rigid_body.get_angular_velocity()
209
209
  end
210
210
 
211
211
  def get_acceleration()
@@ -213,15 +213,15 @@ class GardenObject < Bullet::BtMotionState
213
213
  end
214
214
 
215
215
  def get_gravity()
216
- return @rigid_body.getGravity()
216
+ return @rigid_body.get_gravity()
217
217
  end
218
218
 
219
219
  def get_rotation()
220
- return @transform.getRotation()
220
+ return @transform.get_rotation()
221
221
  end
222
222
 
223
223
  def get_orientation()
224
- return @transform.getRotation()
224
+ return @transform.get_rotation()
225
225
  end
226
226
 
227
227
  def limit_velocity(vel)
@@ -245,7 +245,7 @@ class GardenObject < Bullet::BtMotionState
245
245
 
246
246
  def apply_impulse(imp, rel = Vector3D.new(0, 0, 0))
247
247
  @rigid_body.activate(true)
248
- @rigid_body.applyImpulse(imp, rel)
248
+ @rigid_body.apply_impulse(imp, rel)
249
249
  end
250
250
 
251
251
  #
@@ -260,32 +260,32 @@ class GardenObject < Bullet::BtMotionState
260
260
  qnorm = Quaternion.new()
261
261
  qnorm.copy(quat)
262
262
  qnorm.normalize()
263
- transform = @rigid_body.getCenterOfMassTransform()
264
- curRot = transform.getRotation()
263
+ transform = @rigid_body.get_center_of_mass_transform()
264
+ curRot = transform.get_rotation()
265
265
  newRot = curRot * qnorm
266
- transform.setRotation(newRot)
267
- @rigid_body.setCenterOfMassTransform(transform)
266
+ transform.set_rotation(newRot)
267
+ @rigid_body.set_center_of_mass_transform(transform)
268
268
 
269
- @pivot_scene_node.setOrientation(Quaternion.to_ogre(newRot)) unless @garden.is_server
269
+ @pivot_scene_node.set_orientation(Quaternion.to_ogre(newRot)) unless @garden.is_server
270
270
  end
271
271
 
272
272
  def attach_object_to_bone(boneName, obj)
273
- obj.scene_node.detachObject(obj.entity)
274
- tag = @entity.attachObjectToBone(boneName, obj.entity)
275
- @garden.physics.dynamics_world.removeRigidBody(obj.rigid_body)
273
+ obj.scene_node.detach_object(obj.entity)
274
+ tag = @entity.attach_object_to_bone(boneName, obj.entity)
275
+ @garden.physics.dynamics_world.remove_rigid_body(obj.rigid_body)
276
276
  obj.mode = MODE_ATTACHED
277
277
  return tag
278
278
  end
279
279
 
280
280
  def detach_object_from_bone(obj)
281
- @entity.detachObjectFromBone(obj.entity)
282
- obj.scene_node.attachObject(obj.entity)
281
+ @entity.detach_object_from_bone(obj.entity)
282
+ obj.scene_node.attach_object(obj.entity)
283
283
  if obj.physics_info.collisionFilter
284
- @garden.physics.dynamics_world.addRigidBody(obj.rigid_body,
285
- obj.physics_info.collisionFilter.group,
286
- obj.physics_info.collisionFilter.mask)
284
+ @garden.physics.dynamics_world.add_rigid_body(obj.rigid_body,
285
+ obj.physics_info.collisionFilter.group,
286
+ obj.physics_info.collisionFilter.mask)
287
287
  else
288
- @garden.physics.dynamics_world.addRigidBody(obj.rigid_body)
288
+ @garden.physics.dynamics_world.add_rigid_body(obj.rigid_body)
289
289
  end
290
290
  obj.mode = MODE_FREE
291
291
  end
@@ -11,26 +11,26 @@ class LightObject
11
11
  def initialize(garden, name)
12
12
  @garden = garden
13
13
  @name = name
14
- @light = @garden.view.scene_mgr.createLight(@name);
14
+ @light = @garden.view.scene_mgr.create_light(@name);
15
15
  end
16
16
 
17
17
  def set_type(type)
18
- @light.setType(type)
18
+ @light.set_type(type)
19
19
  end
20
20
 
21
21
  def set_diffuse_color(color)
22
- @light.setDiffuseColour(color);
22
+ @light.set_diffuse_colour(color);
23
23
  end
24
24
 
25
25
  def set_specular_color(color)
26
- @light.setSpecularColour(color)
26
+ @light.set_specular_colour(color)
27
27
  end
28
28
 
29
29
  def set_position(vec)
30
- @light.setPosition(Vector3D.to_ogre(vec));
30
+ @light.set_position(Vector3D.to_ogre(vec));
31
31
  end
32
32
 
33
33
  def set_direction(vec)
34
- @light.setDirection(Vector3D.to_ogre(vec));
34
+ @light.set_direction(Vector3D.to_ogre(vec));
35
35
  end
36
36
  end
@@ -42,7 +42,7 @@ class ObjectFactory
42
42
  # Setting an entity and a node of Ogre3d.
43
43
  normal = Ogre::Vector3.new(0, 1, 0)
44
44
  up = Ogre::Vector3.new(0, 0, 1)
45
- Ogre::MeshManager::getSingleton().createPlane(name,
45
+ Ogre::MeshManager::get_singleton().create_plane(name,
46
46
  Ogre::ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
47
47
  Ogre::Plane.new(normal, 0),
48
48
  object_info.width * 2.0,
@@ -52,19 +52,19 @@ class ObjectFactory
52
52
  true, 1,
53
53
  object_info.u_tile,
54
54
  object_info.v_tile, up)
55
- entity = @garden.view.scene_mgr.createEntity(name, name)
56
- entity.setCastShadows(true)
57
- entity.setMaterialName(object_info.material_name)
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
58
  node = obj.create_scene_node(entity)
59
59
  end
60
60
 
61
61
  # Setting a collision shape and rigid body of Bullet.
62
62
  cShape = Bullet::BtBoxShape.new(Vector3D.new(object_info.width, object_info.depth, object_info.height))
63
63
  rb = obj.create_rigid_body(0, cShape, Vector3D.new(0, 0, 0), Vector3D.new(0.0, -object_info.depth, 0.0))
64
- rb.setAngularFactor(physics_info.angular_factor)
65
- rb.setRestitution(physics_info.restitution)
66
- rb.setFriction(physics_info.friction)
67
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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
68
 
69
69
  @garden.add_object(obj)
70
70
 
@@ -79,23 +79,27 @@ class ObjectFactory
79
79
 
80
80
  unless @garden.is_server
81
81
  gen = Procedural::BoxGenerator.new()
82
- gen.setSizeX(object_info.size.x * 2.0).setSizeY(object_info.size.y * 2.0).setSizeZ(object_info.size.z * 2.0)
83
- gen.setNumSegX(object_info.num_seg_x).setNumSegY(object_info.num_seg_y).setNumSegZ(object_info.num_seg_z)
84
- gen.setUTile(object_info.u_tile).setVTile(object_info.v_tile).realizeMesh(name)
85
- entity = @garden.view.scene_mgr.createEntity(name)
86
- entity.setCastShadows(true)
87
- entity.setMaterialName(object_info.material_name)
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)
88
92
  node = obj.create_scene_node(entity)
89
93
  end
90
94
 
91
95
  cShape = Bullet::BtBoxShape.new(Vector3D.new(object_info.size.x, object_info.size.y, object_info.size.z))
92
96
  inertia = Bullet::BtVector3.new()
93
- cShape.calculateLocalInertia(physics_info.mass, inertia)
97
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
94
98
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
95
- rb.setAngularFactor(physics_info.angular_factor)
96
- rb.setRestitution(physics_info.restitution)
97
- rb.setFriction(physics_info.friction)
98
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
99
103
 
100
104
 
101
105
  @garden.add_object(obj)
@@ -111,24 +115,24 @@ class ObjectFactory
111
115
 
112
116
  unless @garden.is_server
113
117
  gen = Procedural::SphereGenerator.new()
114
- gen.setRadius(object_info.radius)
115
- gen.setNumRings(object_info.num_rings)
116
- gen.setNumSegments(object_info.num_segments)
117
- gen.setUTile(object_info.u_tile).setVTile(object_info.v_tile).realizeMesh(name)
118
- entity = @garden.view.scene_mgr.createEntity(name)
119
- entity.setCastShadows(true)
120
- entity.setMaterialName(object_info.material_name)
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)
121
125
  node = obj.create_scene_node(entity)
122
126
  end
123
127
 
124
128
  cShape = Bullet::BtSphereShape.new(object_info.radius)
125
129
  inertia = Bullet::BtVector3.new()
126
- cShape.calculateLocalInertia(physics_info.mass, inertia)
130
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
127
131
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
128
- rb.setAngularFactor(physics_info.angular_factor)
129
- rb.setRestitution(physics_info.restitution)
130
- rb.setFriction(physics_info.friction)
131
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
132
136
 
133
137
 
134
138
  @garden.add_object(obj)
@@ -144,23 +148,25 @@ class ObjectFactory
144
148
 
145
149
  unless @garden.is_server
146
150
  gen = Procedural::CapsuleGenerator.new()
147
- gen.setRadius(object_info.radius).setHeight(object_info.height)
148
- gen.setNumRings(object_info.num_rings).setNumSegments(object_info.num_segments).setNumSegHeight(object_info.num_seg_height)
149
- gen.setUTile(object_info.u_tile).setVTile(object_info.v_tile).realizeMesh(name)
150
- entity = @garden.view.scene_mgr.createEntity(name)
151
- entity.setCastShadows(true)
152
- entity.setMaterialName(object_info.material_name)
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)
153
159
  node = obj.create_scene_node(entity)
154
160
  end
155
161
 
156
162
  cShape = Bullet::BtCapsuleShape.new(object_info.radius, object_info.height)
157
163
  inertia = Bullet::BtVector3.new()
158
- cShape.calculateLocalInertia(physics_info.mass, inertia)
164
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
159
165
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
160
- rb.setAngularFactor(physics_info.angular_factor)
161
- rb.setRestitution(physics_info.restitution)
162
- rb.setFriction(physics_info.friction)
163
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
164
170
 
165
171
 
166
172
  @garden.add_object(obj)
@@ -176,23 +182,23 @@ class ObjectFactory
176
182
 
177
183
  unless @garden.is_server
178
184
  gen = Procedural::ConeGenerator.new
179
- gen.setRadius(object_info.radius).setHeight(object_info.height)
180
- gen.setNumSegBase(object_info.num_seg_base).setNumSegHeight(object_info.num_seg_height)
181
- gen.setUTile(object_info.u_tile).setVTile(object_info.v_tile).realizeMesh(name)
182
- entity = @garden.view.scene_mgr.createEntity(name)
183
- entity.setCastShadows(true)
184
- entity.setMaterialName(object_info.material_name)
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)
185
191
  node = obj.create_scene_node(entity)
186
192
  end
187
193
 
188
194
  cShape = Bullet::BtConeShape.new(object_info.radius, object_info.height)
189
195
  inertia = Bullet::BtVector3.new()
190
- cShape.calculateLocalInertia(physics_info.mass, inertia)
196
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
191
197
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, Vector3D.new(0, object_info.height / 2, 0))
192
- rb.setAngularFactor(physics_info.angular_factor)
193
- rb.setRestitution(physics_info.restitution)
194
- rb.setFriction(physics_info.friction)
195
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
196
202
 
197
203
 
198
204
  @garden.add_object(obj)
@@ -208,12 +214,12 @@ class ObjectFactory
208
214
 
209
215
  unless @garden.is_server
210
216
  gen = Procedural::CylinderGenerator.new
211
- gen.setRadius(object_info.radius).setHeight(object_info.height).setCapped(object_info.capped)
212
- gen.setNumSegBase(object_info.num_seg_base).setNumSegHeight(object_info.num_seg_height)
213
- gen.setUTile(object_info.u_tile).setVTile(object_info.v_tile).realizeMesh(name)
214
- entity = @garden.view.scene_mgr.createEntity(name)
215
- entity.setCastShadows(true)
216
- entity.setMaterialName(object_info.material_name)
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)
217
223
  node = obj.create_scene_node(entity, Vector3D.new(0, -object_info.height / 2, 0))
218
224
  end
219
225
 
@@ -221,12 +227,12 @@ class ObjectFactory
221
227
  object_info.height / 2,
222
228
  object_info.radius))
223
229
  inertia = Bullet::BtVector3.new()
224
- cShape.calculateLocalInertia(physics_info.mass, inertia)
230
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
225
231
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia)
226
- rb.setAngularFactor(physics_info.angular_factor)
227
- rb.setRestitution(physics_info.restitution)
228
- rb.setFriction(physics_info.friction)
229
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
230
236
 
231
237
  @garden.add_object(obj)
232
238
 
@@ -240,23 +246,23 @@ class ObjectFactory
240
246
  obj.physics_info = physics_info
241
247
 
242
248
  unless @garden.is_server
243
- entity = @garden.view.scene_mgr.createEntity(name, object_info.mesh_path)
244
- entity.setCastShadows(true)
245
- entity.setMaterialName(object_info.material_name) if object_info.material_name
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
246
252
  node = obj.create_scene_node(entity, object_info.view_offset, object_info.view_rotation)
247
- node.setScale(object_info.size.x * object_info.scale.x,
248
- object_info.size.y * object_info.scale.y,
249
- object_info.size.z * object_info.scale.z)
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)
250
256
  end
251
257
 
252
258
  cShape = Bullet::BtBoxShape.new(object_info.size)
253
259
  inertia = Bullet::BtVector3.new()
254
- cShape.calculateLocalInertia(physics_info.mass, inertia)
260
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
255
261
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, object_info.physics_offset)
256
- rb.setAngularFactor(physics_info.angular_factor)
257
- rb.setRestitution(physics_info.restitution)
258
- rb.setFriction(physics_info.friction)
259
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
260
266
 
261
267
  @garden.add_object(obj)
262
268
 
@@ -270,26 +276,26 @@ class ObjectFactory
270
276
  obj.physics_info = physics_info
271
277
 
272
278
  unless @garden.is_server
273
- entity = @garden.view.scene_mgr.createEntity(name, object_info.mesh_path)
274
- entity.setCastShadows(true)
275
- entity.setMaterialName(object_info.material_name) if object_info.material_name
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
276
282
  node = obj.create_scene_node(entity, object_info.view_offset)
277
- node.setScale(object_info.scale.x, object_info.scale.y, object_info.scale.z)
278
- strider = Teienlib::MeshStrider.new(entity.getMesh().get())
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())
279
285
  cShape = Bullet::BtGImpactMeshShape.new(strider)
280
- cShape.setLocalScaling(Bullet::BtVector3.new(object_info.scale.x,
281
- object_info.scale.y,
282
- object_info.scale.z))
286
+ cShape.set_local_scaling(Bullet::BtVector3.new(object_info.scale.x,
287
+ object_info.scale.y,
288
+ object_info.scale.z))
283
289
  cShape.instance_variable_set(:@strider, strider) # prevent this from GC.
284
- cShape.postUpdate()
285
- cShape.updateBound()
290
+ cShape.post_update()
291
+ cShape.update_bound()
286
292
  inertia = Bullet::BtVector3.new()
287
- cShape.calculateLocalInertia(physics_info.mass, inertia)
293
+ cShape.calculate_local_inertia(physics_info.mass, inertia)
288
294
  rb = obj.create_rigid_body(physics_info.mass, cShape, inertia, object_info.physics_offset)
289
- rb.setAngularFactor(physics_info.angular_factor)
290
- rb.setRestitution(physics_info.restitution)
291
- rb.setFriction(physics_info.friction)
292
- rb.setDamping(physics_info.linear_damping, physics_info.angular_damping)
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)
293
299
  end
294
300
 
295
301
  @garden.add_object(obj)
data/lib/teien/physics.rb CHANGED
@@ -12,9 +12,9 @@ class ContactResult < Bullet::ContactResultCallback
12
12
  return @isCollided
13
13
  end
14
14
 
15
- def addSingleResult(cp,
16
- colObj0, partId0, index0,
17
- colObj1, partId1, index1)
15
+ def add_single_result(cp,
16
+ colObj0, partId0, index0,
17
+ colObj1, partId1, index1)
18
18
  @isCollided = true
19
19
  return 0
20
20
  end
@@ -51,10 +51,10 @@ class Physics < Bullet::TickListener
51
51
  @dynamics_world = Bullet::BtDiscreteDynamicsWorld.new(@collision_dispatcher, @aabb_cache,
52
52
  @solver, @collision_config)
53
53
  gravity = Bullet::BtVector3.new(0.0, -9.8, 0.0)
54
- @dynamics_world.setGravity(gravity)
54
+ @dynamics_world.set_gravity(gravity)
55
55
 
56
- @dynamics_world.setInternalTickCallback(self, true);
57
- @dynamics_world.setInternalTickCallback(self, false);
56
+ @dynamics_world.set_internal_tick_callback(self, true);
57
+ @dynamics_world.set_internal_tick_callback(self, false);
58
58
  =begin
59
59
  worldAabbCache->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
60
60
  =end
@@ -70,7 +70,7 @@ class Physics < Bullet::TickListener
70
70
  def finalize
71
71
  # clear all objects.
72
72
  @rigid_bodies.each{|body|
73
- @dynamics_world.removeRigidBody(body)
73
+ @dynamics_world.remove_rigid_body(body)
74
74
  }
75
75
  @rigid_bodies = []
76
76
 
@@ -78,24 +78,24 @@ class Physics < Bullet::TickListener
78
78
  end
79
79
 
80
80
  def update(delta)
81
- @dynamics_world.stepSimulation(delta, @max_sub_steps, @fixed_time_step)
81
+ @dynamics_world.step_simulation(delta, @max_sub_steps, @fixed_time_step)
82
82
  return true
83
83
  end
84
84
 
85
- def frameRenderingQueued(evt)
85
+ def frame_rendering_queued(evt)
86
86
  # print "Physics::tick: ", evt.timeSinceLastFrame * 1000, "ms\n"
87
- @dynamics_world.stepSimulation(evt.timeSinceLastFrame, @max_sub_steps, @fixed_time_step)
87
+ @dynamics_world.step_simulation(evt.timeSinceLastFrame, @max_sub_steps, @fixed_time_step)
88
88
  return true
89
89
  end
90
90
 
91
91
  def flush_pair_cache(rigid_body)
92
- pair_cache = @dynamics_world.getBroadphase().getOverlappingPairCache()
93
- pair_cache.removeOverlappingPairsContainingProxy(rigid_body.getBroadphaseHandle(),
94
- @dynamics_world.getDispatcher())
92
+ pair_cache = @dynamics_world.get_broadphase().get_overlapping_pair_cache()
93
+ pair_cache.remove_overlapping_pairs_containing_proxy(rigid_body.get_broadphase_handle(),
94
+ @dynamics_world.get_dispatcher())
95
95
  end
96
96
 
97
97
  def set_gravity(vec)
98
- @dynamics_world.setGravity(vec)
98
+ @dynamics_world.set_gravity(vec)
99
99
  end
100
100
 
101
101
  =begin
@@ -117,15 +117,15 @@ class Physics < Bullet::TickListener
117
117
  def add_rigid_body(rigid_body, collision_filter = nil)
118
118
  @rigid_bodies.push(rigid_body)
119
119
  if (collision_filter)
120
- @dynamics_world.addRigidBody(rigid_body, collision_filter.group, collision_filter.mask)
120
+ @dynamics_world.add_rigid_body(rigid_body, collision_filter.group, collision_filter.mask)
121
121
  else
122
- @dynamics_world.addRigidBody(rigid_body)
122
+ @dynamics_world.add_rigid_body(rigid_body)
123
123
  end
124
124
  end
125
125
 
126
126
  def contact_pair_test(colObjA, colObjB)
127
127
  result = ContactResult.new
128
- @dynamics_world.contactPairTest(colObjA, colObjB, result)
128
+ @dynamics_world.contact_pair_test(colObjA, colObjB, result)
129
129
  return result
130
130
  end
131
131