当前位置: 首页>>代码示例>>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;未经允许,请勿转载。