소스 검색

LodGenerator used squared length of en edge as parameter for its collapse cost instead of the length. It gives better results

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10639 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
rem..om 12 년 전
부모
커밋
f0b44c0704
2개의 변경된 파일10개의 추가작업 그리고 12개의 파일을 삭제
  1. 8 10
      engine/src/test/jme3test/stress/TestLodGeneration.java
  2. 2 2
      engine/src/tools/jme3tools/optimize/LodGenerator.java

+ 8 - 10
engine/src/test/jme3test/stress/TestLodGeneration.java

@@ -32,6 +32,7 @@
 package jme3test.stress;
 
 import com.jme3.animation.AnimChannel;
+import com.jme3.animation.AnimControl;
 import com.jme3.animation.SkeletonControl;
 import com.jme3.app.SimpleApplication;
 import com.jme3.bounding.BoundingBox;
@@ -79,8 +80,8 @@ public class TestLodGeneration extends SimpleApplication {
         al.setColor(ColorRGBA.White.mult(0.6f));
         rootNode.addLight(al);
 
-        model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
-        //model = (Node) assetManager.loadModel("Models/Jaime/Jaime.j3o");
+       // model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
+       model = (Node) assetManager.loadModel("Models/Jaime/Jaime.j3o");
         BoundingBox b = ((BoundingBox) model.getWorldBound());
         model.setLocalScale(1.2f / (b.getYExtent() * 2));
         //  model.setLocalTranslation(0,-(b.getCenter().y - b.getYExtent())* model.getLocalScale().y, 0);
@@ -98,24 +99,21 @@ public class TestLodGeneration extends SimpleApplication {
 
 
 
-        //   ch = model.getControl(AnimControl.class).createChannel();
-        //  ch.setAnim("Wave");
+//           ch = model.getControl(AnimControl.class).createChannel();
+//          ch.setAnim("Wave");
         SkeletonControl c = model.getControl(SkeletonControl.class);
         if (c != null) {
             c.setEnabled(false);
         }
 
 
-        reductionvalue = 0.001f;
-        // makeLod(LodGenerator.VertexReductionMethod.PROPORTIONAL, reductionvalue, 1);
-
+        reductionvalue = 0.80f;
         lodLevel = 1;
         for (final Geometry geometry : listGeoms) {
-            LodGenerator lODGenerator = new LodGenerator(geometry);
-            lODGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, reductionvalue);
+            LodGenerator lodGenerator = new LodGenerator(geometry);          
+            lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, reductionvalue);
             geometry.setLodLevel(lodLevel);
 
-
         }
 
         rootNode.attachChild(model);

+ 2 - 2
engine/src/tools/jme3tools/optimize/LodGenerator.java

@@ -500,8 +500,8 @@ public class LodGenerator {
         }
         
         assert (cost >= 0);
-        // TODO: use squared distance.
-        return cost * src.position.distance(dest.position);
+        
+        return cost * src.position.distanceSquared(dest.position);
     }
     int nbCollapsedTri = 0;