Export to GitHub

min3d - issue #40

Load model from SD card


Posted on Apr 7, 2011 by Helpful Cat

hi, thanks for the cool framework, it is awesome! just one question, is that anyway we can load the models from sd card instead of res file itself? cause wanna find the possibility to minimize the apk size when developer provide minor update...

thanks ;)

Comment #1

Posted on Sep 23, 2011 by Swift Hippo

Even i am also trying for that but for some reason its not working for me,

Comment #2

Posted on Sep 30, 2011 by Swift Hippo

hey i have figured out how to load images from sdCard buts its not in an efficient way i will share the code soon

Comment #3

Posted on Oct 8, 2011 by Massive Monkey

you would have to modify the parser class, in order to add constructors accepting assetsManager instead of res.

I tried it, adding a class AssetsParser that extends ObjParser. I would have to add contructors in other two parser as well.

Anyway, I'm not sure this is the correct way to do it but, another source folder is needed if you have to load models dinamically or files > 1M

Comment #4

Posted on Oct 21, 2011 by Swift Hippo

Hey I am able to load obj model with textures from sdcard I am attaching my modified source in this comment I have just created and using one static variable called "sdcard" in Parser classes to switch between loading from asserts and sdcard. and this is how you have to load the 3d model from sdcard

@Override public void initScene() {

    scene.lights().add(new Light());

    Parser.sdcard = true;
    IParser parser;
    if(!Parser.sdcard)
    {
    parser = Parser.createParser(Parser.Type.OBJ,
    getResources(), "com.android.objLoader:raw/model_obj", true);
    }
    else
    {
     parser = Parser.createParser(Parser.Type.OBJ, "/sdcard/model.obj", true);
    }

    parser.parse();
    objModel = parser.getParsedObject();
    //objModel.scale().x = objModel.scale().y = objModel.scale().z = .7f;
    scene.addChild(objModel);
    Parser.sdcard = false;
}
Attachments

Comment #5

Posted on Apr 28, 2012 by Quick Elephant

hi varun

using your code i modified our code but still i am getting problem ..see my code public void initScene() { scene.backgroundColor().setAll(0x00000000); Light light = new Light(); scene.lights().add(light); Parser.sdcard = true;

    IParser parser;
    if(!Parser.sdcard)
    {
         parser = Parser.createParser(Parser.Type.MD2,
         getResources(), "com.adstuck.iar:raw/dolphin", true);
         System.out.println("hi this is resource image....................>");
    }
    else
    {
        parser = Parser.createParser(Parser.Type.MD2, "/sdcard//external_sd/raw/dolphin", true);
        System.out.println("hi this is SD card image....................>");
    }
    parser.parse();

    obj = parser.getParsedAnimationObject();
    obj.scale().x = obj.scale().y = obj.scale().z = .005f;

    obj.rotation().z = -90;
    obj.rotation().x = -90;

    obj.setFps(70);
    obj.position().y = -1.1f;
    obj.position().z = -3;
    obj.play();

Comment #6

Posted on Apr 29, 2012 by Massive Wombat

Hi Ashutosh Kumar,

I have modified the source only for the OBJ model Parser only. if you want to load MD2 type model you need to modify in the MD2Parser.java class

InputStream fileIn = resources.openRawResource(resources.getIdentifier( resourceID, null, null));

replace this line in parse() method of MD2Parser class with this.(for reference you can look at the parse() method in OBJParser class)

if(!Parser.sdcard) { fileIn = resources.openRawResource(resources.getIdentifier( resourceID, null, null)); } else { try { fileIn = new FileInputStream(new File(path)); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }
}

Comment #7

Posted on Dec 11, 2012 by Happy Dog

Hi Varun,

your code is working fine for loading .obj file from sd card.One thing i need to know is that how can we change the texture at run time like change the colour of object etc. I am new to 3d animation in android. Any help regarding this will be appreciated.

thanx Arun Goyal goyal.arun16@gmail.com

Comment #8

Posted on Mar 19, 2013 by Happy Bird

Hi Varun, your code is working fine for loading .obj file from sd card. I need import .3ds file from sdcard can you help me? i try change class: Max3DSParser.java but it's not working.

Comment #9

Posted on Mar 22, 2013 by Happy Bird

Hi, please can you help me? i want import .3ds from sd card, it should change Max3DSParser.java to be worked. thanks for any helps :)

Comment #10

Posted on May 1, 2013 by Massive Bird

Hello your code working for me thanks, one question, how can I put lights in the object in runtime using a menu or whatever you want, the point is that I want to know how to put lights for iluminated the object thank you for advice, and sorry for my bad english

Comment #11

Posted on Jun 14, 2015 by Grumpy Kangaroo

Thanks a lot only remember add the Write and Read SD Permission i spend time searching why throws an error.

Status: New

Labels:
Type-Defect Priority-Medium