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


Java Texture類代碼示例

本文整理匯總了Java中com.jme3.texture.Texture的典型用法代碼示例。如果您正苦於以下問題:Java Texture類的具體用法?Java Texture怎麽用?Java Texture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: addObject

import com.jme3.texture.Texture; //導入依賴的package包/類
@Override
protected Spatial addObject(Entity e) {
    Vector3f loc = e.get(PhysicsPosition.class).getLocation();
    Mesh mesh = MeshFactory.createSphere(0.25f);
    Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    material.setColor("Color", ColorRGBA.Orange);
    TextureKey key = new TextureKey("Interface/grid-shaded.png");
    key.setGenerateMips(true);
    Texture texture = assetManager.loadTexture(key);
    texture.setWrap(Texture.WrapMode.Repeat);
    material.setTexture("ColorMap", texture);
    Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
    geometry.setMaterial(material);
    geometry.setLocalTranslation(loc);
    rootNode.attachChild(geometry);
    return geometry;
}
 
開發者ID:jvpichowski,項目名稱:ZayES-Bullet,代碼行數:18,代碼來源:ESDebugViewState.java

示例2: process_slice

import com.jme3.texture.Texture; //導入依賴的package包/類
public  void process_slice(Texture tx, Texel ir, int mipmap, int slice, Map<String,String> options, DDS_HEADER header, DDS_BODY body) throws Exception{
	String gen_mm=options.get("gen-mipmaps");
	if(gen_mm==null)gen_mm="false";
	boolean gen_mipmaps=!tx.getImage().hasMipmaps()&&gen_mm.equals("true");
	if(mipmap==0&&gen_mipmaps){
		int n=numMipMaps(new Vector2f(tx.getImage().getWidth(),tx.getImage().getHeight()))-1/*first mipmap is the image*/;
		Texel mipmaps[]=ir.getMipMap(n,false);
		super.process_slice(tx,ir,mipmap,slice,options,header,body);
		for(int i=0;i<n;i++){
			Texel m=mipmaps[i];
			super.process_slice(tx,m,i+1,slice,options,header,body); 
		}
	}else{
		super.process_slice(tx,ir,mipmap,slice,options,header,body);
	}
}
 
開發者ID:riccardobl,項目名稱:DDSWriter,代碼行數:17,代碼來源:CommonBodyDelegate.java

示例3: load

import com.jme3.texture.Texture; //導入依賴的package包/類
public Object load(AssetInfo info) throws IOException {
    if (!(info.getKey() instanceof TextureKey)) {
        throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey");
    }

    InputStream stream = null;
    try {
        stream = info.openStream();
        in = new LittleEndien(stream);
        loadHeader();
        if (texture3D) {
            ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.ThreeDimensional);
        } else if (depth > 1) {
            ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.CubeMap);
        }
        ArrayList<ByteBuffer> data = readData(((TextureKey) info.getKey()).isFlipY());
        return new Image(pixelFormat, width, height, depth, data, sizes, ColorSpace.sRGB);
    } finally {
        if (stream != null){
            stream.close();
        }
    }
}
 
開發者ID:riccardobl,項目名稱:DDSWriter,代碼行數:24,代碼來源:DDSLoader.java

示例4: readJMETexture

