Examples of VariableMapping


Examples of com.jme3.shader.VariableMapping

                String condition = line.substring(line.lastIndexOf(":") + 1).trim();
                extractCondition(condition, statement);
                shaderNode.setCondition(conditionParser.getFormattedExpression());
            } else if (line.startsWith("InputMapping")) {
                for (Statement statement1 : statement.getContents()) {
                    VariableMapping mapping = readInputMapping(statement1);
                    techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(mapping.getRightVariable().getNameSpace());
                    shaderNode.getInputMapping().add(mapping);
                }
            } else if (line.startsWith("OutputMapping")) {               
                for (Statement statement1 : statement.getContents()) {
                    VariableMapping mapping = readOutputMapping(statement1);
                    techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(shaderNode.getName());
                    shaderNode.getOutputMapping().add(mapping);
                }              
            } else {
                throw new MatParseException("ShaderNodeDefinition", split[0], statement);
View Full Code Here

Examples of com.jme3.shader.VariableMapping

     *
     * @param statement the statement to read
     * @return the read mapping
     */
    protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpace) throws IOException {
        VariableMapping mapping = new VariableMapping();
        String[] cond = statement.getLine().split(":");

        String[] vars = cond[0].split("=");
        checkMappingFormat(vars, statement);
        ShaderNodeVariable[] variables = new ShaderNodeVariable[2];
        String[] swizzle = new String[2];
        for (int i = 0; i < vars.length; i++) {
            String[] expression = vars[i].trim().split("\\.");
            if (hasNameSpace[i]) {
                if (expression.length <= 3) {
                    variables[i] = new ShaderNodeVariable("", expression[0].trim(), expression[1].trim());
                }
                if (expression.length == 3) {
                    swizzle[i] = expression[2].trim();
                }
            } else {
                if (expression.length <= 2) {
                    variables[i] = new ShaderNodeVariable("", expression[0].trim());
                }
                if (expression.length == 2) {
                    swizzle[i] = expression[1].trim();
                }
            }

        }

        mapping.setLeftVariable(variables[0]);
        mapping.setLeftSwizzling(swizzle[0] != null ? swizzle[0] : "");
        mapping.setRightVariable(variables[1]);
        mapping.setRightSwizzling(swizzle[1] != null ? swizzle[1] : "");

        if (cond.length > 1) {
            extractCondition(cond[1], statement);
            mapping.setCondition(conditionParser.getFormattedExpression());
        }

        return mapping;
    }
View Full Code Here

