Java Code Examples for com.jme3.scene.Spatial#setKey()

The following examples show how to use com.jme3.scene.Spatial#setKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SceneLoader.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void parseEntity(Attributes attribs) throws SAXException {
     String name = attribs.getValue("name");
     if (name == null) {
         name = "OgreEntity-" + (++nodeIdx);
     } else {
         name += "-entity";
     }

     String meshFile = attribs.getValue("meshFile");
     if (meshFile == null) {
         throw new SAXException("Required attribute 'meshFile' missing for 'entity' node");
     }

     // TODO: Not currently used
     String materialName = attribs.getValue("materialName");

     if (folderName != null) {
         meshFile = folderName + meshFile;
     }

     // NOTE: append "xml" since its assumed mesh files are binary in dotScene
     meshFile += ".xml";

     entityNode = new com.jme3.scene.Node(name);
     OgreMeshKey meshKey = new OgreMeshKey(meshFile, materialList);
     try {
try{
	Spatial ogreMesh=(Spatial)meshLoader.load(assetManager.locateAsset(meshKey));
	entityNode.attachChild(ogreMesh);
}catch(IOException e){
	throw new AssetNotFoundException(meshKey.toString());
}
     } catch (AssetNotFoundException ex) {
         if (ex.getMessage().equals(meshFile)) {
             logger.log(Level.WARNING, "Cannot locate {0} for scene {1}", new Object[]{meshKey, key});
             // Attach placeholder asset.
             Spatial model = PlaceholderAssets.getPlaceholderModel(assetManager);
             model.setKey(key);
             entityNode.attachChild(model);
         } else {
             throw ex;
         }
     }

     node.attachChild(entityNode);
     node = null;
 }
 
Example 2
Source File: SceneLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void parseEntity(Attributes attribs) throws SAXException {
    String name = attribs.getValue("name");
    if (name == null) {
        name = "OgreEntity-" + (++nodeIdx);
    } else {
        name += "-entity";
    }

    String meshFile = attribs.getValue("meshFile");
    if (meshFile == null) {
        throw new SAXException("Required attribute 'meshFile' missing for 'entity' node");
    }

    // TODO: Not currently used
    String materialName = attribs.getValue("materialName");

    if (folderName != null) {
        meshFile = folderName + meshFile;
    }

    // NOTE: append "xml" since its assumed mesh files are binary in dotScene
    meshFile += ".xml";

    entityNode = new com.jme3.scene.Node(name);
    OgreMeshKey meshKey = new OgreMeshKey(meshFile, materialList);
    try {
        Spatial ogreMesh = assetManager.loadModel(meshKey);
        entityNode.attachChild(ogreMesh);
    } catch (AssetNotFoundException ex) {
        if (ex.getMessage().equals(meshFile)) {
            logger.log(Level.WARNING, "Cannot locate {0} for scene {1}", new Object[]{meshKey, key});
            // Attach placeholder asset.
            Spatial model = PlaceholderAssets.getPlaceholderModel(assetManager);
            model.setKey(key);
            entityNode.attachChild(model);
        } else {
            throw ex;
        }
    }

    node.attachChild(entityNode);
    node = null;
}