Box2D Forums

It is currently Sat May 25, 2013 8:12 am

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 Mar 05, 2008 2:04 pm 
Offline

Joined: Wed Mar 05, 2008 1:55 pm
Posts: 2
Hello

I'm very interesting by your project, so I decided to try it on my NDS.

I already made some little games on it, using DevkitPro. I also use a high-level library you may know, PALib (http://www.palib.info/).

So I tried to mix PALib and Box2D for NDS.
Including PALib makes no problem, it compiles and works fine.
But when I include Box2D.h, with all Box2D source code in a "Source" directory to match with the .h declarations, and launch compiles, it makes a lot of errors and stop.

How can you link / use with library ? I think there's a compilator option I missed somewhere...

Thanks for your help (and sorry for my approximative english...)

EDIT : Here's the errors during the compilation :
Code:
In file included from d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b
2Shape.h:22,
                 from d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b
2CircleShape.h:22,
                 from d:/NDS/Box2d_DS/include/Box2D.h:36,
                 from d:/NDS/Box2d_DS/source/main.cpp:3:
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:4
6: warning: ignoring #pragma warning
d:/NDS/Box2d_DS/include/../Box2D/Source/Common/b2Settings.h:50: error: conflicti
ng declaration 'typedef class Fixed float32'
d:/devkitPro/libnds/include/nds/jtypes.h:114: error: 'float32' has a previous de
claration as 'typedef float float32'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:
In member function 'float32 b2Vec2::Length() const':
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:1
23: error: request for member 'sqrt' in '((((float)((const b2Vec2*)this)->b2Vec2
::x) * ((float)((const b2Vec2*)this)->b2Vec2::x)) + (((float)((const b2Vec2*)thi
s)->b2Vec2::y) * ((float)((const b2Vec2*)this)->b2Vec2::y)))', which is of non-c
lass type 'float'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:
In member function 'b2Mat22 b2Mat22::Invert() const':
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
49: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
49: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
50: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
50: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
55: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
55: error: invalid operands of types 'float' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
56: error: invalid operands of types 'float' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
56: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
64: error: invalid operands of types 'float32' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
64: error: invalid operands of types 'float' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
65: error: invalid operands of types 'float' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
65: error: invalid operands of types 'float32' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:
In member function 'b2Vec2 b2Mat22::Solve(const b2Vec2&) const':
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
88: error: invalid operands of types 'const float32' and 'int' to binary 'operat
or<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
88: error: invalid operands of types 'const float32' and 'int' to binary 'operat
or<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
89: error: invalid operands of types 'const float32' and 'int' to binary 'operat
or<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
89: error: invalid operands of types 'const float32' and 'int' to binary 'operat
or<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
94: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:2
95: error: invalid operands of types 'float32' and 'int' to binary 'operator<<'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:3
03: error: invalid operands of types 'float32' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/../../Common/b2Math.h:3
04: error: invalid operands of types 'float32' and 'int' to binary 'operator>>'
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b2Shape.h: In member fu
nction 'virtual float32 b2Shape::ComputeSubmergedArea(const b2XForm&, const b2Ve
c2&, float32) const':
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b2Shape.h:180: warning:
 statement has no effect
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b2Shape.h:180: warning:
 statement has no effect
d:/NDS/Box2d_DS/include/../Box2D/Source/Collision/Shapes/b2Shape.h:180: warning:
 statement has no effect
d:/NDS/Box2d_DS/include/../Box2D/Source/Dynamics/b2Body.h: At global scope:
d:/NDS/Box2d_DS/include/../Box2D/Source/Dynamics/b2Body.h:437: warning: 'void b2
Body::WakeUp()' was used before it was declared inline
d:/NDS/Box2d_DS/include/../Box2D/Source/Dynamics/b2Body.h:226: warning: previous
 non-inline declaration here
make[1]: *** [main.o] Error 1
make: *** [build] Error 2


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Wed Mar 05, 2008 2:25 pm 
Offline

Joined: Thu Dec 06, 2007 7:36 am
Posts: 13
Oh yes, libnds (and paLib) has a float32 typedef that conflicts with the one in Box2D. For now, you need to comment it out in the libnds headers (i.e. in jtypes.h). I hope we'll find a cleaner solution for this.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Mar 06, 2008 3:58 am 
Offline

