Main repository of MikuMikuStudio
Revisão | 37baed2a93582e687cf8d7a2436e514e8c1814ce (tree) |
---|---|
Hora | 2013-04-25 09:40:25 |
Autor | shadowisLORD <shadowisLORD@75d0...> |
Commiter | shadowisLORD |
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10573 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -45,12 +45,12 @@ import java.util.List; | ||
45 | 45 | public class PerspectiveLodCalculator implements LodCalculator { |
46 | 46 | |
47 | 47 | private Camera cam; |
48 | - private float[] entropyDistances; | |
49 | 48 | private float pixelError; |
49 | + private boolean turnOffLod = false; | |
50 | 50 | |
51 | 51 | public PerspectiveLodCalculator() {} |
52 | 52 | |
53 | - public PerspectiveLodCalculator(Camera cam, float pixelError){ | |
53 | + public PerspectiveLodCalculator(Camera cam, float pixelError) { | |
54 | 54 | this.cam = cam; |
55 | 55 | this.pixelError = pixelError; |
56 | 56 | } |
@@ -73,16 +73,23 @@ public class PerspectiveLodCalculator implements LodCalculator { | ||
73 | 73 | } |
74 | 74 | |
75 | 75 | public boolean calculateLod(TerrainPatch patch, List<Vector3f> locations, HashMap<String, UpdatedTerrainPatch> updates) { |
76 | - if (entropyDistances == null){ | |
77 | - // compute entropy distances | |
78 | - float[] lodEntropies = patch.getLodEntropies(); | |
79 | - entropyDistances = new float[lodEntropies.length]; | |
80 | - float cameraConstant = getCameraConstant(cam, pixelError); | |
81 | - for (int i = 0; i < lodEntropies.length; i++){ | |
82 | - entropyDistances[i] = lodEntropies[i] * cameraConstant; | |
76 | + if (turnOffLod) { | |
77 | + // set to full detail | |
78 | + int prevLOD = patch.getLod(); | |
79 | + UpdatedTerrainPatch utp = updates.get(patch.getName()); | |
80 | + if (utp == null) { | |
81 | + utp = new UpdatedTerrainPatch(patch); | |
82 | + updates.put(utp.getName(), utp); | |
83 | 83 | } |
84 | + utp.setNewLod(0); | |
85 | + utp.setPreviousLod(prevLOD); | |
86 | + //utp.setReIndexNeeded(true); | |
87 | + return true; | |
84 | 88 | } |
85 | - | |
89 | + | |
90 | + float[] lodEntropies = patch.getLodEntropies(); | |
91 | + float cameraConstant = getCameraConstant(cam, pixelError); | |
92 | + | |
86 | 93 | Vector3f patchPos = getCenterLocation(patch); |
87 | 94 | |
88 | 95 | // vector from camera to patch |
@@ -92,7 +99,7 @@ public class PerspectiveLodCalculator implements LodCalculator { | ||
92 | 99 | |
93 | 100 | // go through each lod level to find the one we are in |
94 | 101 | for (int i = 0; i <= patch.getMaxLod(); i++) { |
95 | - if (distance < entropyDistances[i] || i == patch.getMaxLod()){ | |
102 | + if (distance < lodEntropies[i] * cameraConstant || i == patch.getMaxLod()){ | |
96 | 103 | boolean reIndexNeeded = false; |
97 | 104 | if (i != patch.getLod()) { |
98 | 105 | reIndexNeeded = true; |
@@ -133,6 +140,7 @@ public class PerspectiveLodCalculator implements LodCalculator { | ||
133 | 140 | } |
134 | 141 | |
135 | 142 | public void write(JmeExporter ex) throws IOException { |
143 | + | |
136 | 144 | } |
137 | 145 | |
138 | 146 | public void read(JmeImporter im) throws IOException { |
@@ -155,15 +163,15 @@ public class PerspectiveLodCalculator implements LodCalculator { | ||
155 | 163 | } |
156 | 164 | |
157 | 165 | public void turnOffLod() { |
158 | - //TODO | |
166 | + turnOffLod = true; | |
159 | 167 | } |
160 | - | |
168 | + | |
161 | 169 | public boolean isLodOff() { |
162 | - return false; //TODO | |
170 | + return turnOffLod; | |
163 | 171 | } |
164 | 172 | |
165 | 173 | public void turnOnLod() { |
166 | - //TODO | |
174 | + turnOffLod = false; | |
167 | 175 | } |
168 | 176 | |
169 | 177 | } |