Skatty
February 14, 2014, 10:14am
1
Hi, I’m trying to implement LoD for all scene models/objects. I wanna do it by code - automatically generating LoD levels in code.
Here’s my code which seems doesnt work, dunno why:
[java]
for (Spatial spatial : map.getChildren()) {
if (spatial instanceof Geometry) {
listGeoms.add((Geometry) spatial);
}
}
reductionvalue = 0.25f;
lodLevel = 1;
for (final Geometry geometry : listGeoms) {
LodGenerator lodGenerator = new LodGenerator(geometry);
lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, reductionvalue);
//geometry.setLodLevel (lodLevel);
LodControl lc = new LodControl();
geometry.addControl(lc);
}
[/java]
nehon
February 14, 2014, 10:39am
2
How many lod levels are generated?
What does your model looks like?
The lod generator will fail on some models that are triangulated.
Skatty
February 14, 2014, 10:40am
3
How many lod levels are generated? Do I have also set LoD in Scene Composer for each model?
What does your model looks like?
I got alot of buildings,trees etc on my map
Also, do I have to batch geometry first?
nehon
February 17, 2014, 7:03am
5
Answer my questions. I mean really, not answering with another question.
once you called the bakeLods method, how many lod levels are there in the geometry ?(you can fetch them doing geom.getLodLevel()
Post a picture of your models in wireframe mode
Skatty
February 17, 2014, 2:32pm
6
Hmm, dunno what’s going on. I call generateLod method but there isn’t any prints from Syste.out.
[java] private void generateLoD(Node map) {
for (Spatial spatial : map.getChildren()) {
if (spatial instanceof Geometry) {
listGeoms.add((Geometry) spatial);
}
}
reductionvalue = 0.25f;
lodLevel = 1;
for (final Geometry geometry : listGeoms) {
LodGenerator lodGenerator = new LodGenerator(geometry);
lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, reductionvalue);
System.out.println(geometry.getLodLevel());
LodControl lc = new LodControl();
geometry.addControl(lc);
}
System.out.println(listGeoms);
}[/java]
sgold
March 10, 2014, 9:20pm
8
Have you tried stepping through generateLoD() using a debugger?
Skatty
March 11, 2014, 1:42pm
9
No I haven’t. I need also generate LoDs in Scene Composer? And later use code? Because all seems be ok, but still 0 effect …