* Renamed BinaryClassLoader to SavableClassFinder and put it into core * SavableClassFinder now can remap class names, it is used to load old J3O files with particles in them by remapping the old shape names to the new names. * Moved the particle emitter control into an inner class so nobody fools around with it * Loading of old particle emitters now works * Fixed issue with input not responding * Fixed some small javadoc mistakes in RenderState * Javadocs for com.jme3.material (not done) * AbstractControl will now throw exception when an already-attached control is added to another spatial * All tests should now use non-deprecated ParticleEmitter.setGravity method git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7589 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
4079aeab5e
commit
80900a8d64
@ -1,118 +0,0 @@ |
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
package com.jme3.export.binary; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.logging.Logger; |
||||
|
||||
import com.jme3.export.InputCapsule; |
||||
import com.jme3.export.Savable; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* This class is mis-named and is located in an inappropriate package: |
||||
* It is not binary-specific (it is in fact used for XML format too), and it |
||||
* is not a java.lang.ClassLoader, which is what "class loader" is for Java |
||||
* developers. |
||||
* |
||||
* @author mpowell |
||||
*/ |
||||
public class BinaryClassLoader { |
||||
|
||||
/** |
||||
* fromName creates a new Savable from the provided class name. First registered modules |
||||
* are checked to handle special cases, if the modules do not handle the class name, the |
||||
* class is instantiated directly. |
||||
* @param className the class name to create. |
||||
* @param inputCapsule the InputCapsule that will be used for loading the Savable (to look up ctor parameters) |
||||
* @return the Savable instance of the class. |
||||
* @throws InstantiationException thrown if the class does not have an empty constructor. |
||||
* @throws IllegalAccessException thrown if the class is not accessable. |
||||
* @throws ClassNotFoundException thrown if the class name is not in the classpath. |
||||
* @throws IOException when loading ctor parameters fails |
||||
*/ |
||||
public static Savable fromName(String className, InputCapsule inputCapsule) throws InstantiationException, |
||||
IllegalAccessException, ClassNotFoundException, IOException { |
||||
|
||||
try { |
||||
return (Savable)Class.forName(className).newInstance(); |
||||
} |
||||
catch (InstantiationException e) { |
||||
Logger.getLogger(BinaryClassLoader.class.getName()).severe( |
||||
"Could not access constructor of class '" + className + "'! \n" + |
||||
"Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup."); |
||||
throw e; |
||||
} |
||||
catch (IllegalAccessException e) { |
||||
Logger.getLogger(BinaryClassLoader.class.getName()).severe( |
||||
e.getMessage() + " \n" + |
||||
"Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup."); |
||||
throw e; |
||||
} |
||||
} |
||||
|
||||
public static Savable fromName(String className, InputCapsule inputCapsule, List<ClassLoader> loaders) throws InstantiationException, |
||||
IllegalAccessException, ClassNotFoundException, IOException { |
||||
if(loaders == null){ |
||||
return fromName(className, inputCapsule); |
||||
} |
||||
for (Iterator<ClassLoader> it = loaders.iterator(); it.hasNext();) { |
||||
ClassLoader classLoader = it.next(); |
||||
try { |
||||
return (Savable)classLoader.loadClass(className).newInstance(); |
||||
} |
||||
catch (InstantiationException e) { |
||||
} |
||||
catch (IllegalAccessException e) { |
||||
} |
||||
|
||||
} |
||||
|
||||
try { |
||||
return (Savable)Class.forName(className).newInstance(); |
||||
} |
||||
catch (InstantiationException e) { |
||||
Logger.getLogger(BinaryClassLoader.class.getName()).severe( |
||||
"Could not access constructor of class '" + className + "'! \n" + |
||||
"Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup."); |
||||
throw e; |
||||
} |
||||
catch (IllegalAccessException e) { |
||||
Logger.getLogger(BinaryClassLoader.class.getName()).severe( |
||||
e.getMessage() + " \n" + |
||||
"Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup."); |
||||
throw e; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,134 @@ |
||||
/* |
||||
* 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. |
||||
*/ |
||||
package com.jme3.export; |
||||
|
||||
import com.jme3.effect.shapes.EmitterBoxShape; |
||||
import com.jme3.effect.shapes.EmitterMeshConvexHullShape; |
||||
import com.jme3.effect.shapes.EmitterMeshFaceShape; |
||||
import com.jme3.effect.shapes.EmitterMeshVertexShape; |
||||
import com.jme3.effect.shapes.EmitterPointShape; |
||||
import com.jme3.effect.shapes.EmitterSphereShape; |
||||
import java.io.IOException; |
||||
import java.util.logging.Level; |
||||
import java.util.logging.Logger; |
||||
|
||||
import com.jme3.export.InputCapsule; |
||||
import com.jme3.export.Savable; |
||||
import java.util.HashMap; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <code>SavableClassFinder</code> is used to find classes referenced |
||||
* by savables. |
||||
* Currently it will remap any classes from old paths to new paths |
||||
* so that old J3O models can still be loaded. |
||||
* |
||||
* @author mpowell |
||||
* @author Kirill Vainer |
||||
*/ |
||||
public class SavableClassFinder { |
||||
|
||||
private final static HashMap<String, String> classRemappings = new HashMap<String, String>(); |
||||
|
||||
private static void addRemapping(String oldClass, Class<? extends Savable> newClass){ |
||||
classRemappings.put(oldClass, newClass.getName()); |
||||
} |
||||
|
||||
static { |
||||
addRemapping("com.jme3.effect.EmitterSphereShape", EmitterSphereShape.class); |
||||
addRemapping("com.jme3.effect.EmitterBoxShape", EmitterBoxShape.class); |
||||
addRemapping("com.jme3.effect.EmitterMeshConvexHullShape", EmitterMeshConvexHullShape.class); |
||||
addRemapping("com.jme3.effect.EmitterMeshFaceShape", EmitterMeshFaceShape.class); |
||||
addRemapping("com.jme3.effect.EmitterMeshVertexShape", EmitterMeshVertexShape.class); |
||||
addRemapping("com.jme3.effect.EmitterPointShape", EmitterPointShape.class); |
||||
} |
||||
|
||||
private static String remapClass(String className) throws ClassNotFoundException { |
||||
String result = classRemappings.get(className); |
||||
if (result == null) { |
||||
return className; |
||||
} else { |
||||
return result; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* fromName creates a new Savable from the provided class name. First registered modules |
||||
* are checked to handle special cases, if the modules do not handle the class name, the |
||||
* class is instantiated directly. |
||||
* @param className the class name to create. |
||||
* @param inputCapsule the InputCapsule that will be used for loading the Savable (to look up ctor parameters) |
||||
* @return the Savable instance of the class. |
||||
* @throws InstantiationException thrown if the class does not have an empty constructor. |
||||
* @throws IllegalAccessException thrown if the class is not accessable. |
||||
* @throws ClassNotFoundException thrown if the class name is not in the classpath. |
||||
* @throws IOException when loading ctor parameters fails |
||||
*/ |
||||
public static Savable fromName(String className, InputCapsule inputCapsule) throws InstantiationException, |
||||
IllegalAccessException, ClassNotFoundException, IOException { |
||||
|
||||
className = remapClass(className); |
||||
try { |
||||
return (Savable) Class.forName(className).newInstance(); |
||||
} catch (InstantiationException e) { |
||||
Logger.getLogger(SavableClassFinder.class.getName()).log( |
||||
Level.SEVERE, "Could not access constructor of class ''{0}" + "''! \n" |
||||
+ "Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup.", className); |
||||
throw e; |
||||
} catch (IllegalAccessException e) { |
||||
Logger.getLogger(SavableClassFinder.class.getName()).log( |
||||
Level.SEVERE, "{0} \n" |
||||
+ "Some types need to have the BinaryImporter set up in a special way. Please doublecheck the setup.", e.getMessage()); |
||||
throw e; |
||||
} |
||||
} |
||||
|
||||
public static Savable fromName(String className, InputCapsule inputCapsule, List<ClassLoader> loaders) throws InstantiationException, |
||||
IllegalAccessException, ClassNotFoundException, IOException { |
||||
if (loaders == null) { |
||||
return fromName(className, inputCapsule); |
||||
} |
||||
|
||||
String newClassName = remapClass(className); |
||||
for (ClassLoader classLoader : loaders){ |
||||
try { |
||||
return (Savable) classLoader.loadClass(newClassName).newInstance(); |
||||
} catch (InstantiationException e) { |
||||
} catch (IllegalAccessException e) { |
||||
} |
||||
|
||||
} |
||||
|
||||
return fromName(className, inputCapsule); |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
||||
<html> |
||||
|
||||
<head> |
||||
<title></title> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
||||
</head> |
||||
<body> |
||||
|
||||
The <code>com.jme3.material</code> package contains classes for manipulating |
||||
jMonkeyEngine materials. |
||||
Materials are applied to {@link com.jme3.scene.Geoemtry geometries} in the |
||||
scene. |
||||
Each geometry has a single material which is used to render that |
||||
geometry. |
||||
<p> |
||||
Materials (also known as material instances) are extended from |
||||
material definitions. |
||||
|
||||
<h3>Material definitions</h3> |
||||
<p> |
||||
Material definitions provide the "logic" for the material. Usually a shader that |
||||
will handle drawing the object, and corresponding parameters that allow |
||||
configuration of the shader. |
||||
Material definitions can be created through J3MD files. |
||||
The J3MD file abstracts the shader and its configuration away from the user, allowing a |
||||
simple interface where one can simply set a few parameters on the material to change its |
||||
appearance and the way its handled. |
||||
|
||||
<h3>Techniques</h3> |
||||
<p> |
||||
Techniques specify a specific way of rendering a material. Typically |
||||
a technique is used to implement the same material for each configuration |
||||
of the system. For GPUs that do not support shaders, a "fixed function pipeline" |
||||
technique could exist to take care of rendering for that configuration |
||||
|
||||
<h3>Render states</h3> |
||||
<p> |
||||
See {@link com.jme3.material.RenderState}. |
||||
|
||||
<h3>Example Usage</h3> |
||||
<p> |
||||
Creating a textured material |
||||
<code> |
||||
// Create a material instance |
||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); |
||||
|
||||
// Load the texture. |
||||
Texture tex = assetManager.loadTexture("Textures/Test/Test.jpg"); |
||||
|
||||
// Set the parameters |
||||
mat.setTexture("ColorMap", tex); |
||||
</code> |
||||
|
||||
|
||||
|
||||
</body> |
||||
</html> |
Loading…
Reference in new issue