Class: Teien::MeshBBObjectInfo

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

Instance Attribute Summary collapse

Attributes inherited from ObjectInfo

#use_physics

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mesh_path, size, scale = Vector3D.new(1, 1, 1), view_offset = Vector3D.new(0, 0, 0), view_rotation = Quaternion.new(0, 0, 0, 1.0), physics_offset = Vector3D.new(0, 0, 0)) ⇒ MeshBBObjectInfo

Returns a new instance of MeshBBObjectInfo.



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

def initialize(mesh_path, size, scale = Vector3D.new(1, 1, 1),
               view_offset = Vector3D.new(0, 0, 0),
               view_rotation = Quaternion.new(0, 0, 0, 1.0),
               physics_offset = Vector3D.new(0, 0, 0))
  super()
  @size = size
  @mesh_path = mesh_path
  @scale = scale
  @view_offset = view_offset
  @view_rotation = view_rotation
  @physics_offset = physics_offset
  @material_name = nil
end

Instance Attribute Details

#material_nameObject

Returns the value of attribute material_name.



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

def material_name
  @material_name
end

#mesh_pathObject

Returns the value of attribute mesh_path.



6
7
8
# File 'lib/teien/base_object/std_objects/mesh_bb_object_info.rb', line 6

def mesh_path
  @mesh_path
end

#physics_offsetObject

Loading mesh only: offset of collision Box



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

def physics_offset
  @physics_offset
end

#scaleObject

Loading mesh only: scales mesh



8
9
10
# File 'lib/teien/base_object/std_objects/mesh_bb_object_info.rb', line 8

def scale
  @scale
end

#sizeObject

Loading mesh only: bounding box size



7
8
9
# File 'lib/teien/base_object/std_objects/mesh_bb_object_info.rb', line 7

def size
  @size
end

#view_offsetObject

Loading mesh only: offset of Mesh



9
10
11
# File 'lib/teien/base_object/std_objects/mesh_bb_object_info.rb', line 9

def view_offset
  @view_offset
end

#view_rotationObject

Loading mesh only: rotation offset of Mesh



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

def view_rotation
  @view_rotation
end

Class Method Details

.create_physics_object(obj, physics) ⇒ Object



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

def self.create_physics_object(obj, physics)
  physics_object = PhysicsObject.new(physics)
  cShape = Bullet::BtBoxShape.new(obj.object_info.size)
  inertia = Bullet::BtVector3.new()
  cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
  physics_object.set_rigid_body(obj, cShape, inertia, obj.object_info.physics_offset)

  obj.object_info.use_physics = true
  return physics_object
end

.create_view_object(obj, view) ⇒ Object



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

def self.create_view_object(obj, view)
  entity = view.scene_mgr.create_entity(obj.name, obj.object_info.mesh_path)
  entity.set_cast_shadows(true)
  entity.set_material_name(obj.object_info.material_name) if obj.object_info.material_name

  view_object = ViewObject.new(view)
  node = view_object.set_scene_node(entity, obj.object_info.view_offset, obj.object_info.view_rotation)
  node.set_scale(obj.object_info.size.x * obj.object_info.scale.x, 
                 obj.object_info.size.y * obj.object_info.scale.y, 
                 obj.object_info.size.z * obj.object_info.scale.z)

  return view_object
end