Class: Fox::FXGLCone

Inherits:
FXGLShape show all
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.



291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/fox16/glshapes.rb', line 291

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]



260
261
262
# File 'lib/fox16/glshapes.rb', line 260

def height
  @height
end

#loopsObject

Number of loops (default is 4) [Integer]



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

def loops
  @loops
end

#radiusObject

Cone base radius [Float]



263
264
265
# File 'lib/fox16/glshapes.rb', line 263

def radius
  @radius
end

#slicesObject

Number of slices (default is 20) [Integer]



266
267
268
# File 'lib/fox16/glshapes.rb', line 266

def slices
  @slices
end

#stacksObject

Number of stacks (default is 20) [Integer]



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

def stacks
  @stacks
end

Instance Method Details

#drawshape(viewer) ⇒ Object

Draw this cone into viewer (an FXGLViewer instance).



309
310
311
312
313
314
315
316
317
318
319
# File 'lib/fox16/glshapes.rb', line 309

def drawshape(viewer)
  quad = GLU.NewQuadric()
  GLU.QuadricDrawStyle(quad, GLU::FILL)
  GL.PushMatrix()
  GL.Rotated(-90, 1, 0, 0)
  GLU.Cylinder(quad, @radius, 0, @height, @slices, @stacks)
  GLU.QuadricOrientation(quad, GLU::INSIDE)
  GLU.Disk(quad, 0, @radius, @slices, @loops)
  GLU.DeleteQuadric(quad)
  GL.PopMatrix()
end