} else if (node instanceof Link) {
turnOffLightsShareAndModulateTextures(((Link)node).getSharedGroup());
} else if (node instanceof Light) {
((Light)node).setEnable(false);
} else if (node instanceof Shape3D) {
Appearance appearance = ((Shape3D)node).getAppearance();
if (appearance != null) {
Texture texture = appearance.getTexture();
if (texture != null) {
// Share textures data as much as possible
Texture sharedTexture = TextureManager.getInstance().shareTexture(texture);
if (sharedTexture != texture) {
appearance.setTexture(sharedTexture);
}
TextureAttributes textureAttributes = appearance.getTextureAttributes();
if (textureAttributes == null) {
// Mix texture and shape color
textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(TextureAttributes.MODULATE);
appearance.setTextureAttributes(textureAttributes);
// Check shape color is white
Material material = appearance.getMaterial();
if (material == null) {
appearance.setMaterial((Material)DEFAULT_MATERIAL.cloneNodeComponent(true));
} else {
Color3f color = new Color3f();
DEFAULT_MATERIAL.getDiffuseColor(color);
material.setDiffuseColor(color);
DEFAULT_MATERIAL.getAmbientColor(color);
material.setAmbientColor(color);
}
}
// If texture image supports transparency
if (TextureManager.getInstance().isTextureTransparent(sharedTexture)) {
if (appearance.getTransparencyAttributes() == null) {
// Add transparency attributes to ensure transparency works
appearance.setTransparencyAttributes(
new TransparencyAttributes(TransparencyAttributes.NICEST, 0));
}
}
}
}