* Fix crash in TestEverything
* Fix crash in TestWalkingChar * Fix crash in TestDopper * Fix crash in TestApplication * Fix deprecation warnings in audio tests * Fixed issues with particle emitter cloning and import/export * Fixed TempVars crashes in BoundingSphere * Fixed incorrect deprecation warning in AudioNode * Added smart caching to materials * Added test to verify that particle export and cloning is working correctly git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7907 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
7cd213b940
commit
026a72d57e
@ -41,6 +41,7 @@ import com.jme3.math.Vector2f;
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.asset.AssetLoader;
|
import com.jme3.asset.AssetLoader;
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
|
import com.jme3.asset.MaterialKey;
|
||||||
import com.jme3.asset.TextureKey;
|
import com.jme3.asset.TextureKey;
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
import com.jme3.material.RenderState.BlendMode;
|
||||||
import com.jme3.material.RenderState.FaceCullMode;
|
import com.jme3.material.RenderState.FaceCullMode;
|
||||||
@ -63,7 +64,7 @@ public class J3MLoader implements AssetLoader {
|
|||||||
|
|
||||||
private AssetManager owner;
|
private AssetManager owner;
|
||||||
private Scanner scan;
|
private Scanner scan;
|
||||||
private String fileName;
|
private AssetKey key;
|
||||||
|
|
||||||
private MaterialDef materialDef;
|
private MaterialDef materialDef;
|
||||||
private Material material;
|
private Material material;
|
||||||
@ -538,14 +539,15 @@ public class J3MLoader implements AssetLoader {
|
|||||||
throw new IOException("Extended material "+extendedMat+" cannot be found.");
|
throw new IOException("Extended material "+extendedMat+" cannot be found.");
|
||||||
|
|
||||||
material = new Material(def);
|
material = new Material(def);
|
||||||
material.setAssetName(fileName);
|
material.setKey(key);
|
||||||
|
// material.setAssetName(fileName);
|
||||||
}else if (scan.hasNext("\\{")){
|
}else if (scan.hasNext("\\{")){
|
||||||
if (extending){
|
if (extending){
|
||||||
throw new IOException("Expected ':', got '{'");
|
throw new IOException("Expected ':', got '{'");
|
||||||
}
|
}
|
||||||
materialDef = new MaterialDef(owner, name);
|
materialDef = new MaterialDef(owner, name);
|
||||||
// NOTE: pass file name for defs so they can be loaded later
|
// NOTE: pass file name for defs so they can be loaded later
|
||||||
materialDef.setAssetName(fileName);
|
materialDef.setAssetName(key.getName());
|
||||||
}
|
}
|
||||||
scan.next(); // skip {
|
scan.next(); // skip {
|
||||||
|
|
||||||
@ -590,7 +592,7 @@ public class J3MLoader implements AssetLoader {
|
|||||||
try {
|
try {
|
||||||
scan = new Scanner(in);
|
scan = new Scanner(in);
|
||||||
scan.useLocale(Locale.US);
|
scan.useLocale(Locale.US);
|
||||||
this.fileName = info.getKey().getName();
|
key = info.getKey();
|
||||||
loadFromScanner();
|
loadFromScanner();
|
||||||
} finally {
|
} finally {
|
||||||
if (in != null)
|
if (in != null)
|
||||||
@ -598,6 +600,9 @@ public class J3MLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (material != null){
|
if (material != null){
|
||||||
|
if (!(info.getKey() instanceof MaterialKey)){
|
||||||
|
throw new IOException("Material instances must be loaded via MaterialKey");
|
||||||
|
}
|
||||||
// material implementation
|
// material implementation
|
||||||
return material;
|
return material;
|
||||||
}else{
|
}else{
|
||||||
|
29
engine/src/core/com/jme3/asset/MaterialKey.java
Normal file
29
engine/src/core/com/jme3/asset/MaterialKey.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.jme3.asset;
|
||||||
|
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for loading {@link Material materials} only (not material definitions).
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
|
public class MaterialKey extends AssetKey {
|
||||||
|
public MaterialKey(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialKey(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean useSmartCache(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object createClonedInstance(Object asset){
|
||||||
|
Material mat = (Material) asset;
|
||||||
|
return mat.clone();
|
||||||
|
}
|
||||||
|
}
|
@ -200,8 +200,6 @@ public class AudioNode extends Node {
|
|||||||
* @param name The filename of the audio file
|
* @param name The filename of the audio file
|
||||||
* @param stream If true, the audio will be streamed gradually from disk,
|
* @param stream If true, the audio will be streamed gradually from disk,
|
||||||
* otherwise, it will be buffered.
|
* otherwise, it will be buffered.
|
||||||
*
|
|
||||||
* @deprecated AudioRenderer parameter is ignored.
|
|
||||||
*/
|
*/
|
||||||
public AudioNode(AssetManager assetManager, String name, boolean stream) {
|
public AudioNode(AssetManager assetManager, String name, boolean stream) {
|
||||||
this(assetManager, name, stream, false);
|
this(assetManager, name, stream, false);
|
||||||
@ -213,6 +211,8 @@ public class AudioNode extends Node {
|
|||||||
* @param audioRenderer The audio renderer to use for playing. Cannot be null.
|
* @param audioRenderer The audio renderer to use for playing. Cannot be null.
|
||||||
* @param assetManager The asset manager to use to load the audio file
|
* @param assetManager The asset manager to use to load the audio file
|
||||||
* @param name The filename of the audio file
|
* @param name The filename of the audio file
|
||||||
|
*
|
||||||
|
* @deprecated AudioRenderer parameter is ignored.
|
||||||
*/
|
*/
|
||||||
public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name) {
|
public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name) {
|
||||||
this(assetManager, name, false);
|
this(assetManager, name, false);
|
||||||
|
@ -258,7 +258,6 @@ public class BoundingSphere extends BoundingVolume {
|
|||||||
BufferUtils.setInBuffer(tempC, points, j + ap);
|
BufferUtils.setInBuffer(tempC, points, j + ap);
|
||||||
BufferUtils.setInBuffer(tempB, points, j - 1 + ap);
|
BufferUtils.setInBuffer(tempB, points, j - 1 + ap);
|
||||||
}
|
}
|
||||||
vars.release();
|
|
||||||
recurseMini(points, i, b + 1, ap + 1);
|
recurseMini(points, i, b + 1, ap + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ public class ParticleEmitter extends Geometry {
|
|||||||
|
|
||||||
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO);
|
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO);
|
||||||
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer();
|
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer();
|
||||||
private ParticleEmitterControl control = new ParticleEmitterControl(this);
|
|
||||||
|
private ParticleEmitterControl control;
|
||||||
private EmitterShape shape = DEFAULT_SHAPE;
|
private EmitterShape shape = DEFAULT_SHAPE;
|
||||||
private ParticleMesh particleMesh;
|
private ParticleMesh particleMesh;
|
||||||
private ParticleInfluencer particleInfluencer = DEFAULT_INFLUENCER;
|
private ParticleInfluencer particleInfluencer = DEFAULT_INFLUENCER;
|
||||||
@ -106,9 +107,12 @@ public class ParticleEmitter extends Geometry {
|
|||||||
//variable that helps with computations
|
//variable that helps with computations
|
||||||
private transient Vector3f temp = new Vector3f();
|
private transient Vector3f temp = new Vector3f();
|
||||||
|
|
||||||
private static class ParticleEmitterControl implements Control {
|
public static class ParticleEmitterControl implements Control {
|
||||||
|
|
||||||
private ParticleEmitter parentEmitter;
|
ParticleEmitter parentEmitter;
|
||||||
|
|
||||||
|
public ParticleEmitterControl(){
|
||||||
|
}
|
||||||
|
|
||||||
public ParticleEmitterControl(ParticleEmitter parentEmitter){
|
public ParticleEmitterControl(ParticleEmitter parentEmitter){
|
||||||
this.parentEmitter = parentEmitter;
|
this.parentEmitter = parentEmitter;
|
||||||
@ -139,11 +143,9 @@ public class ParticleEmitter extends Geometry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
// the data is not written here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
// the data is not written here
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,6 +208,7 @@ public class ParticleEmitter extends Geometry {
|
|||||||
shape = shape.deepClone();
|
shape = shape.deepClone();
|
||||||
particleInfluencer = particleInfluencer.clone();
|
particleInfluencer = particleInfluencer.clone();
|
||||||
|
|
||||||
|
control = new ParticleEmitterControl(this);
|
||||||
controls.add(control);
|
controls.add(control);
|
||||||
|
|
||||||
switch (meshType) {
|
switch (meshType) {
|
||||||
@ -1155,6 +1158,7 @@ public class ParticleEmitter extends Geometry {
|
|||||||
throw new IllegalStateException("Unrecognized particle type: " + meshType);
|
throw new IllegalStateException("Unrecognized particle type: " + meshType);
|
||||||
}
|
}
|
||||||
particleMesh.initParticleData(this, particles.length);
|
particleMesh.initParticleData(this, particles.length);
|
||||||
|
particleMesh.setImagesXY(imagesX, imagesY);
|
||||||
|
|
||||||
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
||||||
if (particleInfluencer == DEFAULT_INFLUENCER){
|
if (particleInfluencer == DEFAULT_INFLUENCER){
|
||||||
@ -1170,7 +1174,7 @@ public class ParticleEmitter extends Geometry {
|
|||||||
if (obj instanceof ParticleEmitter){
|
if (obj instanceof ParticleEmitter){
|
||||||
controls.remove(i);
|
controls.remove(i);
|
||||||
// now add the proper one in
|
// now add the proper one in
|
||||||
controls.add(control);
|
controls.add(new ParticleEmitterControl(this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1180,6 +1184,11 @@ public class ParticleEmitter extends Geometry {
|
|||||||
gravity = new Vector3f();
|
gravity = new Vector3f();
|
||||||
gravity.y = ic.readFloat("gravity", 0);
|
gravity.y = ic.readFloat("gravity", 0);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
// since the parentEmitter is not loaded, it must be
|
||||||
|
// loaded separately
|
||||||
|
control = getControl(ParticleEmitterControl.class);
|
||||||
|
control.parentEmitter = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.material;
|
package com.jme3.material;
|
||||||
|
|
||||||
|
import com.jme3.asset.Asset;
|
||||||
import com.jme3.asset.AssetKey;
|
import com.jme3.asset.AssetKey;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Matrix4f;
|
import com.jme3.math.Matrix4f;
|
||||||
@ -73,10 +74,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>Material</code> describes the rendering style for a given
|
* <code>Material</code> describes the rendering style for a given
|
||||||
* {
|
* {@link Geometry}.
|
||||||
* <p/>
|
|
||||||
* @link Geometry}.
|
|
||||||
* <p/>
|
|
||||||
* <p>A material is essentially a list of {
|
* <p>A material is essentially a list of {
|
||||||
* @link MatParam parameters}, those parameters map to uniforms which are
|
* @link MatParam parameters}, those parameters map to uniforms which are
|
||||||
* defined in a shader. Setting the parameters can modify the behavior of a
|
* defined in a shader. Setting the parameters can modify the behavior of a
|
||||||
@ -84,7 +82,7 @@ import java.util.logging.Logger;
|
|||||||
* <p/>
|
* <p/>
|
||||||
* @author Kirill Vainer
|
* @author Kirill Vainer
|
||||||
*/
|
*/
|
||||||
public class Material implements Cloneable, Savable, Comparable<Material> {
|
public class Material implements Asset, Cloneable, Savable, Comparable<Material> {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Material.class.getName());
|
private static final Logger logger = Logger.getLogger(Material.class.getName());
|
||||||
private static final RenderState additiveLight = new RenderState();
|
private static final RenderState additiveLight = new RenderState();
|
||||||
@ -100,7 +98,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
additiveLight.setBlendMode(RenderState.BlendMode.AlphaAdditive);
|
additiveLight.setBlendMode(RenderState.BlendMode.AlphaAdditive);
|
||||||
additiveLight.setDepthWrite(false);
|
additiveLight.setDepthWrite(false);
|
||||||
}
|
}
|
||||||
private String assetName;
|
|
||||||
|
private AssetKey key;
|
||||||
private MaterialDef def;
|
private MaterialDef def;
|
||||||
private ListMap<String, MatParam> paramValues = new ListMap<String, MatParam>();
|
private ListMap<String, MatParam> paramValues = new ListMap<String, MatParam>();
|
||||||
private Technique technique;
|
private Technique technique;
|
||||||
@ -139,16 +138,15 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
* @return Asset key name of the j3m file
|
* @return Asset key name of the j3m file
|
||||||
*/
|
*/
|
||||||
public String getAssetName() {
|
public String getAssetName() {
|
||||||
return assetName;
|
return key != null ? key.getName() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setKey(AssetKey key){
|
||||||
* Set the asset key name. This is used internally by the j3m material loader.
|
this.key = key;
|
||||||
*
|
}
|
||||||
* @param assetName the asset key name
|
|
||||||
*/
|
public AssetKey getKey(){
|
||||||
public void setAssetName(String assetName) {
|
return key;
|
||||||
this.assetName = assetName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,7 +291,7 @@ public class DesktopAssetManager implements AssetManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Material loadMaterial(String name){
|
public Material loadMaterial(String name){
|
||||||
return (Material) loadAsset(new AssetKey(name));
|
return (Material) loadAsset(new MaterialKey(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,6 @@ import com.jme3.audio.LowPassFilter;
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -237,6 +236,13 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stop any playing channels
|
||||||
|
for (int i = 0; i < chanSrcs.length; i++){
|
||||||
|
if (chanSrcs[i] != null){
|
||||||
|
clearChannel(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// delete channel-based sources
|
// delete channel-based sources
|
||||||
ib.clear();
|
ib.clear();
|
||||||
ib.put(channels);
|
ib.put(channels);
|
||||||
@ -253,7 +259,8 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable {
|
|||||||
EFX10.alDeleteAuxiliaryEffectSlots(ib);
|
EFX10.alDeleteAuxiliaryEffectSlots(ib);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Delete other buffers/sources
|
// TODO: Cleanup buffers allocated for audio buffers and streams
|
||||||
|
|
||||||
AL.destroy();
|
AL.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,7 +937,6 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable {
|
|||||||
freeChannel(chan);
|
freeChannel(chan);
|
||||||
|
|
||||||
if (src.getAudioData() instanceof AudioStream) {
|
if (src.getAudioData() instanceof AudioStream) {
|
||||||
|
|
||||||
AudioStream stream = (AudioStream)src.getAudioData();
|
AudioStream stream = (AudioStream)src.getAudioData();
|
||||||
if (stream.isOpen()) {
|
if (stream.isOpen()) {
|
||||||
stream.close();
|
stream.close();
|
||||||
|
@ -215,7 +215,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
|
|||||||
}
|
}
|
||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
logger.log(Level.WARNING, "Material {0} not found. Applying default material", matName);
|
logger.log(Level.WARNING, "Material {0} not found. Applying default material", matName);
|
||||||
mat = (Material) assetManager.loadAsset(new AssetKey("Common/Materials/RedColor.j3m"));
|
mat = (Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,15 +70,6 @@ public class TestApplication {
|
|||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
System.out.println("Destroying offscreen buffer");
|
System.out.println("Destroying offscreen buffer");
|
||||||
app.stop();
|
app.stop();
|
||||||
|
|
||||||
System.out.println("Creating JOGL application..");
|
|
||||||
settings = new AppSettings(true);
|
|
||||||
settings.setRenderer(AppSettings.JOGL);
|
|
||||||
app = new Application();
|
|
||||||
app.setSettings(settings);
|
|
||||||
app.start();
|
|
||||||
Thread.sleep(5000);
|
|
||||||
app.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ package jme3test.audio;
|
|||||||
import com.jme3.audio.AudioRenderer;
|
import com.jme3.audio.AudioRenderer;
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.asset.DesktopAssetManager;
|
import com.jme3.asset.DesktopAssetManager;
|
||||||
|
import com.jme3.audio.AudioContext;
|
||||||
import com.jme3.audio.Listener;
|
import com.jme3.audio.Listener;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import com.jme3.system.JmeSystem;
|
import com.jme3.system.JmeSystem;
|
||||||
@ -60,6 +61,7 @@ public class AudioApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initAudioApp(){
|
public void initAudioApp(){
|
||||||
|
AudioContext.setAudioRenderer(audioRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAudioApp(float tpf){
|
public void updateAudioApp(float tpf){
|
||||||
|
@ -51,10 +51,10 @@ public class TestAmbient extends AudioApp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initAudioApp(){
|
public void initAudioApp(){
|
||||||
waves = new AudioNode(audioRenderer, assetManager, "Sound/Environment/Ocean Waves.ogg", false);
|
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
|
||||||
waves.setPositional(true);
|
waves.setPositional(true);
|
||||||
|
|
||||||
nature = new AudioNode(audioRenderer, assetManager, "Sound/Environment/Nature.ogg", true);
|
nature = new AudioNode(assetManager, "Sound/Environment/Nature.ogg", true);
|
||||||
// river = new AudioSource(manager, "sounds/river.ogg");
|
// river = new AudioSource(manager, "sounds/river.ogg");
|
||||||
|
|
||||||
// float[] eax = new float[]
|
// float[] eax = new float[]
|
||||||
|
@ -66,8 +66,6 @@ public class TestDoppler extends AudioApp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initAudioApp(){
|
public void initAudioApp(){
|
||||||
assetManager.registerLocator("C:\\", FileLocator.class);
|
|
||||||
|
|
||||||
Quaternion q = new Quaternion();
|
Quaternion q = new Quaternion();
|
||||||
q.lookAt(new Vector3f(0, 0, -1f), Vector3f.UNIT_Y);
|
q.lookAt(new Vector3f(0, 0, -1f), Vector3f.UNIT_Y);
|
||||||
listener.setRotation(q);
|
listener.setRotation(q);
|
||||||
@ -75,7 +73,7 @@ public class TestDoppler extends AudioApp {
|
|||||||
audioRenderer.setEnvironment(Environment.Dungeon);
|
audioRenderer.setEnvironment(Environment.Dungeon);
|
||||||
AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
|
AL10.alDistanceModel(AL11.AL_EXPONENT_DISTANCE);
|
||||||
|
|
||||||
ufo = new AudioNode(audioRenderer, assetManager, "test.ogg", false);
|
ufo = new AudioNode(assetManager, "Sound/Effects/Beep.ogg", false);
|
||||||
ufo.setPositional(true);
|
ufo.setPositional(true);
|
||||||
ufo.setLooping(true);
|
ufo.setLooping(true);
|
||||||
ufo.setReverbEnabled(true);
|
ufo.setReverbEnabled(true);
|
||||||
|
@ -49,7 +49,7 @@ public class TestMusicStreaming extends AudioApp {
|
|||||||
@Override
|
@Override
|
||||||
public void initAudioApp(){
|
public void initAudioApp(){
|
||||||
assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class);
|
assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class);
|
||||||
AudioNode src = new AudioNode(audioRenderer, assetManager, "Lumme-Badloop.ogg", true);
|
AudioNode src = new AudioNode(assetManager, "Lumme-Badloop.ogg", true);
|
||||||
audioRenderer.playSource(src);
|
audioRenderer.playSource(src);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -262,7 +262,7 @@ public class TestWalkingChar extends SimpleApplication implements ActionListener
|
|||||||
rock.setWrap(WrapMode.Repeat);
|
rock.setWrap(WrapMode.Repeat);
|
||||||
matRock.setTexture("DiffuseMap_2", rock);
|
matRock.setTexture("DiffuseMap_2", rock);
|
||||||
matRock.setFloat("DiffuseMap_2_scale", 128);
|
matRock.setFloat("DiffuseMap_2_scale", 128);
|
||||||
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.png");
|
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
|
||||||
normalMap0.setWrap(WrapMode.Repeat);
|
normalMap0.setWrap(WrapMode.Repeat);
|
||||||
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
|
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
|
||||||
normalMap1.setWrap(WrapMode.Repeat);
|
normalMap1.setWrap(WrapMode.Repeat);
|
||||||
|
@ -57,7 +57,7 @@ public class TestRayCasting extends SimpleApplication {
|
|||||||
// flyCam.setEnabled(false);
|
// flyCam.setEnabled(false);
|
||||||
|
|
||||||
// load material
|
// load material
|
||||||
Material mat = (Material) assetManager.loadAsset(new AssetKey("Interface/Logo/Logo.j3m"));
|
Material mat = (Material) assetManager.loadMaterial("Interface/Logo/Logo.j3m");
|
||||||
|
|
||||||
Mesh q = new Mesh();
|
Mesh q = new Mesh();
|
||||||
q.setBuffer(Type.Position, 3, new float[]
|
q.setBuffer(Type.Position, 3, new float[]
|
||||||
|
@ -128,7 +128,7 @@ public class TestEverything extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupFloor(){
|
public void setupFloor(){
|
||||||
Material mat = assetManager.loadMaterial("Textures/Terrain/Cobblestone/Cobblestone.j3m");
|
Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
|
||||||
mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
|
mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
|
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
|
mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
|
@ -36,13 +36,19 @@ import com.jme3.app.SimpleApplication;
|
|||||||
import com.jme3.effect.ParticleEmitter;
|
import com.jme3.effect.ParticleEmitter;
|
||||||
import com.jme3.effect.ParticleMesh.Type;
|
import com.jme3.effect.ParticleMesh.Type;
|
||||||
import com.jme3.effect.shapes.EmitterSphereShape;
|
import com.jme3.effect.shapes.EmitterSphereShape;
|
||||||
|
import com.jme3.export.binary.BinaryExporter;
|
||||||
|
import com.jme3.export.binary.BinaryImporter;
|
||||||
import com.jme3.material.Material;
|
import com.jme3.material.Material;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class TestParticleEmitter extends SimpleApplication {
|
public class TestParticleExportingCloning extends SimpleApplication {
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
TestParticleEmitter app = new TestParticleEmitter();
|
TestParticleExportingCloning app = new TestParticleExportingCloning();
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +65,25 @@ public class TestParticleEmitter extends SimpleApplication {
|
|||||||
mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
|
mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
|
||||||
emit.setMaterial(mat);
|
emit.setMaterial(mat);
|
||||||
|
|
||||||
|
ParticleEmitter emit2 = emit.clone();
|
||||||
|
emit2.move(3, 0, 0);
|
||||||
|
|
||||||
rootNode.attachChild(emit);
|
rootNode.attachChild(emit);
|
||||||
|
rootNode.attachChild(emit2);
|
||||||
|
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
BinaryExporter.getInstance().save(emit, out);
|
||||||
|
|
||||||
|
BinaryImporter imp = new BinaryImporter();
|
||||||
|
imp.setAssetManager(assetManager);
|
||||||
|
ParticleEmitter emit3 = (ParticleEmitter) imp.load(out.toByteArray());
|
||||||
|
|
||||||
|
emit3.move(-3, 0, 0);
|
||||||
|
rootNode.attachChild(emit3);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// Camera cam2 = cam.clone();
|
// Camera cam2 = cam.clone();
|
||||||
// cam.setViewPortTop(0.5f);
|
// cam.setViewPortTop(0.5f);
|
||||||
@ -67,7 +91,6 @@ public class TestParticleEmitter extends SimpleApplication {
|
|||||||
// ViewPort vp = renderManager.createMainView("SecondView", cam2);
|
// ViewPort vp = renderManager.createMainView("SecondView", cam2);
|
||||||
// viewPort.setClearEnabled(false);
|
// viewPort.setClearEnabled(false);
|
||||||
// vp.attachScene(rootNode);
|
// vp.attachScene(rootNode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user