Class: Teien::FloorObjectInfo

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

Instance Attribute Summary collapse

Attributes inherited from ObjectInfo

#use_physics

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height, depth = 0.5, num_seg_x = 1, num_seg_y = 1, u_tile = 1.0, v_tile = 1.0) ⇒ FloorObjectInfo

Returns a new instance of FloorObjectInfo.



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

def initialize(width, height, depth = 0.5, num_seg_x = 1, num_seg_y = 1, u_tile = 1.0, v_tile = 1.0)
  super()
  @width   = width
  @height  = height
  @depth   = depth
  @num_seg_x = num_seg_x
  @num_seg_y = num_seg_y
  @u_tile   = u_tile
  @v_tile   = v_tile
  @material_name = nil
end

Instance Attribute Details

#depthObject

Returns the value of attribute depth.



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

def depth
  @depth
end

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#material_nameObject

Returns the value of attribute material_name.



13
14
15
# File 'lib/teien/base_object/std_objects/floor_object_info.rb', line 13

def material_name
  @material_name
end

#num_seg_xObject

Returns the value of attribute num_seg_x.



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

def num_seg_x
  @num_seg_x
end

#num_seg_yObject

Returns the value of attribute num_seg_y.



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

def num_seg_y
  @num_seg_y
end

#u_tileObject

Returns the value of attribute u_tile.



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

def u_tile
  @u_tile
end

#v_tileObject

Returns the value of attribute v_tile.



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

def v_tile
  @v_tile
end

#widthObject

Returns the value of attribute width.



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

def width
  @width
end

Class Method Details

.create_physics_object(obj, physics) ⇒ Object

Setting a collision shape and a rigid body of Bullet.



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

def self.create_physics_object(obj, physics)
  physics_object = PhysicsObject.new(physics)
  cShape = Bullet::BtBoxShape.new(Vector3D.new(obj.object_info.width, 
                                               obj.object_info.depth, 
                                               obj.object_info.height))
  physics_object.set_rigid_body(obj, cShape, 
                                Vector3D.new(0, 0, 0), 
                                Vector3D.new(0.0, -obj.object_info.depth, 0.0))

  obj.object_info.use_physics = true

  return physics_object
end

.create_view_object(obj, view) ⇒ Object

Setting an entity and a node of Ogre3d.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/teien/ui/std_objects/floor_object_info.rb', line 8

def self.create_view_object(obj, view)
  normal = Ogre::Vector3.new(0, 1, 0)
  up = Ogre::Vector3.new(0, 0, 1)
  Ogre::MeshManager::get_singleton().create_plane(obj.name, 
                                                  Ogre::ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
                                                  Ogre::Plane.new(normal, 0), 
                                                  obj.object_info.width * 2.0, 
                                                  obj.object_info.height * 2.0, 
                                                  obj.object_info.num_seg_x, 
                                                  obj.object_info.num_seg_y, 
                                                  true, 1, 
                                                  obj.object_info.u_tile, 
                                                  obj.object_info.v_tile, up)
  entity = view.scene_mgr.create_entity(obj.name, obj.name)
  entity.set_cast_shadows(true)
  entity.set_material_name(obj.object_info.material_name)

  view_object = ViewObject.new(view)
  view_object.set_scene_node(entity)

  return view_object
end