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


Java AssetManager.loadTexture方法代碼示例

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


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

示例1: readJMETexture

import com.jme3.asset.AssetManager; //導入方法依賴的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

示例2: setTexture

import com.jme3.asset.AssetManager; //導入方法依賴的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: MSMaterialControl

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public MSMaterialControl(AssetManager assetManager, Geometry geo, MSContainer msCont, MSControl msc){
    material = new Material(assetManager, "MonkeySheet/MatDefs/Anim.j3md");
    Texture[] sheetsX=new Texture[msCont.sheets.length];
    for (int i = 0; i < msCont.sheets.length; i++) {
        sheetsX[i]=assetManager.loadTexture(msCont.sheets[i]);
    }
    material.setFloat("SizeX", msCont.numTiles);
    material.setFloat("SizeY", msCont.numTiles);
    material.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    for (MTween mt:MonkeySheetAppState.anis.values()){
        if (mt.msCont==msCont)
            mt.setTextures(sheetsX);
    }
    geo.setMaterial(material);
    geo.addControl(this);
    this.msc=msc;
        material.setFloat("Position", msc.anim.anim[msc.position].position);
        material.setTexture("ColorMap", msc.anim.anim[msc.position].sheetX);
        material.setFloat("FlipHorizontal", 0.0f);
        material.setFloat("AlphaValue", 1.0f);
        material.setColor("FogColor", fogColor);
        material.setFloat("FogIntensity", 0.0f);
}
 
開發者ID:Pesegato,項目名稱:MonkeySheet,代碼行數:24,代碼來源:MSMaterialControl.java

示例4: ProjectProcessor

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public ProjectProcessor(Node root, AssetManager assetManager) {
        castCam = new Camera((int)128, (int)128);
        castCam.setParallelProjection(true);
        castCam.setFrustum(-1, 1, -1, 1, 1, -1);
        
        //Textures\tex\magic\magic.jpg
        // Textures\tex\sky\default\east.jpg
        tex = assetManager.loadTexture("Textures/tex/magic/magic.jpg");
//        tex = assetManager.loadTexture("Textures/tex/sky/default/east.jpg");
//        tex = assetManager.loadTexture("Interface/item/face/female5.jpg");
        mat = new Material(assetManager, "MatDefs/Projection/Projection.j3md");
        
        QuadXYC quad = new QuadXYC(1,1);
        projGeo = new Geometry("ProjGeo", quad);
        projGeo.setLocalScale(width, height, 1);
        Material debugMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        debugMat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
        projGeo.setMaterial(debugMat);
        projGeo.setCullHint(Spatial.CullHint.Always);
        root.attachChild(projGeo);
        
    }
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:23,代碼來源:ProjectProcessor.java

示例5: applyChanges

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Apple new changes if need.
 *
 * @param varTable the var table.
 */
