Package com.jme3.asset

Examples of com.jme3.asset.TextureKey


  public static void startApp(){
    app.startCanvas();
    app.enqueue(new Callable<Void>(){
      public Void call(){
        if (app instanceof SimpleApplication){
          SimpleApplication simpleApp = (SimpleApplication) app;
          simpleApp.getFlyByCamera().setDragToRotate(true);
          String assdir =  new File(workspace).getAbsolutePath();
          app.setAssetsPath(assdir);
        }
        return null;
      }
View Full Code Here


     * Attaches Statistics View to guiNode and displays it on the screen
     * above FPS statistics line.
     *
     */
    public void loadStatsView() {
        statsView = new StatsView("Statistics View", assetManager, renderer.getStatistics());
//         move it up so it appears above fps text
        statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0);
        guiNode.attachChild(statsView);
    }
View Full Code Here

        listener = new Listener();
        ar.setListener(listener);
       
        // init StateManager ----------------------------
        stateManager = new AppStateManager(this);
       
        // simple Init ----------------------------------
        guiNode.setQueueBucket(Bucket.Gui);
        guiNode.setCullHint(CullHint.Never);
        //loadFPSText();
View Full Code Here

    private void setColor(Node node, ColorRGBA color){
  for(int i = 0; i < node.getQuantity(); i++){
      Spatial spatial = node.getChild(i);
      if(spatial instanceof Geometry){
                //Material material = new Material();
                AssetManager assetManager = JmeSystem.newAssetManager(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
                Material material = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
                material.setColor("m_Color",color);
                //Material geomMaterial = ((Geometry)spatial).getMaterial();
                spatial.setMaterial(material);
                System.out.println("Spatial: "+spatial.getName());
View Full Code Here

     * Sets the color of the geometries of the children and home.
     * Note, this is a recursive method.
     * @param node the node that contains children
     **/
    private void setColor(Geometry geometry, ColorRGBA color){
        AssetManager assetManager = JmeSystem.newAssetManager(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
        Material material = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
        material.setColor("m_Color",color);
        geometry.setMaterial(material);
        System.out.println("Spatial: "+geometry.getName());
    }
View Full Code Here

    //bgNode.attachChild(sky);

    sphere.updateModelBound();
    sphere.setQueueBucket(Bucket.Sky);
    Material sky = new Material(assetManager, "Common/MatDefs/Misc/Sky.j3md");
    TextureKey key = new TextureKey("Textures/Sky/Stars.dds", true);
    key.setGenerateMips(true);
    key.setAsCube(true);
    Texture tex = assetManager.loadTexture(key);
    sky.setTexture("m_Texture", tex);
    sky.setVector3("m_NormalScale", Vector3f.UNIT_XYZ);
    sphere.setMaterial(sky);
    sphere.setCullHint(Spatial.CullHint.Never);
View Full Code Here

    public static Spatial createSky(AssetManager assetManager, Texture texture, boolean sphereMap) {
        return createSky(assetManager, texture, Vector3f.UNIT_XYZ, sphereMap);
    }

    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);
    }
View Full Code Here

        //BufferedImage im = null;
       
        try {
            String name = namer.getName(x, z);
            logger.log(Level.FINE, "Loading heightmap from file: {0}", name);
            final Texture texture = assetManager.loadTexture(new TextureKey(name));
           
            // CREATE HEIGHTMAP
            heightmap = new ImageBasedHeightMap(texture.getImage());
           
            heightmap.setHeightScale(1);
View Full Code Here

  /** Initialize the materials used in this scene. */
  public void initMaterials() {

    wall_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
    key.setGenerateMips(true);
    Texture tex = assetManager.loadTexture(key);
    wall_mat.setTexture("ColorMap", tex);

    stone_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
    key2.setGenerateMips(true);
    Texture tex2 = assetManager.loadTexture(key2);
    stone_mat.setTexture("ColorMap", tex2);

    floor_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
    key3.setGenerateMips(true);
    Texture tex3 = assetManager.loadTexture(key3);
    tex3.setWrap(WrapMode.Repeat);
    floor_mat.setTexture("ColorMap", tex3);
  }
View Full Code Here

import java.nio.ByteBuffer;

public class TextureProcessor implements AssetProcessor {

    public Object postProcess(AssetKey key, Object obj) {
        TextureKey texKey = (TextureKey) key;
        Image img = (Image) obj;
        if (img == null) {
            return null;
        }

        Texture tex;
        if (texKey.isAsCube()) {
            if (texKey.isFlipY()) {
                // also flip -y and +y image in cubemap
                ByteBuffer pos_y = img.getData(2);
                img.setData(2, img.getData(3));
                img.setData(3, pos_y);
            }
            tex = new TextureCubeMap();
        } else if (texKey.isAsTexture3D()) {
            tex = new Texture3D();
        } else {
            tex = new Texture2D();
        }

        // enable mipmaps if image has them
        // or generate them if requested by user
        if (img.hasMipmaps() || texKey.isGenerateMips()) {
            tex.setMinFilter(Texture.MinFilter.Trilinear);
        }

        tex.setAnisotropicFilter(texKey.getAnisotropy());
        tex.setName(texKey.getName());
        tex.setImage(img);
        return tex;
    }
View Full Code Here

TOP

Related Classes of com.jme3.asset.TextureKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.