Class: Fox::FXGLSphere

Inherits:
FXGLShape show all
Defined in:
lib/fox16/glshapes.rb

Overview

OpenGL sphere object

Constant Summary collapse

SLICES_NUMBER =

Sphere fidelity

20
STACKS_NUMBER =
20

Instance Attribute Summary collapse

Attributes inherited from FXGLShape

#position, #tipText

Instance Method Summary collapse

Methods inherited from FXGLShape

#getMaterial, #setMaterial, #setRange

Methods inherited from FXGLObject

#bounds, #canDelete, #canDrag, #copy, #drag, #draw, #hit, #identify

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(*args) ⇒ FXGLSphere

Returns an initialized FXGLSphere instance.

One option is to initialize the sphere with a specified origin and radius:

aSphere = FXGLSphere.new(x, y, z, r)

If left unspecified, the radius (r) defaults to 1.0.

Another option is to initialize the sphere with a specified origin, radius and material:

aSphere = FXGLSphere.new(x, y, z, r, material)

where the material is an FXMaterial instance.



431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/fox16/glshapes.rb', line 431

def initialize(*args)
  if args.length == 4
    super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE)
  else
    super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE,
    args[4], args[4])
  end
  @radius = args[3] ? args[3] : 1.0
  @slices = SLICES_NUMBER
  @stacks = STACKS_NUMBER
  setRange(FXRangef.new(-@radius, @radius, -@radius, @radius, -@radius, @radius))
end

Instance Attribute Details

#radiusObject

Sphere radius [Float]



406
407
408
# File 'lib/fox16/glshapes.rb', line 406

def radius
  @radius
end

#slicesObject

Number of slices (default is 20) [Integer]



409
410
411
# File 'lib/fox16/glshapes.rb', line 409

def slices
  @slices
end

#stacksObject

Number of stacks (default is 20) [Integer]



412
413
414
# File 'lib/fox16/glshapes.rb', line 412

def stacks
  @stacks
end

Instance Method Details

#drawshape(viewer) ⇒ Object

Draw this sphere into viewer (an FXGLViewer instance).



447
448
449
450
451
452
# File 'lib/fox16/glshapes.rb', line 447

def drawshape(viewer)
  quad = GLU.NewQuadric()
  GLU.QuadricDrawStyle(quad, GLU::FILL)
  GLU.Sphere(quad, @radius, @slices, @stacks)
  GLU.DeleteQuadric(quad)
end