當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.getParams方法代碼示例

本文整理匯總了Java中com.jme3.material.Material.getParams方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.getParams方法的具體用法?Java Material.getParams怎麽用?Java Material.getParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jme3.material.Material的用法示例。


在下文中一共展示了Material.getParams方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serializeToString

import com.jme3.material.Material; //導入方法依賴的package包/類
/**
 * Serialize to string string.
 *
 * @param material the material
 * @return the string
 */
public static String serializeToString(@NotNull final Material material) {

    final MaterialDef materialDef = material.getMaterialDef();
    final Collection<MatParam> params = material.getParams();

    final StringBuilder builder = new StringBuilder();
    builder.append("Material MyMaterial : ").append(materialDef.getAssetName()).append(" {\n");
    builder.append("    MaterialParameters {\n");

    params.forEach(matParam -> {
        final String value = toString(matParam.getVarType(), matParam.getValue());
        builder.append("        ").append(matParam.getName()).append(" : ").append(value).append('\n');
    });

    builder.append("    }\n");
    builder.append("    AdditionalRenderState {\n");

    final RenderState renderState = material.getAdditionalRenderState();
    final RenderState.BlendMode blendMode = renderState.getBlendMode();
    final RenderState.FaceCullMode faceCullMode = renderState.getFaceCullMode();

    if (blendMode != RenderState.BlendMode.Off) {
        builder.append("      Blend ").append(blendMode.name()).append('\n');
    }

    if (faceCullMode != RenderState.FaceCullMode.Back) {
        builder.append("      FaceCull ").append(faceCullMode.name()).append('\n');
    }

    if (renderState.isWireframe()) builder.append("      Wireframe On\n");
    if (!renderState.isDepthTest()) builder.append("      DepthTest Off\n");
    if (!renderState.isDepthWrite()) builder.append("      DepthWrite Off\n");
    if (!renderState.isColorWrite()) builder.append("      ColorWrite Off\n");

    final float polyOffsetFactor = renderState.getPolyOffsetFactor();
    final float polyOffsetUnits = renderState.getPolyOffsetUnits();

    if (polyOffsetFactor != 0 || polyOffsetUnits != 0) {
        builder.append("      PolyOffset ").append(polyOffsetFactor).append(' ').append(polyOffsetUnits).append('\n');
    }

    builder.append("    }\n");
    builder.append("}");

    return builder.toString();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:53,代碼來源:MaterialSerializer.java


注:本文中的com.jme3.material.Material.getParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。