Search in sources :

Example 21 with TemporalMesh

use of com.jme3.scene.plugins.blender.meshes.TemporalMesh in project jmonkeyengine by jMonkeyEngine.

the class BlenderContext method getLinkedFeature.

/**
     * The method returns linked feature of a given name from the specified blender path.
     * @param blenderFilePath
     *            the blender file path
     * @param featureName
     *            the feature name we want to get
     * @return linked feature or null if none was found
     */
@SuppressWarnings("unchecked")
public Object getLinkedFeature(String blenderFilePath, String featureName) {
    Map<String, Object> linkedFeatures = this.linkedFeatures.get(blenderFilePath);
    if (linkedFeatures != null) {
        String namePrefix = (featureName.charAt(0) + "" + featureName.charAt(1)).toUpperCase();
        featureName = featureName.substring(2);
        if ("SC".equals(namePrefix)) {
            List<Node> scenes = (List<Node>) linkedFeatures.get("scenes");
            if (scenes != null) {
                for (Node scene : scenes) {
                    if (featureName.equals(scene.getName())) {
                        return scene;
                    }
                }
            }
        } else if ("OB".equals(namePrefix)) {
            List<Node> features = (List<Node>) linkedFeatures.get("objects");
            if (features != null) {
                for (Node feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("ME".equals(namePrefix)) {
            List<TemporalMesh> temporalMeshes = (List<TemporalMesh>) linkedFeatures.get("meshes");
            if (temporalMeshes != null) {
                for (TemporalMesh temporalMesh : temporalMeshes) {
                    if (featureName.equals(temporalMesh.getName())) {
                        return temporalMesh;
                    }
                }
            }
        } else if ("MA".equals(namePrefix)) {
            List<MaterialContext> features = (List<MaterialContext>) linkedFeatures.get("materials");
            if (features != null) {
                for (MaterialContext feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("TX".equals(namePrefix)) {
            List<Texture> features = (List<Texture>) linkedFeatures.get("textures");
            if (features != null) {
                for (Texture feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("IM".equals(namePrefix)) {
            List<Texture> features = (List<Texture>) linkedFeatures.get("images");
            if (features != null) {
                for (Texture feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("AC".equals(namePrefix)) {
            List<Animation> features = (List<Animation>) linkedFeatures.get("animations");
            if (features != null) {
                for (Animation feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("CA".equals(namePrefix)) {
            List<Camera> features = (List<Camera>) linkedFeatures.get("cameras");
            if (features != null) {
                for (Camera feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("LA".equals(namePrefix)) {
            List<Light> features = (List<Light>) linkedFeatures.get("lights");
            if (features != null) {
                for (Light feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        } else if ("FI".equals(featureName)) {
            List<Filter> features = (List<Filter>) linkedFeatures.get("lights");
            if (features != null) {
                for (Filter feature : features) {
                    if (featureName.equals(feature.getName())) {
                        return feature;
                    }
                }
            }
        }
    }
    return null;
}
Also used : Node(com.jme3.scene.Node) Texture(com.jme3.texture.Texture) TemporalMesh(com.jme3.scene.plugins.blender.meshes.TemporalMesh) Filter(com.jme3.post.Filter) Light(com.jme3.light.Light) MaterialContext(com.jme3.scene.plugins.blender.materials.MaterialContext) Animation(com.jme3.animation.Animation) ArrayList(java.util.ArrayList) List(java.util.List) Camera(com.jme3.renderer.Camera)

Aggregations

ArrayList (java.util.ArrayList)11 TemporalMesh (com.jme3.scene.plugins.blender.meshes.TemporalMesh)10 Vector3f (com.jme3.math.Vector3f)8 Structure (com.jme3.scene.plugins.blender.file.Structure)7 List (java.util.List)7 BlenderFileException (com.jme3.scene.plugins.blender.file.BlenderFileException)6 Pointer (com.jme3.scene.plugins.blender.file.Pointer)5 Face (com.jme3.scene.plugins.blender.meshes.Face)5 Vector2f (com.jme3.math.Vector2f)4 Node (com.jme3.scene.Node)4 Edge (com.jme3.scene.plugins.blender.meshes.Edge)4 HashMap (java.util.HashMap)4 Light (com.jme3.light.Light)3 MeshHelper (com.jme3.scene.plugins.blender.meshes.MeshHelper)3 ObjectHelper (com.jme3.scene.plugins.blender.objects.ObjectHelper)3 Texture (com.jme3.texture.Texture)3 Map (java.util.Map)3 BoundingBox (com.jme3.bounding.BoundingBox)2 Filter (com.jme3.post.Filter)2 Camera (com.jme3.renderer.Camera)2