class Fox::FXGLCube
OpenGL cube object
Attributes
Cube depth [Float]
Cube height [Float]
Cube width [Float]
Public Class Methods
Source
# File lib/fox16/glshapes.rb, line 171 def initialize(*args) if args.length == 7 super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE, args[6], args[6]) else super(args[0], args[1], args[2], SHADING_SMOOTH|STYLE_SURFACE) end @width = args[3] ? args[3] : 1.0 @height = args[4] ? args[4] : 1.0 @depth = args[5] ? args[5] : 1.0 setRange(FXRangef.new(-0.5*@width, 0.5*@width, -0.5*@height, 0.5*@height, -0.5*@depth, 0.5*@depth)) end
Return an initialized FXGLCube instance.
One option is to initialize the cube with a specified origin, width, height and depth:
aCube = FXGLCube.new(x, y, z, w, h, d)
If left unspecified, the width (w), height (h) and depth (d) default to 1.0.
Another option is to initialize the cube with a specified origin, width, height, depth and material:
aCube = FXGLCube.new(x, y, z, w, h, d, material)
where the material is an FXMaterial instance.
Calls superclass method
Fox::FXGLShape::new
Public Instance Methods
Source
# File lib/fox16/glshapes.rb, line 189 def drawshape(viewer) xmin, xmax = -0.5*@width, 0.5*@width ymin, ymax = -0.5*@height, 0.5*@height zmin, zmax = -0.5*@depth, 0.5*@depth # Draw low face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(0.0, 0.0, -1.0) GL.Vertex3d(xmin, ymin, zmin) GL.Vertex3d(xmin, ymax, zmin) GL.Vertex3d(xmax, ymin, zmin) GL.Vertex3d(xmax, ymax, zmin) GL.End() # Draw east face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(1.0, 0.0, 0.0) GL.Vertex3d(xmax, ymin, zmin) GL.Vertex3d(xmax, ymax, zmin) GL.Vertex3d(xmax, ymin, zmax) GL.Vertex3d(xmax, ymax, zmax) GL.End() # Draw high face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(0.0, 0.0, 1.0) GL.Vertex3d(xmax, ymin, zmax) GL.Vertex3d(xmax, ymax, zmax) GL.Vertex3d(xmin, ymin, zmax) GL.Vertex3d(xmin, ymax, zmax) GL.End() # Draw west face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(-1.0, 0.0, 0.0) GL.Vertex3d(xmin, ymin, zmax) GL.Vertex3d(xmin, ymax, zmax) GL.Vertex3d(xmin, ymin, zmin) GL.Vertex3d(xmin, ymax, zmin) GL.End() # Draw north face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(0.0, 1.0, 0.0) GL.Vertex3d(xmin, ymax, zmin) GL.Vertex3d(xmin, ymax, zmax) GL.Vertex3d(xmax, ymax, zmin) GL.Vertex3d(xmax, ymax, zmax) GL.End() # Draw south face GL.Begin(GL::TRIANGLE_STRIP) GL.Normal3d(0.0, -1.0, 0.0) GL.Vertex3d(xmin, ymin, zmax) GL.Vertex3d(xmin, ymin, zmin) GL.Vertex3d(xmax, ymin, zmax) GL.Vertex3d(xmax, ymin, zmin) GL.End() end
Draws this cube into viewer (an FXGLViewer instance).