소스 검색

Bugfix: making sure that the first and last bevel line is parallel to its neighbour in curves that have bevel applied (that is how blender works)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9912 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl 13 년 전
부모
커밋
1b04d13f3e
1개의 변경된 파일20개의 추가작업 그리고 0개의 파일을 삭제
  1. 20 0
      engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java

+ 20 - 0
engine/src/blender/com/jme3/scene/plugins/blender/curves/CurvesHelper.java

@@ -482,6 +482,26 @@ public class CurvesHelper extends AbstractBlenderHelper {
 			bevelPoints = this.transformBevel(bevelPoints, curvePoints[curvePoints.length - 2], curvePoints[curvePoints.length - 1], null);
 			bevels.add(bevelPoints);
 			
+			if(bevels.size() > 2) {
+				//changing the first and last bevel so that they are parallel to their neighbours (blender works this way)
+				//notice this implicates that the distances of every corresponding point in th two bevels must be identical and
+				//equal to the distance between the points on curve that define the bevel position
+				//so instead doing complicated rotations on each point we will simply properly translate each of them
+				
+				Vector3f subtractResult = new Vector3f();
+				int[][] pointIndexes = new int[][] { { 0, 1 }, { curvePoints.length - 1, curvePoints.length - 2 } };
+				for(int[] indexes : pointIndexes) {
+					float distance = curvePoints[indexes[1]].subtract(curvePoints[indexes[0]], subtractResult).length();
+					Vector3f[] bevel = bevels.get(indexes[0]);
+					Vector3f[] nextBevel = bevels.get(indexes[1]);
+					for (int i = 0; i < bevel.length; ++i) {
+						float d = bevel[i].subtract(nextBevel[i], subtractResult).length();
+						subtractResult.normalizeLocal().multLocal(distance - d);
+						bevel[i].addLocal(subtractResult);
+					}
+				}
+			}
+			
 			//apply scales to the bevels
 			float lengthAlongCurve = 0;
 			for(int i=0;i<curvePoints.length; ++i) {