开发者

Setting up Bullet Physics for iOS in XCode 4

So, I have downloaded the latest Bullet Physics package (2.78) and I have read the "Getting Started" documentation, which even includes an article on setting up a project in XCode from scratch (but not targeted at iOS nor XCode 4, which is what I'm using). Even so, I am still not able to set this up.

The following are the steps I'm currently taking:

  1. I'm adding the Bullet Physics "src" folder in the classes of the Xcode

  2. I'm including the Bullet Physics "src" folder path in the debug and release "Header Search Paths" in XCode

  3. I add #include "btBulletDynamicsCommon.h" to the file where I want to use Bullet Physic开发者_开发百科s

  4. I change the Objective-C file to Objective-C++ by changing its file extension from "m" to "mm". This is the file where the "btBulletDynamicsCommon.h" is included

After I follow these steps, the compiler complaints about missing files (first few errors, there are 999+ errors shown when I try to build).

These are the first few headers missing in the btSoftBodySolverVertexBuffer_DX11.h:

#include <windows.h>
#include <crtdbg.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dcompiler.h>

Now, I'm pretty new with XCode and iOS, so the fact that these are missing doesn't really tell me much on how to solve this issue, and it makes me even wonder if they are at all needed for iOS development given the appended "DX11" on the file name that is having this issue.

So, what I would appreciate is either information on what's possibly wrong, or information on how to set up Bullet Physics to be used with iOS in XCode 4, from scratch.

Thanks.

Update: I have completely removed the DX11 and OpenCL and I'm now able to compile after step 4 above. I have not yet actually tested the Bullet Physics framework to see if it works without issues. But this now leads me to ask:

What are the specific source files/folders that are strictly necessary to run Bullet Physics in iOS?


There is a tutorial with step by step instruction for integrating Bullet Physics with iOS and Apple's GLKit framework http://www.informit.com/articles/article.aspx?p=1914612

The example code downloadable with the tutorial will get you started quickly and produces an interesting simulation.


How to insert Bullet Physics into iOS: iOS OpenGL BulletPhysics Sample Code

Download the sample code or follow on a new project form Xcode with iOS openGL template:

  1. Download bullet physics... put it into a folder like the following:

*(notice that there is a folder for the project that contains the Xcode project file)

/MyProjectFolder/bullet-2.78/
/MyProjectFolder/MyProject/MyProject.xcproj

1.5. Run CMake in the physics directory to compile the frameworks (assuming you installed cmake already CMake) This step is optional with the sample code I uploaded since it already included the compiled frameworks in it....that made the file 100 megs but what is 100 megs these days anyway?

cmake . -G "Unix Makefiles" -DINSTALL_LIBS=ON -DBUILD_SHARED_LIBS=ON     -DFRAMEWORK=ON  -DCMAKE_OSX_ARCHITECTURES='i386;x86_64'     -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/Library/Frameworks     -DCMAKE_INSTALL_NAME_DIR=/Library/Frameworks -DBUILD_DEMOS:BOOL=OFF
make -j4
sudo make install
  1. Goto your MyProject.xcproj and open in Xcode...

in XCode goto any file you wish to add the physics code to... you must understand that cpp files are c++ and .m .h files are generally cocoa. You must change the Class you wish to add the physics engine code to have a .mm extension signifying it should be compiled as Objective-C++ code...

  1. In the particular class you want to add the physics which is now an Objective-C++ file or a cpp file, add the line

    #include "btBulletDynamicsCommon.h"
    

and you should compile...the error is that the file is not found...

  1. Next goto the MyProjectFolder/bullet-2.78/src and drag the src folder into your project.
  2. Delete the folder named BulletMultiThread...it will eliminate the error of trying to compile some openCL (.cl) files

  3. Last step, copy the following frameworks from the src folder of your bullet physics installation into your project:

    /MyProjectFolder/bullet-2.78/LinearMath/LinearMath.framework /MyProjectFolder/bullet-2.78/BulletCollision/BulletCollision.framework /MyProjectFolder/bullet-2.78/LinearMath/LinearMath.framework

  4. Build and Run... should compile smoothly to iOS and Mac now...


i found Orbitus007's answer a little miss leading. You can just add the bullet physics frameworks to the project instead of adding the whole src folder to your project. adding the src folder gave me errors and just adding the frameworks made my project compile

should look something like this http://imgur.com/CINtb

you can then just go

#import "BulletDynamics/btBulletDynamicsCommon.h"

you will still need to have your file with the .mm extension

also, i found that i got an error when trying to use cmake saying something about xcode-select. if you get it try run this command in the terminal, then try again

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

but other than that, his answer helped me get it working


OK, so as an update and to answer my own question:

I ended up deleting the folders DX11 and OpenCL and their content. This has so far allowed me to run a few Hello World tests.

I still welcome more assertive answers, given it seems strange to me that I can't find any documentation covering this for iOS usage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