Search in sources :

Example 6 with VarType

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

the class J3MOutputCapsule method formatMatParam.

private String formatMatParam(MatParam param) {
    VarType type = param.getVarType();
    Object val = param.getValue();
    switch(type) {
        case Boolean:
        case Float:
        case Int:
            return val.toString();
        case Vector2:
            Vector2f v2 = (Vector2f) val;
            return v2.getX() + " " + v2.getY();
        case Vector3:
            Vector3f v3 = (Vector3f) val;
            return v3.getX() + " " + v3.getY() + " " + v3.getZ();
        case Vector4:
            // can be either ColorRGBA, Vector4f or Quaternion
            if (val instanceof Vector4f) {
                Vector4f v4 = (Vector4f) val;
                return v4.getX() + " " + v4.getY() + " " + v4.getZ() + " " + v4.getW();
            } else if (val instanceof ColorRGBA) {
                ColorRGBA color = (ColorRGBA) val;
                return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha();
            } else if (val instanceof Quaternion) {
                Quaternion quat = (Quaternion) val;
                return quat.getX() + " " + quat.getY() + " " + quat.getZ() + " " + quat.getW();
            } else {
                throw new UnsupportedOperationException("Unexpected Vector4 type: " + val);
            }
        default:
            // parameter type not supported in J3M
            return null;
    }
}
Also used : VarType(com.jme3.shader.VarType)

Example 7 with VarType

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

the class MaterialMatParamTest method uniform.

private Uniform uniform(String name, VarType type, Object value) {
    Uniform u = new Uniform();
    u.setName("m_" + name);
    u.setValue(type, value);
    return u;
}
Also used : Uniform(com.jme3.shader.Uniform)

Example 8 with VarType

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

the class MaterialMatParamTest method outDefines.

private void outDefines(Define... expectedDefinesArray) {
    StringBuilder expectedDefineSource = new StringBuilder();
    for (Define define : expectedDefinesArray) {
        expectedDefineSource.append(define.toString());
    }
    if (!evaluated) {
        evaluateTechniqueDef();
    }
    Material mat = geometry.getMaterial();
    Technique tech = mat.getActiveTechnique();
    TechniqueDef def = tech.getDef();
    DefineList actualDefines = tech.getDynamicDefines();
    String[] defineNames = def.getDefineNames();
    VarType[] defineTypes = def.getDefineTypes();
    String actualDefineSource = actualDefines.generateSource(Arrays.asList(defineNames), Arrays.asList(defineTypes));
    assertEquals(expectedDefineSource.toString(), actualDefineSource);
}
Also used : DefineList(com.jme3.shader.DefineList) VarType(com.jme3.shader.VarType)

Aggregations

VarType (com.jme3.shader.VarType)5 Uniform (com.jme3.shader.Uniform)3 DefineList (com.jme3.shader.DefineList)1 Texture (com.jme3.texture.Texture)1 Texture2D (com.jme3.texture.Texture2D)1 ColorSpace (com.jme3.texture.image.ColorSpace)1 IOException (java.io.IOException)1