X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fbase%2FResourceTextureCache.java;h=10ff6ce9b2fb03798d56b26a50c89c1a12084d19;hb=9ad91ae4a059a4c7b219d2560c5b8b8ed1c5f184;hp=33b189007ceb584c2deab511ffd1b3c08dae958b;hpb=f9e3fe0569bf1cf3bbcdbc56fb81c736cba086f9;p=simantics%2F3d.git diff --git a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ResourceTextureCache.java b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ResourceTextureCache.java index 33b18900..10ff6ce9 100644 --- a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ResourceTextureCache.java +++ b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/base/ResourceTextureCache.java @@ -1,3 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2007- VTT Technical Research Centre of Finland. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ package org.simantics.proconf.g3d.base; import java.nio.ByteBuffer; @@ -18,7 +28,6 @@ import org.simantics.utils.ui.gfx.PixelDimension; import com.jme.image.Image; import com.jme.image.Texture; -import com.jme.util.TextureManager; /** * Caches resource based textures. @@ -26,6 +35,7 @@ import com.jme.util.TextureManager; * TODO : either use shared context or use separate cache for each editor * TODO : ShapeNode implementation won't use release texture yet * TODO : Texture is released when reference count goes to zero; we probably want to wait for a while before texture is released because it might be used again. + * TODO : Support for other types of textures (not just pattern texture, preferably extensible interface) * * @author Marko Luukkainen * @@ -53,19 +63,13 @@ public class ResourceTextureCache { ImageTexture it = new ImageTexture(g,res); org.simantics.image.stubs.Image pattern = it.getImage(); Image image = loadImage(g, pattern.getResource()); -// image.getData().rewind(); -// while (image.getData().hasRemaining()) -// image.getData().put((byte)(Math.random()*256.0 - 127.0)); + if (image == null) { return null; } t = new Texture(); t.setImage(image); - //t = TextureManager.loadTexture(image, Texture.MM_LINEAR, Texture.FM_LINEAR); -// t.setImageLocation(res.toString()); -// URL url = FileLocator.find(com.jme.eclipse.Activator.getDefault().getBundle(),new Path("data/texture/clouds.png"),null); -// t = TextureManager.loadTexture(url, Texture.MM_LINEAR, Texture.FM_LINEAR); t.setFilter(com.jme.image.Texture.FM_LINEAR); t.setMipmapState(com.jme.image.Texture.MM_LINEAR); @@ -167,7 +171,7 @@ public class ResourceTextureCache { return instance; } - private static Image getImage(ImageData imageData) { + public static Image getImage(ImageData imageData) { int width = imageData.width; int height = imageData.height; int type = 0;