Class: FMOD::Geometry::Polygon Abstract
- Inherits:
-
Object
- Object
- FMOD::Geometry::Polygon
- Includes:
- Enumerable
- Defined in:
- lib/fmod/geometry.rb
Overview
Wrapper class for a polygon within a FMOD::Geometry object.
Instance Attribute Summary collapse
-
#direct_occlusion ⇒ Float
The occlusion value from 0.0 to 1.0 which affects volume or audible frequencies.
-
#double_sided ⇒ Boolean
The description of polygon if it is double sided or single sided.
-
#geometry ⇒ Geometry
readonly
The parent geometry object.
-
#index ⇒ Integer
readonly
The index of the Polygon within its parent FMOD::Geometry object.
-
#reverb_occlusion ⇒ Float
The occlusion value from 0.0 to 1.0 which affects the reverb mix.
Instance Method Summary collapse
-
#[](index) ⇒ Vector
Retrieves the vertex of the polygon at the specified index.
-
#[]=(index, vertex) ⇒ Vector
Sets the vertex of the polygon at the specified index.
- #each ⇒ Object
-
#initialize(geometry, index) ⇒ Polygon
constructor
private
Creates a new instance of a Polygon object.
-
#vertex_count ⇒ Integer
(also: #size)
Retrieves the number of vertices within the polygon.
-
#vertices ⇒ Array<Vector>
Retrieves an array of the vertices within the polygon.
Constructor Details
#initialize(geometry, index) ⇒ Polygon
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Polygon objects should not be created by the user, only through FMOD::Geometry#add_polygon, as they are an abstract wrapper only, not backed by an actual object.
Creates a new instance of a Polygon object.
257 258 259 |
# File 'lib/fmod/geometry.rb', line 257 def initialize(geometry, index) @geometry, @index = geometry, index end |
Instance Attribute Details
#direct_occlusion ⇒ Float
The occlusion value from 0.0 to 1.0 which affects volume or audible frequencies.
-
Minimum: 0.0 The polygon does not occlude volume or audible frequencies (sound will be fully audible)
-
Maximum: 1.0 The polygon fully occludes (sound will be silent)
271 272 273 274 275 276 |
# File 'lib/fmod/geometry.rb', line 271 def direct_occlusion occlusion = "\0" * Fiddle::SIZEOF_FLOAT FMOD.invoke(:Geometry_GetPolygonAttributes, @geometry, @index, occlusion, nil, nil) occlusion.unpack1('f') end |
#double_sided ⇒ Boolean
The description of polygon if it is double sided or single sided.
-
true: The polygon is double sided
-
false: The polygon is single sided, and the winding of the polygon (which determines the polygon’s normal) determines which side of the polygon will cause occlusion.
315 316 317 318 319 320 |
# File 'lib/fmod/geometry.rb', line 315 def double_sided double = "\0" * Fiddle::SIZEOF_INT FMOD.invoke(:Geometry_GetPolygonAttributes, @geometry, @index, nil, nil, double) double.unpack1('l') != 0 end |
#geometry ⇒ Geometry (readonly)
The parent geometry object.
242 243 244 |
# File 'lib/fmod/geometry.rb', line 242 def geometry @geometry end |
#index ⇒ Integer (readonly)
The index of the FMOD::Geometry::Polygon within its parent FMOD::Geometry object.
247 248 249 |
# File 'lib/fmod/geometry.rb', line 247 def index @index end |
#reverb_occlusion ⇒ Float
The occlusion value from 0.0 to 1.0 which affects the reverb mix.
-
Minimum: 0.0 The polygon does not occlude reverb (reverb reflections still travel through this polygon)
-
Maximum: 1.0 The polygon fully occludes reverb (reverb reflections will be silent through this polygon)
293 294 295 296 297 298 |
# File 'lib/fmod/geometry.rb', line 293 def reverb_occlusion occlusion = "\0" * Fiddle::SIZEOF_FLOAT FMOD.invoke(:Geometry_GetPolygonAttributes, @geometry, @index, nil, occlusion, nil) occlusion.unpack1('f') end |
Instance Method Details
#[](index) ⇒ Vector
Retrieves the vertex of the polygon at the specified index.
342 343 344 345 346 347 |
# File 'lib/fmod/geometry.rb', line 342 def [](index) return nil unless index.between?(0, vertex_count - 1) vertex = Vector.zero FMOD.invoke(:Geometry_GetPolygonVertex, @geometry, @index, index, vertex) vertex end |
#[]=(index, vertex) ⇒ Vector
Sets the vertex of the polygon at the specified index.
354 355 356 357 358 359 360 361 |
# File 'lib/fmod/geometry.rb', line 354 def []=(index, vertex) unless index.between?(0, vertex_count - 1) = "Index #{index} outside of bounds: 0...#{vertex.count}" raise IndexError, end FMOD.type?(vertex, Vector) FMOD.invoke(:Geometry_SetPolygonVertex, @geometry, @index, index, vertex) end |
#each {|vertex| ... } ⇒ self #each ⇒ Enumerator
373 374 375 376 377 |
# File 'lib/fmod/geometry.rb', line 373 def each return to_enum(:each) unless block_given? (0...vertex_count).each { |i| yield self[i] } self end |
#vertex_count ⇒ Integer Also known as: size
Retrieves the number of vertices within the polygon.
330 331 332 333 334 |
# File 'lib/fmod/geometry.rb', line 330 def vertex_count count = "\0" * Fiddle::SIZEOF_INT FMOD.invoke(:Geometry_GetPolygonNumVertices, @geometry, @index, count) count.unpack1('l') end |
#vertices ⇒ Array<Vector>
Retrieves an array of the vertices within the polygon.
382 383 384 |
# File 'lib/fmod/geometry.rb', line 382 def vertices (0...vertex_count).map { |i| self[i] } end |