Joined: Wed Mar 05, 2008 1:55 pm
Posts: 2
Thank you, I going to test that as soon as I can.

How many sprites / elements do you think Box2D for DS can handle at a time without being too slow ?
I tested pocketphysix yesterday, and with about 20elements it was a mess : elements suddlenly disappear / explode...

But I think this is due to the hardware.
Anyway it's a great work :o


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Mar 06, 2008 7:02 am 
Offline

Joined: Thu Dec 06, 2007 7:36 am
Posts: 13
I've made some great speed improvements to the fixed point port (mainly inlining fixed point operators and using special DS div/sqrt hardware). With this version I can have about 40 circle objects at playable speed. There are still some glitches in the physics, but as soon as these are resolved I'll release the new version. The "explosion" bug has been fixed as well. This was a problem with DS interrupts and the usage of the DS div/sqrt hardware, not a box2d/fixed point issue.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Mar 06, 2008 8:53 am 
Offline

Joined: Wed Oct 24, 2007 12:14 pm
Posts: 38
Also you might try decreasing update frequency and iterations. If you don't use very stiff joints it should still work fine(=good looking).


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Jul 17, 2008 4:05 am 
Offline

Joined: Thu Jul 17, 2008 3:47 am
Posts: 2
Hello,
I am curently trying to use box2d in a nds project. But I have complilation problems... And I have no idea where does it come from :
I have comment the definition of float32 in the jtypes.h file.
I have defined TARGET_IS_NDS.

* When I define TARGET_FLOAT32_IS_FIXED, I have got these errors :
Code:
main.c
In file included from e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/b2Settings.h:49,
                 from e:/worspaceSubtitles/Destroyer/source/box2d/Include/box2d.h:34,
                 from e:/worspaceSubtitles/Destroyer/source/main.c:6:
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/Fixed.h:44: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Fixed'
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/Fixed.h:177: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/Fixed.h:180: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
..........
VERY LONG LIST :)


-> The Fixed class cannot be defined and there are errors on each function implementation

* When I does not define TARGET_FLOAT32_IS_FIXED, I have got these errors :
Code:
main.c
In file included from e:/worspaceSubtitles/Destroyer/source/box2d/Include/box2d.h:34,
                 from e:/worspaceSubtitles/Destroyer/source/main.c:6:
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/b2Settings.h:77: error: initializer element is not constant
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/b2Settings.h:87: error: initializer element is not constant
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/b2Settings.h:92: error: initializer element is not constant
e:/worspaceSubtitles/Destroyer/source/box2d/Include/../Source/Common/b2Settings.h:107: error: initializer element is not constant
..........
VERY LONG LIST TOO:)


-> ...

I really don't know where does it come from... Do you have any idea to put me on the right path ? If you need more precisions about the problem, do not hesitate.
Thank you by advance

(Sorry for my english)


Top
 Profile  
 
PostPosted: Wed Aug 13, 2008 10:33 pm 
Offline

Joined: Wed Aug 13, 2008 10:16 pm
Posts: 3
Hiyas!
So I managed to compile Box2d fine.. but im getting some wierd link error - I cant see where the instantiation of COS_bin etc is done.. am I missing something really obvious? It looks like a trig lookup table from trig_lut.h in libnds... Anyone have any ideas where I might look next?

EDIT:

Looks like its supposed to be from libnds9.a (from compiling the nehe libnds examples):
Code:
d:/devkitPro/libnds/lib\libnds9.a(TAN.o)
                              main.o (TAN_bin)
d:/devkitPro/libnds/lib\libnds9.a(COS.o)
                              d:/devkitPro/libnds/lib\libnds9.a(videoGL.o) (COS_bin)
d:/devkitPro/libnds/lib\libnds9.a(SIN.o)
                              d:/devkitPro/libnds/lib\libnds9.a(videoGL.o) (SIN_bin)


I must be giving the wrong compile/link flag somewhere. One step closer I _guess_.

thanks!

Alia

Code:
D:\Dev\NDS\box2d\NdsTest>make
main.cpp

... SNIP ...

