Class: MSPhysics::Material
- Defined in:
- RubyExtension/MSPhysics/material.rb
Overview
Instance Method Summary collapse
-
#density ⇒ Numeric
Get material density in kilograms per cubic meter (kg/m^3).
-
#density=(value) ⇒ Object
Set material density in kilograms per cubic meter (kg/m^3).
-
#elasticity ⇒ Numeric
Get material coefficient of restitution - bounciness.
-
#elasticity=(coefficient) ⇒ Object
Set material coefficient of restitution - bounciness.
-
#equals?(other_material) ⇒ Boolean
Determine whether thi material has the same properties as another material.
-
#initialize(name, density, static_friction, kinetic_friction, elasticity, softness) ⇒ Material
constructor
A new instance of Material.
-
#kinetic_friction ⇒ Numeric
Get material kinetic friction coefficient.
-
#kinetic_friction=(coefficient) ⇒ Object
Set material kinetic friction coefficient.
-
#name ⇒ String
Get material name.
-
#softness ⇒ Numeric
Get material softness coefficient.
-
#softness=(coefficient) ⇒ Object
Set material softness coefficient.
-
#static_friction ⇒ Numeric
Get material static friction coefficient.
-
#static_friction=(coefficient) ⇒ Object
Set material static friction coefficient.
Methods inherited from Entity
Constructor Details
#initialize(name, density, static_friction, kinetic_friction, elasticity, softness) ⇒ Material
Returns a new instance of Material.
19 20 21 22 23 24 25 26 |
# File 'RubyExtension/MSPhysics/material.rb', line 19 def initialize(name, density, static_friction, kinetic_friction, elasticity, softness) @name = name.to_s @density = AMS.clamp(density, 0.001, nil) @static_friction = AMS.clamp(static_friction, 0.01, 2.00) @kinetic_friction = AMS.clamp(kinetic_friction, 0.01, 2.00) @elasticity = AMS.clamp(elasticity, 0.01, 2.00) @softness = AMS.clamp(softness, 0.01, 1.00) end |
Instance Method Details
#density ⇒ Numeric
Get material density in kilograms per cubic meter (kg/m^3).
36 37 38 |
# File 'RubyExtension/MSPhysics/material.rb', line 36 def density @density end |
#density=(value) ⇒ Object
Set material density in kilograms per cubic meter (kg/m^3).
42 43 44 |
# File 'RubyExtension/MSPhysics/material.rb', line 42 def density=(value) @density = AMS.clamp(value, 0.001, nil) end |
#elasticity ⇒ Numeric
Get material coefficient of restitution - bounciness.
72 73 74 |
# File 'RubyExtension/MSPhysics/material.rb', line 72 def elasticity @elasticity end |
#elasticity=(coefficient) ⇒ Object
Set material coefficient of restitution - bounciness.
78 79 80 |
# File 'RubyExtension/MSPhysics/material.rb', line 78 def elasticity=(coefficient) @elasticity = AMS.clamp(coefficient, 0.01, 2.00) end |
#equals?(other_material) ⇒ Boolean
Determine whether thi material has the same properties as another material.
98 99 100 101 102 103 104 |
# File 'RubyExtension/MSPhysics/material.rb', line 98 def equals?(other_material) ( other_material.density == @density && other_material.static_friction == @static_friction && other_material.kinetic_friction == @kinetic_friction && other_material.elasticity == @elasticity && other_material.softness == @softness ) end |
#kinetic_friction ⇒ Numeric
Get material kinetic friction coefficient.
60 61 62 |
# File 'RubyExtension/MSPhysics/material.rb', line 60 def kinetic_friction @kinetic_friction end |
#kinetic_friction=(coefficient) ⇒ Object
Set material kinetic friction coefficient.
66 67 68 |
# File 'RubyExtension/MSPhysics/material.rb', line 66 def kinetic_friction=(coefficient) @kinetic_friction = AMS.clamp(coefficient, 0.01, 2.00) end |
#name ⇒ String
Get material name.
30 31 32 |
# File 'RubyExtension/MSPhysics/material.rb', line 30 def name @name end |
#softness ⇒ Numeric
Get material softness coefficient.
84 85 86 |
# File 'RubyExtension/MSPhysics/material.rb', line 84 def softness @softness end |
#softness=(coefficient) ⇒ Object
Set material softness coefficient.
90 91 92 |
# File 'RubyExtension/MSPhysics/material.rb', line 90 def softness=(coefficient) @softness = AMS.clamp(coefficient, 0.01, 1.00) end |
#static_friction ⇒ Numeric
Get material static friction coefficient.
48 49 50 |
# File 'RubyExtension/MSPhysics/material.rb', line 48 def static_friction @static_friction end |
#static_friction=(coefficient) ⇒ Object
Set material static friction coefficient.
54 55 56 |
# File 'RubyExtension/MSPhysics/material.rb', line 54 def static_friction=(coefficient) @static_friction = AMS.clamp(coefficient, 0.01, 2.00) end |