Skip to content

Commit 4876b4c

Browse files
committed
PreRelease
1 parent e49c4b2 commit 4876b4c

22 files changed

+146
-37
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
.externalNativeBuild
1313
.cxx
1414
/app/src/main/assets/RocketLeaugeAsset/nbproject/private/
15-
/app/src/main/assets/BasicGame/nbproject/private/
15+
/app/src/main/assets/BasicGame/nbproject/private/
16+
/app/src/main/assets/RocketLeauge/nbproject/private/

.idea/.name

-1
This file was deleted.

.idea/jarRepositories.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GamePad/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77
buildToolsVersion "30.0.2"
88

99
defaultConfig {
10-
minSdkVersion 24
10+
minSdkVersion 16
1111
targetSdkVersion 30
1212
versionCode 1
1313
versionName "1.0"

GamePad/src/main/java/com/scrappers/jmeGamePad/GameStickView.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Canvas;
66
import android.graphics.Paint;
77
import android.graphics.Path;
8+
import android.os.Build;
89
import android.util.DisplayMetrics;
910
import android.view.MotionEvent;
1011
import android.widget.ImageView;
@@ -34,7 +35,9 @@ public GameStickView(Activity appCompatActivity) {
3435
public void initializeGameStickHolder(GamePadView gamePadView, float GAMEPAD_CONFIG, int stickViewBackground){
3536
/*setting the background of the gameStickView ,elevation,focus behaviour */
3637
this.setBackground(ContextCompat.getDrawable(appCompatActivity,stickViewBackground));
37-
this.setElevation(40.20f);
38+
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ){
39+
this.setElevation(40.20f);
40+
}
3841
this.setFocusable(true);
3942
/* get the StickViewSize(mainly height) */
4043
DisplayMetrics deviceDisplayMetrics=new DisplayMetrics();

app/build.gradle

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55
buildToolsVersion "30.0.2"
66

77
defaultConfig {
8-
applicationId "com.exampleGamePad"
9-
minSdkVersion 24
8+
applicationId "com.myGame"
9+
minSdkVersion 16
1010
targetSdkVersion 30
1111
versionCode 1
1212
versionName "1.0"
@@ -26,12 +26,15 @@ dependencies {
2626
implementation fileTree(dir: "libs", include: ["*.jar"])
2727
implementation 'androidx.appcompat:appcompat:1.2.0'
2828
implementation 'com.google.android.material:material:1.2.1'
29+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
30+
implementation 'androidx.navigation:navigation-fragment:2.3.0'
31+
implementation 'androidx.navigation:navigation-ui:2.3.0'
32+
implementation project(path: ':GamePad')
2933
testImplementation 'junit:junit:4.13.1'
3034
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
3135
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3236
implementation "org.jmonkeyengine:jme3-core:3.3.2-stable"
3337
implementation "org.jmonkeyengine:jme3-android-native:3.3.2-stable"
34-
implementation "com.github.stephengold:Minie:3.0.0"
38+
implementation 'com.github.stephengold:Minie:3.0.0'
3539
//add this part to your app build.gradle file plus
36-
implementation "com.github.Scrappers-glitch:JmEGamePad:1.2"
3740
}

app/src/main/AndroidManifest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.exampleGamePad">
3+
package="com.myGame">
44

55
<application
66
android:allowBackup="true"
@@ -10,7 +10,7 @@
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
1212
<activity
13-
android:name="com.exampleGamePad.JmeHarness"
13+
android:name="com.myGame.JmeHarness"
1414
android:label="@string/app_name"
1515
android:screenOrientation="landscape"
1616
android:theme="@style/AppTheme.NoActionBar">

app/src/main/assets/Mars Turrent.j3o

Whitespace-only changes.

app/src/main/assets/Mars.j3o

-657 KB
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
#Wed Nov 11 18:27:42 CST 2020
3+
ORIGINAL_PATH=Models/car22221/car22221.obj
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Blender MTL File: 'car1.blend'
2+
# Material Count: 6
3+
4+
newmtl Lamp
5+
Ns 225.000000
6+
Ka 1.000000 1.000000 1.000000
7+
Kd 0.800000 0.709124 0.030795
8+
Ks 0.500000 0.500000 0.500000
9+
Ke 0.000000 0.000000 0.000000
10+
Ni 1.450000
11+
d 1.000000
12+
illum 2
13+
14+
newmtl Material.001
15+
Ns 225.000000
16+
Ka 1.000000 1.000000 1.000000
17+
Kd 0.140188 0.165811 0.800000
18+
Ks 0.500000 0.500000 0.500000
19+
Ke 0.000000 0.000000 0.000000
20+
Ni 1.450000
21+
d 1.000000
22+
illum 2
23+
24+
newmtl addOns
25+
Ns 225.000000
26+
Ka 1.000000 1.000000 1.000000
27+
Kd 0.800000 0.733426 0.783040
28+
Ks 0.500000 0.500000 0.500000
29+
Ke 0.000000 0.000000 0.000000
30+
Ni 1.450000
31+
d 1.000000
32+
illum 2
33+
34+
newmtl glass
35+
Ns 225.000000
36+
Ka 1.000000 1.000000 1.000000
37+
Kd 0.000000 0.000000 0.000000
38+
Ks 0.500000 0.500000 0.500000
39+
Ke 0.000000 0.000000 0.000000
40+
Ni 1.450000
41+
d 1.000000
42+
illum 2
43+
44+
newmtl glass_separators
45+
Ns 225.000000
46+
Ka 1.000000 1.000000 1.000000
47+
Kd 0.800000 0.800000 0.800000
48+
Ks 0.500000 0.500000 0.500000
49+
Ke 0.000000 0.000000 0.000000
50+
Ni 1.450000
51+
d 1.000000
52+
illum 2
53+
54+
newmtl nitro
55+
Ns 225.000000
56+
Ka 1.000000 1.000000 1.000000
57+
Kd 0.001929 0.000000 0.800000
58+
Ks 0.500000 0.500000 0.500000
59+
Ke 0.000000 0.000000 0.000000
60+
Ni 1.450000
61+
d 1.000000
62+
illum 2
Loading
Loading
Loading
Loading

app/src/main/java/com/exampleGamePad/GameStick.java app/src/main/java/com/myGame/GameStick.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.exampleGamePad;
1+
package com.myGame;
22

33
import android.annotation.SuppressLint;
44
import android.app.Activity;
@@ -16,7 +16,6 @@ public class GameStick extends GameStickView {
1616
private final SimpleApplication jmeContext;
1717
private final float accelerationForce = FastMath.pow(5, 3.5f);
1818
private final float brakeForce = 300f;
19-
private float steeringValue = 0;
2019
private float accelerationValue = 0;
2120

2221
public GameStick(Activity appCompatActivity, SimpleApplication jmeContext) {

app/src/main/java/com/exampleGamePad/JmeGame.java app/src/main/java/com/myGame/JmeGame.java

+53-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.exampleGamePad;
1+
package com.myGame;
22

33
import android.graphics.Color;
44
import android.view.View;
@@ -16,6 +16,7 @@
1616
import com.jme3.input.ChaseCamera;
1717
import com.jme3.light.AmbientLight;
1818
import com.jme3.material.Material;
19+
import com.jme3.material.RenderState;
1920
import com.jme3.math.ColorRGBA;
2021
import com.jme3.math.FastMath;
2122
import com.jme3.math.Plane;
@@ -26,28 +27,28 @@
2627
import com.jme3.scene.shape.Box;
2728
import com.jme3.scene.shape.Cylinder;
2829
import com.jme3.scene.shape.Sphere;
30+
import com.jme3.texture.Texture;
31+
import com.jme3.util.SkyFactory;
2932
import com.scrappers.jmeGamePad.GamePadView;
3033

3134
public class JmeGame extends SimpleApplication {
3235

3336
private BulletAppState bulletAppState;
3437
private VehicleControl vehicle;
35-
private final float accelerationForce = FastMath.pow(5, 3.5f);
3638
private final float brakeForce = 300f;
37-
private float steeringValue = 0;
38-
private float accelerationValue = 0;
39-
private final Vector3f jumpForce = new Vector3f(0, 3000, 0);
39+
private final Vector3f jumpForce = new Vector3f(0, 2000, 0);
4040

4141

4242
@Override
4343
public void simpleInitApp() {
4444
bulletAppState = new BulletAppState();
4545
stateManager.attach(bulletAppState);
4646
bulletAppState.setDebugEnabled(false);
47+
addSky();
4748
createPhysicsTestWorld(rootNode, getAssetManager(), bulletAppState.getPhysicsSpace());
4849
buildPlayer();
4950

50-
51+
/*LIBRARY CODE*/
5152
/*run the gamePad Attachments & listeners from the android activity UI thread */
5253
JmeHarness.jmeHarness.runOnUiThread(new Runnable() {
5354
@Override
@@ -59,7 +60,7 @@ public void run() {
5960
/* create a gamePadView instance of cardView/FrameLayout to display gamePad Component */
6061
GamePadView gamePadView=new GamePadView( JmeHarness.jmeHarness,gameStick);
6162
/* Initialize GamePad Parts*/
62-
gamePadView.initializeGamePad(R.drawable.gamepad_domain,GamePadView.HALF_SCREEN)
63+
gamePadView.initializeGamePad(R.drawable.gamepad_domain,GamePadView.ONE_THIRD_SCREEN)
6364
.initializeGameStickHolder(R.drawable.moving_stick_domain)
6465
.initializeGameStick(GamePadView.CRYSTAL_BUTTONS,R.drawable.ic_baseline_gamepad_24,200);
6566
/*initialize the gameStick track */
@@ -70,13 +71,13 @@ public void run() {
7071
gamePadView.addControlButton("BUTTON A",GamePadView.GAMEPAD_BUTTON_A ,GamePadView.CRYSTAL_BUTTONS, R.drawable.ic_baseline_gamepad_24,new View.OnClickListener() {
7172
@Override
7273
public void onClick(View view) {
73-
vehicle.accelerate(accelerationForce);
74+
vehicle.applyCentralImpulse(jumpForce);
7475
}
7576
},null);
7677
gamePadView.addControlButton("BUTTON B",GamePadView.GAMEPAD_BUTTON_B , GamePadView.CRYSTAL_BUTTONS, R.drawable.ic_baseline_gamepad_24,new View.OnClickListener() {
7778
@Override
7879
public void onClick(View view) {
79-
vehicle.brake(brakeForce);
80+
8081
}
8182
},null);
8283
gamePadView.addControlButton("BUTTON X",GamePadView.GAMEPAD_BUTTON_X , GamePadView.CRYSTAL_BUTTONS, R.drawable.ic_baseline_gamepad_24,new View.OnClickListener() {
@@ -96,6 +97,12 @@ public void onClick(View view) {
9697
});
9798
}
9899

100+
private void addSky() {
101+
Geometry sky = (Geometry) SkyFactory.createSky(assetManager,assetManager.loadTexture("RocketLeauge/assets/Textures/sky.jpg"),Vector3f.UNIT_XYZ, SkyFactory.EnvMapType.EquirectMap);
102+
sky.getMaterial().getAdditionalRenderState().setDepthFunc(RenderState.TestFunction.LessOrEqual);
103+
getRootNode().attachChild(sky);
104+
}
105+
99106
private PhysicsSpace getPhysicsSpace(){
100107
return bulletAppState.getPhysicsSpace();
101108
}
@@ -109,12 +116,12 @@ private PhysicsSpace getPhysicsSpace(){
109116
*/
110117
public static void createPhysicsTestWorld(Node rootNode, AssetManager assetManager, PhysicsSpace space) {
111118
AmbientLight light = new AmbientLight();
112-
light.setColor(ColorRGBA.LightGray);
119+
light.setColor(ColorRGBA.White);
113120
rootNode.addLight(light);
114121

115122

116123
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
117-
material.setTexture("ColorMap", assetManager.loadTexture("mars.jpg"));
124+
material.setTexture("ColorMap", assetManager.loadTexture("RocketLeauge/assets/Textures/mars.jpg"));
118125

119126
Box floorBox = new Box(200f, 0.5f, 200f);
120127
Geometry floorGeometry = new Geometry("Floor", floorBox);
@@ -160,20 +167,25 @@ private void buildPlayer() {
160167
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
161168
//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
162169
CompoundCollisionShape compoundShape = new CompoundCollisionShape();
163-
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(2f, 0.5f, 2.5f));
170+
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(2.2f, 0.5f, 2.5f));
164171

165172
compoundShape.addChildShape(box, new Vector3f(0, 1.5f, 0));
166173

167-
Spatial spatial=assetManager.loadModel("Mars.j3o");
168-
spatial.setLocalScale(0.01f,0.01f,0.01f);
169-
spatial.setLocalTranslation(new Vector3f(0, 1.5f, 0));
174+
Spatial spatial=assetManager.loadModel("RocketLeauge/assets/Models/car22221/car22221.j3o");
175+
spatial.setLocalScale(2.2f,2.2f,2.2f);
176+
spatial.setLocalTranslation(new Vector3f(0, 1.2f, 0));
177+
//colors
178+
((Node)spatial).getChild("glass").setMaterial(createMat(ColorRGBA.BlackNoAlpha,""));
179+
((Node)spatial).getChild("chassis").setMaterial(createMat(new ColorRGBA(0f,1f,3f,1f),"RocketLeauge/assets/Textures/TexturesCom_MetalBare0201_6_M.jpg"));
180+
((Node)spatial).getChild("addOns").setMaterial(createMat(ColorRGBA.White,""));
181+
((Node)spatial).getChild("nitros").setMaterial(createMat(new ColorRGBA(0f,0f,5f,1f),"RocketLeauge/assets/Textures/TexturesCom_MetalBare0201_6_M.jpg"));
182+
((Node)spatial).getChild("light").setMaterial(createMat(ColorRGBA.Yellow,""));
170183

171184
//create vehicle node
172-
Node vehicleNode=new Node("vehicleNfode");
185+
Node vehicleNode=new Node("vehicleNode");
173186
vehicleNode.attachChild(spatial);
174187

175188
// chassis.setMaterial(mat);
176-
// vehicleNode.attachChild(chassis);
177189
vehicle = new VehicleControl(compoundShape, 600f);
178190
vehicleNode.addControl(vehicle);
179191
//add a chaseCam tomove the cam with the object
@@ -186,7 +198,7 @@ private void buildPlayer() {
186198
//setting suspension values for wheels, this can be a bit tricky
187199
//see also https://docs.google.com/Doc?docid=0AXVUZ5xw6XpKZGNuZG56a3FfMzU0Z2NyZnF4Zmo&hl=en
188200
float stiffness =30.0f;//200=f1 car
189-
float compValue = 0.3f; //(should be lower than damp)
201+
float compValue = 0.5f; //(should be lower than damp)
190202
float dampValue = 2f;
191203
//compression force of spring(Shock Producer)
192204
vehicle.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
@@ -201,7 +213,7 @@ private void buildPlayer() {
201213
float radius = 0.5f;
202214
float restLength = 0.1f;
203215
float yOff = radius;
204-
float xOff = 2*radius;
216+
float xOff = 3*radius;
205217
float zOff = 4*radius;
206218

207219
Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.5f, true);
@@ -244,13 +256,33 @@ private void buildPlayer() {
244256
vehicleNode.attachChild(node4);
245257
rootNode.attachChild(vehicleNode);
246258

259+
setWheelFrictionSlip(20f);
260+
247261
getPhysicsSpace().add(vehicle);
248262
}
249263

264+
private void setWheelFrictionSlip(float frictionSlip) {
265+
for(int nOfWheel=0;nOfWheel<vehicle.getNumWheels();nOfWheel++) {
266+
vehicle.getWheel(nOfWheel).setFrictionSlip(frictionSlip);
267+
}
268+
}
269+
270+
public Material createMat(ColorRGBA colorRGBA,String Tex){
271+
Material material=new Material(assetManager,"Common/MatDefs/Misc/Unshaded.j3md");
272+
if(colorRGBA !=null){
273+
material.setColor("Color", colorRGBA);
274+
}
275+
if(Tex.length() >1){
276+
Texture texture=assetManager.loadTexture(Tex);
277+
material.setTexture("ColorMap",texture);
278+
}
279+
material.setReceivesShadows(true);
280+
281+
return material;
282+
}
283+
250284
@Override
251285
public void simpleUpdate(float tpf) {
252-
cam.lookAt(vehicle.getPhysicsLocation(), Vector3f.UNIT_Y);
253-
System.out.println();
254286
}
255287

256288
}

app/src/main/java/com/exampleGamePad/JmeHarness.java app/src/main/java/com/myGame/JmeHarness.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.exampleGamePad;
1+
package com.myGame;
22

33
import android.content.res.AssetManager;
44
import android.os.Bundle;
@@ -27,7 +27,7 @@ public JmeHarness() {
2727

2828
// Set main project class (fully qualified path)
2929
// the class that extends SimpleApplication
30-
appClass = "com.exampleGamePad.JmeGame";
30+
appClass = "com.myGame.JmeGame";
3131

3232

3333
// // Set input configuration settings

build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ allprojects {
1717
google()
1818
jcenter()
1919
// hey you looking to add the GamePad don't forget this line
20-
maven { url 'https://jitpack.io' }
20+
maven { url 'https://jitpack.io'
21+
}
22+
2123
}
2224
}
2325

settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include ':GamePad'
22
include ':app'
3-
rootProject.name = "GamePad Example"
3+
rootProject.name = "JmEGamePad"

0 commit comments

Comments
 (0)