Class: Fox::FXGLCone

Inherits:
FXGLShape show all
Includes:
GLU, OpenGL
Defined in:
lib/fox16/glshapes.rb

Overview

OpenGL cone object

Constant Summary collapse

SLICES_NUMBER =

Cone fidelity

20
STACKS_NUMBER =
20
LOOPS =
4

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) ⇒ FXGLCone

Returns an initialized FXGLCone instance.

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

aCone = FXGLCone.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 cone with a specified origin, height, radius and material:

aCone = FXGLCone.new(x, y, z, h, r, material)

where the material is an FXMaterial instance.


300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/fox16/glshapes.rb', line 300

def initialize(*args)
  if args.length == 5
    super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE)
  elsif args.length == 6
    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

Instance Attribute Details

#heightObject

Cone height [Float]


269
270
271
# File 'lib/fox16/glshapes.rb', line 269

def height
  @height
end

#loopsObject

Number of loops (default is 4) [Integer]


281
282
283
# File 'lib/fox16/glshapes.rb', line 281

def loops
  @loops
end

#radiusObject

Cone base radius [Float]


272
273
274
# File 'lib/fox16/glshapes.rb', line 272

def radius
  @radius
end

#slicesObject

Number of slices (default is 20) [Integer]


275
276
277
# File 'lib/fox16/glshapes.rb', line 275

def slices
  @slices
end

#stacksObject

Number of stacks (default is 20) [Integer]


278
279
280
# File 'lib/fox16/glshapes.rb', line 278

def stacks
  @stacks
end

Instance Method Details

#drawshape(viewer) ⇒ Object

Draw this cone into viewer (an FXGLViewer instance).


318
319
320
321
322
323
324
325
326
327
328
# File 'lib/fox16/glshapes.rb', line 318

def drawshape(viewer)
  quad = gluNewQuadric()
  gluQuadricDrawStyle(quad, GLU_FILL)
  glPushMatrix()
  glRotated(-90, 1, 0, 0)
  gluCylinder(quad, @radius, 0, @height, @slices, @stacks)
  gluQuadricOrientation(quad, GLU_INSIDE)
  gluDisk(quad, 0, @radius, @slices, @loops)
  gluDeleteQuadric(quad)
  glPopMatrix()
end