Examples of com.jme3.shader.VariableMapping

     * @param statement1 the statement being read
     * @return the mapping
     * @throws IOException
     */
    public VariableMapping readInputMapping(Statement statement1) throws IOException {
        VariableMapping mapping = null;
        try {
            mapping = parseMapping(statement1, new boolean[]{false, true});
        } catch (Exception e) {
            throw new MatParseException("Unexpected mapping format", statement1, e);
        }
        ShaderNodeVariable left = mapping.getLeftVariable();
        ShaderNodeVariable right = mapping.getRightVariable();
        if (!updateVariableFromList(left, shaderNode.getDefinition().getInputs())) {
            throw new MatParseException(left.getName() + " is not an input variable of " + shaderNode.getDefinition().getName(), statement1);
        }

        if (left.getType().startsWith("sampler") && !right.getNameSpace().equals("MatParam")) {
            throw new MatParseException("Samplers can only be assigned to MatParams", statement1);
        }

        if (right.getNameSpace().equals("Global")) {
            right.setType("vec4");//Globals are all vec4 for now (maybe forever...)
            //        updateCondition(right, mapping);
            storeGlobal(right, statement1);

        } else if (right.getNameSpace().equals("Attr")) {
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) {
                throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement1);
            }
            updateVarFromAttributes(mapping.getRightVariable(), mapping);
            //          updateCondition(mapping.getRightVariable(), mapping);
            storeAttribute(mapping.getRightVariable());
        } else if (right.getNameSpace().equals("MatParam")) {
            MatParam param = findMatParam(right.getName());
            if (param == null) {
                throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1);
            }
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
                if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) {                 
                    storeVertexUniform(mapping.getRightVariable());
                }
            } else {
                if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement1)) {
                    if (mapping.getRightVariable().getType().contains("|")) {
                        String type = fixSamplerType(left.getType(), mapping.getRightVariable().getType());
                        if (type != null) {
                            mapping.getRightVariable().setType(type);
                        } else {
                            throw new MatParseException(param.getVarType().toString() + " can only be matched to one of " + param.getVarType().getGlslType().replaceAll("\\|", ",") + " found " + left.getType(), statement1);
                        }
                    }               
                    storeFragmentUniform(mapping.getRightVariable());
                }
            }

        } else if (right.getNameSpace().equals("WorldParam")) {
            UniformBinding worldParam = findWorldParam(right.getName());
            if (worldParam == null) {
                throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement1);
            }
            if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) {
                if (updateRightFromUniforms(worldParam, mapping, vertexDeclaredUniforms)) {                   
                    storeVertexUniform(mapping.getRightVariable());
                }
            } else {
                if (updateRightFromUniforms(worldParam, mapping, fragmentDeclaredUniforms)) {                   
                    storeFragmentUniform(mapping.getRightVariable());
                }
            }

        } else {
            ShaderNode node = nodes.get(right.getNameSpace());
            if (node == null) {
                throw new MatParseException("Undeclared node" + right.getNameSpace() + ". Make sure this node is declared before the current node", statement1);
            }
            ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName());
            if (var == null) {
                throw new MatParseException("Cannot find output variable" + right.getName() + " form ShaderNode " + node.getName(), statement1);
            }
            right.setNameSpace(node.getName());
            right.setType(var.getType());
            mapping.setRightVariable(right);           
            storeVaryings(node, mapping.getRightVariable());

        }

        checkTypes(mapping, statement1);

View Full Code Here

Examples of com.jme3.shader.VariableMapping

     * @param statement1 the staement being read
     * @return the mapping
     * @throws IOException
     */
    public VariableMapping readOutputMapping(Statement statement1) throws IOException {
        VariableMapping mapping = null;
        try {
            mapping = parseMapping(statement1, new boolean[]{true, false});
        } catch (Exception e) {
            throw new MatParseException("Unexpected mapping format", statement1, e);
        }
        ShaderNodeVariable left = mapping.getLeftVariable();
        ShaderNodeVariable right = mapping.getRightVariable();


        if (left.getType().startsWith("sampler") || right.getType().startsWith("sampler")) {
            throw new MatParseException("Samplers can only be inputs", statement1);
        }
View Full Code Here

Examples of org.encog.ml.prg.VariableMapping

    pop.getContext().clearDefinedVariables();
    for(AnalystField field : getScript().getNormalize().getNormalizedFields() ) {
      DataField df = getScript().findDataField(field.getName());
      String varName = field.getName();
     
      VariableMapping mapping;
     
      switch( field.getAction() ) {
        case Ignore:
          mapping = null;
          break;
        case PassThrough:
          if( df.isInteger() ) {
            mapping = new VariableMapping(varName, ValueType.intType);
          } else if( df.isReal() ) {
            mapping = new VariableMapping(varName, ValueType.floatingType);
          } else {
            mapping = new VariableMapping(varName, ValueType.stringType);
          }
          break;
        case Equilateral:
        case OneOf:
        case Normalize:
          mapping = new VariableMapping(varName, ValueType.floatingType);
          break;
        case SingleField:
          if( df.isClass() ) {
            mapping = new VariableMapping(varName, ValueType.enumType, classType++, df.getClassMembers().size() );
          } else if( df.isInteger() ) {
            mapping = new VariableMapping(varName, ValueType.intType );
          } else {
            mapping = new VariableMapping(varName, ValueType.floatingType);
          }
          break;
        default:
          throw new AnalystError("Unknown normalization action: " + field.getAction().toString());
      }
View Full Code Here

Examples of org.jboss.ws.metadata.jaxrpcmapping.VariableMapping

            addVariableMappingMap((XSModelGroup)xsterm, jxtm, javaType);
         }
         else if (xsterm instanceof XSElementDeclaration)
         {
            XSElementDeclaration xe = (XSElementDeclaration)xsterm;
            VariableMapping vm = new VariableMapping(jxtm);
            String name = xe.getName();

            // JBWS-1170 Convert characters which are illegal in Java identifiers
            vm.setJavaVariableName(ToolsUtils.convertInvalidCharacters(Introspector.decapitalize(name)));
            vm.setXmlElementName(name);
            jxtm.addVariableMapping(vm);
         }
      }
   }
