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


Java Texture.getImage方法代码示例

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


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

示例1: 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

示例2: 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

示例3: saveIfNeedTexture

import com.jme3.texture.Texture; //导入方法依赖的package包/类
/**
 * Save if need a texture.
 *
 * @param texture the texture.
 */
private static void saveIfNeedTexture(@NotNull final Texture texture) {

    final Image image = texture.getImage();
    if (!image.isChanged()) return;

    final AssetKey key = texture.getKey();
    final Path file = notNull(getRealFile(key.getName()));
    final BufferedImage bufferedImage = ImageToAwt.convert(image, false, true, 0);

    try (final OutputStream out = Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE)) {
        ImageIO.write(bufferedImage, "png", out);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    image.clearChanges();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:MaterialUtils.java

示例4: updateRenderTexture

import com.jme3.texture.Texture; //导入方法依赖的package包/类
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) {
    Texture tex = rb.getTexture();
    Image image = tex.getImage();
    if (image.isUpdateNeeded()) {
        updateTexImageData(image, tex.getType(), tex.getMinFilter().usesMipMapLevels(), 0);

        // NOTE: For depth textures, sets nearest/no-mips mode
        // Required to fix "framebuffer unsupported"
        // for old NVIDIA drivers!
        setupTextureParams(tex);
    }

    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
            convertAttachmentSlot(rb.getSlot()),
            convertTextureType(tex.getType(), image.getMultiSamples()),
            image.getId(),
            0);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:LwjglRenderer.java

示例5: getImageResource

