| Class | LiteFace2 |
| In: |
liteface.rb
|
| Parent: | FXGLShape |
| info | [RW] | ref attributesattr_accessor :p0, :p1, :p2, :p3 interaction attributes |
| selected | [RW] | ref attributesattr_accessor :p0, :p1, :p2, :p3 interaction attributes |
# File liteface.rb, line 257 def initialize(celldef, x, y, z, parent, self1, text) # if independent line is created # LiteFace is created with LiteFace.new[InfoPoint,InfoPoint,InfoPoint,InfoPoint,@parent,@viewerobj,@text,true] # initialize with positions, set nopointref=true #begin super(0.0,0.0,0.0, SHADING_FLAT|STYLE_SURFACE) @firstinit = true @celldef = celldef @x = x @y = y @z = z @parent = parent @viewerobj = self1 @text = text @info = [@parent, @viewerobj, @text] @xlow = @x.min @xhigh = @x.max @ylow = @y.min @yhigh = @y.max @zlow = @z.min @zhigh = @z.max @normal = Array.new @celldef.each_with_index do |cell, num| vec0 = [ @x[cell[1]] - @x[cell[0]], @y[cell[1]] - @y[cell[0]], @z[cell[1]] - @z[cell[0]] ] vec1 = [ @x[cell[3]] - @x[cell[0]], @y[cell[3]] - @y[cell[0]], @z[cell[3]] - @z[cell[0]] ] @normal[num]=crossNormal(vec0, vec1) end @gray2 = [ 165.0/255, 160.0/255, 160.0/255, 0 ] @dark2 = [ 165.0/255, 145.0/255, 145.0/255, 0 ] @selgray2 = [ 255.0/255, 255.0/255, 0.0/255, 0 ] @seldark2 = [ 245.0/255, 245.0/255, 0.0/255, 0 ] #rescue # FXMessageBox.error(self,MBOX_OK,"Error", # "Problem with creation of Face.\nAbort current object creation") #end @selected = false # Now the range is not set, don't now all implications of disabling this setRange(FXRangef.new(@xlow,@xhigh,@ylow,@yhigh,@zlow,@zhigh)) end
# File liteface.rb, line 324 def drawface(selected1) GL.Enable(GL::LIGHT0); @celldef.each_with_index do |cell, num| if !selected1 && cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @dark2); GL.Light(GL::LIGHT0, GL::AMBIENT, @dark2); elsif !selected1 && !cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @gray2); GL.Light(GL::LIGHT0, GL::AMBIENT, @gray2); elsif selected1 && cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @seldark2); GL.Light(GL::LIGHT0, GL::AMBIENT, @seldark2); elsif selected1 && !cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @selgray2); GL.Light(GL::LIGHT0, GL::AMBIENT, @selgray2); end GL::Begin(GL::QUAD_STRIP); GL::Normal(@normal[num][0], @normal[num][1], @normal[num][2]); GL::Vertex(@x[cell[0]], @y[cell[0]], @z[cell[0]]); GL::Vertex(@x[cell[1]], @y[cell[1]], @z[cell[1]]); GL::Vertex(@x[cell[3]], @y[cell[3]], @z[cell[3]]); GL::Vertex(@x[cell[2]], @y[cell[2]], @z[cell[2]]); GL::End(); end end
# File liteface.rb, line 349 def drawshape(viewer) if @firstinit @face1 = GL.GenLists(1) GL.NewList(@face1, GL::COMPILE) #GL.Material(GL::FRONT, GL::AMBIENT_AND_DIFFUSE, @gray2) drawface(false) GL.EndList() @face2 = GL.GenLists(2) GL.NewList(@face2, GL::COMPILE) #GL.Material(GL::FRONT, GL::AMBIENT_AND_DIFFUSE, @gray2) drawface(true) GL.EndList() @currentlist = @face1 @firstinit = false end GL.CallList(@currentlist) end
Draws this face into viewer (an FXGLViewer instance).
# File liteface.rb, line 300 def drawshapeSave(viewer) @celldef.each_with_index do |cell, num| if !@selected && cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @dark2); GL.Light(GL::LIGHT0, GL::AMBIENT, @dark2); elsif !@selected && !cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @gray2); GL.Light(GL::LIGHT0, GL::AMBIENT, @gray2); elsif @selected && cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @seldark2); GL.Light(GL::LIGHT0, GL::AMBIENT, @seldark2); elsif @selected && !cell[4] GL.Light(GL::LIGHT0, GL::DIFFUSE, @selgray2); GL.Light(GL::LIGHT0, GL::AMBIENT, @selgray2); end GL::Begin(GL::QUAD_STRIP); GL::Normal(@normal[num][0], @normal[num][1], @normal[num][2]); GL::Vertex(@x[cell[0]], @y[cell[0]], @z[cell[0]]); GL::Vertex(@x[cell[1]], @y[cell[1]], @z[cell[1]]); GL::Vertex(@x[cell[3]], @y[cell[3]], @z[cell[3]]); GL::Vertex(@x[cell[2]], @y[cell[2]], @z[cell[2]]); GL::End(); end end