import com.jme3.texture.Texture; //導入依賴的package包/類
@FXThread
private @NotNull Image readJMETexture(final int width, final int height, @NotNull final String externalForm,
                                      @NotNull final Path cacheFile) {

    final Editor editor = Editor.getInstance();
    final AssetManager assetManager = editor.getAssetManager();
    final Texture texture = assetManager.loadTexture(externalForm);

    final BufferedImage textureImage;
    try {
        textureImage = ImageToAwt.convert(texture.getImage(), false, true, 0);
    } catch (final UnsupportedOperationException e) {
        EditorUtil.handleException(LOGGER, this, e);
        return Icons.IMAGE_512;
    }

    final int imageWidth = textureImage.getWidth();
    final int imageHeight = textureImage.getHeight();

    return scaleAndWrite(width, height, cacheFile, textureImage, imageWidth, imageHeight);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:22,代碼來源:JavaFXImageManager.java

示例5: openSettings

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Process to open texture's settings.
 */
@FXThread
protected void openSettings() {

    final Texture2D texture = notNull(getPropertyValue());
    final TextureKey key = (TextureKey) texture.getKey();
    final boolean flipY = key.isFlipY();
    final Texture.WrapMode wrapS = texture.getWrap(Texture.WrapAxis.S);
    final Texture.WrapMode wrapT = texture.getWrap(Texture.WrapAxis.T);
    final Texture.MagFilter magFilter = texture.getMagFilter();
    final Texture.MinFilter minFilter = texture.getMinFilter();

    final Array<PropertyDefinition> properties = ArrayFactory.newArray(PropertyDefinition.class);
    properties.add(new PropertyDefinition(EditablePropertyType.BOOLEAN, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_FLIP_Y, PROP_FLIP, flipY));
    properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_S, PROP_WRAP_MODE_S, wrapS));
    properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_WRAP_MODE_T, PROP_WRAP_MODE_T, wrapT));
    properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MAG_FILTER, PROP_MAG_FILTER, magFilter));
    properties.add(new PropertyDefinition(EditablePropertyType.ENUM, Messages.MATERIAL_MODEL_PROPERTY_CONTROL_MIN_FILTER, PROP_MIN_FILTER, minFilter));

    final GenericFactoryDialog dialog = new GenericFactoryDialog(properties, this::applyChanges);
    dialog.setTitle(Messages.MATERIAL_MODEL_PROPERTY_CONTROL_TEXTURE_SETTINGS);
    dialog.setButtonOkText(Messages.SIMPLE_DIALOG_BUTTON_APPLY);
    dialog.setButtonCloseText(Messages.SIMPLE_DIALOG_BUTTON_CANCEL);
    dialog.configureSize(DIALOG_SIZE);
    dialog.show();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:29,代碼來源:Texture2DPropertyControl.java

示例6: setTexture

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Sets new texture to this property.
 *
 * @param file the file to new texture.
 */
