3d library

Started by mgrabul, October 07, 2010, 01:16:13 AM

Previous topic - Next topic

mgrabul

Hi can some one point out a librery whit a 3d models that I can easely use to load 3d models in my application.
I found http://dmi3d.comeze.com/modelsvehicle2.html and I realy like the models but I have trouble importing them in the application. I first installed Blender in order to export the files in a .3ds fromat. After I exported the model in a .3ds format I still had problems ranning the application and I get an error. can someone explane in details the easiest way for adding 3d models to my application. Please:)

EgonOlsen


mgrabul

I am sorry I have no errors, but when I try to add a new 3d object from a the raw folder, the screen becomes black (I am using the code from the demo example). This is my code:

private Object3D jeep=null;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
         TextureManager.getInstance().flush();
         world = new World();
         Resources res = getResources();

         TextureManager tm = TextureManager.getInstance();
                        ................................
                        .....................................
                       jeep=Loader.load3DS(res.openRawResource(R.raw.jipp), 5)[0];
                          jeep.translate(-200, -10, 50);
                        world.addObject(jeep);
}

I try to add a new objec from the file jipp.3ds, I equerd the file from http://dmi3d.comeze.com/modelsvehicle2.html it is a .lwo file so I used Blender to export the file in .3ds
please tell me what am I doing wrong or explane a simpe way to add 3d models in mu application

mgrabul

Quote from: EgonOlsen on October 07, 2010, 07:47:16 AM
Which errors  ???
I am sorry I have no errors, but when I try to add a new 3d object from a the raw folder, the screen becomes black (I am using the code from the demo example). This is my code:

private Object3D jeep=null;
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
         TextureManager.getInstance().flush();
         world = new World();
         Resources res = getResources();

         TextureManager tm = TextureManager.getInstance();
                        ................................
                        .....................................
                       jeep=Loader.load3DS(res.openRawResource(R.raw.jipp), 5)[0];
                          jeep.translate(-200, -10, 50);
                        world.addObject(jeep);
}

I try to add a new objec from the file jipp.3ds, I equerd the file from http://dmi3d.comeze.com/modelsvehicle2.html it is a .lwo file so I used Blender to export the file in .3ds
please tell me what am I doing wrong or explane a simpe way to add 3d models in mu application

EgonOlsen

There are several pitfalls when loading objects. First, you are doing this:


jeep=Loader.load3DS(res.openRawResource(R.raw.jipp), 5)[0];


while i tend to do this myself, it's actually a hack that only works for models that consist of just one part. If that's not given, you'll only add the first part to the world and depending on the model, this can be anything. Try to do


jeep=Object3D.mergeAll(Loader.load3DS(res.openRawResource(R.raw.jipp), 5));


instead.

Second, object space of a model can be anything. Your jeep model might cover coordinates from -10 to 10 or from -100000 to 0 or from -100000 to -99990. Try to play around with the scale of the model to see if that changes something as well as with the models translation. To get a quick grasp of how the model is located in object space, print out the center (Object3D.getCenter()).

Third, make sure that there is light. A black jeep in front of a black background isn't really visible. I tend to choose another color for the background for testing purposes.

mgrabul

Quote from: EgonOlsen on October 08, 2010, 08:24:26 PM
There are several pitfalls when loading objects. First, you are doing this:


jeep=Loader.load3DS(res.openRawResource(R.raw.jipp), 5)[0];


while i tend to do this myself, it's actually a hack that only works for models that consist of just one part. If that's not given, you'll only add the first part to the world and depending on the model, this can be anything. Try to do


jeep=Object3D.mergeAll(Loader.load3DS(res.openRawResource(R.raw.jipp), 5));


instead.

Second, object space of a model can be anything. Your jeep model might cover coordinates from -10 to 10 or from -100000 to 0 or from -100000 to -99990. Try to play around with the scale of the model to see if that changes something as well as with the models translation. To get a quick grasp of how the model is located in object space, print out the center (Object3D.getCenter()).

Third, make sure that there is light. A black jeep in front of a black background isn't really visible. I tend to choose another color for the background for testing purposes.

Thanks for the replay it was very helpful and it solves my problem but the black screen whas probably caused by tthe performance of my phone (g1)  and it still needs time to draw the screen for the first time

EgonOlsen

Make sure to have a look at serialized objects: http://www.jpct.net/wiki/index.php/Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects

It's highly recommended to use them instead of the orginal file formats on Android.