@Override public Texture createSimpleClone() { Texture2D clone = new Texture2D(); createSimpleClone(clone); return clone; }
protected void createTextures() { reflectionTexture = new Texture2D(renderWidth, renderHeight, Format.RGBA8); refractionTexture = new Texture2D(renderWidth, renderHeight, Format.RGBA8); reflectionTexture.setMinFilter(Texture.MinFilter.Trilinear); reflectionTexture.setMagFilter(Texture.MagFilter.Bilinear); refractionTexture.setMinFilter(Texture.MinFilter.Trilinear); refractionTexture.setMagFilter(Texture.MagFilter.Bilinear); depthTexture = new Texture2D(renderWidth, renderHeight, Format.Depth); }
public FbxTexture(SceneLoader scene, FbxElement element) { super(scene, element); for(FbxElement e : element.children) { switch(e.id) { case "Type": bindType = (String) e.properties.get(0); break; case "FileName": filename = (String) e.properties.get(0); break; } } texture = new Texture2D(); texture.setName(name); texture.setWrap(WrapMode.Repeat); // Default FBX wrapping. TODO: Investigate where this is stored (probably, in material) }
@Override public int createNonAtlasTexture(final Image image) { ImageImpl imageImpl = (ImageImpl) image; Texture2D texture = new Texture2D(imageImpl.image); texture.setMinFilter(MinFilter.NearestNoMipMaps); texture.setMagFilter(MagFilter.Nearest); return addTexture(texture); }
private Texture2D createAtlasTextureInternal(final int width, final int height) throws Exception { ByteBuffer initialData = BufferUtils.createByteBuffer(width*height*4); for (int i=0; i<width*height*4; i++) { initialData.put((byte) 0x00); } initialData.rewind(); Texture2D texture = new Texture2D(new com.jme3.texture.Image(Format.RGBA8, width, height, initialData, ColorSpace.sRGB)); texture.setMinFilter(MinFilter.NearestNoMipMaps); texture.setMagFilter(MagFilter.Nearest); return texture; }
protected Texture loadTexture(String path){ String[] split = path.trim().split("\\p{javaWhitespace}+"); // will crash if path is an empty string path = split[split.length-1]; String name = new File(path).getName(); TextureKey texKey = new TextureKey(folderName + name); texKey.setGenerateMips(true); Texture texture; try { texture = assetManager.loadTexture(texKey); texture.setWrap(WrapMode.Repeat); } catch (AssetNotFoundException ex){ logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key}); texture = new Texture2D(PlaceholderAssets.getPlaceholderImage(assetManager)); texture.setWrap(WrapMode.Repeat); texture.setKey(key); } return texture; }
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; } }
/** * Creates a new atlas texture for the given map name. * @param mapName * @return the atlas texture */ public Texture getAtlasTexture(String mapName) { if (images == null) { return null; } byte[] image = images.get(mapName); if (image != null) { //TODO check if color space shouldn't be sRGB Texture2D tex = new Texture2D(new Image(format, atlasWidth, atlasHeight, BufferUtils.createByteBuffer(image), null, ColorSpace.Linear)); tex.setMagFilter(Texture.MagFilter.Bilinear); tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap); tex.setWrap(Texture.WrapMode.EdgeClamp); return tex; } return null; }
/** * 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); //DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash) dummyTex = new Texture2D(size, size, Format.RGBA8); shadowFB.setColorTexture(dummyTex); shadowMapSize = (float)size; preshadowMat = new Material(manager, "Common/MatDefs/Shadow/PreShadow.j3md"); postshadowMat = new Material(manager, "Common/MatDefs/Shadow/BasicPostShadow.j3md"); postshadowMat.setTexture("ShadowMap", shadowMap); dispPic.setTexture(manager, shadowMap, false); for (int i = 0; i < points.length; i++) { points[i] = new Vector3f(); } }
private void readExtendingMaterialStatement(Statement statement) throws IOException { if (statement.getLine().startsWith("set_texture_alias")){ String[] split = statement.getLine().split(" ", 3); String aliasName = split[1]; String texturePath = split[2]; String jmeParamName = matExt.getTextureMapping(aliasName); TextureKey texKey = new TextureKey(texturePath, false); texKey.setGenerateMips(true); Texture tex; try { tex = assetManager.loadTexture(texKey); tex.setWrap(WrapMode.Repeat); } catch (AssetNotFoundException ex){ logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key}); tex = new Texture2D( PlaceholderAssets.getPlaceholderImage(assetManager) ); tex.setWrap(WrapMode.Repeat); tex.setKey(texKey); } material.setTexture(jmeParamName, tex); } }
private Texture createTexture(String name) { ByteBuffer bb = BufferUtils.createByteBuffer(3); Image image = new Image(Format.RGB8, 1, 1, bb, ColorSpace.sRGB); Texture2D texture = new Texture2D(image); texture.setName(name); return texture; }
@Override protected void initialize(Application app) { this.backGroundColor = app.getViewPort().getBackgroundColor(); final Camera[] cameras = new Camera[6]; final Texture2D[] textures = new Texture2D[6]; viewports = new ViewPort[6]; framebuffers = new FrameBuffer[6]; buffers = new ByteBuffer[6]; images = new Image[6]; for (int i = 0; i < 6; i++) { cameras[i] = createOffCamera(size, position, axisX[i], axisY[i], axisZ[i]); viewports[i] = createOffViewPort("EnvView" + i, cameras[i]); framebuffers[i] = createOffScreenFrameBuffer(size, viewports[i]); textures[i] = new Texture2D(size, size, imageFormat); framebuffers[i].setColorTexture(textures[i]); } }
/** * init the given filter * @param filter * @param vp */ private void initFilter(Filter filter, ViewPort vp) { filter.setProcessor(this); if (filter.isRequiresDepthTexture()) { if (!computeDepth && renderFrameBuffer != null) { depthTexture = new Texture2D(width, height, depthFormat); renderFrameBuffer.setDepthTexture(depthTexture); } computeDepth = true; filter.init(assetManager, renderManager, vp, width, height); filter.setDepthTexture(depthTexture); } else { filter.init(assetManager, renderManager, vp, width, height); } }
private static Texture2D createCheckerBoardTexture() { Image image = new Image(Format.RGBA8, 1024, 1024, BufferUtils.createByteBuffer(1024 * 1024 * 4), ColorSpace.sRGB); ImageRaster raster = ImageRaster.create(image); for (int y = 0; y < 1024; y++) { for (int x = 0; x < 1024; x++) { if (y < 512) { if (x < 512) { raster.setPixel(x, y, ColorRGBA.Black); } else { raster.setPixel(x, y, ColorRGBA.White); } } else { if (x < 512) { raster.setPixel(x, y, ColorRGBA.White); } else { raster.setPixel(x, y, ColorRGBA.Black); } } } } return new Texture2D(image); }
@Test public void testTextureOverride() { material("Common/MatDefs/Light/Lighting.j3md"); Texture2D tex1 = new Texture2D(128, 128, Format.RGBA8); Texture2D tex2 = new Texture2D(128, 128, Format.RGBA8); inputMp(mpoTexture2D("DiffuseMap", tex1)); inputMpo(mpoTexture2D("DiffuseMap", tex2)); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex2)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex2); }
@Test public void testTextureMpoOnly() { material("Common/MatDefs/Light/Lighting.j3md"); Texture2D tex = new Texture2D(128, 128, Format.RGBA8); inputMpo(mpoTexture2D("DiffuseMap", tex)); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex); }
private void convertAndPutImage(Image image, float posX, float posY) { Texture tex = new Texture2D(image); tex.setMagFilter(MagFilter.Nearest); tex.setMinFilter(MinFilter.NearestNoMipMaps); tex.setAnisotropicFilter(16); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", tex); Quad q = new Quad(5, 5); Geometry g = new Geometry("quad", q); g.setLocalTranslation(posX, posY - 5, -0.0001f); g.setMaterial(mat); rootNode.attachChild(g); BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText txt = new BitmapText(fnt); txt.setBox(new Rectangle(0, 0, 5, 5)); txt.setQueueBucket(RenderQueue.Bucket.Transparent); txt.setSize(0.5f); txt.setText(image.getFormat().name()); txt.setLocalTranslation(posX, posY, 0); rootNode.attachChild(txt); }
@Override public void simpleInitApp() { initOpenCL1(); tex = new Texture2D(settings.getWidth(), settings.getHeight(), 1, com.jme3.texture.Image.Format.RGBA8); Picture pic = new Picture("julia"); pic.setTexture(assetManager, tex, true); pic.setPosition(0, 0); pic.setWidth(settings.getWidth()); pic.setHeight(settings.getHeight()); guiNode.attachChild(pic); initCounter = 0; flyCam.setEnabled(false); inputManager.setCursorVisible(true); inputManager.addMapping("right", new MouseAxisTrigger(MouseInput.AXIS_X, false)); inputManager.addMapping("left", new MouseAxisTrigger(MouseInput.AXIS_X, true)); inputManager.addMapping("up", new MouseAxisTrigger(MouseInput.AXIS_Y, false)); inputManager.addMapping("down", new MouseAxisTrigger(MouseInput.AXIS_Y, true)); inputManager.addMapping("drag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addListener(this, "right", "left", "up", "down", "drag"); dragging = false; }
@Test public void testRemoveTextureOverride() { material("Common/MatDefs/Light/Lighting.j3md"); Texture2D tex1 = new Texture2D(128, 128, Format.RGBA8); Texture2D tex2 = new Texture2D(128, 128, Format.RGBA8); reset(); inputMp(mpoTexture2D("DiffuseMap", tex1)); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex1)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex1); reset(); inputMpo(mpoTexture2D("DiffuseMap", tex2)); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex2)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex2); reset(); geometry.clearMatParamOverrides(); root.updateGeometricState(); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex1)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex1); }
@Test public void testRemoveTexture() { material("Common/MatDefs/Light/Lighting.j3md"); Texture2D tex = new Texture2D(128, 128, Format.RGBA8); reset(); inputMpo(mpoTexture2D("DiffuseMap", tex)); outDefines(def("DIFFUSEMAP", VarType.Texture2D, tex)); outUniforms(uniform("DiffuseMap", VarType.Int, 0)); outTextures(tex); reset(); geometry.clearMatParamOverrides(); root.updateGeometricState(); outDefines(); outUniforms(); outTextures(); }