@FXThread
protected void setTexture(@Nullable final Path file) {

    if (file == null) {
        changed(null, getPropertyValue());
    } else {

        final EditorConfig config = EditorConfig.getInstance();
        final Path assetFile = notNull(getAssetFile(file));
        final TextureKey textureKey = new TextureKey(toAssetPath(assetFile));
        textureKey.setFlipY(config.isDefaultUseFlippedTexture());

        final AssetManager assetManager = EDITOR.getAssetManager();
        final Texture2D texture = (Texture2D) assetManager.loadTexture(textureKey);
        texture.setWrap(Texture.WrapMode.Repeat);

        changed(texture, getPropertyValue());
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:25,代碼來源:Texture2DPropertyControl.java

示例7: startEditing

import com.jme3.texture.Texture; //導入依賴的package包/類
@Override
public void startEditing(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {

    final Texture alphaTexture = getAlphaTexture();
    if (alphaTexture == null) return;

    super.startEditing(editingInput, contactPoint);

    switch (editingInput) {
        case MOUSE_PRIMARY:
        case MOUSE_SECONDARY: {
            startChange();
            paintTexture(editingInput, contactPoint);
            break;
        }
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:18,代碼來源:PaintTerrainToolControl.java

示例8: startChange

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Start making changes.
 */
private void startChange() {

    final Array<ColorPoint> colorPoints = getColorPoints();
    colorPoints.clear();

    final Texture alphaTexture = notNull(getAlphaTexture());
    final Image image = alphaTexture.getImage();
    final ByteBuffer data = image.getData(0);

    if (prevBuffer == null) {
        prevBuffer = BufferUtils.createByteBuffer(data.capacity());
    } else if (prevBuffer.capacity() < data.capacity()) {
        BufferUtils.destroyDirectBuffer(prevBuffer);
        prevBuffer = BufferUtils.createByteBuffer(data.capacity());
    }

    final int position = data.position();
    data.position(0);
    prevBuffer.clear();
    prevBuffer.put(data);
    prevBuffer.flip();
    data.position(position);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:PaintTerrainToolControl.java

示例9: commitChanges

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Commit all changes.
 */
private void commitChanges() {

    final ByteBuffer prevBuffer = getPrevBuffer();
    final Texture alphaTexture = notNull(getAlphaTexture());
    final Image image = alphaTexture.getImage();

    final Array<ColorPoint> colorPoints = getColorPoints();
    final Array<ColorPoint> prevColorPoints = ArrayFactory.newArray(ColorPoint.class, colorPoints.size());
    final Array<ColorPoint> newColorPoints = ArrayFactory.newArray(ColorPoint.class, colorPoints.size());
    newColorPoints.addAll(colorPoints);

    fillPrevColorPoints(prevBuffer, image, colorPoints, prevColorPoints);

    final PropertyOperation<ChangeConsumer, Image, Array<ColorPoint>> operation =
            new PropertyOperation<>(image, "AlphaMap", newColorPoints, prevColorPoints);
    operation.setApplyHandler((img, toApply) -> applyColorPoints(img, toApply, toApply == newColorPoints));

    colorPoints.clear();

    final ModelChangeConsumer changeConsumer = getChangeConsumer();
    changeConsumer.execute(operation);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:PaintTerrainToolControl.java

示例10: getDiffuse

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Get a diffuse texture of the level.
 *
 * @param layer the layer.
 * @return the diffuse texture or null.
 */
@FromAnyThread
public @Nullable Texture getDiffuse(final int layer) {

    final Function<Integer, String> layerToDiffuseName = getLayerToDiffuseName();
    if (layerToDiffuseName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToDiffuseName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:TextureLayerSettings.java

示例11: setDiffuse

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Set a new diffuse texture to a level.
 *
 * @param texture the new texture.
 * @param layer   the layer.
 */
@FromAnyThread
public void setDiffuse(@Nullable final Texture texture, final int layer) {

    final Function<Integer, String> layerToDiffuseName = getLayerToDiffuseName();
    if (layerToDiffuseName == null) return;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final String paramName = layerToDiffuseName.apply(layer);
    final MatParam matParam = material.getParam(paramName);
    final Texture current = matParam == null ? null : (Texture) matParam.getValue();

    if (texture != null) {
        texture.setWrap(Texture.WrapMode.Repeat);
    }

    final PropertyOperation<ChangeConsumer, Node, Texture> operation =
            new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, texture, current);

    operation.setApplyHandler((node, newTexture) ->
            NodeUtils.visitGeometry(node, geometry -> updateTexture(newTexture, paramName, geometry)));

    final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
    changeConsumer.execute(operation);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:32,代碼來源:TextureLayerSettings.java

示例12: getNormal

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Get a diffuse normal of the level.
 *
 * @param layer the layer.
 * @return the normal texture or null.
 */
@FromAnyThread
public @Nullable Texture getNormal(final int layer) {

    final Function<Integer, String> layerToNormalName = getLayerToNormalName();
    if (layerToNormalName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToNormalName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:TextureLayerSettings.java

示例13: setNormal

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Set a new normal texture to a level.
 *
 * @param texture the normal texture.
 * @param layer   the layer.
 */
@FromAnyThread
public void setNormal(@Nullable final Texture texture, final int layer) {

    final Function<Integer, String> layerToNormalName = getLayerToNormalName();
    if (layerToNormalName == null) return;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final String paramName = layerToNormalName.apply(layer);
    final MatParam matParam = material.getParam(paramName);
    final Texture current = matParam == null ? null : (Texture) matParam.getValue();

    if (texture != null) {
        texture.setWrap(Texture.WrapMode.Repeat);
    }

    final PropertyOperation<ChangeConsumer, Node, Texture> operation =
            new PropertyOperation<>(getTerrainNode(), TERRAIN_PARAM, texture, current);

    operation.setApplyHandler((node, newTexture) ->
            NodeUtils.visitGeometry(node, geometry -> updateTexture(newTexture, paramName, geometry)));

    final ModelChangeConsumer changeConsumer = editingComponent.getChangeConsumer();
    changeConsumer.execute(operation);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:32,代碼來源:TextureLayerSettings.java

示例14: getAlpha

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Get a alpha texture of the level.
 *
 * @param layer the layer.
 * @return the alpha texture or null.
 */
@FromAnyThread
public @Nullable Texture getAlpha(final int layer) {

    final Function<Integer, String> layerToAlphaName = getLayerToAlphaName();
    if (layerToAlphaName == null) return null;

    final Terrain terrain = getTerrain();
    final Material material = terrain.getMaterial();
    final MatParam matParam = material.getParam(layerToAlphaName.apply(layer));

    if (matParam == null || matParam.getValue() == null) {
        return null;
    }

    return (Texture) matParam.getValue();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:TextureLayerSettings.java

示例15: refreshTextures

import com.jme3.texture.Texture; //導入依賴的package包/類
/**
 * Refresh textures in a material.
 *
 * @param material   the material.
 * @param textureKey the texture key.
 */
private static void refreshTextures(@NotNull final Material material, @NotNull final String textureKey) {

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Collection<MatParam> params = material.getParams();
    params.forEach(matParam -> {

        final VarType varType = matParam.getVarType();
        final Object value = matParam.getValue();

        if (varType != VarType.Texture2D || value == null) return;

        final Texture texture = (Texture) value;
        final TextureKey key = (TextureKey) texture.getKey();

        if (key != null && StringUtils.equals(key.getName(), textureKey)) {
            final Texture newTexture = assetManager.loadAsset(key);
            matParam.setValue(newTexture);
        }
    });

}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:29,代碼來源:MaterialUtils.java


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