Sha256: cbc3967afeaa0056f75687a00a4d6c5fd311cdaedf1dc6787dcae2f8da511e9e

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

# mesh_to_vbo.rb, with java_imports becomes a specialist class
module MS  
  java_import 'wblut.hemesh.HEC_IsoSurface'
  java_import 'wblut.hemesh.HE_Mesh'
  java_import 'wblut.hemesh.HEM_Smooth'
  
  class MeshToVBO 
    
    attr_reader :parent
    
    def initialize(parent)
      @parent = parent
    end
    
    def meshToVBO(mesh, col = nil)
      tri_mesh = mesh.get
      tri_mesh.triangulate
      retained = parent.create_shape
      retained.begin_shape(TRIANGLES)
      if col
        retained.fill(col)
      else # we will have a light grey color, created by bit shifting
        fcol = (255 >> 24) & 0xFF|(211 >> 16) & 0xFF|(211 >> 8) & 0xFF|211
        retained.fill(fcol)
      end
      retained.ambient(50)
      retained.specular(50)
      mesh.fItr.each do |face|  # call each on the hemesh mesh iterator
        he = face.getHalfedge
        begin      # this block is the ruby equivalent of do while
          vx = he.getVertex
          vn = vx.getVertexNormal
          retained.normal(vn.xf, vn.yf, vn.zf)
          retained.vertex(vx.xf, vx.yf, vx.zf)
          he = he.getNextInFace
        end while (he != face.getHalfedge)
      end
      retained.end_shape
      return retained
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.6.2 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.6.1 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.6.0 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.5.1 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.5.0 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.4.4 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.4.3 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.4.2 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb
ruby-processing-2.4.1 samples/external_library/java_processing/hemesh/library/vbo/mesh_to_vbo.rb