Ok I tried the createDummyObj(). added all the bits of the array to it.
Sounds like you have this part correct. You call the dummy-object's addChild() method to add each of the objects in the array as children of the dummy-object.
built each part though I don't think I need too.
Yes, you need to build each object in the array returned by the Loader class.
added the dummy to th world.
You do not need to add the dummy object to the world, since there is nothing to see, although it won't hurt anything if you do add it to the world.
and I don't see any form of it.
The child Object3Ds (the ones in the array returned by the Loader) must be built and added to the world. The dummy object is what you will use to move, rotate, and scale the model as a whole, but first all the Object3D parts of the model must be added to the world individually before you will be able to see them.
--EDIT--
Oh, one more thing - this describes the second method I mentioned for loading a 3DS object (the "children of a dummy-object" method). If instead you were trying to use the other method (using Object3D.mergeObjects()), then you should have seen something when you added the root Object3D to the world. In that case, a code snippet would be helpful to track down the problem, as Egon mentioned.
I use various versions of the following methods in all of my projects to make loading 3ds models easy. You will notice that I have an additional step where I rotate the loaded objects. This is to compensate for the fact that all 3ds files exported by Autodesk 3ds Max are oriented incorrectly when loaded into jPCT. If you are not using Autodesk 3ds Max, you might not need that part, but at least you might find this code useful to use for reference:
public class EasyLoader
{
// Load a 3ds file, and return an array of Object3D parts
public static Object3D[] load3DS( String filename, float scale )
{
Object3D[] objs = Loader.load3DS(
Utils.class.getClassLoader().getResourceAsStream(
filename ), scale );
if( objs.length < 1 )
{
System.out.println( "Unknown file format: " + filename );
}
// 3ds files always load wrong, so correct the orientation:
for( int x = 0; x < objs.length; x++ )
{
objs[x].rotateX( (float) Math.PI / 2 );
objs[x].rotateY( (float) Math.PI );
objs[x].rotateZ( (float) Math.PI );
objs[x].rotateMesh();
objs[x].setRotationMatrix( new Matrix() );
}
return objs;
}
// Load a multi-object 3ds file, merge all parts, and return a single Object3D:
public static Object3D loadMerged3DS( String filename, float scale )
{
Object3D newObject = new Object3D(0);
Object3D[] objs = Loader.load3DS(
Utils.class.getClassLoader().getResourceAsStream(
filename ), scale );
if( objs.length < 1 )
{
System.out.println( "Unknown file format: " + filename );
}
for( int x = 0; x < objs.length; x++ )
{
Object3D part = objs[x];
part.setCenter( new SimpleVector( 0, 0, 0 ) );
newObject = Object3D.mergeObjects( newObject, part );
}
// 3ds files always load wrong, so correct the orientation:
newObject.rotateX( (float) Math.PI / 2 );
newObject.rotateY( (float) Math.PI );
newObject.rotateZ( (float) Math.PI );
newObject.rotateMesh();
newObject.setRotationMatrix( new Matrix() );
return newObject;
}
// Load an md2 file
public static Object3D loadMD2( String filename, float scale )
{
Object3D newObject = new Object3D(0);
newObject = Loader.loadMD2(
Utils.class.getClassLoader().getResourceAsStream(
filename ), scale );
// md2 files always load wrong, so correct the orientation:
newObject.rotateY( (float) Math.PI / 2 );
newObject.rotateMesh();
newObject.setRotationMatrix( new Matrix() );
return newObject;
}
// create and return a pivot with the array of objects as children:
public static Object3D assimilate( Object3D[] objs )
{
if( objs == null || objs.length < 1 )
return null;
Object3D pivot = Object3D.createDummyObj();
pivot.setCenter( new SimpleVector( 0, 0, 0 ) );
for( int x = 0; x < objs.length; x++ )
{
pivot.addChild( objs[x] );
}
return pivot;
}
// add the array of Object3D's to the world:
public static void addObjects( Object3D[] objs, World world )
{
if( world == null || objs == null )
return;
for( int x = 0; x < objs.length; x++ )
{
world.addObject( objs[x] );
}
}
// remove the array of Object3D's to the world:
public static void removeObjects( Object3D[] objs, World world )
{
if( world == null || objs == null )
return;
for( int x = 0; x < objs.length; x++ )
{
world.removeObject( objs[x] );
}
}
// Build all Object3Ds in the array:
public static void build( Object3D[] objs )
{
if( objs == null || objs.length < 1 )
return;
for( int x = 0; x < objs.length; x++ )
if( objs[x] != null )
objs[x].build();
}
}
You would use the EasyLoader class to load a 3ds file like this:
Object3D[] modelParts = EasyLoader.load3DS( "myModel.3ds" );
EasyLoader.build( modelParts );
EasyLoader.addObjects( modelParts, myWorld );
Object3D myModel = EasyLoader.assimilate( modelParts );
Then you could use the varriable "myModel" to manipulate your model (scale, rotate, translate, etc).
When you are ready to remove your model from the world, you would simply call:
EasyLoader.removeObjects( modelParts, myWorld );