include ':app', ':core', ':desktop'
apply plugin: "java" sourceSets.main.java.srcDirs = ["src/"]
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' } } allprojects { repositories { jcenter() maven { url 'http://updates.jmonkeyengine.org/maven' } } } project(":core") { apply plugin: "java" dependencies { compile 'com.jme3:jme3-core:3.0.+' } } project(":desktop") { apply plugin: "java" dependencies { compile project(":core") compile 'com.jme3:jme3-desktop:3.0.+' compile 'com.jme3:jme3-lwjgl:3.0.+' } } project(":app") { apply plugin: "android" dependencies { compile project(":core") compile 'com.jme3:jme3-android:3.0.+' } }
package org.lunapark.dev.jme3example; import com.jme3.app.SimpleApplication; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; public class Game extends SimpleApplication { @Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); rootNode.attachChild(geom); } }
package org.lunapark.dev.jme3example; public class DesktopLauncher { public static void main(String[] args) { Game game = new Game(); game.start(); } }
package org.lunapark.dev.jme3example; import android.content.pm.ActivityInfo; import com.jme3.app.AndroidHarness; import com.jme3.system.android.AndroidConfigChooser; import java.util.logging.Level; import java.util.logging.LogManager; public class MainActivity extends AndroidHarness { public MainActivity() { // Set the application class to run appClass = "org.lunapark.dev.jme3example.Game"; // Try ConfigType.FASTEST; or ConfigType.LEGACY if you have problems eglConfigType = AndroidConfigChooser.ConfigType.BEST; // Exit Dialog title & message exitDialogTitle = "Exit?"; exitDialogMessage = "Are you sure you want to quit?"; // Choose screen orientation screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // Enable MouseEvents being generated from TouchEvents (default = true) mouseEventsEnabled = true; // Set the default logging level (default=Level.INFO, Level.ALL=All Debug Info) LogManager.getLogManager().getLogger("").setLevel(Level.INFO); } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.lunapark.dev.jme3example"> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:launchMode="singleTask" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" /> </manifest>
appClass = Game.class.getCanonicalName();
sourceSets { main { assets.srcDirs = ['src/main/assets', 'assets/'] } }
apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "org.lunapark.dev.jme3example" minSdkVersion 8 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { assets.srcDirs = ['src/main/assets', 'assets/'] } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' }
jMonkeyProjects/MyGame/assets/Interface/ # .font, .jpg, .png, .xml jMonkeyProjects/MyGame/assets/MatDefs/ # .j3md jMonkeyProjects/MyGame/assets/Materials/ # .j3m jMonkeyProjects/MyGame/assets/Models/ # .j3o jMonkeyProjects/MyGame/assets/Scenes/ # .j3o jMonkeyProjects/MyGame/assets/Shaders/ # .j3f, .vert, .frag jMonkeyProjects/MyGame/assets/Sounds/ # .ogg, .wav jMonkeyProjects/MyGame/assets/Textures/ # .jpg, .png; also .mesh.xml+.material, .mtl+.obj, .blend (!)
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key = new TextureKey("Textures/poster.jpg"); Texture tex = assetManager.loadTexture(key); mat.setTexture("ColorMap", tex); geom.setMaterial(mat); rootNode.attachChild(geom); }
apply plugin: "java" sourceSets.main.java.srcDirs = ["src/"] dependencies { compile files("../app/assets") }
project(":core") { apply plugin: "java" dependencies { compile 'com.jme3:jme3-core:3.0.+' compile 'com.jme3:jme3-effects:3.0.+' compile 'com.jme3:jme3-networking:3.0.+' compile 'com.jme3:jme3-plugins:3.0.+' compile 'com.jme3:jme3-jogg:3.0.+' compile 'com.jme3:jme3-terrain:3.0.+' compile 'com.jme3:jme3-blender:3.0.+' compile 'com.jme3:jme3-jbullet:3.0.+' compile 'com.jme3:jme3-niftygui:3.0.+' compile 'net.sf.sociaal:jME3-testdata:3.0.0.20130526' } }
Source: https://habr.com/ru/post/249305/
All Articles