shivbits42 / min3d

Automatically exported from code.google.com/p/min3d
0 stars 0 forks source link

Load model from SD card #40

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 ;) 

Original issue reported on code.google.com by Gnic...@gmail.com on 7 Apr 2011 at 10:44

GoogleCodeExporter commented 8 years ago
Even i am also trying for that but for some reason its not working for me,

Original comment by varun.na...@gmail.com on 23 Sep 2011 at 4:58

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

Original comment by varun.na...@gmail.com on 30 Sep 2011 at 2:18

GoogleCodeExporter commented 8 years ago
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

Original comment by shineangelic on 8 Oct 2011 at 10:59

GoogleCodeExporter commented 8 years ago
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;
    }

Original comment by varun.na...@gmail.com on 21 Oct 2011 at 10:07

Attachments:

GoogleCodeExporter commented 8 years ago
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();

Original comment by ashun...@gmail.com on 28 Apr 2012 at 11:13

GoogleCodeExporter commented 8 years ago
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();
        }   
        }

Original comment by varun.na...@paradigmcreatives.com on 29 Apr 2012 at 5:03

GoogleCodeExporter commented 8 years ago
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

Original comment by goyal.ar...@gmail.com on 11 Dec 2012 at 7:00

GoogleCodeExporter commented 8 years ago
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.  

Original comment by ramysco...@gmail.com on 19 Mar 2013 at 12:19

GoogleCodeExporter commented 8 years ago
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 :)

Original comment by ramysco...@gmail.com on 22 Mar 2013 at 6:12

GoogleCodeExporter commented 8 years ago
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

Original comment by Armando....@gmail.com on 1 May 2013 at 6:06

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

Original comment by luis.fu...@gmail.com on 14 Jun 2015 at 2:07