/******************************************************************************* * Copyright (c) 2007- VTT Technical Research Centre of Finland. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package org.simantics.proconf.g3d.base; import java.util.Collection; import org.simantics.layer0.utils.IEntity; import org.simantics.proconf.g3d.Resources; import org.simantics.proconf.g3d.stubs.Appearance; import com.jme.renderer.Renderer; import com.jme.scene.state.RenderState; public class DefaultAppearanceProvider implements AppearanceProvider { @Override public boolean canHandle(IEntity instance) { return instance.hasStatement(Resources.g3dResource.HasAppearance); } @Override public Collection getAppearanceFromResource(IEntity instance, Renderer renderer) { Collection appearanceResource; if ((appearanceResource = instance.getRelatedObjects(Resources.g3dResource.HasAppearance)) != null && appearanceResource.size() > 0) { return AppearanceTools.getAppearance(new Appearance(instance.getGraph(),appearanceResource.iterator().next().getResource()), renderer); } throw new RuntimeException("Given instance does not have Appearance definition!"); } }