Class: Fox::FXGLSphere

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

Overview

OpenGL sphere object

Constant Summary

SLICES_NUMBER =

Sphere fidelity

20
STACKS_NUMBER =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FXGLShape

#position, #position=, #range=, #tipText, #tipText=

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.



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

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]



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

def radius
  @radius
end

#slicesObject

Number of slices (default is 20) [Integer]



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

def slices
  @slices
end

#stacksObject

Number of stacks (default is 20) [Integer]



414
415
416
# File 'lib/fox16/glshapes.rb', line 414

def stacks
  @stacks
end

Instance Method Details

#drawshape(viewer) ⇒ Object

Draw this sphere into viewer (an FXGLViewer instance).



449
450
451
452
453
454
# File 'lib/fox16/glshapes.rb', line 449

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