import com.jme3.texture.Texture; //导入方法依赖的package包/类
@Override
public ImageResource getImageResource(String uri) {
	if (ImageUtil.isEmbeddedBase64Image(uri)) {
		return loadEmbeddedBase64ImageResource(uri);
	} else {
		uri = resolveURI(uri);
		try {
			Texture tex = ToolKit.get().getApplication().getAssetManager().loadTexture(new TextureKey(uri));
			return new ImageResource(uri, new XHTMLFSImage(tex.getImage(), this, uri));
		} catch (AssetNotFoundException anfe) {
			XRLog.exception(String.format("Image at URI %s not found", uri));
		} catch (Exception e) {
			XRLog.exception(String.format("Failed to load %s", uri), e);
		}
		return new ImageResource(uri, new XHTMLFSImage(getMissingImage(), this, uri));
	}
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:18,代码来源:XHTMLUserAgent.java

示例6: paintTexture

import com.jme3.texture.Texture; //导入方法依赖的package包/类
public void paintTexture(Terrain terrain, Vector3f markerLocation, float toolRadius, float toolWeight, int selectedTextureIndex) {
    if (selectedTextureIndex < 0 || markerLocation == null)
        return;
    
    int alphaIdx = selectedTextureIndex/4; // 4 = rgba = 4 textures
    Texture tex = getAlphaTexture(terrain, alphaIdx);
    Image image = tex.getImage();

    Vector2f UV = getPointPercentagePosition(terrain, markerLocation);

    // get the radius of the brush in pixel-percent
    float brushSize = toolRadius/(terrain.getTerrainSize()*((Node)terrain).getWorldScale().x);
    int texIndex = selectedTextureIndex - ((selectedTextureIndex/4)*4); // selectedTextureIndex/4 is an int floor, do not simplify the equation
    boolean erase = toolWeight<0;
    if (erase)
        toolWeight *= -1;

    doPaintAction(texIndex, image, UV, true, brushSize, erase, toolWeight);

    tex.getImage().setUpdateNeeded();
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:22,代码来源:PaintTerrainToolAction.java

示例7: createSky

import com.jme3.texture.Texture; //导入方法依赖的package包/类
/**
 * Create a cube-mapped sky using six textures.
 *
 * @param assetManager from which to load materials
 * @param west         texture for the western face of the cube
 * @param east         texture for the eastern face of the cube
 * @param north        texture for the northern face of the cube
 * @param south        texture for the southern face of the cube
 * @param up           texture for the top face of the cube
 * @param down         texture for the bottom face of the cube
 * @param normalScale  The normal scale is multiplied by the 3D normal to get
 *                     a texture coordinate. Use Vector3f.UNIT_XYZ to not apply and
 *                     transformation to the normal.
 * @param sphereRadius the sky sphere's radius: for the sky to be visible,
 *                     its radius must fall between the near and far planes of the camera's
 *                     frustrum
 * @return a new spatial representing the sky, ready to be attached to the
 * scene graph
 */
public static @NotNull Spatial createSky(@NotNull final AssetManager assetManager, @NotNull final Texture west,
                                         @NotNull final Texture east, @NotNull final Texture north,
                                         @NotNull final Texture south, @NotNull final Texture up,
                                         @NotNull final Texture down, @NotNull final Vector3f normalScale,
                                         float sphereRadius) {

    Image westImg = west.getImage();
    Image eastImg = east.getImage();
    Image northImg = north.getImage();
    Image southImg = south.getImage();
    Image upImg = up.getImage();
    Image downImg = down.getImage();

    checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);

    Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null, westImg.getColorSpace());
    cubeImage.addData(westImg.getData(0));
    cubeImage.addData(eastImg.getData(0));
    cubeImage.addData(downImg.getData(0));
    cubeImage.addData(upImg.getData(0));
    cubeImage.addData(southImg.getData(0));
    cubeImage.addData(northImg.getData(0));

    TextureCubeMap cubeMap = new TextureCubeMap(cubeImage);
    return createSky(assetManager, cubeMap, normalScale, SkyFactory.EnvMapType.CubeMap, sphereRadius);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:46,代码来源:JmbSkyFactory.java

示例8: paintTexture

import com.jme3.texture.Texture; //导入方法依赖的package包/类
/**
 * Paint texture.
 *
 * @param editingInput the editing input.
 * @param contactPoint the contact point.
 */
private void paintTexture(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {

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

    final LocalObjects local = LocalObjects.get();
    final Spatial terrainNode = notNull(getEditedModel());
    final Terrain terrain = (Terrain) terrainNode;
    final Image image = alphaTexture.getImage();

    final Vector3f worldTranslation = terrainNode.getWorldTranslation();
    final Vector3f localPoint = contactPoint.subtract(worldTranslation, local.nextVector());
    final Vector3f localScale = terrainNode.getLocalScale();
    final Vector2f uv = getPointPercentagePosition(terrain, localPoint, localScale, local.nextVector2f());
    final Vector2f temp = local.nextVector2f();
    final ColorRGBA color = local.nextColor();

    final int layer = getLayer();

    // get the radius of the brush in pixel-percent
    float brushSize = getBrushSize() / (terrain.getTerrainSize() * localScale.getX());
    float brushPower = getBrushPower();

    if (editingInput == EditingInput.MOUSE_SECONDARY) {
        brushPower *= -1;
    }

    // selectedTextureIndex/4 is an int floor, do not simplify the equation
    final ObjectFloatObjectConsumer<ColorRGBA, Boolean> colorFunction = COLOR_FUNCTIONS[layer - ((layer / 4) * 4)];

    doPaintAction(colorFunction, image, uv, temp, color, brushSize, false, brushPower);

    image.setUpdateNeeded();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:41,代码来源:PaintTerrainToolControl.java

示例9: createSky

import com.jme3.texture.Texture; //导入方法依赖的package包/类
public static Spatial createSky(AssetManager assetManager, Texture west, Texture east, Texture north, Texture south, Texture up, Texture down, Vector3f normalScale){
    Geometry sky = new Geometry("Sky", sphereMesh);
    sky.setQueueBucket(Bucket.Sky);
    sky.setCullHint(Spatial.CullHint.Never);

    Image westImg  = west.getImage();
    Image eastImg  = east.getImage();
    Image northImg = north.getImage();
    Image southImg = south.getImage();
    Image upImg    = up.getImage();
    Image downImg  = down.getImage();

    checkImagesForCubeMap(westImg, eastImg, northImg, southImg, upImg, downImg);

    Image cubeImage = new Image(westImg.getFormat(), westImg.getWidth(), westImg.getHeight(), null);
    
    cubeImage.addData(westImg.getData(0));
    cubeImage.addData(eastImg.getData(0));
    
    cubeImage.addData(downImg.getData(0));
    cubeImage.addData(upImg.getData(0));

    cubeImage.addData(southImg.getData(0));
    cubeImage.addData(northImg.getData(0));

    TextureCubeMap cubeMap = new TextureCubeMap(cubeImage);
    cubeMap.setAnisotropicFilter(0);
    cubeMap.setMagFilter(Texture.MagFilter.Bilinear);
    cubeMap.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
    cubeMap.setWrap(Texture.WrapMode.EdgeClamp);

    Material skyMat = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
    skyMat.setTexture("Texture", cubeMap);
    skyMat.setVector3("NormalScale", normalScale);
    sky.setMaterial(skyMat);

    return sky;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:SkyFactory.java

示例10: getMissingImage

import com.jme3.texture.Texture; //导入方法依赖的package包/类
protected Image getMissingImage() {
	if (missingImage == null) {
		// Fake element for storing the 'missing image' style
		missingImage = new Element(screen).setStyleClass("missing-image");
	}
	Texture elementTexture = missingImage.getElementTexture();
	if (elementTexture == null) {
		// TODO default
		return null;
	}
	return elementTexture.getImage();
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:13,代码来源:XHTMLUserAgent.java

示例11: setSprite

import com.jme3.texture.Texture; //导入方法依赖的package包/类
public void setSprite(Texture sprite, int rows, int cols, float framesPerSecond) {
	this.sprite = sprite;

	this.spriteRows = rows;
	this.spriteCols = cols;

	Image img = sprite.getImage();
	imgWidth = img.getWidth();
	imgHeight = img.getHeight();

	spriteWidth = imgWidth / cols;
	spriteHeight = imgHeight / rows;

	sprites.clear();
	for (int y = rows - 1; y > -1; y--) {
		for (int x = 0; x < cols; x++) {
			sprites.add(new Vector4f(x * spriteWidth, y * spriteHeight, spriteWidth, spriteHeight));
		}
	}

	setAtlas(sprites.get(currentIndex));
	this.setTexture(sprite);

	this.useInterval = true;
	this.framesPerSecond = framesPerSecond;
	this.trackInterval = 1 / framesPerSecond;

	setEnabled(true);
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:30,代码来源:SpriteElement.java

示例12: calcPreferredBackgroundSize

import com.jme3.texture.Texture; //导入方法依赖的package包/类
protected Vector2f calcPreferredBackgroundSize(C el) {
	BaseElement element = (BaseElement) el;
	Vector2f sz = new Vector2f();
	Size bs = element.getBackgroundDimensions();
	Texture tex = element.getElementTexture();
	Image img = tex == null ? null : tex.getImage();
	if (img == null)
		return null;

	Vector2f imgsz = (element.isAtlasTextureInUse()
			? new Vector2f(element.getAtlasCoords().z, element.getAtlasCoords().w)
			: new Vector2f(img.getWidth(), img.getHeight()));

	switch (bs.xUnit) {
	case PX:
		sz.x = bs.x;
		break;
	case AUTO:
		sz.x = imgsz.x;
		break;
	default:
		break;
	}

	switch (bs.yUnit) {
	case PX:
		sz.y = bs.y;
		break;
	case AUTO:
		sz.y = imgsz.y;
		break;
	default:
		break;
	}
	//
	// if (sz.x == 0 && sz.y == 0)
	// sz = null;

	return sz;
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:41,代码来源:AbstractGenericLayout.java

示例13: getPreferredSizeFromTexture

import com.jme3.texture.Texture; //导入方法依赖的package包/类
protected Vector2f getPreferredSizeFromTexture(BaseElement c) {
	if (c != null && c.getElementTexture() != null) {
		Texture tex = c.getElementTexture();
		if (tex.getImage() != null && c.isUseColorMapForSizeCalculations())
			return new Vector2f(tex.getImage().getWidth(), tex.getImage().getHeight());
	}
	return null;
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:9,代码来源:AbstractGenericLayout.java

示例14: doClearAlphaMap

import com.jme3.texture.Texture; //导入方法依赖的package包/类
private void doClearAlphaMap(int selectedTextureIndex) {
    Terrain terrain = (Terrain) getTerrain(null);
    if (terrain == null)
        return;
    
    int alphaIdx = selectedTextureIndex/4; // 4 = rgba = 4 textures
    int texIndex = selectedTextureIndex - ((selectedTextureIndex/4)*4); // selectedTextureIndex/4 is an int floor
    //selectedTextureIndex - (alphaIdx * 4)
    Texture tex = doGetAlphaTexture(terrain, alphaIdx);
    Image image = tex.getImage();
    
    PaintTerrainToolAction paint = new PaintTerrainToolAction();
    
    ColorRGBA color = ColorRGBA.Black;
    for (int y=0; y<image.getHeight(); y++) {
        for (int x=0; x<image.getWidth(); x++) {
    
            paint.manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer)
            switch (texIndex) {
                case 0:
                    color.r = 0; break;
                case 1:
                    color.g = 0; break;
                case 2:
                    color.b = 0; break;
                case 3:
                    color.a = 0; break;
                default:
                    throw new IllegalArgumentException("Invalid texIndex " + texIndex);
            }
            color.clamp();
            paint.manipulatePixel(image, x, y, color, true); // set the new color
        }
    }
    image.getData(0).rewind();
    tex.getImage().setUpdateNeeded();
    setNeedsSave(true);
    alphaLayersChanged();
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:40,代码来源:TerrainEditorController.java

示例15: doClearAlphaMap

import com.jme3.texture.Texture; //导入方法依赖的package包/类
public final static void doClearAlphaMap(Terrain terrain, int selectedTextureIndex) {
    int alphaIdx = selectedTextureIndex / 4; // 4 = rgba = 4 textures
    int texIndex = selectedTextureIndex - ((selectedTextureIndex/4)*4); // selectedTextureIndex/4 is an int floor
    //selectedTextureIndex - (alphaIdx * 4)
    Texture tex = doGetAlphaTexture(terrain, alphaIdx);
    Image image = tex.getImage();
    
    PaintTerrainToolAction paint = new PaintTerrainToolAction();
    
    ColorRGBA color = ColorRGBA.Black;
    for (int y=0; y<image.getHeight(); y++) {
        for (int x=0; x<image.getWidth(); x++) {
    
            paint.manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer)
            switch (texIndex) {
                case 0:
                    color.r = 0; break;
                case 1:
                    color.g = 0; break;
                case 2:
                    color.b = 0; break;
                case 3:
                    color.a = 0; break;
            }
            color.clamp();
            paint.manipulatePixel(image, x, y, color, true); // set the new color
        }
    }
    image.getData(0).rewind();
    tex.getImage().setUpdateNeeded();
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:32,代码来源:TerrainUtils.java


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