Search in sources :

Example 21 with Uniform

use of com.jme3.shader.Uniform in project jmonkeyengine by jMonkeyEngine.

the class FbxNode method toJmeObject.

@Override
public Spatial toJmeObject() {
    Spatial spatial;
    if (nodeAttribute instanceof FbxMesh) {
        FbxMesh fbxMesh = (FbxMesh) nodeAttribute;
        IntMap<Mesh> jmeMeshes = fbxMesh.getJmeObject();
        if (jmeMeshes == null || jmeMeshes.size() == 0) {
            // No meshes found on FBXMesh (??)
            logger.log(Level.WARNING, "No meshes could be loaded. Creating empty node.");
            spatial = new Node(getName() + "-node");
        } else {
            // Multiple jME3 geometries required for a single FBXMesh.
            String nodeName;
            if (children.isEmpty()) {
                nodeName = getName() + "-mesh";
            } else {
                nodeName = getName() + "-node";
            }
            Node node = new Node(nodeName);
            boolean singleMesh = jmeMeshes.size() == 1;
            for (IntMap.Entry<Mesh> meshInfo : jmeMeshes) {
                node.attachChild(tryCreateGeometry(meshInfo.getKey(), meshInfo.getValue(), singleMesh));
            }
            spatial = node;
        }
    } else {
        if (nodeAttribute != null) {
            // Just specifies that this is a "null" node.
            nodeAttribute.getJmeObject();
        }
        // TODO: handle other node attribute types.
        //       right now everything we don't know about gets converted
        //       to jME3 Node.
        spatial = new Node(getName() + "-node");
    }
    if (!children.isEmpty()) {
        // Check uniform scale.
        // Although, if inheritType is 0 (eInheritRrSs)
        // it might not be a problem.
        Vector3f localScale = jmeLocalNodeTransform.getScale();
        if (!FastMath.approximateEquals(localScale.x, localScale.y) || !FastMath.approximateEquals(localScale.x, localScale.z)) {
            logger.log(Level.WARNING, "Non-uniform scale detected on parent node. " + "The model may appear distorted.");
        }
    }
    spatial.setLocalTransform(jmeLocalNodeTransform);
    if (visibility == 0.0) {
        spatial.setCullHint(CullHint.Always);
    }
    for (Map.Entry<String, Object> userDataEntry : userData.entrySet()) {
        spatial.setUserData(userDataEntry.getKey(), userDataEntry.getValue());
    }
    return spatial;
}
Also used : FbxMesh(com.jme3.scene.plugins.fbx.mesh.FbxMesh) FbxLimbNode(com.jme3.scene.plugins.fbx.anim.FbxLimbNode) Node(com.jme3.scene.Node) FbxAnimCurveNode(com.jme3.scene.plugins.fbx.anim.FbxAnimCurveNode) FbxMesh(com.jme3.scene.plugins.fbx.mesh.FbxMesh) Mesh(com.jme3.scene.Mesh) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) IntMap(com.jme3.util.IntMap) FbxObject(com.jme3.scene.plugins.fbx.obj.FbxObject) IntMap(com.jme3.util.IntMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Uniform (com.jme3.shader.Uniform)10 Vector3f (com.jme3.math.Vector3f)4 Texture2D (com.jme3.texture.Texture2D)4 Test (org.junit.Test)4 DirectionalLight (com.jme3.light.DirectionalLight)3 PointLight (com.jme3.light.PointLight)3 SpotLight (com.jme3.light.SpotLight)3 ColorRGBA (com.jme3.math.ColorRGBA)3 ShaderNodeVariable (com.jme3.shader.ShaderNodeVariable)3 TempVars (com.jme3.util.TempVars)3 Light (com.jme3.light.Light)2 Vector4f (com.jme3.math.Vector4f)2 Renderer (com.jme3.renderer.Renderer)2 VarType (com.jme3.shader.VarType)2 BoundingSphere (com.jme3.bounding.BoundingSphere)1 AmbientLight (com.jme3.light.AmbientLight)1 MatParam (com.jme3.material.MatParam)1 Quaternion (com.jme3.math.Quaternion)1 Caps (com.jme3.renderer.Caps)1 Mesh (com.jme3.scene.Mesh)1