Box2D Forums

It is currently Sat May 25, 2013 12:26 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: Box2D Nintendo DS
PostPosted: Wed Oct 01, 2008 3:03 am 
Offline

Joined: Tue May 06, 2008 3:05 am
Posts: 15
Hi Every1,

I have devprokit and palib working fine. I want to add Box2d into the mix. I have downloaded box2d. What do I do now? where do I put the files? how do I use it in my projects? any help would be great!


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Wed Oct 15, 2008 12:30 pm 
Offline

Joined: Wed Oct 15, 2008 12:15 pm
Posts: 4
I have a problem with compiling and linking box2D for the DS platform.

I downloaded the latest SVN Box2D release (rev.175) and tried compiling it very straight-forwardly : open the .sln in VS2005, add TARGET_IS_NDS,TARGET_FLOAT32_IS_FIXED and ARM9 to the precompiler definitions and fire it up. Doing this, I get a hugely huge bunch of errors (>2500), most of them repeating themselves multiple times, the first one being : "packed, undeclared identifier". From then on I've tried all sorts of logical to less-logical solutions, most of which I don't remember since I was frantically trying stuff.

So my question is : Using the latest revision of Box2D (or r175, whichever is true at the time of your reading), and a current revision(r23b) of DevKitPro/DevKitARM and libnds, how do I compile Box2D so it works well on the DS using fixed point numbers?

Ultimately, I just want to use Box2D in a project that is well under way, I can't really code a physics engine in the time left for the project, and Box2D is already well implemented in the project. In fact I realised yesterday that the version of Box2D I was using was compiled without the NDS & Fixed options, and therefore would not work well / efficiently on the DS.

Thanks,
Hoping for a solution,
Chlikaflok

P.S. For those who are curious about the project, it's a High-Level game engine for homebrew DS games that should be released as RaNGE some time near christmas this year(2008).

Edit : Of course I forgot to mention that when I build my project without the library compiled it says "undeclared reference to b2World::CreateBody(b2BodyDef const*)" and says so for any and all references I made to any Box2D function until the compiler stops for obvious reasons... Not that this point makes much sense for the problem, but it might head people looking for these symptoms towards the solution, which'll be here shortly I do hope... ;)


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Oct 16, 2008 11:55 am 
Offline

Joined: Wed Oct 24, 2007 12:14 pm
Posts: 38
I didn't watch Box2D for quite some time, so I can't really tell what is the problem.
I've seen the fixed point patch made it into official release, but I'm not quite sure if there is also something for DS support. So your best bet is IMO to use an older release patched by 0xtob to make it work on DS. It is also the version I started porting to Symbian. You can get it from here: http://tobw.net/ds/box2d_svn_r80_fixed.tgz

Even if you need to use the latest version of Box2D, it can at least help you identify your problems. If you can't compile this version, either, then look for the problem in some other part of your program.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Oct 16, 2008 12:54 pm 
Offline

Joined: Wed Oct 15, 2008 12:15 pm
Posts: 4
Ok, so just so I don't make another stupid mistake... All I have to do is checkout r80 of the Box2D SVN and apply the SVN Patch you linked, and that should be it...

I'll try it within the next few minutes and edit this post to confirm/ask for more precision.

Cheers,
Chlikaflok

Edit : It does seem to work, all that's left is that I get "error C2666: 'Fixed::operator *' : 12 overloads have similar conversions" 12 times, all in b2World.cpp. I'll try to work this out by casting the types into what should logically be there, and report back.

Edit2 : After researching and making sure that casting values into bigger values (here casting unsigned short to int) didn't change the value, I cast my problems away (haha nice pun ;)) so here is the correction for the problem I had (I'm writing it here for posterity):

I had 12 errors each on a line looking roughly like this (give or take an x for a y or stuff like that)

Code:
b.minVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * bp->m_bounds[0][p->lowerBounds[0]].value;

Adding a static_cast<int> did the job for setting the compiler's mind.
The result :
Code:
b.minVertex.x = bp->m_worldAABB.minVertex.x + invQ.x * static_cast<int>(bp->m_bounds[0][p->lowerBounds[0]].value);

I know I could have used (int)blablabla, but it seemed cleaner using the old-fashioned static_cast<int>.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Fri Oct 17, 2008 6:53 pm 
Offline

Joined: Wed Oct 15, 2008 12:15 pm
Posts: 4
In the end, here's how I solved it :

I was able to compile the library as a .lib in VC2005, but I couldn't get g++ (DS Compiler) to acknowledge box2d.lib as a valid library, therefore I got lots of linking errors with undefined references and such. When I found out that this was the problem, the solution presented itself : If I could compile the files but couldn't link the library, why not simply include all the Box2D files in my project, which I did. And after correcting a few incompatibilities between VC2005 and g++, my project compiled wonderfully well ^^. I hope this helps people who have similar problems solve them.

