package org.pollux3d.system;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.app.Application;
import com.jme3.asset.AssetManager;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystem;
import com.jme3.system.SystemListener;
public class OneTimeRender implements SystemListener{
private static final Logger logger = Logger.getLogger("OneTimeRender");
private AppSettings settings;
private JmeContext context;
private AssetManager assetManager;
/**
* @param args
*/
public static void main(String[] args) {
OneTimeRender test = new OneTimeRender();
test.start();
logger.log(Level.SEVERE, "passed start");
}
/**
* Starts the application. Creating a display and running the main loop.
*/
public void start(){
if (settings == null){
settings = new AppSettings(true);
}
context = JmeSystem.newContext(settings, JmeContext.Type.OffscreenSurface);
context.setSystemListener(this);
context.create(false);
}
private void initAssetManager(){
if (settings != null){
String assetCfg = settings.getString("AssetConfigURL");
if (assetCfg != null){
URL url = null;
try {
url = new URL(assetCfg);
} catch (MalformedURLException ex) {
}
if (url == null) {
url = Application.class.getResource(assetCfg);
if (url == null) {
logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
return;
}
}
assetManager = JmeSystem.newAssetManager(url);
}
}
if (assetManager == null){
assetManager = JmeSystem.newAssetManager(
Thread.currentThread().getContextClassLoader()
.getResource("com/jme3/asset/Desktop.cfg"));
}
}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void gainFocus() {
// TODO Auto-generated method stub
}
@Override
public void handleError(String errorMsg, Throwable t) {
// TODO Auto-generated method stub
}
@Override
public void initialize() {
initAssetManager();
}
@Override
public void loseFocus() {
// TODO Auto-generated method stub
}
@Override
public void requestClose(boolean esc) {
// TODO Auto-generated method stub
}
@Override
public void reshape(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void update() {
// TODO Auto-generated method stub
}
}