hello
I used ModelLoader.java for converting from a .obj file to a .jme file
this is the code I'm using to let it show, probably I'm forgetting more then one thing :roll:
I just get a black screen and thats it , no errors except this one and the file path is valid I think, as you can see in my code I do a printout and it seems right
INFO: Node created.
8-mei-2008 15:22:31 com.jme.scene.Node attachChild
INFO: Child (obj file) attached to this node (null)
package be.khleuven.dhondtjim;
import com.jme.app.*;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.system.DisplaySystem;
import com.jme.util.*;
import com.jmex.game.*;
import com.jmex.game.state.*;
import com.jmex.editors.swing.settings.*;
import com.jmex.physics.*;
import com.jmex.physics.util.states.*;
import com.jmex.physics.impl.ode.OdePhysicsSpace;
import java.util.concurrent.*;
public class StartRaceGame extends Node {
StandardGame game;
public StartRaceGame() {
game = new StandardGame("VGO racing");
game.getSettings().setStencilBits(8);
try {
GameSettingsPanel.prompt(game.getSettings());
} catch (Exception e) {
System.exit(-1);
}
game.start();
}
public static void main(String[] args) {
Util util=new Util();
util.loadModel("SpeedyCar.jme");
new StartRaceGame();
}
}
this is the code for my util class
/*
* Copyright (c) 2005-2007 jME Physics 2
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jME Physics 2' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package be.khleuven.dhondtjim;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import com.jme.bounding.BoundingBox;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.util.export.binary.BinaryImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
/**
* Helper class for loading models and other stuff. Currently only loads JME
* binary models, but it's easily customizable for loading other types.
*
* @author Erick B Passos
*/
public class Util {
// So JME can find the model textures easily.
private static URL resourceSearchPath;
static {
resourceSearchPath = Util.class.getResource( "/be/khleuven/dhondtjim/SpeedyCar/" );
System.out.println(resourceSearchPath);
try {
ResourceLocatorTool.addResourceLocator( ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator( resourceSearchPath ) );
} catch ( URISyntaxException e1 ) {
e1.printStackTrace();
}
}
/**
* Loads a jme binary model from file, creating a bounding box for it.
*
* @param path to jme file
* @return loaded model, null on error
*/
public static Node loadModel( String path ) {
try {
URL modelURL = new URL( resourceSearchPath, path );
BufferedInputStream stream = new BufferedInputStream( modelURL.openStream() );
Node node = new Node();
node.attachChild( (Spatial) BinaryImporter.getInstance().load( stream ) );
node.setModelBound( new BoundingBox() );
node.updateModelBound();
return node;
} catch ( IOException e ) {
e.printStackTrace();
return null;
}
}
/**
* Helper method to apply a ZBufferState to a node.
*
* @param node where to apply to
*/
public static void applyZBuffer( Node node ) {
ZBufferState zbuf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
zbuf.setWritable( false );
zbuf.setEnabled( true );
zbuf.setFunction( ZBufferState.CF_LEQUAL );
node.setRenderState(zbuf);
}
}
anyone can help me with this?
also have another problem, when I use the hellomodelloading class I can display the .obj file but not move it with my mouse to for example see the back of my 3D model :?
thanks in advance