From 9ab6c475e163e32b14a474150469ffc0289c04dc Mon Sep 17 00:00:00 2001 From: artem pecheny Date: Thu, 12 Jul 2012 21:16:14 +0600 Subject: [PATCH] Fix box primitive tangents and binormals, createBinormals() --- src/alternativa/engine3d/objects/WireFrame.as | 2 +- src/alternativa/engine3d/primitives/Box.as | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/alternativa/engine3d/objects/WireFrame.as b/src/alternativa/engine3d/objects/WireFrame.as index b19da9f..edb7161 100644 --- a/src/alternativa/engine3d/objects/WireFrame.as +++ b/src/alternativa/engine3d/objects/WireFrame.as @@ -376,7 +376,7 @@ package alternativa.engine3d.objects { binormal.normalize(); resultGeometry.addLine( vertices[index], vertices[int(index + 1)], vertices[int(index + 2)], - vertices[index] + binormal.z*length, vertices[int(index + 1)] + binormal.z*length, vertices[int(index + 2)] + binormal.z*length); + vertices[index] + binormal.x*length, vertices[int(index + 1)] + binormal.y*length, vertices[int(index + 2)] + binormal.z*length); } result.calculateBoundBox(); result._x = mesh._x; diff --git a/src/alternativa/engine3d/primitives/Box.as b/src/alternativa/engine3d/primitives/Box.as index de05063..dc8432e 100644 --- a/src/alternativa/engine3d/primitives/Box.as +++ b/src/alternativa/engine3d/primitives/Box.as @@ -74,7 +74,7 @@ package alternativa.engine3d.primitives { for (x = 0; x < wp; x++) { for (y = 0; y < lp; y++) { if (x < widthSegments && y < lengthSegments) { - createFace(indices, vertices, (x + 1)*lp + y + 1, (x + 1)*lp + y, x*lp + y, x*lp + y + 1, 0, 0, -1, halfHeight, 0,-1,0,0, reverse); + createFace(indices, vertices, (x + 1)*lp + y + 1, (x + 1)*lp + y, x*lp + y, x*lp + y + 1, 0, 0, -1, halfHeight, -1,0,0,-1, reverse); } } } @@ -95,7 +95,7 @@ package alternativa.engine3d.primitives { for (x = 0; x < wp; x++) { for (y = 0; y < lp; y++) { if (x < widthSegments && y < lengthSegments) { - createFace(indices, vertices, o + x*lp + y, o + (x + 1)*lp + y, o + (x + 1)*lp + y + 1, o + x*lp + y + 1, 0, 0, 1, halfHeight,0,-1,0,0, reverse); + createFace(indices, vertices, o + x*lp + y, o + (x + 1)*lp + y, o + (x + 1)*lp + y + 1, o + x*lp + y + 1, 0, 0, 1, halfHeight,1,0,0,-1, reverse); } } } @@ -117,7 +117,7 @@ package alternativa.engine3d.primitives { for (x = 0; x < wp; x++) { for (z = 0; z < hp; z++) { if (x < widthSegments && z < heightSegments) { - createFace(indices, vertices, o + x*hp + z, o + (x + 1)*hp + z, o + (x + 1)*hp + z + 1, o + x*hp + z + 1, 0, -1, 0, halfLength,0,0,-1,0, reverse); + createFace(indices, vertices, o + x*hp + z, o + (x + 1)*hp + z, o + (x + 1)*hp + z + 1, o + x*hp + z + 1, 0, -1, 0, halfLength,1,0,0,-1, reverse); } } } @@ -138,7 +138,7 @@ package alternativa.engine3d.primitives { for (x = 0; x < wp; x++) { for (z = 0; z < hp; z++) { if (x < widthSegments && z < heightSegments) { - createFace(indices, vertices, o + x*hp + z, o + x*hp + z + 1, o + (x + 1)*hp + z + 1, o + (x + 1)*hp + z, 0, 1, 0, halfLength,0,0,-1,0, reverse); + createFace(indices, vertices, o + x*hp + z, o + x*hp + z + 1, o + (x + 1)*hp + z + 1, o + (x + 1)*hp + z, 0, 1, 0, halfLength,-1,0,0,-1, reverse); } } } @@ -159,7 +159,7 @@ package alternativa.engine3d.primitives { for (y = 0; y < lp; y++) { for (z = 0; z < hp; z++) { if (y < lengthSegments && z < heightSegments) { - createFace(indices, vertices, o + y*hp + z, o + y*hp + z + 1, o + (y + 1)*hp + z + 1, o + (y + 1)*hp + z, -1, 0, 0, halfWidth, 0,0,-1,0,reverse); + createFace(indices, vertices, o + y*hp + z, o + y*hp + z + 1, o + (y + 1)*hp + z + 1, o + (y + 1)*hp + z, -1, 0, 0, halfWidth, 0,-1,0,-1,reverse); } } } @@ -179,7 +179,7 @@ package alternativa.engine3d.primitives { for (y = 0; y < lp; y++) { for (z = 0; z < hp; z++) { if (y < lengthSegments && z < heightSegments) { - createFace(indices, vertices, o + y*hp + z, o + (y + 1)*hp + z, o + (y + 1)*hp + z + 1, o + y*hp + z + 1, 1, 0, 0, halfWidth,0,0,-1,0, reverse); + createFace(indices, vertices, o + y*hp + z, o + (y + 1)*hp + z, o + (y + 1)*hp + z + 1, o + y*hp + z + 1, 1, 0, 0, halfWidth,0,1,0,-1, reverse); } } }