瀏覽代碼

Add 3D Physics for Android. Fix positional Sound to use MIN instead of min.

Joachim Meyer 9 年之前
父節點
當前提交
52df971353

+ 2 - 0
build/android/.idea/gradle.xml

@@ -10,6 +10,7 @@
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/Polycode2DPhysics" />
+            <option value="$PROJECT_DIR$/Polycode3DPhysics" />
             <option value="$PROJECT_DIR$/PolycodeUI" />
             <option value="$PROJECT_DIR$/Polycore" />
             <option value="$PROJECT_DIR$/TemplateApp" />
@@ -19,6 +20,7 @@
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/Polycode2DPhysics" />
+            <option value="$PROJECT_DIR$/Polycode3DPhysics" />
             <option value="$PROJECT_DIR$/PolycodeUI" />
             <option value="$PROJECT_DIR$/Polycore" />
             <option value="$PROJECT_DIR$/TemplateApp" />

+ 1 - 0
build/android/.idea/modules.xml

@@ -3,6 +3,7 @@
   <component name="ProjectModuleManager">
     <modules>
       <module fileurl="file://$PROJECT_DIR$/Polycode2DPhysics/Polycode2DPhysics.iml" filepath="$PROJECT_DIR$/Polycode2DPhysics/Polycode2DPhysics.iml" />
+      <module fileurl="file://$PROJECT_DIR$/Polycode3DPhysics/Polycode3DPhysics.iml" filepath="$PROJECT_DIR$/Polycode3DPhysics/Polycode3DPhysics.iml" />
       <module fileurl="file://$PROJECT_DIR$/PolycodeUI/PolycodeUI.iml" filepath="$PROJECT_DIR$/PolycodeUI/PolycodeUI.iml" />
       <module fileurl="file://$PROJECT_DIR$/Polycore/Polycore.iml" filepath="$PROJECT_DIR$/Polycore/Polycore.iml" />
       <module fileurl="file://$PROJECT_DIR$/TemplateApp/TemplateApp.iml" filepath="$PROJECT_DIR$/TemplateApp/TemplateApp.iml" />

+ 1 - 0
build/android/Polycode3DPhysics/.gitignore

@@ -0,0 +1 @@
+/build

+ 31 - 0
build/android/Polycode3DPhysics/AndroidManifest.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- BEGIN_INCLUDE(manifest) -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.example.native_activity"
+        android:versionCode="1"
+        android:versionName="1.0">
+
+    <uses-sdk android:minSdkVersion="21" />
+
+    <!-- This .apk has no Java code itself, so set hasCode to false. -->
+    <application android:label="Polycore" android:hasCode="false">
+
+        <!-- Our activity is the built-in NativeActivity framework class.
+             This will take care of integrating with our NDK code. -->
+        <activity android:name="android.app.NativeActivity"
+                android:label="Polycode3DPhysics"
+                android:configChanges="orientation|keyboardHidden">
+            <!-- Tell NativeActivity the name of or .so -->
+            <meta-data android:name="android.app.lib_name"
+                    android:value="native-activity" />
+            <meta-data android:name="android.app.func_name"
+                    android:value="main" />
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest> 
+<!-- END_INCLUDE(manifest) -->

+ 41 - 0
build/android/Polycode3DPhysics/build.gradle

@@ -0,0 +1,41 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 23
+    buildToolsVersion "23.0.2"
+
+    defaultConfig {
+    applicationId "org.polycode.polycode3dphysics"
+        minSdkVersion 21
+        targetSdkVersion 23
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+    sourceSets.main {
+        manifest.srcFile 'AndroidManifest.xml'
+        //jniLibs.srcDir '../../../lib/android/' //set libs as .so's location instead of jniLibs
+        jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk
+    }
+    // call regular ndk-build(.cmd) script from app directory
+    task ndkBuild(type: Exec) {
+        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+            commandLine 'ndk-build.cmd'
+        } else {
+            commandLine 'ndk-build'
+        }
+    }
+    tasks.withType(JavaCompile) {
+        compileTask -> compileTask.dependsOn ndkBuild
+    }
+}
+
+dependencies {
+}

+ 9 - 0
build/android/Polycode3DPhysics/jni/Android.mk

