NvTriStrip: Triangle stripification library
NvTriStrip provides a Ruby interface for Nvidia’s Triangle stripification library.
Original NvTriStrip is available from developer.nvidia.com , I’ve slightly modified the lib to fix compiling on various platforms.
Features
All features and shortcomings of Nvidia’s library are (hopefully) preserved.
Namely, features
-
Makes trianglestrips out of triangle lists
-
Optimizes trianglestrips for good cache use
-
Optionally stitches separate strips with degenerates
-
Can throw small strips into a list instead
-
Remaps indices to improve spatial locality in your vertex buffer
Some shortcomings
-
Limited geometry to 65k vertices (But that also has some practical value)
-
Uses global state to control some options (but should be otherwise reentrant)
-
Ruby version has to do some back and forth copying of the indices
Installation
With rubygems:
gem install nvtristrip-ruby
Otherwise:
ruby setup.rb
Usage
require 'nvtristrip'
my_triangle_indices=[0,1,2,1,2,3] # Two triangles
validate=true
stripified_indices=NvTriStrip::generate_strips my_triangle_indices, validate
# And now stripifiedIndices is an Array of NvTriStrip::PrimitiveGroup objects, which are Enumerable.
remapped_indices=NvTriStrip::remap_indices stripified_indices, 3
# And now remappedIndices is an array of PrimitiveGroups objects with indices
# remapped for better spatial locality. With this information you should remap your vertex buffer.