class Fox::FXGLSphere

OpenGL sphere object

Constants

SLICES_NUMBER

Sphere fidelity

STACKS_NUMBER

Attributes

radius[RW]

Sphere radius [Float]

slices[RW]

Number of slices (default is 20) [Integer]

stacks[RW]

Number of stacks (default is 20) [Integer]

Public Class Methods

new(*args) click to toggle source

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.

Calls superclass method Fox::FXGLShape::new
# File lib/fox16/glshapes.rb, line 446
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

Public Instance Methods

drawshape(viewer) click to toggle source

Draw this sphere into viewer (an FXGLViewer instance).

# File lib/fox16/glshapes.rb, line 462
def drawshape(viewer)
  quad = gluNewQuadric()
  gluQuadricDrawStyle(quad, GLU_FILL)
  gluSphere(quad, @radius, @slices, @stacks)
  gluDeleteQuadric(quad)
end