arm-eabi-g++ -g -mthumb-interwork -mno-fpu -L/D/devkitPro/PAlib/lib -Wl,--gc-sections -specs=ds_arm9.specs main.o -LD:/d
evkitPro/PAlib//lib -lpa9 -L/D/devkitPro/libnds/lib -L/D/devkitPro/libbox2d/nds-fixed/lib -lfat -lnds9 -ldswifi9 -lbox2d
 -o build.elf
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2World.o): In function `b2World::SolveTOI(b2TimeStep const&)':
D:\Dev\NDS\box2d\Source/Dynamics/b2World.cpp:730: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2World.cpp:730: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2PulleyJoint.o): In function `b2PulleyJoint::SolvePositionConstraints(Fi
xed)':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/b2PulleyJoint.cpp:375: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/b2PulleyJoint.cpp:375: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2PulleyJoint.o): In function `Fixed':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:180: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:180: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2RevoluteJoint.o): In function `Fixed::operator=(Fixed)':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:183: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:183: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2PrismaticJoint.o): In function `Fixed::cosf()':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:455: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:455: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2DistanceJoint.o): In function `Fixed':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:180: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/../../Common/Fixed.h:180: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2GearJoint.o): In function `b2GearJoint::SolvePositionConstraints(Fixed)
':
D:\Dev\NDS\box2d\Source/Dynamics/Joints/b2GearJoint.cpp:206: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Joints/b2GearJoint.cpp:206: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Math.o): In function `Fixed::cosf()':
D:\Dev\NDS\box2d\Source/Common/Fixed.h:457: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Common/Fixed.h:457: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2PolygonShape.o): In function `b2PolygonDef::SetAsBox(Fixed, Fixed, b2Ve
c2 const&, Fixed)':
D:\Dev\NDS\box2d\Source/Collision/Shapes/b2PolygonShape.cpp:42: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Collision/Shapes/b2PolygonShape.cpp:42: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Body.o): In function `b2Body::SetXForm(b2Vec2 const&, Fixed)':
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:314: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:314: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Body.o): In function `b2Body::SynchronizeShapes()':
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:394: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:394: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Body.o): In function `b2Body':
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:26: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:26: undefined reference to `SIN_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:26: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Body.cpp:26: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Island.o): In function `b2Island::SolveTOI(b2TimeStep&)':
D:\Dev\NDS\box2d\Source/Dynamics/b2Island.cpp:447: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/b2Island.cpp:447: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2Island.o): In function `Fixed::operator=(Fixed)':
D:\Dev\NDS\box2d\Source/Dynamics/../Common/Fixed.h:189: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/../Common/Fixed.h:189: undefined reference to `SIN_bin'
d:/devkitPro/libbox2d/nds-fixed/lib\libbox2d.a(b2ContactSolver.o): In function `b2ContactSolver::SolvePositionConstraint
s(Fixed)':
D:\Dev\NDS\box2d\Source/Dynamics/Contacts/b2ContactSolver.cpp:596: undefined reference to `COS_bin'
D:\Dev\NDS\box2d\Source/Dynamics/Contacts/b2ContactSolver.cpp:596: undefined reference to `SIN_bin'
collect2: ld returned 1 exit status
make[1]: *** [/d/Dev/NDS/box2d/NdsTest/release/NdsTest.elf] Error 1
make: *** [build] Error 2

D:\Dev\NDS\box2d\NdsTest>


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Aug 14, 2008 2:10 am 
Offline

Joined: Thu Dec 06, 2007 7:36 am
Posts: 13
Hey! The order in which libraries are specified in the linker flags is important. If library A depends on library B, it needs to be specified first. So you need to put -lbox2d before -lnds9.


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Thu Aug 14, 2008 7:49 am 
Offline

Joined: Wed Aug 13, 2008 10:16 pm
Posts: 3
You - sir, are a scholar and a gentleman! Thanks!


Top
 Profile  
 
 Post subject: Re: Box2D Nintendo DS
PostPosted: Fri Aug 22, 2008 7:59 pm 
Offline

Joined: Wed Aug 13, 2008 10:16 pm
Posts: 3
I just gotta say:

Thanks!


Box2d is the awesomest... the fixed point/ds just works.. even the test setups mostly run fine.

Image

one wierd thing is once ive moved to fixed point.. every emulator does the wrong thing and makes the images rendered about 10 times bigger than how they appear on the DS. Nothing that im worried about just interesting is all :) (for example try: http://alia.devlog.googlepages.com/NdsTest.nds)

thanks again!


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