Merge pull request #7 from jMonkeyEngine/master
Merge branch "jmonkeyengine/master" into "sdk_scenecomposer"experimental
commit
a111817457
@ -0,0 +1,13 @@ |
|||||||
|
apply plugin: 'com.android.application' |
||||||
|
|
||||||
|
group = 'com.jme3' |
||||||
|
version = jmeVersion + '-' + jmeVersionTag |
||||||
|
|
||||||
|
sourceCompatibility = '1.6' |
||||||
|
|
||||||
|
repositories { |
||||||
|
mavenCentral() |
||||||
|
maven { |
||||||
|
url "http://nifty-gui.sourceforge.net/nifty-maven-repo" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
dependencies { |
||||||
|
compile project(':jme3-core') |
||||||
|
compile project(':jme3-android') |
||||||
|
compile project(':jme3-effects') |
||||||
|
compile project(':jme3-bullet') |
||||||
|
compile project(':jme3-bullet-native-android') |
||||||
|
compile project(':jme3-networking') |
||||||
|
compile project(':jme3-niftygui') |
||||||
|
compile project(':jme3-plugins') |
||||||
|
compile project(':jme3-terrain') |
||||||
|
compile project(':jme3-testdata') |
||||||
|
} |
||||||
|
|
||||||
|
android { |
||||||
|
compileSdkVersion 10 |
||||||
|
buildToolsVersion "22.0.1" |
||||||
|
|
||||||
|
lintOptions { |
||||||
|
// Fix nifty gui referencing "java.awt" package. |
||||||
|
disable 'InvalidPackage' |
||||||
|
} |
||||||
|
|
||||||
|
defaultConfig { |
||||||
|
applicationId "com.jme3.android" |
||||||
|
minSdkVersion 10 // Android 2.3 GINGERBREAD |
||||||
|
targetSdkVersion 22 // Android 5.1 LOLLIPOP |
||||||
|
versionCode 1 |
||||||
|
versionName "1.0" // TODO: from settings.gradle |
||||||
|
} |
||||||
|
|
||||||
|
buildTypes { |
||||||
|
release { |
||||||
|
minifyEnabled false |
||||||
|
} |
||||||
|
debug { |
||||||
|
applicationIdSuffix ".debug" |
||||||
|
debuggable true |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
package="com.jme3.android"> |
||||||
|
|
||||||
|
<!-- Tell the system that you need ES 2.0. --> |
||||||
|
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> |
||||||
|
|
||||||
|
<!-- Tell the system that you need distinct touches (for the zoom gesture). --> |
||||||
|
<uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="true" /> |
||||||
|
|
||||||
|
<application android:label="@string/app_name" android:allowBackup="true"> |
||||||
|
<activity android:name="jme3test.android.TestChooserAndroid" |
||||||
|
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> |
||||||
|
|
||||||
|
</manifest> |
@ -0,0 +1,12 @@ |
|||||||
|
package jme3test.android; |
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo; |
||||||
|
import android.app.*; |
||||||
|
import android.os.Bundle; |
||||||
|
|
||||||
|
public class TestChooserAndroid extends Activity { |
||||||
|
@Override |
||||||
|
public void onCreate(Bundle savedInstanceState) { |
||||||
|
super.onCreate(savedInstanceState); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<resources> |
||||||
|
<string name="app_name">JMEAndroidTest</string> |
||||||
|
<string name="about">About</string> |
||||||
|
<string name="quit">Quit</string> |
||||||
|
</resources> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,214 @@ |
|||||||
|
package com.jme3.scene.plugins.blender.math; |
||||||
|
|
||||||
|
import java.text.DecimalFormat; |
||||||
|
|
||||||
|
import org.ejml.ops.CommonOps; |
||||||
|
import org.ejml.simple.SimpleMatrix; |
||||||
|
import org.ejml.simple.SimpleSVD; |
||||||
|
|
||||||
|
import com.jme3.math.FastMath; |
||||||
|
|
||||||
|
/** |
||||||
|
* Encapsulates a 4x4 matrix |
||||||
|
* |
||||||
|
* |
||||||
|
*/ |
||||||
|
public class Matrix extends SimpleMatrix { |
||||||
|
private static final long serialVersionUID = 2396600537315902559L; |
||||||
|
|
||||||
|
public Matrix(int rows, int cols) { |
||||||
|
super(rows, cols); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Copy constructor |
||||||
|
*/ |
||||||
|
public Matrix(SimpleMatrix m) { |
||||||
|
super(m); |
||||||
|
} |
||||||
|
|
||||||
|
public Matrix(double[][] data) { |
||||||
|
super(data); |
||||||
|
} |
||||||
|
|
||||||
|
public static Matrix identity(int size) { |
||||||
|
Matrix result = new Matrix(size, size); |
||||||
|
CommonOps.setIdentity(result.mat); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public Matrix pseudoinverse() { |
||||||
|
return this.pseudoinverse(1); |
||||||
|
} |
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
public Matrix pseudoinverse(double lambda) { |
||||||
|
SimpleSVD<SimpleMatrix> simpleSVD = this.svd(); |
||||||
|
|
||||||
|
SimpleMatrix U = simpleSVD.getU(); |
||||||
|
SimpleMatrix S = simpleSVD.getW(); |
||||||
|
SimpleMatrix V = simpleSVD.getV(); |
||||||
|
|
||||||
|
int N = Math.min(this.numRows(),this.numCols()); |
||||||
|
double maxSingular = 0; |
||||||
|
for( int i = 0; i < N; ++i ) { |
||||||
|
if( S.get(i, i) > maxSingular ) { |
||||||
|
maxSingular = S.get(i, i); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
double tolerance = FastMath.DBL_EPSILON * Math.max(this.numRows(),this.numCols()) * maxSingular; |
||||||
|
for(int i=0;i<Math.min(S.numRows(), S.numCols());++i) { |
||||||
|
double a = S.get(i, i); |
||||||
|
if(a <= tolerance) { |
||||||
|
a = 0; |
||||||
|
} else { |
||||||
|
a = a/(a * a + lambda * lambda); |
||||||
|
} |
||||||
|
S.set(i, i, a); |
||||||
|
} |
||||||
|
return new Matrix(V.mult(S.transpose()).mult(U.transpose())); |
||||||
|
} |
||||||
|
|
||||||
|
public void setColumn(Vector3d col, int column) { |
||||||
|
this.setColumn(column, 0, col.x, col.y, col.z); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Just for some debug informations in order to compare the results with the scilab computation program. |
||||||
|
* @param name the name of the matrix |
||||||
|
* @param m the matrix to print out |
||||||
|
* @return the String format of the matrix to easily input it to Scilab |
||||||
|
*/ |
||||||
|
public String toScilabString(String name, SimpleMatrix m) { |
||||||
|
String result = name + " = ["; |
||||||
|
|
||||||
|
for(int i=0;i<m.numRows();++i) { |
||||||
|
for(int j=0;j<m.numCols();++j) { |
||||||
|
result += m.get(i, j) + " "; |
||||||
|
} |
||||||
|
result += ";"; |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return a String representation of the matrix |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
DecimalFormat df = new DecimalFormat("#.0000"); |
||||||
|
StringBuilder buf = new StringBuilder(); |
||||||
|
for (int r = 0; r < this.numRows(); ++r) { |
||||||
|
buf.append("\n| "); |
||||||
|
for (int c = 0; c < this.numCols(); ++c) { |
||||||
|
buf.append(df.format(this.get(r, c))).append(' '); |
||||||
|
} |
||||||
|
buf.append('|'); |
||||||
|
} |
||||||
|
return buf.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setTranslation(Vector3d translation) { |
||||||
|
this.setColumn(translation, 3); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets the scale. |
||||||
|
* |
||||||
|
* @param scale |
||||||
|
* the scale vector to set |
||||||
|
*/ |
||||||
|
public void setScale(Vector3d scale) { |
||||||
|
this.setScale(scale.x, scale.y, scale.z); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets the scale. |
||||||
|
* |
||||||
|
* @param x |
||||||
|
* the X scale |
||||||
|
* @param y |
||||||
|
* the Y scale |
||||||
|
* @param z |
||||||
|
* the Z scale |
||||||
|
*/ |
||||||
|
public void setScale(double x, double y, double z) { |
||||||
|
Vector3d vect1 = new Vector3d(this.get(0, 0), this.get(1, 0), this.get(2, 0)); |
||||||
|
vect1.normalizeLocal().multLocal(x); |
||||||
|
this.set(0, 0, vect1.x); |
||||||
|
this.set(1, 0, vect1.y); |
||||||
|
this.set(2, 0, vect1.z); |
||||||
|
|
||||||
|
vect1.set(this.get(0, 1), this.get(1, 1), this.get(2, 1)); |
||||||
|
vect1.normalizeLocal().multLocal(y); |
||||||
|
this.set(0, 1, vect1.x); |
||||||
|
this.set(1, 1, vect1.y); |
||||||
|
this.set(2, 1, vect1.z); |
||||||
|
|
||||||
|
vect1.set(this.get(0, 2), this.get(1, 2), this.get(2, 2)); |
||||||
|
vect1.normalizeLocal().multLocal(z); |
||||||
|
this.set(0, 2, vect1.x); |
||||||
|
this.set(1, 2, vect1.y); |
||||||
|
this.set(2, 2, vect1.z); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* <code>setRotationQuaternion</code> builds a rotation from a |
||||||
|
* <code>Quaternion</code>. |
||||||
|
* |
||||||
|
* @param quat |
||||||
|
* the quaternion to build the rotation from. |
||||||
|
* @throws NullPointerException |
||||||
|
* if quat is null. |
||||||
|
*/ |
||||||
|
public void setRotationQuaternion(DQuaternion quat) { |
||||||
|
quat.toRotationMatrix(this); |
||||||
|
} |
||||||
|
|
||||||
|
public DTransform toTransform() { |
||||||
|
DTransform result = new DTransform(); |
||||||
|
result.setTranslation(this.toTranslationVector()); |
||||||
|
result.setRotation(this.toRotationQuat()); |
||||||
|
result.setScale(this.toScaleVector()); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public Vector3d toTranslationVector() { |
||||||
|
return new Vector3d(this.get(0, 3), this.get(1, 3), this.get(2, 3)); |
||||||
|
} |
||||||
|
|
||||||
|
public DQuaternion toRotationQuat() { |
||||||
|
DQuaternion quat = new DQuaternion(); |
||||||
|
quat.fromRotationMatrix(this.get(0, 0), this.get(0, 1), this.get(0, 2), this.get(1, 0), this.get(1, 1), this.get(1, 2), this.get(2, 0), this.get(2, 1), this.get(2, 2)); |
||||||
|
return quat; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Retreives the scale vector from the matrix and stores it into a given |
||||||
|
* vector. |
||||||
|
* |
||||||
|
* @param the |
||||||
|
* vector where the scale will be stored |
||||||
|
*/ |
||||||
|
public Vector3d toScaleVector() { |
||||||
|
Vector3d result = new Vector3d(); |
||||||
|
this.toScaleVector(result); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Retreives the scale vector from the matrix and stores it into a given |
||||||
|
* vector. |
||||||
|
* |
||||||
|
* @param the |
||||||
|
* vector where the scale will be stored |
||||||
|
*/ |
||||||
|
public void toScaleVector(Vector3d vector) { |
||||||
|
double scaleX = Math.sqrt(this.get(0, 0) * this.get(0, 0) + this.get(1, 0) * this.get(1, 0) + this.get(2, 0) * this.get(2, 0)); |
||||||
|
double scaleY = Math.sqrt(this.get(0, 1) * this.get(0, 1) + this.get(1, 1) * this.get(1, 1) + this.get(2, 1) * this.get(2, 1)); |
||||||
|
double scaleZ = Math.sqrt(this.get(0, 2) * this.get(0, 2) + this.get(1, 2) * this.get(1, 2) + this.get(2, 2) * this.get(2, 2)); |
||||||
|
vector.set(scaleX, scaleY, scaleZ); |
||||||
|
} |
||||||
|
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,66 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2009-2015 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 com.jme3.system; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.Properties; |
||||||
|
import java.util.logging.Level; |
||||||
|
import java.util.logging.Logger; |
||||||
|
|
||||||
|
/** |
||||||
|
* Pulls in version info from the version.properties file. |
||||||
|
* |
||||||
|
* @author Kirill Vainer |
||||||
|
*/ |
||||||
|
public class JmeVersion { |
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(JmeVersion.class.getName()); |
||||||
|
private static final Properties props = new Properties(); |
||||||
|
|
||||||
|
static { |
||||||
|
try { |
||||||
|
props.load(JmeVersion.class.getResourceAsStream("version.properties")); |
||||||
|
} catch (IOException ex) { |
||||||
|
logger.log(Level.WARNING, "Unable to read version info!", ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static final String BUILD_DATE = props.getProperty("build.date", "1900-01-01"); |
||||||
|
public static final String BRANCH_NAME = props.getProperty("git.branch", "unknown"); |
||||||
|
public static final String GIT_HASH = props.getProperty("git.hash", ""); |
||||||
|
public static final String GIT_SHORT_HASH = props.getProperty("git.hash.short", ""); |
||||||
|
public static final String GIT_TAG = props.getProperty("git.tag", ""); |
||||||
|
public static final String VERSION_NUMBER = props.getProperty("version.number", ""); |
||||||
|
public static final String VERSION_TAG = props.getProperty("version.tag", ""); |
||||||
|
public static final String VERSION_FULL = props.getProperty("version.full", ""); |
||||||
|
public static final String FULL_NAME = props.getProperty("name.full", "jMonkeyEngine (unknown version)"); |
||||||
|
} |
@ -0,0 +1,140 @@ |
|||||||
|
/* |
||||||
|
* 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 com.jme3.util; |
||||||
|
|
||||||
|
import com.jme3.math.ColorRGBA; |
||||||
|
import com.jme3.math.FastMath; |
||||||
|
import com.jme3.texture.Image; |
||||||
|
import com.jme3.texture.Image.Format; |
||||||
|
import com.jme3.texture.image.ImageRaster; |
||||||
|
import java.nio.ByteBuffer; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
public class MipMapGenerator { |
||||||
|
|
||||||
|
private MipMapGenerator() { |
||||||
|
} |
||||||
|
|
||||||
|
public static Image scaleImage(Image inputImage, int outputWidth, int outputHeight) { |
||||||
|
int size = outputWidth * outputHeight * inputImage.getFormat().getBitsPerPixel() / 8; |
||||||
|
ByteBuffer buffer = BufferUtils.createByteBuffer(size); |
||||||
|
Image outputImage = new Image(inputImage.getFormat(), |
||||||
|
outputWidth, |
||||||
|
outputHeight, |
||||||
|
buffer, |
||||||
|
inputImage.getColorSpace()); |
||||||
|
|
||||||
|
ImageRaster input = ImageRaster.create(inputImage, 0, 0, false); |
||||||
|
ImageRaster output = ImageRaster.create(outputImage, 0, 0, false); |
||||||
|
|
||||||
|
float xRatio = ((float)(input.getWidth() - 1)) / output.getWidth(); |
||||||
|
float yRatio = ((float)(input.getHeight() - 1)) / output.getHeight(); |
||||||
|
|
||||||
|
ColorRGBA outputColor = new ColorRGBA(); |
||||||
|
ColorRGBA bottomLeft = new ColorRGBA(); |
||||||
|
ColorRGBA bottomRight = new ColorRGBA(); |
||||||
|
ColorRGBA topLeft = new ColorRGBA(); |
||||||
|
ColorRGBA topRight = new ColorRGBA(); |
||||||
|
|
||||||
|
for (int y = 0; y < outputHeight; y++) { |
||||||
|
for (int x = 0; x < outputWidth; x++) { |
||||||
|
float x2f = x * xRatio; |
||||||
|
float y2f = y * yRatio; |
||||||
|
|
||||||
|
int x2 = (int)x2f; |
||||||
|
int y2 = (int)y2f; |
||||||
|
|
||||||
|
float xDiff = x2f - x2; |
||||||
|
float yDiff = y2f - y2; |
||||||
|
|
||||||
|
input.getPixel(x2, y2, bottomLeft); |
||||||
|
input.getPixel(x2 + 1, y2, bottomRight); |
||||||
|
input.getPixel(x2, y2 + 1, topLeft); |
||||||
|
input.getPixel(x2 + 1, y2 + 1, topRight); |
||||||
|
|
||||||
|
bottomLeft.multLocal( (1f - xDiff) * (1f - yDiff) ); |
||||||
|
bottomRight.multLocal( (xDiff) * (1f - yDiff) ); |
||||||
|
topLeft.multLocal( (1f - xDiff) * (yDiff) ); |
||||||
|
topRight.multLocal( (xDiff) * (yDiff) ); |
||||||
|
|
||||||
|
outputColor.set(bottomLeft).addLocal(bottomRight) |
||||||
|
.addLocal(topLeft).addLocal(topRight); |
||||||
|
|
||||||
|
output.setPixel(x, y, outputColor); |
||||||
|
} |
||||||
|
} |
||||||
|
return outputImage; |
||||||
|
} |
||||||
|
|
||||||
|
public static Image resizeToPowerOf2(Image original){ |
||||||
|
int potWidth = FastMath.nearestPowerOfTwo(original.getWidth()); |
||||||
|
int potHeight = FastMath.nearestPowerOfTwo(original.getHeight()); |
||||||
|
return scaleImage(original, potWidth, potHeight); |
||||||
|
} |
||||||
|
|
||||||
|
public static void generateMipMaps(Image image){ |
||||||
|
int width = image.getWidth(); |
||||||
|
int height = image.getHeight(); |
||||||
|
|
||||||
|
Image current = image; |
||||||
|
ArrayList<ByteBuffer> output = new ArrayList<ByteBuffer>(); |
||||||
|
int totalSize = 0; |
||||||
|
|
||||||
|
while (height >= 1 || width >= 1){ |
||||||
|
output.add(current.getData(0)); |
||||||
|
totalSize += current.getData(0).capacity(); |
||||||
|
|
||||||
|
if (height == 1 || width == 1) { |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
height /= 2; |
||||||
|
width /= 2; |
||||||
|
|
||||||
|
current = scaleImage(current, width, height); |
||||||
|
} |
||||||
|
|
||||||
|
ByteBuffer combinedData = BufferUtils.createByteBuffer(totalSize); |
||||||
|
int[] mipSizes = new int[output.size()]; |
||||||
|
for (int i = 0; i < output.size(); i++){ |
||||||
|
ByteBuffer data = output.get(i); |
||||||
|
data.clear(); |
||||||
|
combinedData.put(data); |
||||||
|
mipSizes[i] = data.capacity(); |
||||||
|
} |
||||||
|
combinedData.flip(); |
||||||
|
|
||||||
|
// insert mip data into image
|
||||||
|
image.setData(0, combinedData); |
||||||
|
image.setMipMapSizes(mipSizes); |
||||||
|
} |
||||||
|
} |
@ -1,97 +1,121 @@ |
|||||||
MaterialDef UnshadedNodes { |
MaterialDef UnshadedNodes { |
||||||
|
|
||||||
MaterialParameters { |
MaterialParameters { |
||||||
Texture2D ColorMap |
Texture2D ColorMap |
||||||
Texture2D LightMap |
Texture2D LightMap |
||||||
Color Color (Color) |
Color Color (Color) |
||||||
Boolean VertexColor (UseVertexColor) |
Boolean VertexColor (UseVertexColor) |
||||||
Boolean SeparateTexCoord |
Boolean SeparateTexCoord |
||||||
|
|
||||||
// Alpha threshold for fragment discarding |
|
||||||
Float AlphaDiscardThreshold (AlphaTestFallOff) |
Float AlphaDiscardThreshold (AlphaTestFallOff) |
||||||
|
|
||||||
// For hardware skinning |
|
||||||
Int NumberOfBones |
Int NumberOfBones |
||||||
Matrix4Array BoneMatrices |
Matrix4Array BoneMatrices |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
Technique { |
Technique { |
||||||
|
|
||||||
WorldParameters { |
WorldParameters { |
||||||
WorldViewProjectionMatrix |
WorldViewProjectionMatrix |
||||||
//used for fog |
|
||||||
WorldViewMatrix |
WorldViewMatrix |
||||||
} |
} |
||||||
|
VertexShaderNodes { |
||||||
VertexShaderNodes{ |
ShaderNode GpuSkinning { |
||||||
ShaderNode GpuSkinning{ |
Definition : BasicGPUSkinning : Common/MatDefs/ShaderNodes/HardwareSkinning/HardwareSkinning.j3sn |
||||||
Definition: BasicGPUSkinning : Common/MatDefs/ShaderNodes/HardwareSkinning/HardwareSkinning.j3sn |
|
||||||
Condition : NumberOfBones |
Condition : NumberOfBones |
||||||
InputMapping{ |
InputMapping { |
||||||
modelPosition = Global.position; |
modelPosition = Global.position |
||||||
boneMatrices = MatParam.BoneMatrices |
boneMatrices = MatParam.BoneMatrices |
||||||
boneWeight = Attr.inHWBoneWeight |
boneWeight = Attr.inHWBoneWeight |
||||||
boneIndex = Attr.inHWBoneIndex |
boneIndex = Attr.inHWBoneIndex |
||||||
} |
} |
||||||
OutputMapping{ |
OutputMapping { |
||||||
Global.position = modModelPosition |
Global.position = modModelPosition |
||||||
} |
} |
||||||
} |
} |
||||||
ShaderNode UnshadedVert{ |
ShaderNode UnshadedVert { |
||||||
Definition: CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn |
Definition : CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn |
||||||
InputMapping{ |
InputMapping { |
||||||
worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix |
worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix |
||||||
modelPosition = Global.position.xyz |
modelPosition = Global.position.xyz |
||||||
texCoord1 = Attr.inTexCoord: ColorMap || (LightMap && !SeparateTexCoord) |
texCoord1 = Attr.inTexCoord : ColorMap || (LightMap && !SeparateTexCoord) |
||||||
texCoord2 = Attr.inTexCoord2: SeparateTexCoord |
texCoord2 = Attr.inTexCoord2 : SeparateTexCoord |
||||||
vertColor = Attr.inColor: VertexColor |
vertColor = Attr.inColor : VertexColor |
||||||
} |
} |
||||||
OutputMapping{ |
OutputMapping { |
||||||
Global.position = projPosition |
Global.position = projPosition |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
FragmentShaderNodes{ |
FragmentShaderNodes { |
||||||
ShaderNode UnshadedFrag{ |
ShaderNode MatColorMult { |
||||||
Definition: Unshaded : Common/MatDefs/ShaderNodes/Common/Unshaded.j3sn |
Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn |
||||||
InputMapping{ |
InputMappings { |
||||||
texCoord = UnshadedVert.texCoord1: ColorMap |
color1 = MatParam.Color |
||||||
vertColor = UnshadedVert.vertColor: VertexColor |
color2 = Global.outColor |
||||||
matColor = MatParam.Color: Color |
|
||||||
colorMap = MatParam.ColorMap: ColorMap |
|
||||||
color = Global.outColor |
|
||||||
} |
} |
||||||
OutputMapping{ |
OutputMappings { |
||||||
Global.outColor = color |
Global.outColor = outColor |
||||||
} |
} |
||||||
|
Condition : Color |
||||||
} |
} |
||||||
|
ShaderNode VertColorMult { |
||||||
ShaderNode AlphaDiscardThreshold{ |
Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn |
||||||
Definition: AlphaDiscard : Common/MatDefs/ShaderNodes/Basic/AlphaDiscard.j3sn |
InputMappings { |
||||||
|
color1 = UnshadedVert.vertColor |
||||||
|
color2 = Global.outColor |
||||||
|
} |
||||||
|
OutputMappings { |
||||||
|
Global.outColor = outColor |
||||||
|
} |
||||||
|
Condition : VertexColor |
||||||
|
} |
||||||
|
ShaderNode ColorMapTF { |
||||||
|
Definition : TextureFetch : Common/MatDefs/ShaderNodes/Basic/TextureFetch.j3sn |
||||||
|
InputMappings { |
||||||
|
texCoord = UnshadedVert.texCoord1 |
||||||
|
textureMap = MatParam.ColorMap |
||||||
|
} |
||||||
|
OutputMappings { |
||||||
|
} |
||||||
|
Condition : ColorMap |
||||||
|
} |
||||||
|
ShaderNode ColorMapMult { |
||||||
|
Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn |
||||||
|
InputMappings { |
||||||
|
color1 = ColorMapTF.outColor |
||||||
|
color2 = Global.outColor |
||||||
|
} |
||||||
|
OutputMappings { |
||||||
|
Global.outColor = outColor |
||||||
|
} |
||||||
|
Condition : ColorMap |
||||||
|
} |
||||||
|
ShaderNode AlphaDiscardThreshold { |
||||||
|
Definition : AlphaDiscard : Common/MatDefs/ShaderNodes/Basic/AlphaDiscard.j3sn |
||||||
Condition : AlphaDiscardThreshold |
Condition : AlphaDiscardThreshold |
||||||
InputMapping{ |
InputMapping { |
||||||
alpha = Global.outColor.a |
alpha = Global.outColor.a |
||||||
threshold = MatParam.AlphaDiscardThreshold |
threshold = MatParam.AlphaDiscardThreshold |
||||||
} |
} |
||||||
} |
} |
||||||
ShaderNode LightMap{ |
ShaderNode LightMapTF { |
||||||
Definition: LightMapping : Common/MatDefs/ShaderNodes/LightMapping/LightMapping.j3sn |
Definition : TextureFetch : Common/MatDefs/ShaderNodes/Basic/TextureFetch.j3sn |
||||||
Condition: LightMap |
InputMappings { |
||||||
InputMapping{ |
textureMap = MatParam.LightMap |
||||||
texCoord = UnshadedVert.texCoord1: !SeparateTexCoord |
texCoord = UnshadedVert.texCoord2 : SeparateTexCoord |
||||||
texCoord = UnshadedVert.texCoord2: SeparateTexCoord |
texCoord = UnshadedVert.texCoord1 : !SeparateTexCoord |
||||||
lightMap = MatParam.LightMap |
} |
||||||
color = Global.outColor |
OutputMappings { |
||||||
|
} |
||||||
|
Condition : LightMap |
||||||
|
} |
||||||
|
ShaderNode LightMapMult { |
||||||
|
Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn |
||||||
|
OutputMappings { |
||||||
|
Global.outColor = outColor |
||||||
} |
} |
||||||
OutputMapping{ |
InputMappings { |
||||||
Global.outColor = color |
color1 = LightMapTF.outColor |
||||||
|
color2 = Global.outColor |
||||||
} |
} |
||||||
|
Condition : LightMap |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
@ -1,3 +1,3 @@ |
|||||||
void main(){ |
void main(){ |
||||||
outColor = texture2D(texture,texCoord); |
outColor = texture2D(textureMap,texCoord); |
||||||
} |
} |
@ -0,0 +1,3 @@ |
|||||||
|
void main(){ |
||||||
|
outColor = texture(textureMap,texCoord); |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
#if defined _GL_ES_ |
||||||
|
# define hfloat highp float |
||||||
|
# define hvec2 highp vec2 |
||||||
|
# define hvec3 highp vec3 |
||||||
|
# define hvec4 highp vec4 |
||||||
|
# define lfloat lowp float |
||||||
|
# define lvec2 lowp vec2 |
||||||
|
# define lvec3 lowp vec3 |
||||||
|
# define lvec4 lowp vec4 |
||||||
|
#else |
||||||
|
# define hfloat float |
||||||
|
# define hvec2 vec2 |
||||||
|
# define hvec3 vec3 |
||||||
|
# define hvec4 vec4 |
||||||
|
# define lfloat float |
||||||
|
# define lvec2 vec2 |
||||||
|
# define lvec3 vec3 |
||||||
|
# define lvec4 vec4 |
||||||
|
#endif |
||||||
|
|
||||||
|
#if __VERSION__ >= 130 |
||||||
|
out vec4 outFragColor; |
||||||
|
# define texture1D texture |
||||||
|
# define texture2D texture |
||||||
|
# define texture3D texture |
||||||
|
# define texture2DLod texture |
||||||
|
# if defined VERTEX_SHADER |
||||||
|
# define varying out |
||||||
|
# define attribute in |
||||||
|
# elif defined FRAGMENT_SHADER |
||||||
|
# define varying in |
||||||
|
# define gl_FragColor outFragColor |
||||||
|
# endif |
||||||
|
#endif |
@ -0,0 +1,11 @@ |
|||||||
|
# THIS IS AN AUTO-GENERATED FILE.. |
||||||
|
# DO NOT MODIFY! |
||||||
|
build.date=1900-01-01 |
||||||
|
git.revision=0 |
||||||
|
git.branch=unknown |
||||||
|
git.hash= |
||||||
|
git.hash.short= |
||||||
|
git.tag= |
||||||
|
name.full=jMonkeyEngine 3.1.0-UNKNOWN |
||||||
|
version.number=3.1.0 |
||||||
|
version.tag=SNAPSHOT |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue