1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5 package jme3test.texture;
6 
7 import com.jme3.app.SimpleApplication;
8 import com.jme3.asset.TextureKey;
9 import com.jme3.material.Material;
10 import com.jme3.math.ColorRGBA;
11 import com.jme3.math.Vector2f;
12 import com.jme3.math.Vector3f;
13 import com.jme3.scene.Geometry;
14 import com.jme3.scene.shape.Quad;
15 import com.jme3.texture.Texture;
16 
17 public class TestTexture3DLoading extends SimpleApplication {
18 
main(String[] args)19     public static void main(String[] args) {
20         TestTexture3DLoading app = new TestTexture3DLoading();
21         app.start();
22     }
23 
24     @Override
simpleInitApp()25     public void simpleInitApp() {
26         viewPort.setBackgroundColor(ColorRGBA.DarkGray);
27         flyCam.setEnabled(false);
28 
29 
30         Quad q = new Quad(10, 10);
31 
32         Geometry geom = new Geometry("Quad", q);
33         Material material = new Material(assetManager, "jme3test/texture/tex3DThumb.j3md");
34         TextureKey key = new TextureKey("Textures/3D/flame.dds");
35         key.setGenerateMips(true);
36         key.setAsTexture3D(true);
37 
38         Texture t = assetManager.loadTexture(key);
39 
40         int rows = 4;//4 * 4
41 
42         q.scaleTextureCoordinates(new Vector2f(rows, rows));
43 
44         //The image only have 8 pictures and we have 16 thumbs, the data will be interpolated by the GPU
45         material.setFloat("InvDepth", 1f / 16f);
46         material.setInt("Rows", rows);
47         material.setTexture("Texture", t);
48         geom.setMaterial(material);
49 
50         rootNode.attachChild(geom);
51 
52         cam.setLocation(new Vector3f(4.7444625f, 5.160054f, 13.1939f));
53     }
54 }