Examples of AssetManager


Examples of com.jme3.asset.AssetManager

    @Override
    public void read(JmeImporter e) throws IOException {
        super.read(e);
        InputCapsule capsule = e.getCapsule(this);
        BinaryImporter importer = BinaryImporter.getInstance();
        AssetManager loaderManager = e.getAssetManager();

        assetLoaderKeys = (ArrayList<ModelKey>) capsule.readSavableArrayList("assetLoaderKeyList", new ArrayList<ModelKey>());
        for (Iterator<ModelKey> it = assetLoaderKeys.iterator(); it.hasNext();) {
            ModelKey modelKey = it.next();
            AssetInfo info = loaderManager.locateAsset(modelKey);
            Spatial child = null;
            if (info != null) {
                child = (Spatial) importer.load(info);
            }
            if (child != null) {
View Full Code Here

Examples of com.jme3.asset.AssetManager

            rm.renderScene(physicsDebugRootNode, viewPort);
        }
    }

    private void setupMaterials(Application app) {
        AssetManager manager = app.getAssetManager();
        DEBUG_BLUE = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        DEBUG_BLUE.getAdditionalRenderState().setWireframe(true);
        DEBUG_BLUE.setColor("Color", ColorRGBA.Blue);
        DEBUG_GREEN = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
        DEBUG_GREEN.getAdditionalRenderState().setWireframe(true);
View Full Code Here

Examples of com.jme3.asset.AssetManager

                break;
            default:
                throw new IllegalStateException("Unknown mipmap generation method: " + blenderContext.getBlenderKey().getMipmapGenerationMethod());
        }

        AssetManager assetManager = blenderContext.getAssetManager();
        name = name.replace('\\', '/');
        Texture result = null;

        if (name.startsWith("//")) {
            // This is a relative path, so try to find it relative to the .blend file
            String relativePath = name.substring(2);
            // Augument the path with blender key path
            BlenderKey blenderKey = blenderContext.getBlenderKey();
            int idx = blenderKey.getName().lastIndexOf('/');
            String blenderAssetFolder = blenderKey.getName().substring(0, idx != -1 ? idx : 0);
            String absoluteName = blenderAssetFolder + '/' + relativePath;
            // Directly try to load texture so AssetManager can report missing textures
            try {
                TextureKey key = new TextureKey(absoluteName);
                key.setAsCube(false);
                key.setFlipY(true);
                key.setGenerateMips(generateMipmaps);
                result = assetManager.loadTexture(key);
                result.setKey(key);
            } catch (AssetNotFoundException e) {
                LOGGER.fine(e.getLocalizedMessage());
            }
        } else {
            // This is a full path, try to truncate it until the file can be found
            // this works as the assetManager root is most probably a part of the
            // image path. E.g. AssetManager has a locator at c:/Files/ and the
            // texture path is c:/Files/Textures/Models/Image.jpg.
            // For this we create a list with every possible full path name from
            // the asset name to the root. Image.jpg, Models/Image.jpg,
            // Textures/Models/Image.jpg (bingo) etc.
            List<String> assetNames = new ArrayList<String>();
            String[] paths = name.split("\\/");
            StringBuilder sb = new StringBuilder(paths[paths.length - 1]);// the asset name
            assetNames.add(paths[paths.length - 1]);

            for (int i = paths.length - 2; i >= 0; --i) {
                sb.insert(0, '/');
                sb.insert(0, paths[i]);
                assetNames.add(0, sb.toString());
            }
            // Now try to locate the asset
            for (String assetName : assetNames) {
                try {
                    TextureKey key = new TextureKey(assetName);
                    key.setAsCube(false);
                    key.setFlipY(true);
                    key.setGenerateMips(generateMipmaps);
                    AssetInfo info = assetManager.locateAsset(key);
                    if (info != null) {
                        Texture texture = assetManager.loadTexture(key);
                        result = texture;
                        // Set key explicitly here if other ways fail
                        texture.setKey(key);
                        // If texture is found return it;
                        return result;
                    }
                } catch (AssetNotFoundException e) {
                    LOGGER.fine(e.getLocalizedMessage());
                }
            }
            // The asset was not found in the loop above, call loadTexture with
            // the original path once anyway so that the AssetManager can report
            // the missing asset to subsystems.
            try {
                TextureKey key = new TextureKey(name);
                assetManager.loadTexture(key);
            } catch (AssetNotFoundException e) {
                LOGGER.fine(e.getLocalizedMessage());
            }
        }
View Full Code Here

Examples of com.jme3.asset.AssetManager

  public void internalLoadSceneObject() {
    sceneObject = createSimpleSkyBox();
  }

  private static Spatial createSimpleSkyBox() {
    AssetManager assetManager = GlobalObjectStore
        .<AssetManager> getObject(AssetManager.class);
    Texture west = assetManager.loadTexture("skybox/milkyway/left.png");
    Texture east = assetManager.loadTexture("skybox/milkyway/right.png");
    Texture north = assetManager.loadTexture("skybox/milkyway/front.png");
    Texture south = assetManager.loadTexture("skybox/milkyway/back.png");
    Texture up = assetManager.loadTexture("skybox/milkyway/top.png");
    Texture down = assetManager.loadTexture("skybox/milkyway/bottom.png");

    Spatial skySpatial = SkyFactory.createSky(assetManager, west, east,
        north, south, up, down);

    return skySpatial;
View Full Code Here

Examples of juzu.impl.asset.AssetManager

    //
    if (response instanceof Response.Content) {

      //
      AssetManager assetManager;
      if (assetPlugin != null) {
        assetManager = assetPlugin.getAssetManager();
      } else {
        assetManager = null;
      }
View Full Code Here

Examples of org.jdesktop.wonderland.client.assetmgr.AssetManager

    /**
     * Register the progress listener with the asset manager
     */
    public void register() {
        AssetManager manager = AssetManager.getAssetManager();
        manager.addProgressListener(progressListener);
    }
View Full Code Here

Examples of org.jdesktop.wonderland.client.assetmgr.AssetManager

   
    /**
     * Stop listener for events
     */
    public void deactivate() {
        AssetManager manager = AssetManager.getAssetManager();
        manager.removeProgressListener(progressListener);
    }
View Full Code Here

Examples of org.terasology.asset.AssetManager

        double secs = 0.001 * sw.elapsed(TimeUnit.MILLISECONDS);
        logger.info("Initialization completed in {}sec.", String.format("%.2f", secs));
    }

    private void initAssets() {
        AssetManager assetManager = CoreRegistry.get(AssetManager.class);
        assetManager.setAssetFactory(AssetType.PREFAB, new AssetFactory<PrefabData, Prefab>() {

            @Override
            public Prefab buildAsset(AssetUri uri, PrefabData data) {
                return new PojoPrefab(uri, data);
            }
        });
        assetManager.setAssetFactory(AssetType.SHAPE, new AssetFactory<BlockShapeData, BlockShape>() {

            @Override
            public BlockShape buildAsset(AssetUri uri, BlockShapeData data) {
                return new BlockShapeImpl(uri, data);
            }
        });
        assetManager.setAssetFactory(AssetType.UI_SKIN, new AssetFactory<UISkinData, UISkin>() {
            @Override
            public UISkin buildAsset(AssetUri uri, UISkinData data) {
                return new UISkin(uri, data);
            }
        });
        assetManager.setAssetFactory(AssetType.BEHAVIOR, new AssetFactory<BehaviorTreeData, BehaviorTree>() {
            @Override
            public BehaviorTree buildAsset(AssetUri uri, BehaviorTreeData data) {
                return new BehaviorTree(uri, data);
            }
        });
        assetManager.setAssetFactory(AssetType.UI_ELEMENT, new AssetFactory<UIData, UIElement>() {
            @Override
            public UIElement buildAsset(AssetUri uri, UIData data) {
                return new UIElement(uri, data);
            }
        });
View Full Code Here

Examples of org.terasology.asset.AssetManager

        ReflectFactory reflectFactory = CoreRegistry.putPermanently(ReflectFactory.class, new ReflectionReflectFactory());
        CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.putPermanently(CopyStrategyLibrary.class, new CopyStrategyLibrary(reflectFactory));

        CoreRegistry.putPermanently(TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary));

        AssetManager assetManager = CoreRegistry.putPermanently(AssetManager.class, new AssetManager(moduleManager.getEnvironment()));
        assetManager.setEnvironment(moduleManager.getEnvironment());
        CoreRegistry.putPermanently(CollisionGroupManager.class, new CollisionGroupManager());
        CoreRegistry.putPermanently(WorldGeneratorManager.class, new WorldGeneratorManager());
        CoreRegistry.putPermanently(ComponentSystemManager.class, new ComponentSystemManager());
        CoreRegistry.putPermanently(NetworkSystem.class, new NetworkSystemImpl(time));
        CoreRegistry.putPermanently(Game.class, new Game(this, time));
        assetManager.setEnvironment(moduleManager.getEnvironment());

        AssetType.registerAssetTypes(assetManager);
        ApplyModulesUtil.applyModules();
    }
View Full Code Here

Examples of org.terasology.asset.AssetManager

            } else {
                logger.error("Cannot register CopyStrategy '{}' - unable to determine target type", copyStrategy);
            }
        }

        AssetManager assetManager = CoreRegistry.get(AssetManager.class);
        assetManager.setEnvironment(moduleManager.getEnvironment());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.