Bullet(Cocos2dx)之交叉编译Android,集成到cocos2dx3.x

前端之家收集整理的这篇文章主要介绍了Bullet(Cocos2dx)之交叉编译Android,集成到cocos2dx3.x前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Bullet(Cocos2dx)之交叉编译Android,集成到cocos2dx3.x

分类 cocos2d-x Android 物理引擎 86人阅读 评论(0) 收藏 举报

首先将src文件夹复制到jni文件夹,没有可以新建一个

新建两个文件Android.mkApplication.mk

Application.mk内容如下:

APP_ABI:=armeabiarmeabi-v7ax86

APP_PLATFORM:=android-8

APP_STL:=stlport_static

Android.mk内容如下:

LOCAL_PATH:=$(callmy-dir)

include$(CLEAR_VARS)

LOCAL_MODULE :=bullet_static(可随便起)

LOCAL_MODULE_FILENAME:=libbullet(可随便起)

LOCAL_C_INCLUDES:=src/(文件位置)

(源文件,要列出所有用到的,这里用到BulletSoftBodyBulletDynamics

BulletCollisionsLinearMath

  1. LOCAL_SRC_FILES:=src/BulletSoftBody/btSoftBody.cpp\
  2. src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp\
  3. src/BulletSoftBody/btSoftBodyHelpers.cpp\
  4. src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp\
  5. src/BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp\
  6. src/BulletSoftBody/btSoftRigidDynamicsWorld.cpp\
  7. src/BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp\
  8. src/BulletSoftBody/btDefaultSoftBodySolver.cpp\
  9. src/BulletDynamics/Character/btKinematicCharacterController.cpp\
  10. src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp\
  11. src/BulletDynamics/ConstraintSolver/btContactConstraint.cpp\
  12. src/BulletDynamics/ConstraintSolver/btFixedConstraint.cpp\
  13. src/BulletDynamics/ConstraintSolver/btGearConstraint.cpp\
  14. src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp\
  15. src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp\
  16. src/BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp\
  17. src/BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp\
  18. src/BulletDynamics/ConstraintSolver/btHingeConstraint.cpp\
  19. src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp\
  20. src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp\
  21. src/BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.cpp\
  22. src/BulletDynamics/ConstraintSolver/btSliderConstraint.cpp\
  23. src/BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp\
  24. src/BulletDynamics/ConstraintSolver/btTypedConstraint.cpp\
  25. src/BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp\
  26. src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp\
  27. src/BulletDynamics/Dynamics/btRigidBody.cpp\
  28. src/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp\
  29. src/BulletDynamics/Vehicle/btRaycastVehicle.cpp\
  30. src/BulletDynamics/Vehicle/btWheelInfo.cpp\
  31. src/BulletDynamics/Featherstone/btMultiBody.cpp\
  32. src/BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp\
  33. src/BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp\
  34. src/BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp\
  35. src/BulletDynamics/Featherstone/btMultiBodyConstraint.cpp\
  36. src/BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp\
  37. src/BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp\
  38. src/BulletDynamics/MLCPSolvers/btDantzigLCP.cpp\
  39. src/BulletDynamics/MLCPSolvers/btMLCPSolver.cpp\
  40. src/BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp\
  41. src/BulletCollision/BroadphaseCollision/btAxisSweep3.cpp\
  42. src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp\
  43. src/BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp\
  44. src/BulletCollision/BroadphaseCollision/btDbvt.cpp\
  45. src/BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp\
  46. src/BulletCollision/BroadphaseCollision/btDispatcher.cpp\
  47. src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp\
  48. src/BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp\
  49. src/BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp\
  50. src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp\
  51. src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp\
  52. src/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp\
  53. src/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp\
  54. src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp\
  55. src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp\
  56. src/BulletCollision/CollisionDispatch/btCollisionObject.cpp\
  57. src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp\
  58. src/BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp\
  59. src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp\
  60. src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp\
  61. src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp\
  62. src/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp\
  63. src/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp\
  64. src/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp\
  65. src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp\
  66. src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp\
  67. src/BulletCollision/CollisionDispatch/btGhostObject.cpp\
  68. src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp\
  69. src/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp\
  70. src/BulletCollision/CollisionDispatch/btManifoldResult.cpp\
  71. src/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp\
  72. src/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp\
  73. src/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp\
  74. src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp\
  75. src/BulletCollision/CollisionDispatch/btUnionFind.cpp\
  76. src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp\
  77. src/BulletCollision/CollisionShapes/btBoxShape.cpp\
  78. src/BulletCollision/CollisionShapes/btBox2dShape.cpp\
  79. src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp\
  80. src/BulletCollision/CollisionShapes/btCapsuleShape.cpp\
  81. src/BulletCollision/CollisionShapes/btCollisionShape.cpp\
  82. src/BulletCollision/CollisionShapes/btCompoundShape.cpp\
  83. src/BulletCollision/CollisionShapes/btConcaveShape.cpp\
  84. src/BulletCollision/CollisionShapes/btConeShape.cpp\
  85. src/BulletCollision/CollisionShapes/btConvexHullShape.cpp\
  86. src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp\
  87. src/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp\
  88. src/BulletCollision/CollisionShapes/btConvexPolyhedron.cpp\
  89. src/BulletCollision/CollisionShapes/btConvexShape.cpp\
  90. src/BulletCollision/CollisionShapes/btConvex2dShape.cpp\
  91. src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp\
  92. src/BulletCollision/CollisionShapes/btCylinderShape.cpp\
  93. src/BulletCollision/CollisionShapes/btEmptyShape.cpp\
  94. src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp\
  95. src/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp\
  96. src/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp\
  97. src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp\
  98. src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp\
  99. src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp\
  100. src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp\
  101. src/BulletCollision/CollisionShapes/btShapeHull.cpp\
  102. src/BulletCollision/CollisionShapes/btSphereShape.cpp\
  103. src/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp\
  104. src/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp\
  105. src/BulletCollision/CollisionShapes/btTetrahedronShape.cpp\
  106. src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp\
  107. src/BulletCollision/CollisionShapes/btTriangleCallback.cpp\
  108. src/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp\
  109. src/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp\
  110. src/BulletCollision/CollisionShapes/btTriangleMesh.cpp\
  111. src/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp\
  112. src/BulletCollision/CollisionShapes/btUniformScalingShape.cpp\
  113. src/BulletCollision/Gimpact/btContactProcessing.cpp\
  114. src/BulletCollision/Gimpact/btGenericPoolAllocator.cpp\
  115. src/BulletCollision/Gimpact/btGImpactBvh.cpp\
  116. src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp\
  117. src/BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp\
  118. src/BulletCollision/Gimpact/btGImpactShape.cpp\
  119. src/BulletCollision/Gimpact/btTriangleShapeEx.cpp\
  120. src/BulletCollision/Gimpact/gim_Box_set.cpp\
  121. src/BulletCollision/Gimpact/gim_contact.cpp\
  122. src/BulletCollision/Gimpact/gim_memory.cpp\
  123. src/BulletCollision/Gimpact/gim_tri_collision.cpp\
  124. src/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp\
  125. src/BulletCollision/NarrowPhaseCollision/btConvexCast.cpp\
  126. src/BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp\
  127. src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp\
  128. src/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp\
  129. src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp\
  130. src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp\
  131. src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp\
  132. src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp\
  133. src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp\
  134. src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp\
  135. src/BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp\
  136. src/LinearMath/btAlignedAllocator.cpp\
  137. src/LinearMath/btConvexHull.cpp\
  138. src/LinearMath/btConvexHullComputer.cpp\
  139. src/LinearMath/btGeometryUtil.cpp\
  140. src/LinearMath/btPolarDecomposition.cpp\
  141. src/LinearMath/btQuickprof.cpp\
  142. src/LinearMath/btSerializer.cpp\
  143. src/LinearMath/btVector3.cpp

最后还要加上一句,表示生成静态库如果将STATIC该文SHARED生成动态库

include$(BUILD_STATIC_LIBRARY)

然后进入命令行

进入jni所在目录

ndk-build

等待编译完成


将三个目录下的libbullet.a分别复制到cocos2dx的安装目录下的

安装目录\Cocos\frameworks\cocos2d-x\prebuilt\android\相应文件

进入Cocos\frameworks\cocos2d-x\external

新建文件Bullet,在Bullet下新建prebuild-mk

Box2D\prebuild-mk下的Android.mk复制到Bullet/prebuild-mk

修改如下3

LOCAL_MODULE:=bullet_static

LOCAL_MODULE_FILENAME:=libbullet

LOCAL_SRC_FILES:=../../../prebuilt/android/$(TARGET_ARCH_ABI)/libbullet.a


复制头文件

bullet3src的所有文件复制到新建的Bullet文件


删除不是.h的所有文件

下一步任务繁重,

将所有用到BulletCollisionBulletDynamicsBulletSoftBodyLinearMath目录下的include加上Bullet/,可以使用Notepad++Bullet目录搜索Bullet,并替换为Bullet/BulletLinearMath并替换为Bullet/LinearMath

进入Cocos\frameworks\cocos2d-x\cocos\prebuilt-mk

Android.mk

LOCAL_WHOLE_STATIC_LIBRARIES+=Box2d_static下面添加

LOCAL_WHOLE_STATIC_LIBRARIES+=bullet_static

$(callimport-module,Box2D/prebuilt-mk)下面添加

$(callimport-module,Bullet/prebuilt-mk)

至此已经完成编译静态库

下载地址

猜你在找的Cocos2d-x相关文章