View Full Code Here

Examples of org.jboss.ws.metadata.jaxrpcmapping.VariableMapping

      {
         XSAttributeUse obj = (XSAttributeUse)attributes.item(i);
         XSAttributeDeclaration att = obj.getAttrDeclaration();
         XSSimpleTypeDefinition simple = att.getTypeDefinition();
         addJavaXMLTypeMap(simple, "none", "", "", jxtm.getJavaWsdlMapping(), true);
         VariableMapping vm = new VariableMapping(jxtm);
         String name = att.getName();
         vm.setXmlAttributeName(name);
         // JBWS-1170 Convert characters which are illegal in Java identifiers
         vm.setJavaVariableName(ToolsUtils.convertInvalidCharacters(Introspector.decapitalize(name)));
         jxtm.addVariableMapping(vm);
      }
   }
View Full Code Here

Examples of org.jboss.ws.metadata.jaxrpcmapping.VariableMapping

         typeCopy.setJavaType(type.getJavaType());
         typeCopy.setRootTypeQName(name);

         for (VariableMapping variable : type.getVariableMappings())
         {
            VariableMapping variableCopy = new VariableMapping(typeCopy);
            variableCopy.setDataMember(variable.isDataMember());
            variableCopy.setJavaVariableName(variable.getJavaVariableName());
            variableCopy.setXmlAttributeName(variable.getXmlAttributeName());
            variableCopy.setXmlElementName(variable.getXmlElementName());
            variableCopy.setXmlWildcard(variable.getXmlWildcard());

            typeCopy.addVariableMapping(variableCopy);
         }

         javaWsdlMapping.addJavaXmlTypeMappings(typeCopy);
View Full Code Here

Examples of org.jboss.ws.metadata.jaxrpcmapping.VariableMapping

         String name = term.getName();
         String variableName = name;
         if (reversedNames != null && reversedNames.get(name) != null)
            variableName = reversedNames.get(name);

         VariableMapping mapping = new VariableMapping(javaXmlTypeMapping);

         mapping.setJavaVariableName(variableName);
         mapping.setXmlElementName(name);
         mapping.setDataMember(utils.doesPublicFieldExist(javaType, variableName));

         if (isAlreadyMapped(javaXmlTypeMapping, mapping) == false)
         {
            javaXmlTypeMapping.addVariableMapping(mapping);
         }
View Full Code Here

Examples of org.jboss.ws.metadata.jaxrpcmapping.VariableMapping

         if (xsterm instanceof XSModelGroup)
            addVariableMappingMap((XSModelGroup)xsterm, jxtm, javaType);
         else if (xsterm instanceof XSElementDeclaration)
         {
            XSElementDeclaration xe = (XSElementDeclaration)xsterm;
            VariableMapping vm = new VariableMapping(jxtm);
            String name = xe.getName();
            // JBWS-1170 Convert characters which are illegal in Java identifiers
            vm.setJavaVariableName(ToolsUtils.convertInvalidCharacters(Introspector.decapitalize(name)));
            vm.setXmlElementName(name);
            jxtm.addVariableMapping(vm);
         }
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.