Author Topic: 3d library  (Read 2609 times)

Offline mgrabul

  • byte
  • *
  • Posts: 10
    • View Profile
3d library
« on: October 07, 2010, 01:16:13 am »
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:)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3d library
« Reply #1 on: October 07, 2010, 07:47:16 am »
Which errors  ???

Offline mgrabul

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3d library
« Reply #2 on: October 07, 2010, 11:34:26 pm »
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

Offline mgrabul

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3d library
« Reply #3 on: October 08, 2010, 03:00:13 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3d library
« Reply #4 on: October 08, 2010, 08:24:26 pm »
There are several pitfalls when loading objects. First, you are doing this:

Code: [Select]
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

Code: [Select]
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.

Offline mgrabul

  • byte
  • *
  • Posts: 10
    • View Profile
Re: 3d library
« Reply #5 on: October 10, 2010, 03:45:46 am »
There are several pitfalls when loading objects. First, you are doing this:

Code: [Select]
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

Code: [Select]
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: 3d library
« Reply #6 on: October 12, 2010, 08:12:24 pm »
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.