お約束の立方体回転

require 'dxruby'

rgb = [[0, 0, 0], [0, 0, 255], [0, 255, 0], [0, 255, 255], [255, 0, 0], [255, 0, 255], [255, 255, 0], [255, 255,255]]
image = Image.new( 128 * 8, 128 )
rgb.each_with_index do |c, i|
  image.boxFill(i * 128, 0, i * 128 + 127, 127, c)
end

def createSquare(p, t)
  p = p.flatten
  t = t.flatten
  pa = Polygon.new
  pa.vertex = [p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]]
  pa.tutv = [t[0], t[1], t[2], t[3], t[4], t[5]]
  pb = Polygon.new
  pb.vertex = [p[0], p[1], p[2] ,p[6], p[7], p[8], p[9], p[10], p[11]]
  pb.tutv = [t[0], t[1], t[4], t[5], t[6], t[7]]
  [pa, pb]
end

tutv = []
for i in 1..6
  tutv.push([i * 128, 0, i * 128 + 127, 0, i * 128 + 127, 127, i * 128, 127])
end

point = [[-1, -1, -1], [1, -1, -1], [1, -1, 1], [-1, -1, 1], [-1, 1, -1], [1, 1, -1], [1, 1, 1], [-1, 1, 1]]
p = createSquare([point[0], point[1], point[2], point[3]], tutv[0])
p.concat createSquare([point[3], point[2], point[6], point[7]], tutv[1])
p.concat createSquare([point[0], point[3], point[7], point[4]], tutv[2])
p.concat createSquare([point[1], point[0], point[4], point[5]], tutv[3])
p.concat createSquare([point[2], point[1], point[5], point[6]], tutv[4])
p.concat createSquare([point[7], point[6], point[5], point[4]], tutv[5])

m = Mesh.new(p, image)

a = 0
Window.loop do
  Window.drawMesh([300,240,-300], [30, a, 0], [100,100,100], m, -10)
  a += 1
end

手でデータを作ることができると言っても、それをするのは大変だ。
この機能はなんらかのデータを元にアルゴリズムで生成する時には必要だから、無いと困る。
お手軽3Dダンジョンも、ダンジョンの壁をモデリングツールで作れといわれたら俺なら困る。
もっと簡単にならんもんかね、とも思うのだが、これ以上簡単にするにはなんらかのツールとの連携か、D3DXの基本形状生成みたいなものになってしまうわけで。
すなわち、3Dは根本的に難しいものなのだ。