Sign in to follow this  
flyjason

Get a good 3ds loader

Recommended Posts

Hello, I need help please. Can anybody provide me a good 3ds loader made in C or any particular link. I've got quite a lot on the web (most in C++) but they are not that good...when I load a ".3ds" file, there is no colour at all - so you understand. I need it specifically in C because I'm going to integrate it with ARToolKit afterwards which is also in C language. More info on ARToolKit @ http://www.hitl.washington.edu/artoolkit/. Thanks.

Share this post


Link to post
Share on other sites
I don't know a pure C loader, but if you only need basic features (i.e. geometry, textures and surfaces) you can easily write one yourself or translate a c++ one in C.

Share this post


Link to post
Share on other sites
@ ViLiO

Thank you very much ViLiO.

I just downloaded it. I guess you had use that before.

I have been able to compile and build player.c...fine. I use MS Visual C++.

But unfortunately when I execute it, I get the following error:

***ERROR*** No 3DS file specified
Press any key to continue_

So I figure out that somewhere in the code I am expected to provide a ".3DS" filename.

I saw the line "static const char* filename=0;" in file 3ds2rib.c.

So I tried to change it to "static const char* filename="grenade.3DS";". I don't know if it's the right thing to do?? In fact grenade.3DS is a 3DS file that I've added to the folder "msvc".

Now when I execute player.c again, I get the same error as above.

Can you help me please?? Is it the right way in executing player.c or should I execute another file instead.

Thanks.

Share this post


Link to post
Share on other sites
I have never used lib3ds before and hope I never have to (3ds is a horrible format in my opinion) [smile]

As for your problem with not specifying a 3ds file when executing player. If you have a look at the main method in player.c, you will see that it takes the filename as an argument. So when running player from the commandline, you could do something like "player.exe grenade.3DS" assuming your 3ds file is in the same folder as the executable.

I would also advise you remove any changes you just made to the library itself as it kind of defeats the purpose of using a library if you are going to hack through it and change bits. player.c is an example program of using lib3ds so only make changes to it until you are ready to write your own equivalent inside your own codebase.

Regards,
ViLiO

Share this post


Link to post
Share on other sites
@ ViLiO

I did as you've said but now another error pops out...

***ERROR*** No camera found.

:(

What to do next?

P.S: Running from the command line...are you meaning that I cannot run it from MSVC++ itself??

Share this post


Link to post
Share on other sites
Come on dude, you put absolutely zero effort into debugging that yourself [rolleyes]

Do a search through player.c for that error message and you will see it is thrown inside the init method when the 3ds file contains no camera data. I stress again that player.c is just an example and you may or may not want to use the camera information stored inside the 3ds for your own app, but player.c wants it.

So when you exported your grenade from max (or some other modelling application) you didn't export a camera too and that makes player.c sad as it has no idea where to look. So you can either add a camera to your grenade scene in max (or whatever) and export it to 3ds again but this time making sure you also export that camera information too, or you can have a hack at player.c and hard-code the camera information into the app so when rendering, it can tell OpenGL where to look.

Regards,
ViLiO

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this