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
This commit is contained in:
parent
b918c707b8
commit
f0b44c0704
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user