@@ -0,0 +1,9 @@
+LOCAL_PATH := $(call my-dir)
+SRCDIR := ../../../../src
+LIBDIR := ../../../../lib/linux/android
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Polycode3DPhysics
+LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../include
+LOCAL_SRC_FILES := $(SRCDIR)/modules/physics3D/PolyPhysicsConstraint.cpp $(SRCDIR)/modules/physics3D/PolyPhysicsSceneEntity.cpp $(SRCDIR)/modules/physics3D/PolyPhysicsScene.cpp $(SRCDIR)/modules/physics3D/PolyCollisionSceneEntity.cpp $(SRCDIR)/modules/physics3D/PolyCollisionScene.cpp
+include $(BUILD_STATIC_LIBRARY)

+ 5 - 0
build/android/Polycode3DPhysics/jni/Application.mk

@@ -0,0 +1,5 @@
+APP_PLATFORM := android-21
+APP_ABI := armeabi x86
+APP_STL := gnustl_static
+APP_CPPFLAGS += -std=c++11
+APP_OPTIM := release

+ 17 - 0
build/android/Polycode3DPhysics/proguard-rules.pro

@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /home/joachim/Android/Sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

文件差異過大導致無法顯示
+ 0 - 0
build/android/Polycore/jni/Android.mk


+ 6 - 1
build/android/TemplateApp/jni/Android.mk

@@ -17,6 +17,11 @@ LOCAL_MODULE := Polycode2DPhysics
 LOCAL_SRC_FILES := ../../Polycode2DPhysics/obj/local/$(TARGET_ARCH_ABI)/libPolycode2DPhysics.a
 include $(PREBUILT_STATIC_LIBRARY)
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := Polycode3DPhysics
+LOCAL_SRC_FILES := ../../Polycode3DPhysics/obj/local/$(TARGET_ARCH_ABI)/libPolycode3DPhysics.a
+include $(PREBUILT_STATIC_LIBRARY)
+
 include $(CLEAR_VARS)
 LOCAL_MODULE := freetype
 LOCAL_SRC_FILES := $(LIBDIR)/libfreetype.a
@@ -70,7 +75,7 @@ include $(PREBUILT_SHARED_LIBRARY)
 include $(CLEAR_VARS)
 LOCAL_MODULE := TemplateApp
 LOCAL_LDLIBS := -landroid -lEGL -lGLESv2 -lOpenSLES -lz -llog
-LOCAL_STATIC_LIBRARIES := Polycore PolycodeUI Polycode2DPhysics freetype lua physfs box2d
+LOCAL_STATIC_LIBRARIES := Polycore PolycodeUI Polycode3DPhysics freetype lua physfs box2d BulletDynamics BulletCollision BulletSoftBody LinearMath
 LOCAL_SHARED_LIBRARIES := ogg vorbis
 LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../include -DUSE_EGL -DSTRICT_OPENGLES2
 LOCAL_SRC_FILES := PolycodeTemplate.cpp PolycodeTemplateApp.cpp

+ 1 - 1
build/android/TemplateApp/jni/PolycodeTemplateApp.h

@@ -4,7 +4,7 @@
 
 #include "Polycode.h"
 #include "polycode/modules/ui/PolycodeUI.h"
-#include "polycode/modules/physics2D/Polycode2DPhysics.h"
+#include "polycode/modules/physics3D/Polycode3DPhysics.h"
 
 using namespace Polycode;
 

+ 1 - 1
build/android/settings.gradle

@@ -1 +1 @@
-include ':Polycore', ':TemplateApp', ':PolycodeUI', ':Polycode2DPhysics'
+include ':Polycore', ':TemplateApp', ':PolycodeUI', ':Polycode2DPhysics', ':Polycode3DPhysics'

+ 2 - 2
src/core/PolySound.cpp

@@ -363,8 +363,8 @@ Number Sound::modulateSampleForListener(Number sample, unsigned int channel, con
 	Number distance = position.distance(this->position);
 	Number attenuate = 0.5 * pow(referenceDistance/distance, 2.0);
 	
-	attenuate = min(attenuate, 1.0);
-	attenuate = max(attenuate, 0.0);
+	attenuate = MIN(attenuate, 1.0);
+	attenuate = MAX(attenuate, 0.0);
 	ret *= attenuate;
 	return ret;
 }

部分文件因文件數量過多而無法顯示