Merge pull request #5 from jMonkeyEngine/master
Merge jMonkeyEngine/master into scenecomposer/master
This commit is contained in:
commit
a457b81d13
.travis.ymlcommon.gradlegradle.properties
jme3-android/src/main/java/com/jme3/renderer/android
jme3-bullet-native/src/native/cpp
jme3-bullet/src
jme3-core/src/main/java/com/jme3/renderer/opengl
jme3-examples/src/main/java/jme3test/bullet
TestAttachDriver.javaTestAttachGhostObject.javaTestCcd.javaTestCollisionGroups.javaTestCollisionListener.javaTestCollisionShapeFactory.javaTestGhostObject.javaTestKinematicAddToPhysicsSpaceIssue.javaTestLocalPhysics.javaTestPhysicsCar.javaTestPhysicsHingeJoint.javaTestPhysicsRayCast.javaTestPhysicsReadWrite.javaTestRagDoll.javaTestSimplePhysics.javaTestSweepTest.java
jme3-ios/src/main
java/com/jme3
resources/com/jme3/asset
jme3-jbullet/src/main/java/com/jme3/bullet
sdk
14
.travis.yml
14
.travis.yml
@ -1,11 +1,21 @@
|
||||
language: java
|
||||
# jdk:
|
||||
# - oraclejdk8
|
||||
sudo: false
|
||||
env:
|
||||
- GRADLE_USER_HOME=gradle-cache
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- gradle-cache
|
||||
- netbeans
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
notifications:
|
||||
slack:
|
||||
secure: "PWEk4+VL986c3gAjWp12nqyifvxCjBqKoESG9d7zWh1uiTLadTHhZJRMdsye36FCpz/c/Jt7zCRO/5y7FaubQptnRrkrRfjp5f99MJRzQVXnUAM+y385qVkXKRKd/PLpM7XPm4AvjvxHCyvzX2wamRvul/TekaXKB9Ti5FCN87s="
|
||||
|
||||
before_install:
|
||||
# required libs for android build tools
|
||||
# sudo apt-get update
|
||||
|
@ -4,16 +4,17 @@
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
String mavenGroupId = 'com.jme3'
|
||||
String mavenVersion = jmeVersion + '-' + jmeVersionTag //'-SNAPSHOT'
|
||||
group = 'com.jme3'
|
||||
version = jmeVersion + '-' + jmeVersionTag
|
||||
|
||||
sourceCompatibility = '1.6'
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven{
|
||||
maven {
|
||||
url "http://nifty-gui.sourceforge.net/nifty-maven-repo"
|
||||
}
|
||||
}
|
||||
@ -23,11 +24,6 @@ dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.10'
|
||||
}
|
||||
|
||||
String mavenArtifactId = name
|
||||
|
||||
group = mavenGroupId
|
||||
version = mavenVersion
|
||||
|
||||
javadoc {
|
||||
failOnError = false
|
||||
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
@ -60,11 +56,40 @@ artifacts {
|
||||
}
|
||||
}
|
||||
|
||||
configure(install.repositories.mavenInstaller) {
|
||||
pom.project {
|
||||
groupId = mavenGroupId
|
||||
artifactId = mavenArtifactId
|
||||
version = mavenVersion
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
|
||||
pom.withXml {
|
||||
asNode().children().last() + {
|
||||
resolveStrategy = Closure.DELEGATE_FIRST
|
||||
name POM_NAME
|
||||
description POM_DESCRIPTION
|
||||
url POM_URL
|
||||
scm {
|
||||
url POM_SCM_URL
|
||||
connection POM_SCM_CONNECTION
|
||||
developerConnection POM_SCM_DEVELOPER_CONNECTION
|
||||
}
|
||||
licenses {
|
||||
license {
|
||||
name POM_LICENSE_NAME
|
||||
url POM_LICENSE_URL
|
||||
distribution POM_LICENSE_DISTRIBUTION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "${rootProject.buildDir}/repo" // change to point to your repo, e.g. http://my.org/repo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,3 +23,14 @@ bulletZipFile = bullet.zip
|
||||
|
||||
# Path for downloading NetBeans Base
|
||||
netbeansUrl = http://download.netbeans.org/netbeans/8.0.2/final/zip/netbeans-8.0.2-201411181905-javase.zip
|
||||
|
||||
# POM settings
|
||||
POM_NAME=jMonkeyEngine
|
||||
POM_DESCRIPTION=jMonkeyEngine is a 3D game engine for adventurous Java developers
|
||||
POM_URL=http://jmonkeyengine.org
|
||||
POM_SCM_URL=https://github.com/jMonkeyEngine/jmonkeyengine
|
||||
POM_SCM_CONNECTION=scm:git:git://github.com/jMonkeyEngine/jmonkeyengine.git
|
||||
POM_SCM_DEVELOPER_CONNECTION=scm:git:git@github.com:jMonkeyEngine/jmonkeyengine.git
|
||||
POM_LICENSE_NAME=New BSD (3-clause) License
|
||||
POM_LICENSE_URL=http://opensource.org/licenses/BSD-3-Clause
|
||||
POM_LICENSE_DISTRIBUTION=repo
|
||||
|
@ -35,42 +35,43 @@ import android.opengl.GLES20;
|
||||
import com.jme3.renderer.RendererException;
|
||||
import com.jme3.renderer.opengl.GL;
|
||||
import com.jme3.renderer.opengl.GLExt;
|
||||
import com.jme3.renderer.opengl.GLFbo;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class AndroidGL implements GL, GLExt {
|
||||
public class AndroidGL implements GL, GLExt, GLFbo {
|
||||
|
||||
public void resetStats() {
|
||||
}
|
||||
|
||||
|
||||
private static int getLimitBytes(ByteBuffer buffer) {
|
||||
checkLimit(buffer);
|
||||
return buffer.limit();
|
||||
}
|
||||
|
||||
|
||||
private static int getLimitBytes(ShortBuffer buffer) {
|
||||
checkLimit(buffer);
|
||||
return buffer.limit() * 2;
|
||||
}
|
||||
|
||||
|
||||
private static int getLimitBytes(IntBuffer buffer) {
|
||||
checkLimit(buffer);
|
||||
return buffer.limit() * 4;
|
||||
}
|
||||
|
||||
|
||||
private static int getLimitBytes(FloatBuffer buffer) {
|
||||
checkLimit(buffer);
|
||||
return buffer.limit() * 4;
|
||||
}
|
||||
|
||||
|
||||
private static int getLimitCount(Buffer buffer, int elementSize) {
|
||||
checkLimit(buffer);
|
||||
return buffer.limit() / elementSize;
|
||||
}
|
||||
|
||||
|
||||
private static void checkLimit(Buffer buffer) {
|
||||
if (buffer == null) {
|
||||
return;
|
||||
@ -82,7 +83,7 @@ public class AndroidGL implements GL, GLExt {
|
||||
throw new RendererException("Attempting to upload empty buffer (remaining = 0), that's an error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void glActiveTexture(int texture) {
|
||||
GLES20.glActiveTexture(texture);
|
||||
}
|
||||
@ -130,7 +131,7 @@ public class AndroidGL implements GL, GLExt {
|
||||
public void glBufferSubData(int target, long offset, ByteBuffer data) {
|
||||
GLES20.glBufferSubData(target, (int) offset, getLimitBytes(data), data);
|
||||
}
|
||||
|
||||
|
||||
public void glGetBufferSubData(int target, long offset, ByteBuffer data) {
|
||||
throw new UnsupportedOperationException("OpenGL ES 2 does not support glGetBufferSubData");
|
||||
}
|
||||
|
@ -528,6 +528,18 @@ extern "C" {
|
||||
space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration);
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations
|
||||
(JNIEnv *env, jobject object, jlong spaceId, jint value) {
|
||||
jmePhysicsSpace* space = reinterpret_cast<jmePhysicsSpace*>(spaceId);
|
||||
if (space == NULL) {
|
||||
jclass newExc = env->FindClass("java/lang/NullPointerException");
|
||||
env->ThrowNew(newExc, "The physics space does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
space->getDynamicsWorld()->getSolverInfo().m_numIterations = value;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -174,6 +174,14 @@ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_finalizeNative
|
||||
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native
|
||||
(JNIEnv *, jobject, jlong, jobject, jobject, jlong, jobject, jfloat);
|
||||
|
||||
/*
|
||||
* Class: com_jme3_bullet_PhysicsSpace
|
||||
* Method: setSolverNumIterations
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations
|
||||
(JNIEnv *, jobject, jlong, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -166,7 +166,7 @@ public class BulletAppState implements AppState, PhysicsTickListener {
|
||||
pSpace.addTickListener(this);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
public void stopPhysics() {
|
||||
if(!initialized){
|
||||
return;
|
||||
@ -226,19 +226,9 @@ public class BulletAppState implements AppState, PhysicsTickListener {
|
||||
if (debugEnabled && debugAppState == null && pSpace != null) {
|
||||
debugAppState = new BulletDebugAppState(pSpace);
|
||||
stateManager.attach(debugAppState);
|
||||
pSpace.enableDebug(app.getAssetManager());
|
||||
} else if (!debugEnabled && debugAppState != null) {
|
||||
stateManager.detach(debugAppState);
|
||||
debugAppState = null;
|
||||
if (pSpace != null) {
|
||||
pSpace.enableDebug(null);
|
||||
}
|
||||
}
|
||||
//TODO: remove when deprecation of PhysicsSpace.enableDebug is through
|
||||
if (pSpace.getDebugManager() != null && !debugEnabled) {
|
||||
debugEnabled = true;
|
||||
} else if (pSpace.getDebugManager() == null && debugEnabled) {
|
||||
debugEnabled = false;
|
||||
}
|
||||
if (!active) {
|
||||
return;
|
||||
|
@ -102,7 +102,7 @@ public class PhysicsSpace {
|
||||
private Vector3f worldMax = new Vector3f(10000f, 10000f, 10000f);
|
||||
private float accuracy = 1f / 60f;
|
||||
private int maxSubSteps = 4, rayTestFlags = 1 << 2;
|
||||
private AssetManager debugManager;
|
||||
private int solverNumIterations = 10;
|
||||
|
||||
static {
|
||||
// System.loadLibrary("bulletjme");
|
||||
@ -702,7 +702,7 @@ public class PhysicsSpace {
|
||||
public Vector3f getGravity(Vector3f gravity) {
|
||||
return gravity.set(this.gravity);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * applies gravity value to all objects
|
||||
// */
|
||||
@ -783,7 +783,7 @@ public class PhysicsSpace {
|
||||
public void SetRayTestFlags(int flags) {
|
||||
rayTestFlags = flags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets m_flags for raytest, see https://code.google.com/p/bullet/source/browse/trunk/src/BulletCollision/NarrowPhaseCollision/btRaycastCallback.h
|
||||
* for possible options.
|
||||
@ -792,7 +792,7 @@ public class PhysicsSpace {
|
||||
public int GetRayTestFlags() {
|
||||
return rayTestFlags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs a ray collision test and returns the results as a list of
|
||||
* PhysicsRayTestResults
|
||||
@ -837,7 +837,7 @@ public class PhysicsSpace {
|
||||
return (List<PhysicsSweepTestResult>) results;
|
||||
}
|
||||
|
||||
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) {
|
||||
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) {
|
||||
return sweepTest(shape, start, end, results, 0.0f);
|
||||
}
|
||||
|
||||
@ -849,7 +849,7 @@ public class PhysicsSpace {
|
||||
* collision if it starts INSIDE an object and is moving AWAY from its
|
||||
* center.
|
||||
*/
|
||||
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results, float allowedCcdPenetration ) {
|
||||
public List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results, float allowedCcdPenetration ) {
|
||||
results.clear();
|
||||
sweepTest_native(shape.getObjectId(), start, end, physicsSpaceId, results, allowedCcdPenetration);
|
||||
return results;
|
||||
@ -960,28 +960,28 @@ public class PhysicsSpace {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable debug display for physics.
|
||||
*
|
||||
* @deprecated in favor of BulletDebugAppState, use
|
||||
* <code>BulletAppState.setDebugEnabled(boolean)</code> to add automatically
|
||||
* @param manager AssetManager to use to create debug materials
|
||||
* Set the number of iterations used by the contact solver.
|
||||
*
|
||||
* The default is 10. Use 4 for low quality, 20 for high quality.
|
||||
*
|
||||
* @param numIterations The number of iterations used by the contact & constraint solver.
|
||||
*/
|
||||
@Deprecated
|
||||
public void enableDebug(AssetManager manager) {
|
||||
debugManager = manager;
|
||||
public void setSolverNumIterations(int numIterations) {
|
||||
this.solverNumIterations = numIterations;
|
||||
setSolverNumIterations(physicsSpaceId, numIterations);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable debug display
|
||||
* Get the number of iterations used by the contact solver.
|
||||
*
|
||||
* @return The number of iterations used by the contact & constraint solver.
|
||||
*/
|
||||
public void disableDebug() {
|
||||
debugManager = null;
|
||||
public int getSolverNumIterations() {
|
||||
return solverNumIterations;
|
||||
}
|
||||
|
||||
public AssetManager getDebugManager() {
|
||||
return debugManager;
|
||||
}
|
||||
|
||||
|
||||
private static native void setSolverNumIterations(long physicsSpaceId, int numIterations);
|
||||
|
||||
public static native void initNativePhysics();
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ public class GLRenderer implements Renderer {
|
||||
|
||||
private HashSet<String> loadExtensions() {
|
||||
HashSet<String> extensionSet = new HashSet<String>(64);
|
||||
if (gl3 != null) {
|
||||
if (caps.contains(Caps.OpenGL30)) {
|
||||
// If OpenGL3+ is available, use the non-deprecated way
|
||||
// of getting supported extensions.
|
||||
gl3.glGetInteger(GL3.GL_NUM_EXTENSIONS, intBuf16);
|
||||
|
@ -69,7 +69,7 @@ public class TestAttachDriver extends SimpleApplication implements ActionListene
|
||||
private float accelerationValue = 0;
|
||||
private Vector3f jumpForce = new Vector3f(0, 3000, 0);
|
||||
private BulletAppState bulletAppState;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestAttachDriver app = new TestAttachDriver();
|
||||
app.start();
|
||||
@ -79,7 +79,7 @@ public class TestAttachDriver extends SimpleApplication implements ActionListene
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
setupKeys();
|
||||
setupFloor();
|
||||
buildPlayer();
|
||||
|
@ -85,7 +85,7 @@ public class TestAttachGhostObject extends SimpleApplication implements AnalogLi
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
setupKeys();
|
||||
setupJoint();
|
||||
}
|
||||
|
@ -1,152 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package jme3test.bullet;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.PhysicsSpace;
|
||||
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.MeshCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.scene.shape.Sphere.TextureMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
public class TestCcd extends SimpleApplication implements ActionListener {
|
||||
|
||||
private Material mat;
|
||||
private Material mat2;
|
||||
private Sphere bullet;
|
||||
private SphereCollisionShape bulletCollisionShape;
|
||||
private BulletAppState bulletAppState;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCcd app = new TestCcd();
|
||||
app.start();
|
||||
}
|
||||
|
||||
private void setupKeys() {
|
||||
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
inputManager.addMapping("shoot2", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||
inputManager.addListener(this, "shoot");
|
||||
inputManager.addListener(this, "shoot2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||
bullet.setTextureMode(TextureMode.Projected);
|
||||
bulletCollisionShape = new SphereCollisionShape(0.1f);
|
||||
setupKeys();
|
||||
|
||||
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.getAdditionalRenderState().setWireframe(true);
|
||||
mat.setColor("Color", ColorRGBA.Green);
|
||||
|
||||
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat2.getAdditionalRenderState().setWireframe(true);
|
||||
mat2.setColor("Color", ColorRGBA.Red);
|
||||
|
||||
// An obstacle mesh, does not move (mass=0)
|
||||
Node node2 = new Node();
|
||||
node2.setName("mesh");
|
||||
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
|
||||
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO, 4, 4, 0.1f)), 0));
|
||||
rootNode.attachChild(node2);
|
||||
getPhysicsSpace().add(node2);
|
||||
|
||||
// The floor, does not move (mass=0)
|
||||
Node node3 = new Node();
|
||||
node3.setLocalTranslation(new Vector3f(0f, -6, 0f));
|
||||
node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0));
|
||||
rootNode.attachChild(node3);
|
||||
getPhysicsSpace().add(node3);
|
||||
|
||||
}
|
||||
|
||||
private PhysicsSpace getPhysicsSpace() {
|
||||
return bulletAppState.getPhysicsSpace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
//TODO: add update code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleRender(RenderManager rm) {
|
||||
//TODO: add render code
|
||||
}
|
||||
|
||||
public void onAction(String binding, boolean value, float tpf) {
|
||||
if (binding.equals("shoot") && !value) {
|
||||
Geometry bulletg = new Geometry("bullet", bullet);
|
||||
bulletg.setMaterial(mat);
|
||||
bulletg.setName("bullet");
|
||||
bulletg.setLocalTranslation(cam.getLocation());
|
||||
bulletg.setShadowMode(ShadowMode.CastAndReceive);
|
||||
bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
|
||||
bulletg.getControl(RigidBodyControl.class).setCcdMotionThreshold(0.1f);
|
||||
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
||||
rootNode.attachChild(bulletg);
|
||||
getPhysicsSpace().add(bulletg);
|
||||
} else if (binding.equals("shoot2") && !value) {
|
||||
Geometry bulletg = new Geometry("bullet", bullet);
|
||||
bulletg.setMaterial(mat2);
|
||||
bulletg.setName("bullet");
|
||||
bulletg.setLocalTranslation(cam.getLocation());
|
||||
bulletg.setShadowMode(ShadowMode.CastAndReceive);
|
||||
bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
|
||||
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
||||
rootNode.attachChild(bulletg);
|
||||
getPhysicsSpace().add(bulletg);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package jme3test.bullet;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.PhysicsSpace;
|
||||
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.MeshCollisionShape;
|
||||
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
|
||||
import com.jme3.bullet.control.RigidBodyControl;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||
import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.scene.shape.Sphere.TextureMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
public class TestCcd extends SimpleApplication implements ActionListener {
|
||||
|
||||
private Material mat;
|
||||
private Material mat2;
|
||||
private Sphere bullet;
|
||||
private SphereCollisionShape bulletCollisionShape;
|
||||
private BulletAppState bulletAppState;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCcd app = new TestCcd();
|
||||
app.start();
|
||||
}
|
||||
|
||||
private void setupKeys() {
|
||||
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
|
||||
inputManager.addMapping("shoot2", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
|
||||
inputManager.addListener(this, "shoot");
|
||||
inputManager.addListener(this, "shoot2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||
bullet.setTextureMode(TextureMode.Projected);
|
||||
bulletCollisionShape = new SphereCollisionShape(0.1f);
|
||||
setupKeys();
|
||||
|
||||
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat.getAdditionalRenderState().setWireframe(true);
|
||||
mat.setColor("Color", ColorRGBA.Green);
|
||||
|
||||
mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||
mat2.getAdditionalRenderState().setWireframe(true);
|
||||
mat2.setColor("Color", ColorRGBA.Red);
|
||||
|
||||
// An obstacle mesh, does not move (mass=0)
|
||||
Node node2 = new Node();
|
||||
node2.setName("mesh");
|
||||
node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f));
|
||||
node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(Vector3f.ZERO, 4, 4, 0.1f)), 0));
|
||||
rootNode.attachChild(node2);
|
||||
getPhysicsSpace().add(node2);
|
||||
|
||||
// The floor, does not move (mass=0)
|
||||
Node node3 = new Node();
|
||||
node3.setLocalTranslation(new Vector3f(0f, -6, 0f));
|
||||
node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0));
|
||||
rootNode.attachChild(node3);
|
||||
getPhysicsSpace().add(node3);
|
||||
|
||||
}
|
||||
|
||||
private PhysicsSpace getPhysicsSpace() {
|
||||
return bulletAppState.getPhysicsSpace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
//TODO: add update code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleRender(RenderManager rm) {
|
||||
//TODO: add render code
|
||||
}
|
||||
|
||||
public void onAction(String binding, boolean value, float tpf) {
|
||||
if (binding.equals("shoot") && !value) {
|
||||
Geometry bulletg = new Geometry("bullet", bullet);
|
||||
bulletg.setMaterial(mat);
|
||||
bulletg.setName("bullet");
|
||||
bulletg.setLocalTranslation(cam.getLocation());
|
||||
bulletg.setShadowMode(ShadowMode.CastAndReceive);
|
||||
bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
|
||||
bulletg.getControl(RigidBodyControl.class).setCcdMotionThreshold(0.1f);
|
||||
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
||||
rootNode.attachChild(bulletg);
|
||||
getPhysicsSpace().add(bulletg);
|
||||
} else if (binding.equals("shoot2") && !value) {
|
||||
Geometry bulletg = new Geometry("bullet", bullet);
|
||||
bulletg.setMaterial(mat2);
|
||||
bulletg.setName("bullet");
|
||||
bulletg.setLocalTranslation(cam.getLocation());
|
||||
bulletg.setShadowMode(ShadowMode.CastAndReceive);
|
||||
bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
|
||||
bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
|
||||
rootNode.attachChild(bulletg);
|
||||
getPhysicsSpace().add(bulletg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ public class TestCollisionGroups extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
|
||||
// Add a physics sphere to the world
|
||||
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||
physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
|
||||
|
@ -1,98 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package jme3test.bullet;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.PhysicsSpace;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionEvent;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionListener;
|
||||
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.scene.shape.Sphere.TextureMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
public class TestCollisionListener extends SimpleApplication implements PhysicsCollisionListener {
|
||||
|
||||
private BulletAppState bulletAppState;
|
||||
private Sphere bullet;
|
||||
private SphereCollisionShape bulletCollisionShape;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCollisionListener app = new TestCollisionListener();
|
||||
app.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||
bullet.setTextureMode(TextureMode.Projected);
|
||||
bulletCollisionShape = new SphereCollisionShape(0.4f);
|
||||
|
||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
|
||||
|
||||
// add ourselves as collision listener
|
||||
getPhysicsSpace().addCollisionListener(this);
|
||||
}
|
||||
|
||||
private PhysicsSpace getPhysicsSpace(){
|
||||
return bulletAppState.getPhysicsSpace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
//TODO: add update code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleRender(RenderManager rm) {
|
||||
//TODO: add render code
|
||||
}
|
||||
|
||||
public void collision(PhysicsCollisionEvent event) {
|
||||
if ("Box".equals(event.getNodeA().getName()) || "Box".equals(event.getNodeB().getName())) {
|
||||
if ("bullet".equals(event.getNodeA().getName()) || "bullet".equals(event.getNodeB().getName())) {
|
||||
fpsText.setText("You hit the box!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package jme3test.bullet;
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.PhysicsSpace;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionEvent;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionListener;
|
||||
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.scene.shape.Sphere;
|
||||
import com.jme3.scene.shape.Sphere.TextureMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
public class TestCollisionListener extends SimpleApplication implements PhysicsCollisionListener {
|
||||
|
||||
private BulletAppState bulletAppState;
|
||||
private Sphere bullet;
|
||||
private SphereCollisionShape bulletCollisionShape;
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestCollisionListener app = new TestCollisionListener();
|
||||
app.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
bullet = new Sphere(32, 32, 0.4f, true, false);
|
||||
bullet.setTextureMode(TextureMode.Projected);
|
||||
bulletCollisionShape = new SphereCollisionShape(0.4f);
|
||||
|
||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());
|
||||
|
||||
// add ourselves as collision listener
|
||||
getPhysicsSpace().addCollisionListener(this);
|
||||
}
|
||||
|
||||
private PhysicsSpace getPhysicsSpace(){
|
||||
return bulletAppState.getPhysicsSpace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
//TODO: add update code
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simpleRender(RenderManager rm) {
|
||||
//TODO: add render code
|
||||
}
|
||||
|
||||
public void collision(PhysicsCollisionEvent event) {
|
||||
if ("Box".equals(event.getNodeA().getName()) || "Box".equals(event.getNodeB().getName())) {
|
||||
if ("bullet".equals(event.getNodeA().getName()) || "bullet".equals(event.getNodeB().getName())) {
|
||||
fpsText.setText("You hit the box!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class TestCollisionShapeFactory extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
createMaterial();
|
||||
|
||||
Node node = new Node("node1");
|
||||
|
@ -62,7 +62,7 @@ public class TestGhostObject extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
|
||||
// Mesh to be shared across several boxes.
|
||||
Box boxGeom = new Box(Vector3f.ZERO, 1f, 1f, 1f);
|
||||
|
@ -60,7 +60,7 @@ public class TestKinematicAddToPhysicsSpaceIssue extends SimpleApplication {
|
||||
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
// Add a physics sphere to the world
|
||||
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||
physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
|
||||
@ -69,7 +69,7 @@ public class TestKinematicAddToPhysicsSpaceIssue extends SimpleApplication {
|
||||
//Setting the rigidBody to kinematic before adding it to the physic space
|
||||
physicsSphere.getControl(RigidBodyControl.class).setKinematic(true);
|
||||
//adding it to the physic space
|
||||
getPhysicsSpace().add(physicsSphere);
|
||||
getPhysicsSpace().add(physicsSphere);
|
||||
//Making it not kinematic again, it should fall under gravity, it doesn't
|
||||
physicsSphere.getControl(RigidBodyControl.class).setKinematic(false);
|
||||
|
||||
@ -77,7 +77,7 @@ public class TestKinematicAddToPhysicsSpaceIssue extends SimpleApplication {
|
||||
Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||
physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(5, 6, 0));
|
||||
rootNode.attachChild(physicsSphere2);
|
||||
|
||||
|
||||
//Adding the rigid body to physic space
|
||||
getPhysicsSpace().add(physicsSphere2);
|
||||
//making it kinematic
|
||||
@ -85,7 +85,7 @@ public class TestKinematicAddToPhysicsSpaceIssue extends SimpleApplication {
|
||||
//Making it not kinematic again, it works properly, the rigidbody is affected by grvity.
|
||||
physicsSphere2.getControl(RigidBodyControl.class).setKinematic(false);
|
||||
|
||||
|
||||
|
||||
|
||||
// an obstacle mesh, does not move (mass=0)
|
||||
Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
|
||||
|
@ -59,7 +59,7 @@ public class TestLocalPhysics extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
|
||||
// Add a physics sphere to the world
|
||||
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||
|
@ -69,7 +69,7 @@ public class TestPhysicsCar extends SimpleApplication implements ActionListener
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||
setupKeys();
|
||||
buildPlayer();
|
||||
|
@ -76,7 +76,7 @@ public class TestPhysicsHingeJoint extends SimpleApplication implements AnalogLi
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
setupKeys();
|
||||
setupJoint();
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class TestPhysicsHingeJoint extends SimpleApplication implements AnalogLi
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
package jme3test.bullet;
|
||||
|
||||
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.bullet.BulletAppState;
|
||||
import com.jme3.bullet.collision.PhysicsCollisionObject;
|
||||
@ -16,30 +16,30 @@ import java.util.List;
|
||||
* @author @wezrule
|
||||
*/
|
||||
public class TestPhysicsRayCast extends SimpleApplication {
|
||||
|
||||
|
||||
private BulletAppState bulletAppState = new BulletAppState();
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestPhysicsRayCast().start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
stateManager.attach(bulletAppState);
|
||||
initCrossHair();
|
||||
|
||||
|
||||
Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
|
||||
s.setLocalScale(0.1f);
|
||||
|
||||
|
||||
CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s);
|
||||
Node n = new Node("elephant");
|
||||
n.addControl(new RigidBodyControl(collisionShape, 1));
|
||||
n.getControl(RigidBodyControl.class).setKinematic(true);
|
||||
bulletAppState.getPhysicsSpace().add(n);
|
||||
rootNode.attachChild(n);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
List<PhysicsRayTestResult> rayTest = bulletAppState.getPhysicsSpace().rayTest(cam.getLocation(), cam.getLocation().add(cam.getDirection()));
|
||||
@ -50,7 +50,7 @@ public class TestPhysicsRayCast extends SimpleApplication {
|
||||
fpsText.setText(collisionObject.getUserObject().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initCrossHair() {
|
||||
BitmapText bitmapText = new BitmapText(guiFont);
|
||||
bitmapText.setText("+");
|
||||
|
@ -69,7 +69,7 @@ public class TestPhysicsReadWrite extends SimpleApplication{
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
physicsRootNode=new Node("PhysicsRootNode");
|
||||
rootNode.attachChild(physicsRootNode);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class TestRagDoll extends SimpleApplication implements ActionListener {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
inputManager.addMapping("Pull ragdoll up", new MouseButtonTrigger(0));
|
||||
inputManager.addListener(this, "Pull ragdoll up");
|
||||
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
|
||||
|
@ -59,7 +59,7 @@ public class TestSimplePhysics extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
bulletAppState = new BulletAppState();
|
||||
stateManager.attach(bulletAppState);
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
|
||||
// Add a physics sphere to the world
|
||||
Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
|
||||
|
@ -35,7 +35,7 @@ public class TestSweepTest extends SimpleApplication {
|
||||
public void simpleInitApp() {
|
||||
obstacleCollisionShape = new CapsuleCollisionShape(0.3f, 0.5f);
|
||||
capsuleCollisionShape = new CapsuleCollisionShape(1f, 1f);
|
||||
|
||||
|
||||
stateManager.attach(bulletAppState);
|
||||
|
||||
capsule = new Node("capsule");
|
||||
@ -52,7 +52,7 @@ public class TestSweepTest extends SimpleApplication {
|
||||
bulletAppState.getPhysicsSpace().add(obstacle);
|
||||
rootNode.attachChild(obstacle);
|
||||
|
||||
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
|
||||
bulletAppState.setDebugEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +70,7 @@ public class TestSweepTest extends SimpleApplication {
|
||||
colliding = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!colliding) {
|
||||
// if the sweep is clear then move the spatial
|
||||
capsule.move(move, 0, 0);
|
||||
|
@ -2,7 +2,9 @@ INCLUDE com/jme3/asset/General.cfg
|
||||
|
||||
# IOS specific loaders
|
||||
LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3m, j3md
|
||||
LOADER com.jme3.audio.plugins.OGGLoader : ogg
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3m
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3md
|
||||
LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
|
||||
LOADER com.jme3.export.binary.BinaryImporter : j3o
|
||||
LOADER com.jme3.font.plugins.BitmapFontLoader : fnt
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,576 +0,0 @@
|
||||
package com.jme3.renderer.ios;
|
||||
|
||||
//import android.graphics.Bitmap;
|
||||
//import android.opengl.ETC1;
|
||||
//import android.opengl.ETC1Util.ETC1Texture;
|
||||
//import android.opengl.JmeIosGLES;
|
||||
//import android.opengl.GLUtils;
|
||||
//import com.jme3.asset.AndroidImageInfo;
|
||||
import com.jme3.renderer.ios.JmeIosGLES;
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.renderer.RendererException;
|
||||
import com.jme3.texture.Image;
|
||||
import com.jme3.texture.Image.Format;
|
||||
import com.jme3.util.BufferUtils;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TextureUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TextureUtil.class.getName());
|
||||
//TODO Make this configurable through appSettings
|
||||
public static boolean ENABLE_COMPRESSION = true;
|
||||
private static boolean NPOT = false;
|
||||
private static boolean ETC1support = false;
|
||||
private static boolean DXT1 = false;
|
||||
private static boolean PVRTC = false;
|
||||
private static boolean DEPTH24_STENCIL8 = false;
|
||||
private static boolean DEPTH_TEXTURE = false;
|
||||
private static boolean RGBA8 = false;
|
||||
|
||||
// Same constant used by both GL_ARM_rgba8 and GL_OES_rgb8_rgba8.
|
||||
private static final int GL_RGBA8 = 0x8058;
|
||||
|
||||
private static final int GL_DXT1 = 0x83F0;
|
||||
private static final int GL_DXT1A = 0x83F1;
|
||||
|
||||
private static final int GL_DEPTH_STENCIL_OES = 0x84F9;
|
||||
private static final int GL_UNSIGNED_INT_24_8_OES = 0x84FA;
|
||||
private static final int GL_DEPTH24_STENCIL8_OES = 0x88F0;
|
||||
|
||||
public static void loadTextureFeatures(String extensionString) {
|
||||
ETC1support = extensionString.contains("GL_OES_compressed_ETC1_RGB8_texture");
|
||||
DEPTH24_STENCIL8 = extensionString.contains("GL_OES_packed_depth_stencil");
|
||||
NPOT = extensionString.contains("GL_IMG_texture_npot")
|
||||
|| extensionString.contains("GL_OES_texture_npot")
|
||||
|| extensionString.contains("GL_NV_texture_npot_2D_mipmap");
|
||||
|
||||
PVRTC = extensionString.contains("GL_IMG_texture_compression_pvrtc");
|
||||
|
||||
DXT1 = extensionString.contains("GL_EXT_texture_compression_dxt1");
|
||||
DEPTH_TEXTURE = extensionString.contains("GL_OES_depth_texture");
|
||||
|
||||
RGBA8 = extensionString.contains("GL_ARM_rgba8") ||
|
||||
extensionString.contains("GL_OES_rgb8_rgba8");
|
||||
|
||||
logger.log(Level.FINE, "Supports ETC1? {0}", ETC1support);
|
||||
logger.log(Level.FINE, "Supports DEPTH24_STENCIL8? {0}", DEPTH24_STENCIL8);
|
||||
logger.log(Level.FINE, "Supports NPOT? {0}", NPOT);
|
||||
logger.log(Level.FINE, "Supports PVRTC? {0}", PVRTC);
|
||||
logger.log(Level.FINE, "Supports DXT1? {0}", DXT1);
|
||||
logger.log(Level.FINE, "Supports DEPTH_TEXTURE? {0}", DEPTH_TEXTURE);
|
||||
logger.log(Level.FINE, "Supports RGBA8? {0}", RGBA8);
|
||||
}
|
||||
|
||||
/*
|
||||
private static void buildMipmap(Bitmap bitmap, boolean compress) {
|
||||
int level = 0;
|
||||
int height = bitmap.getHeight();
|
||||
int width = bitmap.getWidth();
|
||||
|
||||
logger.log(Level.FINEST, " - Generating mipmaps for bitmap using SOFTWARE");
|
||||
|
||||
JmeIosGLES.glPixelStorei(JmeIosGLES.GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
while (height >= 1 || width >= 1) {
|
||||
//First of all, generate the texture from our bitmap and set it to the according level
|
||||
if (compress) {
|
||||
logger.log(Level.FINEST, " - Uploading LOD level {0} ({1}x{2}) with compression.", new Object[]{level, width, height});
|
||||
uploadBitmapAsCompressed(JmeIosGLES.GL_TEXTURE_2D, level, bitmap, false, 0, 0);
|
||||
} else {
|
||||
logger.log(Level.FINEST, " - Uploading LOD level {0} ({1}x{2}) directly.", new Object[]{level, width, height});
|
||||
GLUtils.texImage2D(JmeIosGLES.GL_TEXTURE_2D, level, bitmap, 0);
|
||||
}
|
||||
|
||||
if (height == 1 || width == 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
//Increase the mipmap level
|
||||
height /= 2;
|
||||
width /= 2;
|
||||
Bitmap bitmap2 = Bitmap.createScaledBitmap(bitmap, width, height, true);
|
||||
|
||||
// Recycle any bitmaps created as a result of scaling the bitmap.
|
||||
// Do not recycle the original image (mipmap level 0)
|
||||
if (level != 0) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
|
||||
bitmap = bitmap2;
|
||||
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void uploadBitmapAsCompressed(int target, int level, Bitmap bitmap, boolean subTexture, int x, int y) {
|
||||
if (bitmap.hasAlpha()) {
|
||||
logger.log(Level.FINEST, " - Uploading bitmap directly. Cannot compress as alpha present.");
|
||||
if (subTexture) {
|
||||
GLUtils.texSubImage2D(target, level, x, y, bitmap);
|
||||
JmeIosGLES.checkGLError();
|
||||
} else {
|
||||
GLUtils.texImage2D(target, level, bitmap, 0);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
} else {
|
||||
// Convert to RGB565
|
||||
int bytesPerPixel = 2;
|
||||
Bitmap rgb565 = bitmap.copy(Bitmap.Config.RGB_565, true);
|
||||
|
||||
// Put texture data into ByteBuffer
|
||||
ByteBuffer inputImage = BufferUtils.createByteBuffer(bitmap.getRowBytes() * bitmap.getHeight());
|
||||
rgb565.copyPixelsToBuffer(inputImage);
|
||||
inputImage.position(0);
|
||||
|
||||
// Delete the copied RGB565 image
|
||||
rgb565.recycle();
|
||||
|
||||
// Encode the image into the output bytebuffer
|
||||
int encodedImageSize = ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight());
|
||||
ByteBuffer compressedImage = BufferUtils.createByteBuffer(encodedImageSize);
|
||||
ETC1.encodeImage(inputImage, bitmap.getWidth(),
|
||||
bitmap.getHeight(),
|
||||
bytesPerPixel,
|
||||
bytesPerPixel * bitmap.getWidth(),
|
||||
compressedImage);
|
||||
|
||||
// Delete the input image buffer
|
||||
BufferUtils.destroyDirectBuffer(inputImage);
|
||||
|
||||
// Create an ETC1Texture from the compressed image data
|
||||
ETC1Texture etc1tex = new ETC1Texture(bitmap.getWidth(), bitmap.getHeight(), compressedImage);
|
||||
|
||||
// Upload the ETC1Texture
|
||||
if (bytesPerPixel == 2) {
|
||||
int oldSize = (bitmap.getRowBytes() * bitmap.getHeight());
|
||||
int newSize = compressedImage.capacity();
|
||||
logger.log(Level.FINEST, " - Uploading compressed image to GL, oldSize = {0}, newSize = {1}, ratio = {2}", new Object[]{oldSize, newSize, (float) oldSize / newSize});
|
||||
if (subTexture) {
|
||||
JmeIosGLES.glCompressedTexSubImage2D(target,
|
||||
level,
|
||||
x, y,
|
||||
bitmap.getWidth(),
|
||||
bitmap.getHeight(),
|
||||
ETC1.ETC1_RGB8_OES,
|
||||
etc1tex.getData().capacity(),
|
||||
etc1tex.getData());
|
||||
|
||||
JmeIosGLES.checkGLError();
|
||||
} else {
|
||||
JmeIosGLES.glCompressedTexImage2D(target,
|
||||
level,
|
||||
ETC1.ETC1_RGB8_OES,
|
||||
bitmap.getWidth(),
|
||||
bitmap.getHeight(),
|
||||
0,
|
||||
etc1tex.getData().capacity(),
|
||||
etc1tex.getData());
|
||||
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
|
||||
// ETC1Util.loadTexture(target, level, 0, JmeIosGLES.GL_RGB,
|
||||
// JmeIosGLES.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
|
||||
// } else if (bytesPerPixel == 3) {
|
||||
// ETC1Util.loadTexture(target, level, 0, JmeIosGLES.GL_RGB,
|
||||
// JmeIosGLES.GL_UNSIGNED_BYTE, etc1Texture);
|
||||
}
|
||||
|
||||
BufferUtils.destroyDirectBuffer(compressedImage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>uploadTextureBitmap</code> uploads a native android bitmap
|
||||
*/
|
||||
/*
|
||||
public static void uploadTextureBitmap(final int target, Bitmap bitmap, boolean needMips) {
|
||||
uploadTextureBitmap(target, bitmap, needMips, false, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>uploadTextureBitmap</code> uploads a native android bitmap
|
||||
*/
|
||||
/*
|
||||
public static void uploadTextureBitmap(final int target, Bitmap bitmap, boolean needMips, boolean subTexture, int x, int y) {
|
||||
boolean recycleBitmap = false;
|
||||
//TODO, maybe this should raise an exception when NPOT is not supported
|
||||
|
||||
boolean willCompress = ENABLE_COMPRESSION && ETC1support && !bitmap.hasAlpha();
|
||||
if (needMips && willCompress) {
|
||||
// Image is compressed and mipmaps are desired, generate them
|
||||
// using software.
|
||||
buildMipmap(bitmap, willCompress);
|
||||
} else {
|
||||
if (willCompress) {
|
||||
// Image is compressed but mipmaps are not desired, upload directly.
|
||||
logger.log(Level.FINEST, " - Uploading compressed bitmap. Mipmaps are not generated.");
|
||||
uploadBitmapAsCompressed(target, 0, bitmap, subTexture, x, y);
|
||||
|
||||
} else {
|
||||
// Image is not compressed, mipmaps may or may not be desired.
|
||||
logger.log(Level.FINEST, " - Uploading bitmap directly.{0}",
|
||||
(needMips
|
||||
? " Mipmaps will be generated in HARDWARE"
|
||||
: " Mipmaps are not generated."));
|
||||
if (subTexture) {
|
||||
System.err.println("x : " + x + " y :" + y + " , " + bitmap.getWidth() + "/" + bitmap.getHeight());
|
||||
GLUtils.texSubImage2D(target, 0, x, y, bitmap);
|
||||
JmeIosGLES.checkGLError();
|
||||
} else {
|
||||
GLUtils.texImage2D(target, 0, bitmap, 0);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
|
||||
if (needMips) {
|
||||
// No pregenerated mips available,
|
||||
// generate from base level if required
|
||||
JmeIosGLES.glGenerateMipmap(target);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recycleBitmap) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static void uploadTextureAny(Image img, int target, int index, boolean needMips) {
|
||||
/*
|
||||
if (img.getEfficentData() instanceof AndroidImageInfo) {
|
||||
logger.log(Level.FINEST, " === Uploading image {0}. Using BITMAP PATH === ", img);
|
||||
// If image was loaded from asset manager, use fast path
|
||||
AndroidImageInfo imageInfo = (AndroidImageInfo) img.getEfficentData();
|
||||
uploadTextureBitmap(target, imageInfo.getBitmap(), needMips);
|
||||
} else {
|
||||
*/
|
||||
logger.log(Level.FINEST, " === Uploading image {0}. Using BUFFER PATH === ", img);
|
||||
boolean wantGeneratedMips = needMips && !img.hasMipmaps();
|
||||
if (wantGeneratedMips && img.getFormat().isCompressed()) {
|
||||
logger.log(Level.WARNING, "Generating mipmaps is only"
|
||||
+ " supported for Bitmap based or non-compressed images!");
|
||||
}
|
||||
|
||||
// Upload using slower path
|
||||
logger.log(Level.FINEST, " - Uploading bitmap directly.{0}",
|
||||
(wantGeneratedMips
|
||||
? " Mipmaps will be generated in HARDWARE"
|
||||
: " Mipmaps are not generated."));
|
||||
|
||||
uploadTexture(img, target, index);
|
||||
|
||||
// Image was uploaded using slower path, since it is not compressed,
|
||||
// then compress it
|
||||
if (wantGeneratedMips) {
|
||||
// No pregenerated mips available,
|
||||
// generate from base level if required
|
||||
JmeIosGLES.glGenerateMipmap(target);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
private static void unsupportedFormat(Format fmt) {
|
||||
throw new UnsupportedOperationException("The image format '" + fmt + "' is unsupported by the video hardware.");
|
||||
}
|
||||
|
||||
public static IosGLImageFormat getImageFormat(Format fmt) throws UnsupportedOperationException {
|
||||
IosGLImageFormat imageFormat = new IosGLImageFormat();
|
||||
switch (fmt) {
|
||||
case Depth32:
|
||||
case Depth32F:
|
||||
throw new UnsupportedOperationException("The image format '"
|
||||
+ fmt + "' is not supported by OpenGL ES 2.0 specification.");
|
||||
case Alpha8:
|
||||
imageFormat.format = JmeIosGLES.GL_ALPHA;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
// Highest precision alpha supported by vanilla OGLES2
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGBA4;
|
||||
}
|
||||
break;
|
||||
case Luminance8:
|
||||
imageFormat.format = JmeIosGLES.GL_LUMINANCE;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
// Highest precision luminance supported by vanilla OGLES2
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGB565;
|
||||
}
|
||||
break;
|
||||
case Luminance8Alpha8:
|
||||
imageFormat.format = JmeIosGLES.GL_LUMINANCE_ALPHA;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGBA4;
|
||||
}
|
||||
break;
|
||||
case RGB565:
|
||||
imageFormat.format = JmeIosGLES.GL_RGB;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_SHORT_5_6_5;
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGB565;
|
||||
break;
|
||||
case RGB5A1:
|
||||
imageFormat.format = JmeIosGLES.GL_RGBA;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGB5_A1;
|
||||
break;
|
||||
case RGB8:
|
||||
imageFormat.format = JmeIosGLES.GL_RGB;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
// Fallback: Use RGB565 if RGBA8 is not available.
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGB565;
|
||||
}
|
||||
break;
|
||||
case BGR8:
|
||||
imageFormat.format = JmeIosGLES.GL_RGB;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGB565;
|
||||
}
|
||||
break;
|
||||
case RGBA8:
|
||||
imageFormat.format = JmeIosGLES.GL_RGBA;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
if (RGBA8) {
|
||||
imageFormat.renderBufferStorageFormat = GL_RGBA8;
|
||||
} else {
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_RGBA4;
|
||||
}
|
||||
break;
|
||||
case Depth:
|
||||
case Depth16:
|
||||
if (!DEPTH_TEXTURE) {
|
||||
unsupportedFormat(fmt);
|
||||
}
|
||||
imageFormat.format = JmeIosGLES.GL_DEPTH_COMPONENT;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_SHORT;
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_DEPTH_COMPONENT16;
|
||||
break;
|
||||
case Depth24:
|
||||
case Depth24Stencil8:
|
||||
if (!DEPTH_TEXTURE) {
|
||||
unsupportedFormat(fmt);
|
||||
}
|
||||
if (DEPTH24_STENCIL8) {
|
||||
// NEW: True Depth24 + Stencil8 format.
|
||||
imageFormat.format = GL_DEPTH_STENCIL_OES;
|
||||
imageFormat.dataType = GL_UNSIGNED_INT_24_8_OES;
|
||||
imageFormat.renderBufferStorageFormat = GL_DEPTH24_STENCIL8_OES;
|
||||
} else {
|
||||
// Vanilla OGLES2, only Depth16 available.
|
||||
imageFormat.format = JmeIosGLES.GL_DEPTH_COMPONENT;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_SHORT;
|
||||
imageFormat.renderBufferStorageFormat = JmeIosGLES.GL_DEPTH_COMPONENT16;
|
||||
}
|
||||
break;
|
||||
case DXT1:
|
||||
if (!DXT1) {
|
||||
unsupportedFormat(fmt);
|
||||
}
|
||||
imageFormat.format = GL_DXT1;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
imageFormat.compress = true;
|
||||
break;
|
||||
case DXT1A:
|
||||
if (!DXT1) {
|
||||
unsupportedFormat(fmt);
|
||||
}
|
||||
imageFormat.format = GL_DXT1A;
|
||||
imageFormat.dataType = JmeIosGLES.GL_UNSIGNED_BYTE;
|
||||
imageFormat.compress = true;
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unrecognized format: " + fmt);
|
||||
}
|
||||
return imageFormat;
|
||||
}
|
||||
|
||||
public static class IosGLImageFormat {
|
||||
|
||||
boolean compress = false;
|
||||
int format = -1;
|
||||
int renderBufferStorageFormat = -1;
|
||||
int dataType = -1;
|
||||
}
|
||||
|
||||
private static void uploadTexture(Image img,
|
||||
int target,
|
||||
int index) {
|
||||
|
||||
/*
|
||||
if (img.getEfficentData() instanceof AndroidImageInfo) {
|
||||
throw new RendererException("This image uses efficient data. "
|
||||
+ "Use uploadTextureBitmap instead.");
|
||||
}
|
||||
*/
|
||||
|
||||
// Otherwise upload image directly.
|
||||
// Prefer to only use power of 2 textures here to avoid errors.
|
||||
Image.Format fmt = img.getFormat();
|
||||
ByteBuffer data;
|
||||
if (index >= 0 || img.getData() != null && img.getData().size() > 0) {
|
||||
data = img.getData(index);
|
||||
} else {
|
||||
data = null;
|
||||
}
|
||||
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
|
||||
if (!NPOT && img.isNPOT()) {
|
||||
// Check if texture is POT
|
||||
throw new RendererException("Non-power-of-2 textures "
|
||||
+ "are not supported by the video hardware "
|
||||
+ "and no scaling path available for image: " + img);
|
||||
}
|
||||
IosGLImageFormat imageFormat = getImageFormat(fmt);
|
||||
|
||||
if (data != null) {
|
||||
JmeIosGLES.glPixelStorei(JmeIosGLES.GL_UNPACK_ALIGNMENT, 1);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
|
||||
int[] mipSizes = img.getMipMapSizes();
|
||||
int pos = 0;
|
||||
if (mipSizes == null) {
|
||||
if (data != null) {
|
||||
mipSizes = new int[]{data.capacity()};
|
||||
} else {
|
||||
mipSizes = new int[]{width * height * fmt.getBitsPerPixel() / 8};
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mipSizes.length; i++) {
|
||||
int mipWidth = Math.max(1, width >> i);
|
||||
int mipHeight = Math.max(1, height >> i);
|
||||
|
||||
if (data != null) {
|
||||
data.position(pos);
|
||||
data.limit(pos + mipSizes[i]);
|
||||
}
|
||||
|
||||
if (imageFormat.compress && data != null) {
|
||||
JmeIosGLES.glCompressedTexImage2D(target,
|
||||
i,
|
||||
imageFormat.format,
|
||||
mipWidth,
|
||||
mipHeight,
|
||||
0,
|
||||
data.remaining(),
|
||||
data);
|
||||
} else {
|
||||
JmeIosGLES.glTexImage2D(target,
|
||||
i,
|
||||
imageFormat.format,
|
||||
mipWidth,
|
||||
mipHeight,
|
||||
0,
|
||||
imageFormat.format,
|
||||
imageFormat.dataType,
|
||||
data);
|
||||
}
|
||||
JmeIosGLES.checkGLError();
|
||||
|
||||
pos += mipSizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the texture currently bound to target at with data from the given
|
||||
* Image at position x and y. The parameter index is used as the zoffset in
|
||||
* case a 3d texture or texture 2d array is being updated.
|
||||
*
|
||||
* @param image Image with the source data (this data will be put into the
|
||||
* texture)
|
||||
* @param target the target texture
|
||||
* @param index the mipmap level to update
|
||||
* @param x the x position where to put the image in the texture
|
||||
* @param y the y position where to put the image in the texture
|
||||
*/
|
||||
public static void uploadSubTexture(
|
||||
Image img,
|
||||
int target,
|
||||
int index,
|
||||
int x,
|
||||
int y) {
|
||||
//TODO:
|
||||
/*
|
||||
if (img.getEfficentData() instanceof AndroidImageInfo) {
|
||||
AndroidImageInfo imageInfo = (AndroidImageInfo) img.getEfficentData();
|
||||
uploadTextureBitmap(target, imageInfo.getBitmap(), true, true, x, y);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
// Otherwise upload image directly.
|
||||
// Prefer to only use power of 2 textures here to avoid errors.
|
||||
Image.Format fmt = img.getFormat();
|
||||
ByteBuffer data;
|
||||
if (index >= 0 || img.getData() != null && img.getData().size() > 0) {
|
||||
data = img.getData(index);
|
||||
} else {
|
||||
data = null;
|
||||
}
|
||||
|
||||
int width = img.getWidth();
|
||||
int height = img.getHeight();
|
||||
|
||||
if (!NPOT && img.isNPOT()) {
|
||||
// Check if texture is POT
|
||||
throw new RendererException("Non-power-of-2 textures "
|
||||
+ "are not supported by the video hardware "
|
||||
+ "and no scaling path available for image: " + img);
|
||||
}
|
||||
IosGLImageFormat imageFormat = getImageFormat(fmt);
|
||||
|
||||
if (data != null) {
|
||||
JmeIosGLES.glPixelStorei(JmeIosGLES.GL_UNPACK_ALIGNMENT, 1);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
|
||||
int[] mipSizes = img.getMipMapSizes();
|
||||
int pos = 0;
|
||||
if (mipSizes == null) {
|
||||
if (data != null) {
|
||||
mipSizes = new int[]{data.capacity()};
|
||||
} else {
|
||||
mipSizes = new int[]{width * height * fmt.getBitsPerPixel() / 8};
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mipSizes.length; i++) {
|
||||
int mipWidth = Math.max(1, width >> i);
|
||||
int mipHeight = Math.max(1, height >> i);
|
||||
|
||||
if (data != null) {
|
||||
data.position(pos);
|
||||
data.limit(pos + mipSizes[i]);
|
||||
}
|
||||
|
||||
if (imageFormat.compress && data != null) {
|
||||
JmeIosGLES.glCompressedTexSubImage2D(target, i, x, y, mipWidth, mipHeight, imageFormat.format, data.remaining(), data);
|
||||
JmeIosGLES.checkGLError();
|
||||
} else {
|
||||
JmeIosGLES.glTexSubImage2D(target, i, x, y, mipWidth, mipHeight, imageFormat.format, imageFormat.dataType, data);
|
||||
JmeIosGLES.checkGLError();
|
||||
}
|
||||
|
||||
pos += mipSizes[i];
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ INCLUDE com/jme3/asset/General.cfg
|
||||
|
||||
# IOS specific loaders
|
||||
LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3m, j3md
|
||||
LOADER com.jme3.audio.plugins.OGGLoader : ogg
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3m
|
||||
LOADER com.jme3.material.plugins.J3MLoader : j3md
|
||||
LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
|
||||
LOADER com.jme3.export.binary.BinaryImporter : j3o
|
||||
LOADER com.jme3.font.plugins.BitmapFontLoader : fnt
|
||||
|
@ -142,7 +142,6 @@ public class PhysicsSpace {
|
||||
private javax.vecmath.Vector3f rayVec2 = new javax.vecmath.Vector3f();
|
||||
private com.bulletphysics.linearmath.Transform sweepTrans1 = new com.bulletphysics.linearmath.Transform(new javax.vecmath.Matrix3f());
|
||||
private com.bulletphysics.linearmath.Transform sweepTrans2 = new com.bulletphysics.linearmath.Transform(new javax.vecmath.Matrix3f());
|
||||
private AssetManager debugManager;
|
||||
|
||||
/**
|
||||
* Get the current PhysicsSpace <b>running on this thread</b><br/>
|
||||
@ -362,7 +361,7 @@ public class PhysicsSpace {
|
||||
eventFactory.recycle(physicsCollisionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <V> Future<V> enqueueOnThisThread(Callable<V> callable) {
|
||||
AppTask<V> task = new AppTask<V>(callable);
|
||||
System.out.println("created apptask");
|
||||
@ -620,7 +619,7 @@ public class PhysicsSpace {
|
||||
physicsJoints.remove(joint.getObjectId());
|
||||
dynamicsWorld.removeConstraint(joint.getObjectId());
|
||||
}
|
||||
|
||||
|
||||
public Collection<PhysicsRigidBody> getRigidBodyList(){
|
||||
return new LinkedList<PhysicsRigidBody>(physicsBodies.values());
|
||||
}
|
||||
@ -628,19 +627,19 @@ public class PhysicsSpace {
|
||||
public Collection<PhysicsGhostObject> getGhostObjectList(){
|
||||
return new LinkedList<PhysicsGhostObject>(physicsGhostObjects.values());
|
||||
}
|
||||
|
||||
|
||||
public Collection<PhysicsCharacter> getCharacterList(){
|
||||
return new LinkedList<PhysicsCharacter>(physicsCharacters.values());
|
||||
}
|
||||
|
||||
|
||||
public Collection<PhysicsJoint> getJointList(){
|
||||
return new LinkedList<PhysicsJoint>(physicsJoints.values());
|
||||
}
|
||||
|
||||
|
||||
public Collection<PhysicsVehicle> getVehicleList(){
|
||||
return new LinkedList<PhysicsVehicle>(physicsVehicles.values());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the gravity of the PhysicsSpace, set before adding physics objects!
|
||||
* @param gravity
|
||||
@ -658,7 +657,7 @@ public class PhysicsSpace {
|
||||
dynamicsWorld.getGravity(tempVec);
|
||||
return Converter.convert(tempVec, gravity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* applies gravity value to all objects
|
||||
*/
|
||||
@ -876,30 +875,22 @@ public class PhysicsSpace {
|
||||
public void setWorldMax(Vector3f worldMax) {
|
||||
this.worldMax.set(worldMax);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable debug display for physics.
|
||||
*
|
||||
* @deprecated in favor of BulletDebugAppState, use
|
||||
* <code>BulletAppState.setDebugEnabled(boolean)</code> to add automatically
|
||||
* @param manager AssetManager to use to create debug materials
|
||||
* Set the number of iterations used by the contact solver.
|
||||
*
|
||||
* The default is 10. Use 4 for low quality, 20 for high quality.
|
||||
*
|
||||
* @param numIterations The number of iterations used by the contact & constraint solver.
|
||||
*/
|
||||
@Deprecated
|
||||
public void enableDebug(AssetManager manager) {
|
||||
debugManager = manager;
|
||||
public void setSolverNumIterations(int numIterations) {
|
||||
dynamicsWorld.getSolverInfo().numIterations = numIterations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug display
|
||||
*/
|
||||
public void disableDebug() {
|
||||
debugManager = null;
|
||||
public int getSolverNumIterations() {
|
||||
return dynamicsWorld.getSolverInfo().numIterations;
|
||||
}
|
||||
|
||||
public AssetManager getDebugManager() {
|
||||
return debugManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* interface with Broadphase types
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ task checkPlatformConfig {
|
||||
def platformFile = file("nbproject/private/platform-private.properties")
|
||||
if(!platformFile.exists()){
|
||||
def netbeansFolder = file("../netbeans")
|
||||
if(!netbeansFolder.exists()){
|
||||
if(!netbeansFolder.exists() || netbeansFolder.list().length == 0){
|
||||
println "Downloading NetBeans Platform base, this only has to be done once.."
|
||||
def f = file("netbeans.zip")
|
||||
new URL(netbeansUrl).withInputStream{ i -> f.withOutputStream{ it << i }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user