class Fox::FXGLCylinder

OpenGL cylinder object

Constants

LOOPS
SLICES_NUMBER

Cylinder fidelity

STACKS_NUMBER

Attributes

height[RW]

Cylinder height [Float]

loops[RW]

Number of loops (default is 4) [Integer]

radius[RW]

Cylinder 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 FXGLCylinder instance.

One option is to initialize the cylinder with a specified origin, height and radius:

aCylinder = FXGLCylinder.new(x, y, z, h, r)

If left unspecified, the height (h) and radius (r) default to 1.0.

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

aCylinder = FXGLCylinder.new(x, y, z, h, r, material)

where the material is an FXMaterial instance.

Calls superclass method Fox::FXGLShape.new
# File lib/fox16/glshapes.rb, line 366
def initialize(*args)
  if args.length == 5
    super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE)
  else
    super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE,
          args[5], args[5])
  end
  @height = args[3] ? args[3] : 1.0
  @radius = args[4] ? args[4] : 1.0
  @slices = SLICES_NUMBER
  @stacks = STACKS_NUMBER
  @loops  = LOOPS
  setRange(FXRangef.new(-@radius, @radius, 0, @height, -@radius, @radius))
end

Public Instance Methods

drawshape(viewer) click to toggle source

Draw this cylinder into viewer (an FXGLViewer instance).

# File lib/fox16/glshapes.rb, line 384
def drawshape(viewer)
  quad = GLU::NewQuadric()
  GLU::QuadricDrawStyle(quad, GLU::FILL)
  GL::PushMatrix()
  GL::Rotate(-90, 1, 0, 0)
  GLU::Cylinder(quad, @radius, @radius, @height, @slices, @stacks)
  GLU::QuadricOrientation(quad, GLU::INSIDE)
  GLU::Disk(quad, 0, @radius, @slices, @loops)
  GL::Translate(0, 0, @height)
  GLU::QuadricOrientation(quad, GLU::OUTSIDE)
  GLU::Disk(quad, 0, @radius, @slices, @loops)
  GL::PopMatrix()
  GLU::DeleteQuadric(quad)
end