public static int getCardinality(String type, String swizzling) {
        int card = 0;
        if (isSwizzlable(type)) {
            if (type.equals("float")) {
                card = 1;
                if (swizzling.length() != 0) {
                    card = 0;
                }
            } else {
                card = Integer.parseInt(type.replaceAll(".*vec", ""));

                if (swizzling.length() > 0) {
                    card = swizzling.length();
                }
            }
        }
        return card;
    }
return the cardinality of a type and a swizzle example : vec4 cardinality
is 4 float cardinality is 1 vec4.xyz cardinality is 3. sampler2D
cardinality is 0

@param type the glsl type
@param swizzling the swizzling of a variable
@return the cardinality
jme3-core/src/main/java/com/jme3/shader/ShaderUtils.java