I have a problem with Xith3D toolkit, the 3DS loader part.
I want to load a model created with Wings3D and with a BMP or JPG texture ( they both won't load ).
My texture is created with the Gimp.
I launch my test program with the following command, under Linux :
java -classpath../libs/xith3d.jar:./xith-3ds.jar:./ TDSTest2
Here is the program output :
`Available 0: GLCapabilities[DoubleBuffered: true, Stereo: false, HardwareAccelerated: true,DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0,Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 132
Available 1: GLCapabilities[DoubleBuffered: true, Stereo: false, HardwareAccelerated: true,DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0,Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 132
[…]
Available 23: GLCapabilities[DoubleBuffered: false, Stereo: false, HardwareAccelerated: true,DepthBits: 0, StencilBits: 0, Red: 8, Green: 8, Blue: 8, Alpha: 8, RedAccum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 1944
Chosen index: 0
Chosen capabilities:
GLCapabilities [DoubleBuffered:true, Stereo: false, HardwareAccelerated: true, DepthBits: 24,StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0, Red Accum: 16,Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS: false 0
Load took: 0.073 seconds
Init GL isnet.java.games.jogl.impl.x11.X11GLImpl
OpenGL Renderer = GeForce2MX/AGP/SSE/3DNOW!
OpenGL Version = 1.5.1 NVIDIA61.06
OpenGL Vendor = NVIDIA Corporation
OpenGL Extensions =GL_ARB_imaging GL_ARB_multitexture GL_ARB_point_parameters
[…]
GL_SUN_slice_accum`
After that, i have a black window on my Linux desktop with nothingdisplayed on it.
I tried the same model without textures : it's all right.
The texture is in the right directory and the program find it,otherwise it would display the message "texture not found".
Here’s the source code ( nothing very interesting ) :
import com.xith3d.scenegraph.VirtualUniverse;
import com.xith3d.scenegraph.View;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.DirectionalLight;
import com.xith3d.scenegraph.AmbientLight;
import com.xith3d.scenegraph.TransformGroup;
import com.xith3d.scenegraph.Transform3D;
import com.xith3d.render.RenderOptions;
import com.xith3d.render.Option;
import com.xith3d.render.CanvasPeer;
import com.xith3d.render.RenderPeer;
import com.xith3d.render.jogl.RenderPeerImpl;
import javax.vecmath.Vector3f;
import javax.vecmath.Color3f;
import java.util.ArrayList;
import org.newdawn.xith3d.threeds.TDSLoader;
import org.newdawn.xith3d.threeds.model.TDSModel;
/**
* A test for OBJ files
*
* @author Kevin Glass
*/
public class TDSTest2 implements Runnable {
private View view;
private double lightAngle;
private double modelAngle;
private float anim = 0.0f;
private DirectionalLight light;
private TransformGroup tg = new TransformGroup();
private TDSModel model;
public TDSTest2() {
VirtualUniverse universe = new VirtualUniverse();
view = new View();
view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
universe.addView(view);
Locale locale = new Locale();
universe.addLocale(locale);
view.setBackClipDistance(500.0f);
// setup view
view.getTransform().lookAt(
new Vector3f( 20, 10, 0), // location of eye (cubes)
new Vector3f( 0, 10, 0), // center of view (cubes)
new Vector3f( 0, 1, 0)); // vector pointing up
RenderPeer rp = new RenderPeerImpl();
CanvasPeer cp = rp.makeCanvas(null, 800, 600, 32, false);
Canvas3D canvas = new Canvas3D();
canvas.set3DPeer(cp);
view.addCanvas3D(canvas);
RenderOptions options = new RenderOptions();
options.setOption(Option.USE_SHADOWS,true);
options.setOption(Option.USE_LIGHTING,true);
cp.setRenderOptions(options);
BranchGroup root = new BranchGroup();
locale.addBranchGraph(root);
Color3f ambientColor = new Color3f(0.5f, 0.5f, 0.5f);
AmbientLight ambientLightNode = new AmbientLight(ambientColor);
root.addChild(ambientLightNode);
light = new DirectionalLight(true,new Color3f(1f,1f,1f),new Vector3f(0,0,1));
root.addChild(light);
TDSLoader.setDebug(false);
try {
long start = System.currentTimeMillis();
//model = new TDSLoader().load("model/character.3ds",true);
//model = new TDSLoader().load("model/cube_set/cube_rotation.3ds");
//model = new TDSLoader().load("model/jeep/jeep1.3ds",true);
//model = new TDSLoader().load("angel/angel.3ds",true);
//model = new TDSLoader().load("angel/chalice.3ds",true);
//model.setShowBounds(true,true);
model = new TDSLoader().load("model/WA/William.3ds",true);
//tg.addChild(model);
//model = new TDSLoader().load("model_set/redbox_max.3DS",true);
//model = new TDSLoader().load("jeep2/jeep.3ds",true);
//model = new TDSLoader().load("jeep2/scale.3ds",true);
//model = new TDSLoader().load("others/Tube.3ds",true);
//model = new TDSLoader().load("samples/Kugel.3ds",true);
//model = new TDSLoader().load("samples/building09.3ds",true);
//model = new TDSLoader().load("scaleanim/output.3ds",true);
System.out.println("Load took: "+((System.currentTimeMillis() - start) / 1000.0)+" seconds");
tg.addChild(model);
//model.setShowBounds(true,true);
root.addChild(tg);
} catch (Exception e) {
e.printStackTrace();
}
new Thread(this).start();
}
public void run() {
int count = 0;
while (true) {
try { Thread.sleep(10); } catch (Exception e) {};
view.renderOnce();
lightAngle -= 0.01;
Vector3f dir = new Vector3f((float) -Math.cos(lightAngle),0,(float) Math.sin(lightAngle));
//light.setDirection(dir);
modelAngle += 0.01;
Transform3D yrot = new Transform3D();
yrot.rotY((float) modelAngle);
Transform3D xrot = new Transform3D();
//xrot.rotX((float) modelAngle);
//xrot.rotX((float) -Math.PI/2);
yrot.mul(xrot);
tg.setTransform(yrot);
/*anim += 0.005f;
if (anim > 1) {
anim = 0;
}
model.setTime(anim);*/
count++;
}
}
public static void main(String argv[]) {
new TDSTest2();
}
}