jMonkeyEngine / sdk

The jMonkeyEngine3 Software Development Kit based on Netbeans
BSD 3-Clause "New" or "Revised" License
312 stars 100 forks source link

MaterialEditor: MorphWeights - wrong parameter type. #594

Closed capdevon closed 1 month ago

capdevon commented 1 month ago

Hi guys, the MorphWeights parameter is a FloatArray not a Float.

See PBRLighting.j3md

        // For Morph animation
        FloatArray MorphWeights
        Int NumberOfMorphTargets
        Int NumberOfTargetsBuffers

Its representation in the Options tab of the Material Editor is wrong. image

The problem should be caused by the incorrect defLine.startsWith(string) and defLine.replaceFirst() algorithm when string = "Float" and defLine starts with FloatArray:

https://github.com/jMonkeyEngine/sdk/blob/master/jme3-materialeditor/src/com/jme3/gde/materials/EditableMaterialFile.java#L243

    private static final String[] variableTypes = new String[]{
            "Int", 
            "Boolean", 
            "Float", 
            "Vector2", 
            "Vector3", 
            "Vector4", 
            "Color", 
            "Texture2D", 
            "Texture3D", 
            "TextureArray", 
            "TextureBuffer", 
            "TextureCubeMap" };
        for (String string : variableTypes) {
            if (defLine.startsWith(string)) {
                final String propName = MaterialUtils.trimName(defLine.replaceFirst(string, ""));
                matDefEntries.add(propName);
                ...
            }
        }

Output: MaterialProperty [type=Float, name=Array ShadowMapSize, value=]

tonihele commented 1 month ago

I don't know would be easier to parse the file with StringTokenizer or something. But I think the easiest fix is to set FloatArray as one of the types. It just needs to be before Float (startsWith...), need to comment this in code. Do we have editor type for float array...