Class: Fox::FXGLPoint

Inherits:
FXGLObject show all
Includes:
OpenGL
Defined in:
lib/fox16/glshapes.rb

Overview

OpenGL point object

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FXGLObject

#canDelete, #canDrag, #copy, #drag, #identify

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(*args) ⇒ FXGLPoint

Returns an initialized FXGLPoint instance. If no arguments are passed to #new, the initial point position is (0.0, 0.0, 0.0). You can specify a different initial position by passing in the x, y and z coordinates individually:

aPoint = FXGLPoint.new(x, y, z)

or as a 3-element array:

aPoint = FXGLPoint.new([x, y, z])

29
30
31
32
33
34
35
36
37
38
# File 'lib/fox16/glshapes.rb', line 29

def initialize(*args)
  super()
  if args.length == 0
    @pos = [0.0, 0.0, 0.0]
  elsif args.length == 3
    @pos = [args[0], args[1], args[2]]
  else
    @pos = args[0]
  end
end

Instance Attribute Details

#posObject

Point position, in model coordinates (a 3-element array)


15
16
17
# File 'lib/fox16/glshapes.rb', line 15

def pos
  @pos
end

Instance Method Details

#boundsObject

Return the bounding box (an FXRangef instance) for this point.


43
44
45
# File 'lib/fox16/glshapes.rb', line 43

def bounds
  FXRangef.new(@pos[0], @pos[0], @pos[1], @pos[1], @pos[2], @pos[2])
end

#draw(viewer) ⇒ Object

Draw this point into viewer (an FXGLViewer instance).


50
51
52
53
54
55
56
# File 'lib/fox16/glshapes.rb', line 50

def draw(viewer)
  glColor3d(0.0, 0.0, 1.0)
  glPointSize(HANDLE_SIZE)
  glBegin(GL_POINTS)
  glVertex3d(*@pos)
  glEnd()
end

#hit(viewer) ⇒ Object

Perform hit test for this point in viewer (an FXGLViewer instance).


61
62
63
64
65
# File 'lib/fox16/glshapes.rb', line 61

def hit(viewer)
  glBegin(GL_POINTS)
  glVertex3d(*@pos)
  glEnd()
end