Port the AndroidBullet physical engine to Intel architecture

Source: Internet
Author: User

Port the AndroidBullet physical engine to Intel architecture

Introduction

Because mobile devices can use higher computing performance, mobile games can now provide shocking images and real-world physics ). The grenade explosion effect in the gun battle game and the car drifting effect in the racing simulator are provided by the physical engine. Its core is physical simulation. In general, physical simulation determines the performance of the game engine. The success or failure of a game usually depends on the speed and accuracy of the physical engine computing the physical model.

This article describes how to build and migrate the Android Bullet physical engine to Intel-based®Lingdong SoC platform.

Bullet physical

The Bullet physical library is a real-time Physical engine. It is usually used as a component of other game engines for many computer games, movies, 3D modeling systems, and other applications [http://bulletphysics.org/#. In mid 2011, arm neon * was released to support Android OS ).

First, we run the Bullet physical application on Samsung Galaxy * Tab 3 10.1 using an ARM-based processor with 30 frames per second. Then we port the Bullet physical application to the x86 architecture, and now use intel in the Samsung Galaxy * Tab 3 10.1®Run the Bullet physical application on the x86 processor with 60 frames per second. We use intel®The graphic Performance Analyzer compares the performance in each scenario [http://software.intel.com/en-us/vcsource/tools/intel-gpa].

After the application is transplanted to the x86 architecture, developers can obtain additional frame time to improve the physical computing speed in their games, therefore, they have more time to deal with real physics or actions in more games.Preparations

Build and port the required Bullet:

Android SDK [https://developer.android.com/sdk/index.html]

Android NDK [https://developer.android.com/tools/sdk/ndk/index.html]

Eclipse * ADT [https://developer.android.com/sdk/installing/bundle.html]

Bullet Physics [https://bullet.googlecode.com/files/bullet-2.80-rev2531.zip]

The entire process can be run on Windows *, Linux *, or Mac OS *. There is no essential difference between these three systems. We ran the test on Lenovo K900 and Samsung Galaxy * Tab 10.1 3. Both devices are based on the Intel Atom processor Z2460.

The script described in this article that can automatically execute all operations is provided here.

Build

The first step is to build and run the example application PfxApp_1_Simple under ARM.

Then, we will build the PfxLibrary library-the main component of the physical engine. To complete this operation, you need to access the library project directory:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxLibrary \ jni

<BulletPhysics> is the path to accessing the bullet-2.80-rev2531 folder. Open the Android. mk file in the directory and find and replace the declared variables, as shown below:

LOCAL_PATH: = <BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects

Then, open the console and navigate:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxLibrary

Run the following command:

Ndk-build

Successful! We successfully built the PfxLibrary for the armeabi-v7a.

Next, we will build an example application. Navigate to the following directory:

<BulletPhysics> \ bullet-2.80-ev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxApp_1_Simple \ jni

Open the Android. mk file and change the Declaration:

LOCAL_PATH: = <BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects

At the command prompt, change the directory in the project folder:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ pfxapp_fill simple

Run the following command:

Ndk-build

We use Eclipse IDE to start the application. Import the project to Eclipse:

File => Import => Android => Existing Android Code Into Workspace => Browse... =>

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ pfxapp_appssimple \ =>

OK => Finish

Run the same application. Right-click the project icon and choose "Run As => Android Application", 2

The sample runs in the conversion mode.

Port

Next, we will port the PfxApp_1_Simple example to x86. Start with the core PfxLibrary library. Navigate to the project folder:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxLibrary \ jni

Open the Android. mk file and change the Declaration:

APP_ABI: = x86

Make the following changes to the Android. mk file:

LOCAL_PATH: = <BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects

LOCAL_CFLAGS :=$ (LOCAL_C_INCLUDES: % =-I %)-DUSE_PTHREADS-pthread

LOCAL_ARM_NEON: = false

Remove arm neon * optimized assembly files by removing the following content from the LOCAL_SRC_FILES declaration list:

Src/base_level/solver/pfx_constraint_row_solver_neon.cpp \

Include/vecmath/neon/vectormath_neon_assembly_implementations.S

Rebuild the physical engine. At the command prompt, change the working directory:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxLibrary

Run ndk-build. We have now created a PfxLibrary for the x86 architecture. Repeat the preceding steps to port the sample application. Navigate to the following project directory:

<BulletPhysics> \ bullet-2.80-ev2531 \ Extras \ PhysicsEffects \ project \ Android \ PfxApp_1_Simple \ jni

Open the Application. mk file and change the Declaration:

APP_ABI: = x86

Replace the variables in the Android. mk file:

LOCAL_PATH: =\ bullet-2.80-rev2531 \ Extras \ PhysicsEffects

LOCAL_SRC_FILES: = project/Android/PfxLibrary/obj/local/x86/libpfxlibrary.

LOCAL_CFLAGS :=$ (LOCAL_C_INCLUDES: % =-I %)

LOCAL_ARM_NEON: = false

Delete the following content from LOCAL_SRC_FILES:

Sample/test_ARM_NEON_performance/neon_dot_product.S \

Sample/test_ARM_NEON_performance/neon_cross_product.S \

Sample/test_ARM_NEON_performance/neon_matrix4_operator_multiply.S \

Sample/test_ARM_NEON_performance/neon_matrix3_operator_multiply.S \

Sample/test_ARM_NEON_performance/neon_orthoInverse_transform3.S \

Sample/test_ARM_NEON_performance/neon_transform3_operator_multiply.S \

Sample/test_ARM_NEON_performance/neon_transpose_matrix3.S \

Sample/test_ARM_NEON_performance/test_neon_cross_product.cpp \

Sample/test_ARM_NEON_performance/test_neon_dot_product.cpp \

Sample/test_ARM_NEON_performance/test_neon_matrix3_operator_multiply.cpp \

Sample/test_ARM_NEON_performance/test_neon_matrix4_operator_multiply.cpp \

Sample/test_ARM_NEON_performance/test_neon_orthoInverse_transform3.cpp \

Sample/test_ARM_NEON_performance/test_neon_transform3_operator_multiply.cpp \

Sample/test_ARM_NEON_performance/test_neon_transpose_matrix3.cpp \

Sample/test_ARM_NEON_performance/test_neon_solve_linear_constraint_row.cpp

Change the working directory for the project folder:

<BulletPhysics> \ bullet-2.80-rev2531 \ Extras \ PhysicsEffects \ project \ Android \ pfxapp_fill simple

Use the ndk-build command to build the project and then run the example on the device.

Use the APK Info app provided by Google Play to view the supported architecture [https://play.google.com/store/apps/details? Id1_com.intelloware.apk info].

Conclusion

This article describes how to build and port the physical engine-Bullet Physics step by step. After the application is successfully transplanted to the x86 architecture, the physical porting speed of the application is doubled, and the frame rate FPS is improved.

Link: https://software.intel.com/zh-cn/android/articles/porting-the-android-bullet-physics-engine-to-intel-architecture? Utm_campaign = eoe & utm_source = eoe.cn & utm_medium = Link & utm_content = intel-optimization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.