当前位置: 首页>>代码示例>>Java>>正文


Java Texture2D类代码示例

本文整理汇总了Java中com.jme3.texture.Texture2D的典型用法代码示例。如果您正苦于以下问题:Java Texture2D类的具体用法?Java Texture2D怎么用?Java Texture2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Texture2D类属于com.jme3.texture包,在下文中一共展示了Texture2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openSettings

import com.jme3.texture.Texture2D; //导入依赖的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

示例2: setTexture

import com.jme3.texture.Texture2D; //导入依赖的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

示例3: readTextureUnit

import com.jme3.texture.Texture2D; //导入依赖的package包/类
private void readTextureUnit(){
    // name is optional
    if (!scan.hasNext("\\{")){
        texName = readString("\\{");
    }else{
        texName = null;
    }
    scan.next(); // skip "{"

    texture = new Texture2D();

    while (!scan.hasNext("\\}")){
        readTextureUnitStatement();
    }
    scan.next(); // skip "}"
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:MaterialLoader.java

示例4: setFilterMode

import com.jme3.texture.Texture2D; //导入依赖的package包/类
/**
 * Sets the filtering mode for shadow edges see {@link FilterMode} for more info
 * @param filterMode 
 */
public void setFilterMode(FilterMode filterMode) {
    if (filterMode == null) {
        throw new NullPointerException();
    }

    if (this.filterMode == filterMode) {
        return;
    }

    this.filterMode = filterMode;
    postshadowMat.setInt("FilterMode", filterMode.ordinal());
    postshadowMat.setFloat("PCFEdge", edgesThickness);
    if (compareMode == CompareMode.Hardware) {
        for (Texture2D shadowMap : shadowMaps) {
            if (filterMode == FilterMode.Bilinear) {
                shadowMap.setMagFilter(MagFilter.Bilinear);
                shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
            } else {
                shadowMap.setMagFilter(MagFilter.Nearest);
                shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
            }
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:PssmShadowRenderer.java

示例5: BasicShadowRenderer

import com.jme3.texture.Texture2D; //导入依赖的package包/类
/**
 * Creates a BasicShadowRenderer
 * @param manager the asset manager
 * @param size the size of the shadow map (the map is square)
 */
public BasicShadowRenderer(AssetManager manager, int size) {
    shadowFB = new FrameBuffer(size, size, 1);
    shadowMap = new Texture2D(size, size, Format.Depth);
    shadowFB.setDepthTexture(shadowMap);
    shadowCam = new Camera(size, size);

    preshadowMat = new Material(manager, "Common/MatDefs/Shadow/PreShadow.j3md");
    postshadowMat = new Material(manager, "Common/MatDefs/Shadow/PostShadow.j3md");
    postshadowMat.setTexture("ShadowMap", shadowMap);

    dispPic.setTexture(manager, shadowMap, false);

    for (int i = 0; i < points.length; i++) {
        points[i] = new Vector3f();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:BasicShadowRenderer.java

示例6: guiRun

import com.jme3.texture.Texture2D; //导入依赖的package包/类
void guiRun() {
	screenController.setSolving(true);
	if (solver == null) {
		int size = map.getSize();
		solver = new ErosionSolver(temperature, moisture, map);
		solverAlphaTexture = new Texture2D(size, size, Image.Format.ABGR8);
		solverHeightTexture = new Texture2D(size, size, Image.Format.Depth16);
		iteration = 0;
	} //else: resume after guiStop()
	solver.setRiverSources(riverSources);
	updateSolverTexture();
	updateSolverHeightmap();
	app.forceTerrainMaterial(solverMaterial);
	solving = true;
	LOG.info("start solving");
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:17,代码来源:WaterErosionSimulation.java

示例7: createWater

import com.jme3.texture.Texture2D; //导入依赖的package包/类
private void createWater() {
	water = new WaterFilter(rootNode, new Vector3f(-0.1f, -0.1f, -0.1f));
       water.setWaterColor(new ColorRGBA().setAsSrgb(0.0078f, 0.3176f, 0.5f, 1.0f));
       water.setDeepWaterColor(new ColorRGBA().setAsSrgb(0.0039f, 0.00196f, 0.145f, 1.0f));
       water.setUnderWaterFogDistance(80);
       water.setWaterTransparency(0.12f);
       water.setFoamIntensity(0.4f);        
       water.setFoamHardness(0.3f);
       water.setFoamExistence(new Vector3f(0.8f, 8f, 1f));
       water.setReflectionDisplace(50);
       water.setRefractionConstant(0.25f);
       water.setColorExtinction(new Vector3f(30, 50, 70));
       water.setCausticsIntensity(0.4f);        
       water.setWaveScale(0.003f);
       water.setMaxAmplitude(2f);
       water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
       water.setRefractionStrength(0.2f);
       water.setWaterHeight(0);
	waterFilter = new FilterPostProcessor(assetManager);
	waterFilter.addFilter(water);
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:22,代码来源:TerrainHeighmapCreator.java

示例8: updateAlphaMap

import com.jme3.texture.Texture2D; //导入依赖的package包/类
public void updateAlphaMap(int size) {		
	ByteBuffer data;
	data = BufferUtils.createByteBuffer(size*size*4);
	data.rewind();
	for (int x=0; x<size; ++x) {
		for (int y=0; y<size; ++y) {
			float r = 1;
			data.put((byte) (255*r)).put((byte) 0).put((byte) 0).put((byte) 0);
		}
	}
	data.rewind();
	Image image = new Image(Image.Format.RGBA8, size, size, data, ColorSpace.Linear);
	Texture alphaMap = new Texture2D(image);
	alphaMap.setMagFilter(Texture.MagFilter.Bilinear);
	matTerrain.setTexture("AlphaMap", alphaMap);
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:17,代码来源:GrassTest.java

示例9: createDensityMap

import com.jme3.texture.Texture2D; //导入依赖的package包/类
private Texture createDensityMap(Heightmap map) {
	ByteBuffer data = BufferUtils.createByteBuffer(map.getSize() * map.getSize() * 4);
	data.rewind();
	for (int x=0; x<map.getSize(); ++x) {
		for (int y=0; y<map.getSize(); ++y) {
			float h = map.getHeightAt(y, map.getSize()-x-1);
			float[] b = biomes.getVectorAt(x, y);
			float v = h>0 ? 1 : 0;
			v *= (b[Biome.GRASSLAND.ordinal()]*1 + b[Biome.TUNDRA.ordinal()]*0.2f
					+ b[Biome.TAIGA.ordinal()]*0.2f);
			data.put((byte) (255*v)).put((byte) (255*v)).put((byte) (255*v)).put((byte) (255*v));
		}
	}
	data.rewind();
	Image img = new Image(Image.Format.RGBA8, map.getSize(), map.getSize(), data, ColorSpace.Linear);
	return new Texture2D(img);
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:18,代码来源:GrassPlanter.java

示例10: initializeGeometry

import com.jme3.texture.Texture2D; //导入依赖的package包/类
@Override
public void initializeGeometry(AssetManager assetManager)
{
	this.assetManager = assetManager;
	quad = new CenteredQuad(100, 100);
	bufferedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
	gfx = (Graphics2D) bufferedImage.getGraphics();
	gfx.setColor(Color.white);
	gfx.fillRect(0, 0, 100, 100);
	quadGeometry = new Geometry("_quad_geom", quad);

	// reminder of where to find j3md stuff: jme3/src/core-data
	mat = new Material(this.assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
	mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
	// Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
	Image img = new AWTLoader().load(bufferedImage, true);
	t = new Texture2D(img);
	mat.setTexture("m_ColorMap", t);

	quadGeometry.setMaterial(mat);

	ItemMap.register(quadGeometry, this);
	attachChild(quadGeometry);

}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:26,代码来源:JMEKeyboard.java

示例11: build

import com.jme3.texture.Texture2D; //导入依赖的package包/类
public void build(App app) {
	ByteBuffer bb = BufferUtils.createByteBuffer(buffer);

	Image image = new Image(Image.Format.ABGR8, width, height, bb);

	Texture2D texture = new Texture2D(image);
	texture.setImage(image);
	texture.setMagFilter(Texture2D.MagFilter.Nearest);

	Material mat = app.unshaded();
	mat.setTexture("ColorMap", texture);
	mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

	Geometry g = new Geometry("FrameBuffer", new Box(50, 25, 1));
	g.setMaterial(mat);

	node = new Node("FrameBuffer");
	node.attachChild(g);
}
 
开发者ID:morris,项目名称:vstools-java,代码行数:20,代码来源:FrameBuffer.java

示例12: add

import com.jme3.texture.Texture2D; //导入依赖的package包/类
/**
 * This method adds a texture data to the resulting texture.
 * 
 * @param texture
 *            the source texture
 * @param textureBlender
 *            the texture blender (to mix the texture with its material
 *            color)
 * @param uvCoordinatesType
 *            the type of UV coordinates
 * @param projectionType
 *            the type of UV coordinates projection (for flat textures)
 * @param textureStructure
 *            the texture sructure
 * @param blenderContext
 *            the blender context
 */
public void add(Texture texture, TextureBlender textureBlender, int uvCoordinatesType, int projectionType, Structure textureStructure, BlenderContext blenderContext) {
    if (!(texture instanceof GeneratedTexture) && !(texture instanceof Texture2D)) {
        throw new IllegalArgumentException("Unsupported texture type: " + (texture == null ? "null" : texture.getClass()));
    }
    if (!(texture instanceof GeneratedTexture) || blenderContext.getBlenderKey().isLoadGeneratedTextures()) {
        if (UVCoordinatesGenerator.isTextureCoordinateTypeSupported(UVCoordinatesType.valueOf(uvCoordinatesType))) {
            TextureData textureData = new TextureData();
            textureData.texture = texture;
            textureData.textureBlender = textureBlender;
            textureData.uvCoordinatesType = UVCoordinatesType.valueOf(uvCoordinatesType);
            textureData.projectionType = UVProjectionType.valueOf(projectionType);
            textureData.textureStructure = textureStructure;

            if (textureDatas.size() > 0 && this.isWithoutAlpha(textureData, blenderContext)) {
                textureDatas.clear();// clear previous textures, they will be covered anyway
            }
            textureDatas.add(textureData);
        } else {
            LOGGER.warning("The texture coordinates type is not supported: " + UVCoordinatesType.valueOf(uvCoordinatesType) + ". The texture '" + textureStructure.getName() + "'.");
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:40,代码来源:CombinedTexture.java

示例13: merge

import com.jme3.texture.Texture2D; //导入依赖的package包/类
/**
 * This method merges two given textures. The result is stored in the
 * 'target' texture.
 * 
 * @param target
 *            the target texture
 * @param source
 *            the source texture
 */
private void merge(Texture2D target, Texture2D source) {
    if (target.getImage().getDepth() != source.getImage().getDepth()) {
        throw new IllegalArgumentException("Cannot merge images with different depths!");
    }
    Image sourceImage = source.getImage();
    Image targetImage = target.getImage();
    PixelInputOutput sourceIO = PixelIOFactory.getPixelIO(sourceImage.getFormat());
    PixelInputOutput targetIO = PixelIOFactory.getPixelIO(targetImage.getFormat());
    TexturePixel sourcePixel = new TexturePixel();
    TexturePixel targetPixel = new TexturePixel();
    int depth = target.getImage().getDepth() == 0 ? 1 : target.getImage().getDepth();

    for (int layerIndex = 0; layerIndex < depth; ++layerIndex) {
        for (int x = 0; x < sourceImage.getWidth(); ++x) {
            for (int y = 0; y < sourceImage.getHeight(); ++y) {
                sourceIO.read(sourceImage, layerIndex, sourcePixel, x, y);
                targetIO.read(targetImage, layerIndex, targetPixel, x, y);
                targetPixel.merge(sourcePixel);
                targetIO.write(targetImage, layerIndex, targetPixel, x, y);
            }
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:CombinedTexture.java

示例14: scale

import com.jme3.texture.Texture2D; //导入依赖的package包/类
/**
 * This method scales the given texture to the given size.
 * 
 * @param texture
 *            the texture to be scaled
 * @param width
 *            new width of the texture
 * @param height
 *            new height of the texture
 */
private void scale(Texture2D texture, int width, int height) {
    // first determine if scaling is required
    boolean scaleRequired = texture.getImage().getWidth() != width || texture.getImage().getHeight() != height;

    if (scaleRequired) {
        Image image = texture.getImage();
        BufferedImage sourceImage = ImageToAwt.convert(image, false, true, 0);

        int sourceWidth = sourceImage.getWidth();
        int sourceHeight = sourceImage.getHeight();

        BufferedImage targetImage = new BufferedImage(width, height, sourceImage.getType());

        Graphics2D g = targetImage.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        g.drawImage(sourceImage, 0, 0, width, height, 0, 0, sourceWidth, sourceHeight, null);
        g.dispose();

        Image output = new ImageLoader().load(targetImage, false);
        image.setWidth(width);
        image.setHeight(height);
        image.setData(output.getData(0));
        image.setFormat(output.getFormat());
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:36,代码来源:CombinedTexture.java

示例15: readTextureUnit

import com.jme3.texture.Texture2D; //导入依赖的package包/类
private void readTextureUnit(Statement statement){
    String[] split = statement.getLine().split(" ", 2); 
    // name is optional
    if (split.length == 2){
        texName = split[1];
    }else{
        texName = null;
    }

    textures[texUnit] = new Texture2D();
    for (Statement texUnitStat : statement.getContents()){
        readTextureUnitStatement(texUnitStat);
    }
    if (textures[texUnit].getImage() != null){
        texUnit++;
    }else{
        // no image was loaded, ignore
        textures[texUnit] = null;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:21,代码来源:MaterialLoader.java


注:本文中的com.jme3.texture.Texture2D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。