Cheers (I'm saved! Never would have had the time to build another physics engine from the ground up...)
Chlikaflok!


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Tue Nov 04, 2008 4:59 pm 
Offline

Joined: Tue Nov 04, 2008 4:38 pm
Posts: 1
I can't get the Nintendo DS port to work. The library compiles just fine and my game correctly links with the library, but when I try to run the game, even with just the following simple code (taken from the HelloWorld example), the game crashes as soon as I add the line "b2World world(worldAABB, gravity, doSleep)". I tried with both the float and fixed version using both the official 2.0.1 release and the latest SVN code.

Code:
   b2AABB worldAABB;
   worldAABB.lowerBound.Set(-100.0f, -100.0f);
   worldAABB.upperBound.Set(100.0f, 100.0f);
   b2Vec2 gravity(0.0f, -10.0f);
   bool doSleep = true;

   //Game crashes when the following line is added
   b2World world(worldAABB, gravity, doSleep);


I have no idea what the problem is, since the library compiles and links OK. Any ideas?


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Wed Nov 05, 2008 6:26 am 
Offline

Joined: Wed Oct 15, 2008 12:15 pm
Posts: 4
A simple check first :

Did you add the TARGET_FLOAT32_IS_FIXED and TARGET_IS_NDS preprocessor definition? They are necessary to actually compile Box2D into NDS-compatible code.

If you did, then tell me how since I couldn't ever compile Box2D 2.0+ with the NDS definitions. If you didn't, then try it with the 2.0+ version you have. And if it still doesn't work, try the 1.4.3 version @revision 80 of the SVN repository, and apply the patch given earlier in this topic. It should compile fine, at least it does for me...

I haven't finished my project yet, but I have successfully created my world, and added a few bodies/shapes, so I guess if you follow my trail of messages in this topic you should be able to get to whatever point I am at the moment.

I don't know how much more help I can be at the moment, but don't hesitate to ask more questions.

Cheers and good luck,
Chlikaflok

P.S. I had a little problem last week in my project, namely the fact that whenever I instantiated a certain shape, it would crash. The simple answer was : "don't give circle shapes a radius of 65 meters". The complete answer is : from what I've found in the Box2D code, the mass of a circle shape within a body is at least radius^4, and the inertia even more than that. Working with such big numbers is too heavy on the DS CPU, I guess, and the computations probably make numbers that fall outside of the limits of int32, or whatever the basic number type is in Box2D. I'm just writing it here so people don't make my mistake ^^.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Wed Nov 05, 2008 12:54 pm 
Offline

Joined: Wed Jan 02, 2008 3:19 am
Posts: 67
The last versions that I compiled and got to work was devkitPro version 21 with box2d SVN rev 130. I tried box2d rev 175 but the API changed from 130 to 175 so I'm waiting until I have more time to upgrade my code. I hear there is new version of devkitPro too, which might be the problem you are seeing, again I haven't had time to upgrade my devkitPro.

For the fixed point version you should keep well away from the limits of +-32767 for coordinates and 179 for velocities. Other values such as force and mass are also constrained but in a more complex way. Generally if you overflow the dimensions then you might get an assert. If you overflow a dynamic value then you will see sudden discontinuities in velocity (i.e. explosions).

EDIT: I tried rev 175 and it works for me. Still using devkitPro version 21.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Tue Jan 27, 2009 5:18 am 
Offline

Joined: Tue Jan 27, 2009 4:38 am
Posts: 3
Revision 190 compiles fine with current devkitpro toolchain, after applying some changes (due to libNDS having renamed some things).

However, running the hello world example, I do also get a crashing rom when creating a b2world.

*EDIT*:
Using devkitpro r23b works just fine, while r24 crashes. Going into deeper investigations.

PS: putting Box2D into a namespace would resolve this ugly issue of having to comment out the float32 typedef in nds.h


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Tue Jan 27, 2009 7:03 am 
Offline

Joined: Sun Jan 04, 2009 11:03 am
Posts: 48
Methedrine wrote:
Revision 190 compiles fine with current devkitpro toolchain, after applying some changes (due to libNDS having renamed some things).

However, running the hello world example, I do also get a crashing rom when creating a b2world.

*EDIT*:
Using devkitpro r23b works just fine, while r24 crashes. Going into deeper investigations.

PS: putting Box2D into a namespace would resolve this ugly issue of having to comment out the float32 typedef in nds.h


Can't you just wrap the include in a namespace?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group