J3O incompatibility issues fixed
* When loading models with SimpleTextured/WireColor/SolidColor materials * When loading Unshaded material with spelling error "SeperateTexCoord" instead of "SeparateTexCoord" * Also fixed issue with loading animated models git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7729 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
4dffbc95f5
commit
951d9fe23a
@ -5,6 +5,50 @@
|
|||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml"/>
|
||||||
<!-- <import file="nbproject/profiler-build-impl.xml"/> -->
|
<!-- <import file="nbproject/profiler-build-impl.xml"/> -->
|
||||||
|
|
||||||
|
<target depends="init" if="have.sources" name="-javadoc-build">
|
||||||
|
<mkdir dir="${dist.javadoc.dir}"/>
|
||||||
|
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||||
|
<classpath>
|
||||||
|
<path path="${javac.classpath}"/>
|
||||||
|
</classpath>
|
||||||
|
<fileset dir="${src.core.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/*.java"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.terrain.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.networking.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.desktop-fx.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.jbullet.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.niftygui.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.tools.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${src.xml.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||||
|
<include name="**/*.java"/>
|
||||||
|
</fileset>
|
||||||
|
</javadoc>
|
||||||
|
<copy todir="${dist.javadoc.dir}">
|
||||||
|
<fileset dir="${src.core.dir}" excludes="${excludes}" includes="${includes}">
|
||||||
|
<filename name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||||
|
<include name="**/doc-files/**"/>
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="-post-compile" depends="-compile-bullet, -compile-android">
|
<target name="-post-compile" depends="-compile-bullet, -compile-android">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ jnlp.signed=true
|
|||||||
jnlp.signing=generated
|
jnlp.signing=generated
|
||||||
jnlp.signing.alias=
|
jnlp.signing.alias=
|
||||||
jnlp.signing.keystore=
|
jnlp.signing.keystore=
|
||||||
main.class=jme3test.TestChooser
|
main.class=jme3test.export.TestOgreConvert
|
||||||
manifest.file=MANIFEST.MF
|
manifest.file=MANIFEST.MF
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
mkdist.disabled=false
|
mkdist.disabled=false
|
||||||
@ -86,7 +86,7 @@ platform.active=default_platform
|
|||||||
run.classpath=\
|
run.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}
|
${build.classes.dir}
|
||||||
run.jvmargs=-Xms40m -Xmx40m -XX:MaxDirectMemorySize=256M
|
run.jvmargs=-Xms30m -Xmx30m -XX:MaxDirectMemorySize=256M
|
||||||
run.test.classpath=\
|
run.test.classpath=\
|
||||||
${javac.test.classpath}:\
|
${javac.test.classpath}:\
|
||||||
${build.test.classes.dir}
|
${build.test.classes.dir}
|
||||||
|
@ -38,16 +38,16 @@ MaterialDef Phong Lighting {
|
|||||||
Boolean UseVertexColor
|
Boolean UseVertexColor
|
||||||
|
|
||||||
// Ambient color
|
// Ambient color
|
||||||
Color Ambient
|
Color Ambient : MaterialAmbient
|
||||||
|
|
||||||
// Diffuse color
|
// Diffuse color
|
||||||
Color Diffuse : Color
|
Color Diffuse : MaterialDiffuse
|
||||||
|
|
||||||
// Specular color
|
// Specular color
|
||||||
Color Specular
|
Color Specular : MaterialSpecular
|
||||||
|
|
||||||
// Specular power/shininess
|
// Specular power/shininess
|
||||||
Float Shininess
|
Float Shininess : MaterialShininess
|
||||||
|
|
||||||
// Diffuse map
|
// Diffuse map
|
||||||
Texture2D DiffuseMap
|
Texture2D DiffuseMap
|
||||||
|
@ -14,7 +14,7 @@ uniform vec4 m_Color;
|
|||||||
|
|
||||||
#ifdef HAS_LIGHTMAP
|
#ifdef HAS_LIGHTMAP
|
||||||
uniform sampler2D m_LightMap;
|
uniform sampler2D m_LightMap;
|
||||||
#ifdef SEPERATE_TEXCOORD
|
#ifdef SEPARATE_TEXCOORD
|
||||||
varying vec2 texCoord2;
|
varying vec2 texCoord2;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,6 +60,12 @@ public class AppTask<V> implements Future<V> {
|
|||||||
private final ReentrantLock stateLock = new ReentrantLock();
|
private final ReentrantLock stateLock = new ReentrantLock();
|
||||||
private final Condition finishedCondition = stateLock.newCondition();
|
private final Condition finishedCondition = stateLock.newCondition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an <code>AppTask</code> that will execute the given
|
||||||
|
* {@link Callable}.
|
||||||
|
*
|
||||||
|
* @param callable The callable to be executed
|
||||||
|
*/
|
||||||
public AppTask(Callable<V> callable) {
|
public AppTask(Callable<V> callable) {
|
||||||
this.callable = callable;
|
this.callable = callable;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ import com.jme3.input.JoyInput;
|
|||||||
import com.jme3.input.KeyInput;
|
import com.jme3.input.KeyInput;
|
||||||
import com.jme3.input.MouseInput;
|
import com.jme3.input.MouseInput;
|
||||||
import com.jme3.input.TouchInput;
|
import com.jme3.input.TouchInput;
|
||||||
import com.jme3.system.*;
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.Renderer;
|
import com.jme3.renderer.Renderer;
|
||||||
@ -47,6 +46,9 @@ import com.jme3.audio.Listener;
|
|||||||
import com.jme3.input.InputManager;
|
import com.jme3.input.InputManager;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.system.AppSettings;
|
||||||
|
import com.jme3.system.JmeCanvasContext;
|
||||||
|
import com.jme3.system.JmeContext;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
@ -54,6 +56,10 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import com.jme3.system.JmeContext.Type;
|
||||||
|
import com.jme3.system.JmeSystem;
|
||||||
|
import com.jme3.system.SystemListener;
|
||||||
|
import com.jme3.system.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>Application</code> class represents an instance of a
|
* The <code>Application</code> class represents an instance of a
|
||||||
@ -103,14 +109,36 @@ public class Application implements SystemListener {
|
|||||||
public Application(){
|
public Application(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if pause on lost focus is enabled, false otherwise.
|
||||||
|
*
|
||||||
|
* @return true if pause on lost focus is enabled
|
||||||
|
*
|
||||||
|
* @see #setPauseOnLostFocus(boolean)
|
||||||
|
*/
|
||||||
public boolean isPauseOnLostFocus() {
|
public boolean isPauseOnLostFocus() {
|
||||||
return pauseOnFocus;
|
return pauseOnFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable pause on lost focus.
|
||||||
|
* <p>
|
||||||
|
* By default, pause on lost focus is enabled.
|
||||||
|
* If enabled, the application will stop updating
|
||||||
|
* when it loses focus or becomes inactive (e.g. alt-tab).
|
||||||
|
* For online or real-time applications, this might not be preferable,
|
||||||
|
* so this feature should be set to disabled. For other applications,
|
||||||
|
* it is best to keep it on so that CPU usage is not used when
|
||||||
|
* not necessary.
|
||||||
|
*
|
||||||
|
* @param pauseOnLostFocus True to enable pause on lost focus, false
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
public void setPauseOnLostFocus(boolean pauseOnLostFocus) {
|
public void setPauseOnLostFocus(boolean pauseOnLostFocus) {
|
||||||
this.pauseOnFocus = pauseOnLostFocus;
|
this.pauseOnFocus = pauseOnLostFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setAssetManager(AssetManager assetManager){
|
public void setAssetManager(AssetManager assetManager){
|
||||||
if (this.assetManager != null)
|
if (this.assetManager != null)
|
||||||
throw new IllegalStateException("Can only set asset manager"
|
throw new IllegalStateException("Can only set asset manager"
|
||||||
@ -243,78 +271,80 @@ public class Application implements SystemListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The asset manager for this application.
|
* @return The {@link AssetManager asset manager} for this application.
|
||||||
*/
|
*/
|
||||||
public AssetManager getAssetManager(){
|
public AssetManager getAssetManager(){
|
||||||
return assetManager;
|
return assetManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the input manager.
|
* @return the {@link InputManager input manager}.
|
||||||
*/
|
*/
|
||||||
public InputManager getInputManager(){
|
public InputManager getInputManager(){
|
||||||
return inputManager;
|
return inputManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the app state manager
|
* @return the {@link AppStateManager app state manager}
|
||||||
*/
|
*/
|
||||||
public AppStateManager getStateManager() {
|
public AppStateManager getStateManager() {
|
||||||
return stateManager;
|
return stateManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the render manager
|
* @return the {@link RenderManager render manager}
|
||||||
*/
|
*/
|
||||||
public RenderManager getRenderManager() {
|
public RenderManager getRenderManager() {
|
||||||
return renderManager;
|
return renderManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The renderer for the application, or null if was not started yet.
|
* @return The {@link Renderer renderer} for the application
|
||||||
*/
|
*/
|
||||||
public Renderer getRenderer(){
|
public Renderer getRenderer(){
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The audio renderer for the application, or null if was not started yet.
|
* @return The {@link AudioRenderer audio renderer} for the application
|
||||||
*/
|
*/
|
||||||
public AudioRenderer getAudioRenderer() {
|
public AudioRenderer getAudioRenderer() {
|
||||||
return audioRenderer;
|
return audioRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The listener object for audio
|
* @return The {@link Listener listener} object for audio
|
||||||
*/
|
*/
|
||||||
public Listener getListener() {
|
public Listener getListener() {
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The display context for the application, or null if was not
|
* @return The {@link JmeContext display context} for the application
|
||||||
* started yet.
|
|
||||||
*/
|
*/
|
||||||
public JmeContext getContext(){
|
public JmeContext getContext(){
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The camera for the application, or null if was not started yet.
|
* @return The {@link Camera camera} for the application
|
||||||
*/
|
*/
|
||||||
public Camera getCamera(){
|
public Camera getCamera(){
|
||||||
return cam;
|
return cam;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the application as a display.
|
* Starts the application in {@link Type#Display display} mode.
|
||||||
|
*
|
||||||
|
* @see #start(com.jme3.system.JmeContext.Type)
|
||||||
*/
|
*/
|
||||||
public void start(){
|
public void start(){
|
||||||
start(JmeContext.Type.Display);
|
start(JmeContext.Type.Display);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the application. Creating a rendering context and executing
|
* Starts the application.
|
||||||
|
* Creating a rendering context and executing
|
||||||
* the main loop in a separate thread.
|
* the main loop in a separate thread.
|
||||||
*/
|
*/
|
||||||
public void start(JmeContext.Type contextType){
|
public void start(JmeContext.Type contextType){
|
||||||
@ -333,6 +363,21 @@ public class Application implements SystemListener {
|
|||||||
context.create(false);
|
context.create(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the application's canvas for use.
|
||||||
|
* <p>
|
||||||
|
* After calling this method, cast the {@link #getContext() context} to
|
||||||
|
* {@link JmeCanvasContext},
|
||||||
|
* then acquire the canvas with {@link JmeCanvasContext#getCanvas() }
|
||||||
|
* and attach it to an AWT/Swing Frame.
|
||||||
|
* The rendering thread will start when the canvas becomes visible on
|
||||||
|
* screen, however if you wish to start the context immediately you
|
||||||
|
* may call {@link #startCanvas() } to force the rendering thread
|
||||||
|
* to start.
|
||||||
|
*
|
||||||
|
* @see JmeCanvasContext
|
||||||
|
* @see Type#Canvas
|
||||||
|
*/
|
||||||
public void createCanvas(){
|
public void createCanvas(){
|
||||||
if (context != null && context.isCreated()){
|
if (context != null && context.isCreated()){
|
||||||
logger.warning("createCanvas() called when application already created!");
|
logger.warning("createCanvas() called when application already created!");
|
||||||
@ -348,30 +393,66 @@ public class Application implements SystemListener {
|
|||||||
context.setSystemListener(this);
|
context.setSystemListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the rendering thread after createCanvas() has been called.
|
||||||
|
* <p>
|
||||||
|
* Same as calling startCanvas(false)
|
||||||
|
*
|
||||||
|
* @see #startCanvas(boolean)
|
||||||
|
*/
|
||||||
public void startCanvas(){
|
public void startCanvas(){
|
||||||
startCanvas(false);
|
startCanvas(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the rendering thread after createCanvas() has been called.
|
||||||
|
* <p>
|
||||||
|
* Calling this method is optional, the canvas will start automatically
|
||||||
|
* when it becomes visible.
|
||||||
|
*
|
||||||
|
* @param waitFor If true, the current thread will block until the
|
||||||
|
* rendering thread is running
|
||||||
|
*/
|
||||||
public void startCanvas(boolean waitFor){
|
public void startCanvas(boolean waitFor){
|
||||||
context.create(waitFor);
|
context.create(waitFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only.
|
||||||
|
*/
|
||||||
public void reshape(int w, int h){
|
public void reshape(int w, int h){
|
||||||
renderManager.notifyReshape(w, h);
|
renderManager.notifyReshape(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restarts the context, applying any changed settings.
|
||||||
|
* <p>
|
||||||
|
* Changes to the {@link AppSettings} of this Application are not
|
||||||
|
* applied immediately; calling this method forces the context
|
||||||
|
* to restart, applying the new settings.
|
||||||
|
*/
|
||||||
public void restart(){
|
public void restart(){
|
||||||
context.setSettings(settings);
|
context.setSettings(settings);
|
||||||
context.restart();
|
context.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Requests the context to close, shutting down the main loop
|
||||||
|
* and making necessary cleanup operations.
|
||||||
|
*
|
||||||
|
* Same as calling stop(false)
|
||||||
|
*
|
||||||
|
* @see #stop(boolean)
|
||||||
|
*/
|
||||||
public void stop(){
|
public void stop(){
|
||||||
stop(false);
|
stop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the display to close, shutting down the main loop
|
* Requests the context to close, shutting down the main loop
|
||||||
* and making neccessary cleanup operations.
|
* and making necessary cleanup operations.
|
||||||
|
* After the application has stopped, it cannot be used anymore.
|
||||||
*/
|
*/
|
||||||
public void stop(boolean waitFor){
|
public void stop(boolean waitFor){
|
||||||
logger.log(Level.FINE, "Closing application: {0}", getClass().getName());
|
logger.log(Level.FINE, "Closing application: {0}", getClass().getName());
|
||||||
@ -381,7 +462,7 @@ public class Application implements SystemListener {
|
|||||||
/**
|
/**
|
||||||
* Do not call manually.
|
* Do not call manually.
|
||||||
* Callback from ContextListener.
|
* Callback from ContextListener.
|
||||||
*
|
* <p>
|
||||||
* Initializes the <code>Application</code>, by creating a display and
|
* Initializes the <code>Application</code>, by creating a display and
|
||||||
* default camera. If display settings are not specified, a default
|
* default camera. If display settings are not specified, a default
|
||||||
* 640x480 display is created. Default values are used for the camera;
|
* 640x480 display is created. Default values are used for the camera;
|
||||||
@ -409,12 +490,18 @@ public class Application implements SystemListener {
|
|||||||
// user code here..
|
// user code here..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only.
|
||||||
|
*/
|
||||||
public void handleError(String errMsg, Throwable t){
|
public void handleError(String errMsg, Throwable t){
|
||||||
logger.log(Level.SEVERE, errMsg, t);
|
logger.log(Level.SEVERE, errMsg, t);
|
||||||
// user should add additional code to handle the error.
|
// user should add additional code to handle the error.
|
||||||
stop(); // stop the application
|
stop(); // stop the application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only.
|
||||||
|
*/
|
||||||
public void gainFocus(){
|
public void gainFocus(){
|
||||||
if (pauseOnFocus){
|
if (pauseOnFocus){
|
||||||
paused = false;
|
paused = false;
|
||||||
@ -424,6 +511,9 @@ public class Application implements SystemListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only.
|
||||||
|
*/
|
||||||
public void loseFocus(){
|
public void loseFocus(){
|
||||||
if (pauseOnFocus){
|
if (pauseOnFocus){
|
||||||
paused = true;
|
paused = true;
|
||||||
@ -431,6 +521,9 @@ public class Application implements SystemListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal use only.
|
||||||
|
*/
|
||||||
public void requestClose(boolean esc){
|
public void requestClose(boolean esc){
|
||||||
context.destroy(false);
|
context.destroy(false);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ import com.jme3.renderer.Renderer;
|
|||||||
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
||||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.shader.Shader;
|
import com.jme3.shader.Shader;
|
||||||
import com.jme3.shader.Uniform;
|
import com.jme3.shader.Uniform;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
@ -1009,13 +1008,42 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
|
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
InputCapsule ic = im.getCapsule(this);
|
InputCapsule ic = im.getCapsule(this);
|
||||||
String defName = ic.readString("material_def", null);
|
|
||||||
def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName));
|
|
||||||
additionalState = (RenderState) ic.readSavable("render_state", null);
|
additionalState = (RenderState) ic.readSavable("render_state", null);
|
||||||
transparent = ic.readBoolean("is_transparent", false);
|
transparent = ic.readBoolean("is_transparent", false);
|
||||||
|
|
||||||
|
// Load the material def
|
||||||
|
String defName = ic.readString("material_def", null);
|
||||||
HashMap<String, MatParam> params = (HashMap<String, MatParam>) ic.readStringSavableMap("parameters", null);
|
HashMap<String, MatParam> params = (HashMap<String, MatParam>) ic.readStringSavableMap("parameters", null);
|
||||||
// paramValues.putAll(params);
|
|
||||||
|
boolean enableVcolor = false;
|
||||||
|
boolean separateTexCoord = false;
|
||||||
|
|
||||||
|
if (im.getFormatVersion() == 0){
|
||||||
|
// Enable compatibility with old models
|
||||||
|
if (defName.equalsIgnoreCase("Common/MatDefs/Misc/VertexColor.j3md")){
|
||||||
|
// Using VertexColor, switch to Unshaded and set VertexColor=true
|
||||||
|
enableVcolor = true;
|
||||||
|
defName = "Common/MatDefs/Misc/Unshaded.j3md";
|
||||||
|
}else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/SimpleTextured.j3md")
|
||||||
|
|| defName.equalsIgnoreCase("Common/MatDefs/Misc/SolidColor.j3md")){
|
||||||
|
// Using SimpleTextured/SolidColor, just switch to Unshaded
|
||||||
|
defName = "Common/MatDefs/Misc/Unshaded.j3md";
|
||||||
|
}else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/WireColor.j3md")){
|
||||||
|
// Using WireColor, set wireframe renderstate = true and use Unshaded
|
||||||
|
additionalState.setWireframe(true);
|
||||||
|
defName = "Common/MatDefs/Misc/Unshaded.j3md";
|
||||||
|
}else if (defName.equalsIgnoreCase("Common/MatDefs/Misc/Unshaded.j3md")){
|
||||||
|
// Uses unshaded, ensure that the proper param is set
|
||||||
|
MatParam value = params.get("SeperateTexCoord");
|
||||||
|
if (value != null && ((Boolean)value.getValue()) == true){
|
||||||
|
params.remove("SeperateTexCoord");
|
||||||
|
separateTexCoord = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName));
|
||||||
paramValues = new ListMap<String, MatParam>();
|
paramValues = new ListMap<String, MatParam>();
|
||||||
|
|
||||||
// load the textures and update nextTexUnit
|
// load the textures and update nextTexUnit
|
||||||
@ -1037,5 +1065,12 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
param.setName(checkSetParam(param.getVarType(), param.getName()));
|
param.setName(checkSetParam(param.getVarType(), param.getName()));
|
||||||
paramValues.put(param.getName(), param);
|
paramValues.put(param.getName(), param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enableVcolor){
|
||||||
|
setBoolean("VertexColor", true);
|
||||||
|
}
|
||||||
|
if (separateTexCoord){
|
||||||
|
setBoolean("SeparateTexCoord", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,10 @@ public class Node extends Spatial implements Savable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(JmeImporter e) throws IOException {
|
public void read(JmeImporter e) throws IOException {
|
||||||
super.read(e);
|
// XXX: Load children before loading itself!!
|
||||||
|
// This prevents empty children list if controls query
|
||||||
|
// it in Control.setSpatial().
|
||||||
|
|
||||||
children = e.getCapsule(this).readSavableArrayList("children", null);
|
children = e.getCapsule(this).readSavableArrayList("children", null);
|
||||||
|
|
||||||
// go through children and set parent to this node
|
// go through children and set parent to this node
|
||||||
@ -602,6 +605,8 @@ public class Node extends Spatial implements Savable {
|
|||||||
child.parent = this;
|
child.parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.read(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
194
engine/src/core/com/jme3/scene/shape/StripBox.java
Normal file
194
engine/src/core/com/jme3/scene/shape/StripBox.java
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2010 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $Id: Box.java 4131 2009-03-19 20:15:28Z blaine.dev $
|
||||||
|
package com.jme3.scene.shape;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
|
import com.jme3.util.BufferUtils;
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A box with solid (filled) faces.
|
||||||
|
*
|
||||||
|
* @author Mark Powell
|
||||||
|
* @version $Revision: 4131 $, $Date: 2009-03-19 16:15:28 -0400 (Thu, 19 Mar 2009) $
|
||||||
|
*/
|
||||||
|
public class StripBox extends AbstractBox {
|
||||||
|
|
||||||
|
private static final short[] GEOMETRY_INDICES_DATA =
|
||||||
|
{ 1, 0, 4,
|
||||||
|
5,
|
||||||
|
7,
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
4,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
2,
|
||||||
|
3 };
|
||||||
|
|
||||||
|
private static final float[] GEOMETRY_TEXTURE_DATA = {
|
||||||
|
1, 0,
|
||||||
|
0, 0,
|
||||||
|
0, 1,
|
||||||
|
1, 1,
|
||||||
|
|
||||||
|
1, 0,
|
||||||
|
0, 0,
|
||||||
|
1, 1,
|
||||||
|
0, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new box.
|
||||||
|
* <p>
|
||||||
|
* The box has a center of 0,0,0 and extends in the out from the center by
|
||||||
|
* the given amount in <em>each</em> direction. So, for example, a box
|
||||||
|
* with extent of 0.5 would be the unit cube.
|
||||||
|
*
|
||||||
|
* @param name the name of the box.
|
||||||
|
* @param x the size of the box along the x axis, in both directions.
|
||||||
|
* @param y the size of the box along the y axis, in both directions.
|
||||||
|
* @param z the size of the box along the z axis, in both directions.
|
||||||
|
*/
|
||||||
|
public StripBox(float x, float y, float z) {
|
||||||
|
super();
|
||||||
|
updateGeometry(Vector3f.ZERO, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new box.
|
||||||
|
* <p>
|
||||||
|
* The box has the given center and extends in the out from the center by
|
||||||
|
* the given amount in <em>each</em> direction. So, for example, a box
|
||||||
|
* with extent of 0.5 would be the unit cube.
|
||||||
|
*
|
||||||
|
* @param name the name of the box.
|
||||||
|
* @param center the center of the box.
|
||||||
|
* @param x the size of the box along the x axis, in both directions.
|
||||||
|
* @param y the size of the box along the y axis, in both directions.
|
||||||
|
* @param z the size of the box along the z axis, in both directions.
|
||||||
|
*/
|
||||||
|
public StripBox(Vector3f center, float x, float y, float z) {
|
||||||
|
super();
|
||||||
|
updateGeometry(center, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor instantiates a new <code>Box</code> object.
|
||||||
|
* <p>
|
||||||
|
* The minimum and maximum point are provided, these two points define the
|
||||||
|
* shape and size of the box but not it’s orientation or position. You should
|
||||||
|
* use the {@link #setLocalTranslation()} and {@link #setLocalRotation()}
|
||||||
|
* methods to define those properties.
|
||||||
|
*
|
||||||
|
* @param name the name of the box.
|
||||||
|
* @param min the minimum point that defines the box.
|
||||||
|
* @param max the maximum point that defines the box.
|
||||||
|
*/
|
||||||
|
public StripBox(Vector3f min, Vector3f max) {
|
||||||
|
super();
|
||||||
|
updateGeometry(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty constructor for serialization only. Do not use.
|
||||||
|
*/
|
||||||
|
public StripBox(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a clone of this box.
|
||||||
|
* <p>
|
||||||
|
* The cloned box will have ‘_clone’ appended to it’s name, but all other
|
||||||
|
* properties will be the same as this box.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public StripBox clone() {
|
||||||
|
return new StripBox(center.clone(), xExtent, yExtent, zExtent);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void duUpdateGeometryIndices() {
|
||||||
|
if (getBuffer(Type.Index) == null){
|
||||||
|
setBuffer(Type.Index, 3, BufferUtils.createShortBuffer(GEOMETRY_INDICES_DATA));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void duUpdateGeometryNormals() {
|
||||||
|
if (getBuffer(Type.Normal) == null){
|
||||||
|
float[] normals = new float[8 * 3];
|
||||||
|
|
||||||
|
Vector3f[] vert = computeVertices();
|
||||||
|
Vector3f norm = new Vector3f();
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
norm.set(vert[i]).normalizeLocal();
|
||||||
|
|
||||||
|
normals[i * 3 + 0] = norm.x;
|
||||||
|
normals[i * 3 + 1] = norm.x;
|
||||||
|
normals[i * 3 + 2] = norm.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBuffer(Type.Normal, 3, BufferUtils.createFloatBuffer(normals));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void duUpdateGeometryTextures() {
|
||||||
|
if (getBuffer(Type.TexCoord) == null){
|
||||||
|
setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(GEOMETRY_TEXTURE_DATA));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void duUpdateGeometryVertices() {
|
||||||
|
FloatBuffer fpb = BufferUtils.createVector3Buffer(8 * 3);
|
||||||
|
Vector3f[] v = computeVertices();
|
||||||
|
fpb.put(new float[] {
|
||||||
|
v[0].x, v[0].y, v[0].z,
|
||||||
|
v[1].x, v[1].y, v[1].z,
|
||||||
|
v[2].x, v[2].y, v[2].z,
|
||||||
|
v[3].x, v[3].y, v[3].z,
|
||||||
|
v[4].x, v[4].y, v[4].z,
|
||||||
|
v[5].x, v[5].y, v[5].z,
|
||||||
|
v[6].x, v[6].y, v[6].z,
|
||||||
|
v[7].x, v[7].y, v[7].z,
|
||||||
|
});
|
||||||
|
setBuffer(Type.Position, 3, fpb);
|
||||||
|
setMode(Mode.TriangleStrip);
|
||||||
|
updateBound();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -56,16 +56,10 @@ import java.util.WeakHashMap;
|
|||||||
*/
|
*/
|
||||||
public final class BufferUtils {
|
public final class BufferUtils {
|
||||||
|
|
||||||
//// -- TEMP DATA OBJECTS -- ////
|
|
||||||
// private static final Vector2f _tempVec2 = new Vector2f();
|
|
||||||
// private static final Vector3f _tempVec3 = new Vector3f();
|
|
||||||
// private static final ColorRGBA _tempColor = new ColorRGBA();
|
|
||||||
//// -- TRACKER HASH -- ////
|
|
||||||
private static final Map<Buffer, Object> trackingHash = Collections.synchronizedMap(new WeakHashMap<Buffer, Object>());
|
private static final Map<Buffer, Object> trackingHash = Collections.synchronizedMap(new WeakHashMap<Buffer, Object>());
|
||||||
private static final Object ref = new Object();
|
private static final Object ref = new Object();
|
||||||
private static final boolean trackDirectMemory = false;
|
private static final boolean trackDirectMemory = true;
|
||||||
|
|
||||||
//// -- GENERIC CLONE -- ////
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of the given buffer. The clone's capacity is
|
* Creates a clone of the given buffer. The clone's capacity is
|
||||||
* equal to the given buffer's limit.
|
* equal to the given buffer's limit.
|
||||||
@ -89,7 +83,57 @@ public final class BufferUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//// -- VECTOR3F METHODS -- ////
|
private static void onBufferAllocated(Buffer buffer){
|
||||||
|
/*
|
||||||
|
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||||
|
int initialIndex = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < stackTrace.length; i++){
|
||||||
|
if (!stackTrace[i].getClassName().equals(BufferUtils.class.getName())){
|
||||||
|
initialIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int allocated = buffer.capacity();
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
if (buffer instanceof FloatBuffer){
|
||||||
|
size = 4;
|
||||||
|
}else if (buffer instanceof ShortBuffer){
|
||||||
|
size = 2;
|
||||||
|
}else if (buffer instanceof ByteBuffer){
|
||||||
|
size = 1;
|
||||||
|
}else if (buffer instanceof IntBuffer){
|
||||||
|
size = 4;
|
||||||
|
}else if (buffer instanceof DoubleBuffer){
|
||||||
|
size = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
allocated *= size;
|
||||||
|
|
||||||
|
for (int i = initialIndex; i < stackTrace.length; i++){
|
||||||
|
StackTraceElement element = stackTrace[i];
|
||||||
|
if (element.getClassName().startsWith("java")){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class clazz = Class.forName(element.getClassName());
|
||||||
|
if (i == initialIndex){
|
||||||
|
System.out.println(clazz.getSimpleName()+"."+element.getMethodName()+"():" + element.getLineNumber() + " allocated " + allocated);
|
||||||
|
}else{
|
||||||
|
System.out.println(" at " + clazz.getSimpleName()+"."+element.getMethodName()+"()");
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (trackDirectMemory){
|
||||||
|
trackingHash.put(buffer, ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a new FloatBuffer using the given array of Vector3f objects.
|
* Generate a new FloatBuffer using the given array of Vector3f objects.
|
||||||
* The FloatBuffer will be 3 * data.length long and contain the vector data
|
* The FloatBuffer will be 3 * data.length long and contain the vector data
|
||||||
@ -658,9 +702,7 @@ public final class BufferUtils {
|
|||||||
public static DoubleBuffer createDoubleBuffer(int size) {
|
public static DoubleBuffer createDoubleBuffer(int size) {
|
||||||
DoubleBuffer buf = ByteBuffer.allocateDirect(8 * size).order(ByteOrder.nativeOrder()).asDoubleBuffer();
|
DoubleBuffer buf = ByteBuffer.allocateDirect(8 * size).order(ByteOrder.nativeOrder()).asDoubleBuffer();
|
||||||
buf.clear();
|
buf.clear();
|
||||||
if (trackDirectMemory) {
|
onBufferAllocated(buf);
|
||||||
trackingHash.put(buf, ref);
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,9 +765,7 @@ public final class BufferUtils {
|
|||||||
public static FloatBuffer createFloatBuffer(int size) {
|
public static FloatBuffer createFloatBuffer(int size) {
|
||||||
FloatBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
FloatBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||||
buf.clear();
|
buf.clear();
|
||||||
if (trackDirectMemory) {
|
onBufferAllocated(buf);
|
||||||
trackingHash.put(buf, ref);
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,9 +827,7 @@ public final class BufferUtils {
|
|||||||
public static IntBuffer createIntBuffer(int size) {
|
public static IntBuffer createIntBuffer(int size) {
|
||||||
IntBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer();
|
IntBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||||
buf.clear();
|
buf.clear();
|
||||||
if (trackDirectMemory) {
|
onBufferAllocated(buf);
|
||||||
trackingHash.put(buf, ref);
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,9 +890,7 @@ public final class BufferUtils {
|
|||||||
public static ByteBuffer createByteBuffer(int size) {
|
public static ByteBuffer createByteBuffer(int size) {
|
||||||
ByteBuffer buf = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
ByteBuffer buf = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
||||||
buf.clear();
|
buf.clear();
|
||||||
if (trackDirectMemory) {
|
onBufferAllocated(buf);
|
||||||
trackingHash.put(buf, ref);
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,9 +968,7 @@ public final class BufferUtils {
|
|||||||
public static ShortBuffer createShortBuffer(int size) {
|
public static ShortBuffer createShortBuffer(int size) {
|
||||||
ShortBuffer buf = ByteBuffer.allocateDirect(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer();
|
ShortBuffer buf = ByteBuffer.allocateDirect(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer();
|
||||||
buf.clear();
|
buf.clear();
|
||||||
if (trackDirectMemory) {
|
onBufferAllocated(buf);
|
||||||
trackingHash.put(buf, ref);
|
|
||||||
}
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,15 @@
|
|||||||
|
|
||||||
package jme3test.audio;
|
package jme3test.audio;
|
||||||
|
|
||||||
|
import com.jme3.asset.plugins.FileLocator;
|
||||||
import com.jme3.audio.AudioNode;
|
import com.jme3.audio.AudioNode;
|
||||||
|
import com.jme3.audio.Environment;
|
||||||
|
import com.jme3.audio.LowPassFilter;
|
||||||
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import org.lwjgl.openal.AL10;
|
||||||
|
import org.lwjgl.openal.AL11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Doppler Effect
|
* Test Doppler Effect
|
||||||
@ -42,8 +49,15 @@ public class TestDoppler extends AudioApp {
|
|||||||
|
|
||||||
private AudioNode ufo;
|
private AudioNode ufo;
|
||||||
|
|
||||||
private float location = 0;
|
private float x = 20, z = 0;
|
||||||
private float rate = 1;
|
|
||||||
|
private float rate = -0.05f;
|
||||||
|
private float xDist = 20;
|
||||||
|
private float zDist = 5;
|
||||||
|
|
||||||
|
private float angle = FastMath.TWO_PI;
|
||||||
|
|
||||||
|
private LowPassFilter filter = new LowPassFilter(1, 1);
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
TestDoppler test = new TestDoppler();
|
TestDoppler test = new TestDoppler();
|
||||||
@ -52,28 +66,50 @@ public class TestDoppler extends AudioApp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initAudioApp(){
|
public void initAudioApp(){
|
||||||
ufo = new AudioNode(audioRenderer, assetManager, "Sound/Effects/Beep.ogg", false);
|
assetManager.registerLocator("C:\\", FileLocator.class);
|
||||||
|
|
||||||
|
Quaternion q = new Quaternion();
|
||||||
|
q.lookAt(new Vector3f(0, 0, -1f), Vector3f.UNIT_Y);
|
||||||
|
listener.setRotation(q);
|
||||||
|
|
||||||
|
audioRenderer.setEnvironment(Environment.Dungeon);
|
||||||
|
AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
|
||||||
|
|
||||||
|
ufo = new AudioNode(audioRenderer, assetManager, "test.ogg", false);
|
||||||
ufo.setPositional(true);
|
ufo.setPositional(true);
|
||||||
ufo.setLooping(true);
|
ufo.setLooping(true);
|
||||||
|
ufo.setReverbEnabled(true);
|
||||||
|
ufo.setRefDistance(100000000);
|
||||||
|
ufo.setMaxDistance(100000000);
|
||||||
audioRenderer.playSource(ufo);
|
audioRenderer.playSource(ufo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAudioApp(float tpf){
|
public void updateAudioApp(float tpf){
|
||||||
// move the location variable left and right
|
//float x = (float) (Math.cos(angle) * xDist);
|
||||||
if (location > 10){
|
float dx = (float) Math.sin(angle) * xDist;
|
||||||
location = 10;
|
|
||||||
|
//float z = (float) (Math.sin(angle) * zDist);
|
||||||
|
float dz = (float)(-Math.cos(angle) * zDist);
|
||||||
|
|
||||||
|
x += dx * tpf * 0.05f;
|
||||||
|
z += dz * tpf * 0.05f;
|
||||||
|
|
||||||
|
angle += tpf * rate;
|
||||||
|
|
||||||
|
if (angle > FastMath.TWO_PI){
|
||||||
|
angle = FastMath.TWO_PI;
|
||||||
rate = -rate;
|
rate = -rate;
|
||||||
ufo.setVelocity(new Vector3f(rate*10, 0, 0));
|
}else if (angle < -0){
|
||||||
}else if (location < -10){
|
angle = -0;
|
||||||
location = -10;
|
|
||||||
rate = -rate;
|
rate = -rate;
|
||||||
ufo.setVelocity(new Vector3f(rate*10, 0, 0));
|
|
||||||
}else{
|
|
||||||
location += rate * tpf * 10;
|
|
||||||
}
|
}
|
||||||
ufo.setLocalTranslation(location, 0, 2);
|
|
||||||
|
ufo.setVelocity(new Vector3f(dx, 0, dz));
|
||||||
|
ufo.setLocalTranslation(x, 0, z);
|
||||||
ufo.updateGeometricState();
|
ufo.updateGeometricState();
|
||||||
|
|
||||||
|
System.out.println("LOC: " + (int)x +", " + (int)z + ", VEL: " + (int)dx + ", " + (int)dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import com.jme3.app.Application;
|
|||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.system.JmeCanvasContext;
|
import com.jme3.system.JmeCanvasContext;
|
||||||
import com.jme3.system.JmeSystem;
|
|
||||||
import com.jme3.util.JmeFormatter;
|
import com.jme3.util.JmeFormatter;
|
||||||
import java.awt.Canvas;
|
import java.awt.Canvas;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -60,7 +59,7 @@ public class TestCanvas {
|
|||||||
private static Canvas canvas;
|
private static Canvas canvas;
|
||||||
private static Application app;
|
private static Application app;
|
||||||
private static JFrame frame;
|
private static JFrame frame;
|
||||||
private static final String appClass = "jme3test.model.shape.TestBox";
|
private static final String appClass = "jme3test.post.TestMultiplesFilters";
|
||||||
|
|
||||||
private static void createFrame(){
|
private static void createFrame(){
|
||||||
frame = new JFrame("Test");
|
frame = new JFrame("Test");
|
||||||
|
@ -75,7 +75,6 @@ public class TestOgreConvert extends SimpleApplication {
|
|||||||
AnimControl control = ogreModelReloaded.getControl(AnimControl.class);
|
AnimControl control = ogreModelReloaded.getControl(AnimControl.class);
|
||||||
AnimChannel chan = control.createChannel();
|
AnimChannel chan = control.createChannel();
|
||||||
chan.setAnim("Walk");
|
chan.setAnim("Walk");
|
||||||
// fis.close();
|
|
||||||
|
|
||||||
rootNode.attachChild(ogreModelReloaded);
|
rootNode.attachChild(ogreModelReloaded);
|
||||||
} catch (IOException ex){
|
} catch (IOException ex){
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
package jme3test.stress;
|
package jme3test.stress;
|
||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.input.KeyInput;
|
|
||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.Quaternion;
|
import com.jme3.math.Quaternion;
|
||||||
@ -41,29 +40,31 @@ import com.jme3.math.Vector3f;
|
|||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.control.LodControl;
|
import com.jme3.scene.control.LodControl;
|
||||||
|
import com.jme3.scene.shape.Sphere;
|
||||||
|
|
||||||
public class TestLodStress extends SimpleApplication {
|
public class TestLodStress extends SimpleApplication {
|
||||||
|
|
||||||
private boolean lod = false;
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
TestLodStress app = new TestLodStress();
|
TestLodStress app = new TestLodStress();
|
||||||
|
app.setShowSettings(false);
|
||||||
|
app.setPauseOnLostFocus(false);
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void simpleInitApp() {
|
public void simpleInitApp() {
|
||||||
// inputManager.registerKeyBinding("USELOD", KeyInput.KEY_L);
|
|
||||||
|
|
||||||
DirectionalLight dl = new DirectionalLight();
|
DirectionalLight dl = new DirectionalLight();
|
||||||
dl.setDirection(new Vector3f(-1,-1,-1).normalizeLocal());
|
dl.setDirection(new Vector3f(-1,-1,-1).normalizeLocal());
|
||||||
rootNode.addLight(dl);
|
rootNode.addLight(dl);
|
||||||
|
|
||||||
Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
|
// Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
|
||||||
Geometry teapot = (Geometry) teapotNode.getChild(0);
|
// Geometry teapot = (Geometry) teapotNode.getChild(0);
|
||||||
|
|
||||||
|
Sphere sph = new Sphere(16, 16, 4);
|
||||||
|
Geometry teapot = new Geometry("teapot", sph);
|
||||||
|
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
||||||
mat.setFloat("Shininess", 16f);
|
mat.setFloat("Shininess", 16f);
|
||||||
mat.setBoolean("VertexLighting", true);
|
// mat.setBoolean("VertexLighting", true);
|
||||||
teapot.setMaterial(mat);
|
teapot.setMaterial(mat);
|
||||||
|
|
||||||
// show normals as material
|
// show normals as material
|
||||||
@ -77,9 +78,9 @@ public class TestLodStress extends SimpleApplication {
|
|||||||
clonePot.setLocalTranslation(x * .5f, 0, y * .5f);
|
clonePot.setLocalTranslation(x * .5f, 0, y * .5f);
|
||||||
clonePot.setLocalScale(.15f);
|
clonePot.setLocalScale(.15f);
|
||||||
|
|
||||||
LodControl control = new LodControl();
|
// LodControl control = new LodControl();
|
||||||
clonePot.addControl(control);
|
// clonePot.addControl(control);
|
||||||
rootNode.attachChild(clonePot);
|
// rootNode.attachChild(clonePot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,12 @@ import java.awt.image.Raster;
|
|||||||
import java.awt.image.WritableRaster;
|
import java.awt.image.WritableRaster;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.HashMap;
|
import java.util.EnumMap;
|
||||||
|
|
||||||
public class ImageToAwt {
|
public class ImageToAwt {
|
||||||
|
|
||||||
private static final HashMap<Format, DecodeParams> params = new HashMap<Format, DecodeParams>();
|
private static final EnumMap<Format, DecodeParams> params
|
||||||
|
= new EnumMap<Format, DecodeParams>(Format.class);
|
||||||
|
|
||||||
private static class DecodeParams {
|
private static class DecodeParams {
|
||||||
|
|
||||||
@ -294,6 +295,80 @@ public class ImageToAwt {
|
|||||||
image.setData(BufferUtils.createByteBuffer(total));
|
image.setData(BufferUtils.createByteBuffer(total));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the image from the given format to the output format.
|
||||||
|
* It is assumed that both images have buffers with the appropriate
|
||||||
|
* number of elements and that both have the same dimensions.
|
||||||
|
*
|
||||||
|
* @param input
|
||||||
|
* @param output
|
||||||
|
*/
|
||||||
|
public static void convert(Image input, Image output){
|
||||||
|
DecodeParams inParams = params.get(input.getFormat());
|
||||||
|
DecodeParams outParams = params.get(output.getFormat());
|
||||||
|
|
||||||
|
if (inParams == null || outParams == null)
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
|
||||||
|
int width = input.getWidth();
|
||||||
|
int height = input.getHeight();
|
||||||
|
|
||||||
|
if (width != output.getWidth() || height != output.getHeight())
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
ByteBuffer inData = input.getData(0);
|
||||||
|
|
||||||
|
boolean inAlpha = false;
|
||||||
|
boolean inLum = false;
|
||||||
|
boolean inRGB = false;
|
||||||
|
if (inParams.am != 0) {
|
||||||
|
inAlpha = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inParams.rm != 0 && inParams.gm == 0 && inParams.bm == 0) {
|
||||||
|
inLum = true;
|
||||||
|
} else if (inParams.rm != 0 && inParams.gm != 0 && inParams.bm != 0) {
|
||||||
|
inRGB = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int expansionA = 8 - Integer.bitCount(inParams.am);
|
||||||
|
int expansionR = 8 - Integer.bitCount(inParams.rm);
|
||||||
|
int expansionG = 8 - Integer.bitCount(inParams.gm);
|
||||||
|
int expansionB = 8 - Integer.bitCount(inParams.bm);
|
||||||
|
|
||||||
|
int inputPixel;
|
||||||
|
for (int y = 0; y < height; y++){
|
||||||
|
for (int x = 0; x < width; x++){
|
||||||
|
int i = Ix(x, y, width) * inParams.bpp;
|
||||||
|
inputPixel = (readPixel(inData, i, inParams.bpp) & inParams.im) >> inParams.is;
|
||||||
|
|
||||||
|
int a = (inputPixel & inParams.am) >> inParams.as;
|
||||||
|
int r = (inputPixel & inParams.rm) >> inParams.rs;
|
||||||
|
int g = (inputPixel & inParams.gm) >> inParams.gs;
|
||||||
|
int b = (inputPixel & inParams.bm) >> inParams.bs;
|
||||||
|
|
||||||
|
r = r & 0xff;
|
||||||
|
g = g & 0xff;
|
||||||
|
b = b & 0xff;
|
||||||
|
a = a & 0xff;
|
||||||
|
|
||||||
|
a = a << expansionA;
|
||||||
|
r = r << expansionR;
|
||||||
|
g = g << expansionG;
|
||||||
|
b = b << expansionB;
|
||||||
|
|
||||||
|
if (inLum)
|
||||||
|
b = g = r;
|
||||||
|
|
||||||
|
if (!inAlpha)
|
||||||
|
a = 0xff;
|
||||||
|
|
||||||
|
// int argb = (a << 24) | (r << 16) | (g << 8) | b;
|
||||||
|
// out.setRGB(x, y, argb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static BufferedImage convert(Image image, boolean do16bit, boolean fullalpha, int mipLevel){
|
public static BufferedImage convert(Image image, boolean do16bit, boolean fullalpha, int mipLevel){
|
||||||
Format format = image.getFormat();
|
Format format = image.getFormat();
|
||||||
DecodeParams p = params.get(image.getFormat());
|
DecodeParams p = params.get(image.getFormat());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user