@FXThread
private void applyChanges(@NotNull final VarTable varTable) {

    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 boolean needFlipY = varTable.getBoolean(PROP_FLIP);
    final Texture.WrapMode needWrapS = varTable.getEnum(PROP_WRAP_MODE_S, Texture.WrapMode.class);
    final Texture.WrapMode needWrapT = varTable.getEnum(PROP_WRAP_MODE_T, Texture.WrapMode.class);
    final Texture.MagFilter needMagFilter = varTable.getEnum(PROP_MAG_FILTER, Texture.MagFilter.class);
    final Texture.MinFilter needMinFilter = varTable.getEnum(PROP_MIN_FILTER, Texture.MinFilter.class);

    if (flipY == needFlipY && wrapS == needWrapS && wrapT == needWrapT && magFilter == needMagFilter &&
            minFilter == needMinFilter) {
        return;
    }

    final TextureKey newKey = new TextureKey(key.getName());
    newKey.setFlipY(needFlipY);

    final AssetManager assetManager = EDITOR.getAssetManager();
    assetManager.deleteFromCache(key);

    final Texture2D loadedTexture = (Texture2D) assetManager.loadTexture(newKey);
    loadedTexture.setWrap(Texture.WrapAxis.S, needWrapS);
    loadedTexture.setWrap(Texture.WrapAxis.T, needWrapT);
    loadedTexture.setMagFilter(needMagFilter);
    loadedTexture.setMinFilter(needMinFilter);

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

示例6: setDiffuseFile

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Set a new diffuse texture.
 *
 * @param diffuseFile the file to diffuse texture or null.
 */
@FromAnyThread
public void setDiffuseFile(@Nullable final Path diffuseFile) {
    final AssetManager assetManager = EDITOR.getAssetManager();
    final Path assetFile = diffuseFile == null ? null : getAssetFile(diffuseFile);
    final String assetPath = assetFile == null ? null : toAssetPath(assetFile);
    final Texture texture = assetPath == null ? null : assetManager.loadTexture(assetPath);
    settings.setDiffuse(texture, getLayer());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:14,代碼來源:TextureLayer.java

示例7: setNormalFile

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * Set a new normal texture.
 *
 * @param normalFile the file to normal texture or null.
 */
@FromAnyThread
public void setNormalFile(@Nullable final Path normalFile) {
    final AssetManager assetManager = EDITOR.getAssetManager();
    final Path assetFile = normalFile == null ? null : getAssetFile(normalFile);
    final String assetPath = assetFile == null ? null : toAssetPath(assetFile);
    final Texture texture = assetPath == null ? null : assetManager.loadTexture(assetPath);
    settings.setNormal(texture, getLayer());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:14,代碼來源:TextureLayer.java

示例8: BlockMaterial

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public BlockMaterial(
		Block block,
		AssetManager assetManager,
		JmeResourceManager resourceManager) {
	super(assetManager, getShader(block.getBlockType()));
	
	if (block.getColor() != null) {
		Color blockColor = block.getColor();
		
		color.x = (float)blockColor.red;
		color.y = (float)blockColor.green;
		color.z = (float)blockColor.blue;
		color.w = (float)blockColor.alpha;
		
		setInt("ColorBlendMode", ShaderUtil.getColorBlendModeAsInteger(ColorBlendMode.NORMAL));
	} else {
		setInt("ColorBlendMode", ShaderUtil.COLOR_BLEND_MODE_INVALID);
	}
	
	setVector4("Color", color);
	
	if (block.getTexture() != null) {
		texture = resourceManager.loadTexture(block.getName(), block.getTexture().getAsResource(resourceManager));
	} else {
		texture = assetManager.loadTexture("/assets/images/white-pixel.png");
	}
	
	texture.setMagFilter(MagFilter.Nearest);
	texture.setMinFilter(MinFilter.NearestNoMipMaps);
	texture.setWrap(WrapMode.Repeat);
	
	setTexture("ColorMap", texture);
	
	getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
}
 
開發者ID:quadracoatl,項目名稱:quadracoatl,代碼行數:36,代碼來源:BlockMaterial.java

示例9: loadToKey

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
protected boolean loadToKey(AssetManager assetManager, MeshConfiguration meshConfig, MeshConfiguration.TextureDefinition def, Material material, String key) {
    if (material.getMaterialDef().getMaterialParam(key) != null) {
        final String texturePath = meshConfig.absolutize(def.getName());
        LOG.info(String.format("Loading texture %s", texturePath));
        final Texture tex = assetManager.loadTexture(new TextureKey(texturePath, false));
        configureTexture(material, key, tex);
        return true;
    }
    return false;
}
 
開發者ID:rockfireredmoon,項目名稱:iceclient,代碼行數:11,代碼來源:TestLoading.java

示例10: main

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLoader(AWTLoader.class.getName(), "png");
    am.registerLoader(WAVLoader.class.getName(), "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class.getName());

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.png");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.png");

    System.out.println("Success!");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:28,代碼來源:TestAbsoluteLocators.java

示例11: createSky

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap){
    TextureKey key = new TextureKey(textureName, true);
    key.setGenerateMips(true);
    key.setAsCube(!sphereMap);
    Texture tex = assetManager.loadTexture(key);
    return createSky(assetManager, tex, sphereMap);
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:8,代碼來源:SkyFactory.java

示例12: createLightBulb

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
protected static Geometry createLightBulb(AssetManager assetManager) {
    Quad q = new Quad(0.5f, 0.5f);
    Geometry lightBulb = new Geometry("light bulb", q);
    lightBulb.move(-q.getHeight() / 2f, -q.getWidth() / 2f, 0);
    
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Texture tex = assetManager.loadTexture("com/jme3/gde/scenecomposer/lightbulb32.png");
    mat.setTexture("ColorMap", tex);
    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    lightBulb.setMaterial(mat);
    lightBulb.setQueueBucket(RenderQueue.Bucket.Transparent);
    
    return lightBulb;
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:15,代碼來源:LightGizmoFactory.java

示例13: createAudioMarker

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
/**
 * A marker on the screen that shows where an audio node is.
 */
protected static Geometry createAudioMarker(AssetManager assetManager) {
    Quad q = new Quad(0.5f, 0.5f);
    Geometry audioMarker = new Geometry("light bulb", q);
    audioMarker.move(-q.getHeight() / 2f, -q.getWidth() / 2f, 0);

    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    Texture tex = assetManager.loadTexture("com/jme3/gde/scenecomposer/audionode.gif");
    mat.setTexture("ColorMap", tex);
    mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
    audioMarker.setMaterial(mat);
    audioMarker.setQueueBucket(RenderQueue.Bucket.Transparent);

    return audioMarker;
}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:18,代碼來源:AudioGizmoFactory.java

示例14: loadModel

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
@Override
protected Spatial loadModel() {
    AssetManager am = LuoYing.getApp().getAssetManager();
    Texture w = am.loadTexture(baseDir != null ? baseDir + west : west);
    Texture e = am.loadTexture(baseDir != null ? baseDir + east : east);
    Texture n = am.loadTexture(baseDir != null ? baseDir + north : north);
    Texture s = am.loadTexture(baseDir != null ? baseDir + south : south);
    Texture u = am.loadTexture(baseDir != null ? baseDir + up : up);
    Texture d = am.loadTexture(baseDir != null ? baseDir + down : down);
    sky = SkyFactory.createSky(am, w, e, n, s, u, d);
    return sky;
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:13,代碼來源:SkyBoxEntity.java

示例15: create

import com.jme3.asset.AssetManager; //導入方法依賴的package包/類
private void create() {
        if (mat == null) {
            AssetManager am = LuoYing.getAssetManager();
            mat = new Material(am, AssetConstants.MATERIAL_SLIDE_COLOR_IO);
            mat.setColor("StartColor", startColor);
            mat.setColor("EndColor", endColor);

            Texture maskMap = am.loadTexture(mask);
            mat.setTexture("MaskMap", maskMap);

            Texture texMap = am.loadTexture(tex);
            mat.setTexture("TexMap", texMap);
            mat.setBoolean("TexAnimY", texAnimY);
            mat.setBoolean("TexChangeDir", texChangeDir);
            mat.setFloat("offsetY", -1.0f);

            mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off); // Allow to see both sides of a face
            mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Additive);
            mat.getAdditionalRenderState().setColorWrite(true);
            mat.getAdditionalRenderState().setDepthTest(true);
            mat.getAdditionalRenderState().setDepthWrite(false);
        }
        if (animObj == null) {
            animObj = loadAnimModel();
            animObj.setMaterial(mat);
            animNode.attachChild(animObj);
            
//            // for debug
//            Material debugMat = new Material(Common.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
//            debugMat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
//            debugMat.getAdditionalRenderState().setWireframe(true);
//            Spatial debugObj = (animObj instanceof Geometry) ? animObj.clone() : ((Node) animObj).getChild(0).clone();
//            debugObj.setMaterial(debugMat);
//            attachChild(debugObj);
        }
    }
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:37,代碼來源:SlideColorIOSplineEffect.java


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