I’m still having problem to get hided object set visible back again.
I’m hiding objects when they are LoD 9 (CullHint.Always), and in other cases using CullHint.Never, but objects are not appearing but they physics exist - block player etc.
Here’s my code:
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
distance = (vp.getCamera().getLocation().distance(spatial.getWorldTranslation()));
int dist = checkDistance(distance);
switch(dist) {
case 10:
spatial.setCullHint(CullHint.Always);
break;
case 9:
spatial.setCullHint(CullHint.Never);
break;
case 8:
spatial.setCullHint(CullHint.Never);
break;
case 7:
spatial.setCullHint(CullHint.Never);
break;
case 6:
spatial.setCullHint(CullHint.Never);
break;
case 5:
spatial.setCullHint(CullHint.Never);
break;
case 4:
spatial.setCullHint(CullHint.Never);
break;
case 3:
spatial.setCullHint(CullHint.Never);
break;
case 2:
spatial.setCullHint(CullHint.Never);
break;
case 1:
spatial.setCullHint(CullHint.Never);
break;
default:
spatial.setCullHint(CullHint.Never);
}
if (dist < ((Geometry)spatial).getMesh().getNumLodLevels()) {
((Geometry)spatial).setLodLevel(dist);
}
}
The object isn’t rendered when the cullhint is set, hence render is not called. Your distance is never updated after the cullhint is set. Again, don’t use render.
Edit: And btw you never do anything about the physics, it will always stay in the physics space if these geometries are in it.
Yay, right. Thanks, already fixed and working fine . Well, I don’t need to remove physics because if player is far from that objects anyway he can’t collide with then, but when he will come closer it’s fine because I don’t need to recreate physics.