Class: Teien::ConeObjectInfo

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

Instance Attribute Summary collapse

Attributes inherited from ObjectInfo

#use_physics

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(radius, height, num_seg_base = 16, num_seg_height = 1, u_tile = 1.0, v_tile = 1.0) ⇒ ConeObjectInfo

Returns a new instance of ConeObjectInfo.



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

def initialize(radius, height, num_seg_base = 16, num_seg_height = 1, u_tile = 1.0, v_tile = 1.0)
  super()
  @radius = radius
  @height = height
  @num_seg_base = num_seg_base
  @num_seg_height = num_seg_height
  @u_tile = u_tile
  @v_tile = v_tile
  @material_name = nil
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#material_nameObject

Returns the value of attribute material_name.



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

def material_name
  @material_name
end

#num_seg_baseObject

Returns the value of attribute num_seg_base.



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

def num_seg_base
  @num_seg_base
end

#num_seg_heightObject

Returns the value of attribute num_seg_height.



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

def num_seg_height
  @num_seg_height
end

#radiusObject

Returns the value of attribute radius.



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

def radius
  @radius
end

#u_tileObject

Returns the value of attribute u_tile.



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

def u_tile
  @u_tile
end

#v_tileObject

Returns the value of attribute v_tile.



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

def v_tile
  @v_tile
end

Class Method Details

.create_physics_object(obj, physics) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/teien/base_object/std_objects/cone_object_info.rb', line 25

def self.create_physics_object(obj, physics)
  physics_object = PhysicsObject.new(physics)
  cShape = Bullet::BtConeShape.new(obj.object_info.radius, obj.object_info.height)
  inertia = Bullet::BtVector3.new()
  cShape.calculate_local_inertia(obj.physics_info.mass, inertia)
  physics_object.set_rigid_body(obj, cShape, inertia, 
                                Vector3D.new(0, obj.object_info.height / 2, 0))

  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
20
# File 'lib/teien/ui/std_objects/cone_object_info.rb', line 7

def self.create_view_object(obj, view)
  gen = Procedural::ConeGenerator.new
  gen.set_radius(obj.object_info.radius).set_height(obj.object_info.height)
  gen.set_num_seg_base(obj.object_info.num_seg_base).set_num_seg_height(obj.object_info.num_seg_height)
  gen.set_utile(obj.object_info.u_tile).set_vtile(obj.object_info.v_tile).realize_mesh(obj.name)
  entity = view.scene_mgr.create_entity(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