// right var right_p0:Vector3D = new Vector3D(1, 1, 1); var right_e1:Vector3D = new Vector3D(0, 0, -2); var right_e2:Vector3D = new Vector3D(0, -2, 0);
// bottom var bottom_p0:Vector3D = new Vector3D(-1, -1, 1); var bottom_e1:Vector3D = new Vector3D(2, 0, 0); var bottom_e2:Vector3D = new Vector3D(0, 0, -2);
// forward var forward_p0:Vector3D = new Vector3D(1, 1, -1); var forward_e1:Vector3D = new Vector3D(-2, 0, 0); var forward_e2:Vector3D = new Vector3D(0, -2, 0);
var dir:Vector3D = new Vector3D(0.5, 0.0, 0.1); // 反射ベクトル dir.normalize(); var org:Vector3D = new Vector3D(0, 0, 0); // オブジェクトの頂点 var e1:Vector3D = new Vector3D(); var e2:Vector3D = new Vector3D(); var p0:Vector3D = new Vector3D(); var q:Vector3D = new Vector3D(); var e:Vector3D = new Vector3D(); var r:Vector3D = new Vector3D(); var s:Number, u:Number, v:Number, t:Number, w:Number;
for (var i:int = 0; i < 6; i++) { p0 = new Vector3D(); e1 = new Vector3D(); e2 = new Vector3D();
p0 = p0_Arr[i]; e1 = e1_Arr[i]; e2 = e2_Arr[i];
q = dir.crossProduct(e2); s = q.dotProduct(e1);
if (s != 0.0) { e = org.subtract(p0); r = e.crossProduct(e1);
t = r.dotProduct(e2) / s; u = q.dotProduct(e) / s; v = r.dotProduct(dir) / s; }else { u = 100; v = 100; }
w = 2 - u - v;
if (u >= 0 && v >= 0 && w >= 0 && t >= 0) { if (i == 0) { trace("■ 左面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } if (i == 1) { trace("■ 右面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } if (i == 2) { trace("■ 上面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } if (i == 3) { trace("■ 下面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } if (i == 4) { trace("■ 後面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } if (i == 5) { trace("■ 前面とヒットしました!"); trace("u == " + u); trace("v == " + v); trace("t == " + t); } } } }