Java Code Examples for com.jme3.asset.TextureKey#setTextureTypeHint()
The following examples show how to use
com.jme3.asset.TextureKey#setTextureTypeHint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelImportDialog.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Copy textures from the external model. * * @param texturesFolder the textures folder. * @param overwriteTextures true if need to overwrite existing textures. * @param textures the found textures. */ @BackgroundThread private void copyTextures(@NotNull final Path texturesFolder, final boolean overwriteTextures, @NotNull final Array<Texture> textures) { if (textures.isEmpty()) { return; } final ObjectDictionary<String, String> oldKeyToNew = DictionaryFactory.newObjectDictionary(); final Array<AssetKey<?>> newTextureKeys = ArrayFactory.newArray(AssetKey.class); for (final Texture texture : textures) { final TextureKey textureKey = (TextureKey) texture.getKey(); if (newTextureKeys.contains(textureKey)) continue; final String newKey = oldKeyToNew.get(textureKey.getName(), makeCopyTextureFunction(texturesFolder, overwriteTextures)); final TextureKey newTextureKey = new TextureKey(newKey, textureKey.isFlipY()); newTextureKey.setGenerateMips(textureKey.isGenerateMips()); newTextureKey.setTextureTypeHint(textureKey.getTextureTypeHint()); texture.setKey(newTextureKey); newTextureKeys.add(newTextureKey); } }
Example 2
Source File: TestEnvironmentMapping.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o"); TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true); key.setGenerateMips(true); key.setTextureTypeHint(Texture.Type.CubeMap); final Texture tex = assetManager.loadTexture(key); for (Spatial geom : buggy.getChildren()) { if (geom instanceof Geometry) { Material m = ((Geometry) geom).getMaterial(); m.setTexture("EnvMap", tex); m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f)); } } flyCam.setEnabled(false); ChaseCamera chaseCam = new ChaseCamera(cam, inputManager); chaseCam.setLookAtOffset(new Vector3f(0,0.5f,-1.0f)); buggy.addControl(chaseCam); rootNode.attachChild(buggy); rootNode.attachChild(SkyFactory.createSky(assetManager, tex, SkyFactory.EnvMapType.CubeMap)); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects); bf.setBloomIntensity(2.3f); bf.setExposurePower(0.6f); fpp.addFilter(bf); DirectionalLight l = new DirectionalLight(); l.setDirection(new Vector3f(0, -1, -1)); rootNode.addLight(l); viewPort.addProcessor(fpp); }
Example 3
Source File: TestTexture3DLoading.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void simpleInitApp() { viewPort.setBackgroundColor(ColorRGBA.DarkGray); flyCam.setEnabled(false); Quad q = new Quad(10, 10); Geometry geom = new Geometry("Quad", q); Material material = new Material(assetManager, "jme3test/texture/tex3DThumb.j3md"); TextureKey key = new TextureKey("Textures/3D/flame.dds"); key.setGenerateMips(true); key.setTextureTypeHint(Texture.Type.ThreeDimensional); Texture t = assetManager.loadTexture(key); int rows = 4;//4 * 4 q.scaleTextureCoordinates(new Vector2f(rows, rows)); //The image only have 8 pictures and we have 16 thumbs, the data will be interpolated by the GPU material.setFloat("InvDepth", 1f / 16f); material.setInt("Rows", rows); material.setTexture("Texture", t); geom.setMaterial(material); rootNode.attachChild(geom); cam.setLocation(new Vector3f(4.7444625f, 5.160054f, 13.1939f)); }
Example 4
Source File: SkyFactory.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create a sky using the given cubemap or spheremap texture. * * @param assetManager from which to load materials * @param textureName the path to the texture asset to use * @param envMapType see {@link EnvMapType} * @return a new spatial representing the sky, ready to be attached to the * scene graph */ public static Spatial createSky(AssetManager assetManager, String textureName, EnvMapType envMapType) { TextureKey key = new TextureKey(textureName, true); key.setGenerateMips(false); if (envMapType == EnvMapType.CubeMap) { key.setTextureTypeHint(Texture.Type.CubeMap); } Texture tex = assetManager.loadTexture(key); return createSky(assetManager, tex, envMapType); }