* Javadoc for Asset

* Javadoc fix for AudioData, BoundingVolume, CollisionResult 
 * Javadoc package.html for asset 
 * Add test for bad tangent generation models 

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8575 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 13 years ago
parent 6286ac495f
commit 0e49c439b7
  1. 32
      engine/src/core/com/jme3/asset/Asset.java
  2. 37
      engine/src/core/com/jme3/asset/package.html
  3. 4
      engine/src/core/com/jme3/audio/AudioData.java
  4. 25
      engine/src/core/com/jme3/bounding/BoundingVolume.java
  5. 6
      engine/src/core/com/jme3/collision/CollisionResult.java
  6. 103
      engine/src/test/jme3test/light/TestTangentGenBadModels.java

@ -34,8 +34,40 @@ package com.jme3.asset;
/** /**
* Implementing the asset interface allows use of smart asset management. * Implementing the asset interface allows use of smart asset management.
* <p>
* Smart asset management requires cooperation from the {@link AssetKey}.
* In particular, the AssetKey should return true in its
* {@link AssetKey#useSmartCache() } method. Also smart assets MUST
* create a clone of the asset and cannot return the same reference,
* e.g. {@link AssetKey#createClonedInstance(java.lang.Object) createCloneInstance(someAsset)} <code>!= someAsset</code>.
* <p>
* If the {@link AssetManager#loadAsset(com.jme3.asset.AssetKey) } method
* is called twice with the same asset key (equals() wise, not necessarily reference wise)
* then both assets will have the same asset key set (reference wise) via
* {@link Asset#setKey(com.jme3.asset.AssetKey) }, then this asset key
* is used to track all instances of that asset. Once all clones of the asset
* are garbage collected, the shared asset key becomes unreachable and at that
* point it is removed from the smart asset cache.
*/ */
public interface Asset { public interface Asset {
/**
* Set by the {@link AssetManager} to track this asset.
*
* Only clones of the asset has this set, the original copy that
* was loaded has this key set to null so that only the clones are tracked
* for garbage collection.
*
* @param key The AssetKey to set
*/
public void setKey(AssetKey key); public void setKey(AssetKey key);
/**
* Returns the asset key that is used to track this asset for garbage
* collection.
*
* @return the asset key that is used to track this asset for garbage
* collection.
*/
public AssetKey getKey(); public AssetKey getKey();
} }

@ -0,0 +1,37 @@
<!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>
<code>com.jme3.asset</code> contains the {@link com.jme3.asset.AssetManager},
a utility class that is used to load assets such as textures, models, and
sound effects in a jME3 application. <br>
<p>
<h3>AssetLoaders</h3>
{@link com.jme3.asset.AssetLoader asset loaders} are registered to load
assets of a particular format. For example, an <code>AssetLoader</code> that
loads TGA images should read a stream in .tga format and return an
{@link com.jme3.texture.Image} object as its output.
<code>AssetLoader</code>s are initialized once a file of that format
is loaded, there's only one AssetLoader per thread so
AssetLoader's load() method does not have to be thread safe.
<h3>AssetLocators</h3>
{@link com.jme3.asset.AssetLocators asset locators} are used to resolve
an asset name (a string) into an {@link java.io.InputStream} which is
contained in an {@link com.jme3.asset.AssetInfo} object.
There are <code>AssetLocators</code> for loading files from the application's
classpath, the local hard drive, a ZIP file, an HTTP server, and more. The user
can implement their own AssetLocators and register them with the <code>AssetManager</code>
to load their resources from their own location.
</body>
</html>

@ -37,8 +37,8 @@ import com.jme3.util.NativeObject;
/** /**
* <code>AudioData</code> is an abstract representation * <code>AudioData</code> is an abstract representation
* of audio data. There are two ways to handle audio data, short audio files * of audio data. There are two ways to handle audio data, short audio files
* are to be stored entirely in memory, while long audio files (music) is * are to be stored entirely in memory, while long audio files (music) are
* streamed from the hard drive as it is played. * streamed from the hard drive as they are played.
* *
* @author Kirill Vainer * @author Kirill Vainer
*/ */

@ -54,12 +54,33 @@ import com.jme3.math.Vector3f;
*/ */
public abstract class BoundingVolume implements Savable, Cloneable, Collidable { public abstract class BoundingVolume implements Savable, Cloneable, Collidable {
/**
* The type of bounding volume being used.
*/
public enum Type { public enum Type {
Sphere, AABB, OBB, Capsule; /**
* {@link BoundingSphere}
*/
Sphere,
/**
* {@link BoundingBox}.
*/
AABB,
/**
* {@link com.jme3.bounding.OrientedBoundingBox}
*/
OBB,
/**
* Currently unsupported by jME3.
*/
Capsule;
} }
protected int checkPlane = 0; protected int checkPlane = 0;
Vector3f center = new Vector3f(); protected Vector3f center = new Vector3f();
public BoundingVolume() { public BoundingVolume() {
} }

@ -38,7 +38,11 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
/** /**
* @author Kirill * A <code>CollisionResult</code> represents a single collision instance
* between two {@link Collidable}. A collision check can result in many
* collision instances (places where collision has occured).
*
* @author Kirill Vainer
*/ */
public class CollisionResult implements Comparable<CollisionResult> { public class CollisionResult implements Comparable<CollisionResult> {

@ -0,0 +1,103 @@
package jme3test.light;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.UrlLocator;
import com.jme3.light.AmbientLight;
import com.jme3.light.PointLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.material.Material;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Sphere;
import com.jme3.light.DirectionalLight;
import com.jme3.scene.Mesh;
import com.jme3.scene.SceneGraphVisitorAdapter;
import com.jme3.util.TangentBinormalGenerator;
/**
*
* @author Kirusha
*/
public class TestTangentGenBadModels extends SimpleApplication {
float angle;
PointLight pl;
Geometry lightMdl;
public static void main(String[] args){
TestTangentGenBadModels app = new TestTangentGenBadModels();
app.start();
}
@Override
public void simpleInitApp() {
assetManager.registerLocator("http://jme-glsl-shaders.googlecode.com/hg/assets/Models/LightBlow/", UrlLocator.class);
assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/", UrlLocator.class);
Spatial badModel = assetManager.loadModel("jme_lightblow.obj");
badModel.setLocalScale(2f);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("NormalMap", assetManager.loadTexture("jme_lightblow_nor.png"));
badModel.setMaterial(mat);
rootNode.attachChild(badModel);
// TODO: For some reason blender loader fails to load this.
// need to check it
// Spatial model = assetManager.loadModel("test.blend");
// rootNode.attachChild(model);
rootNode.depthFirstTraversal(new SceneGraphVisitorAdapter(){
@Override
public void visit(Geometry g){
Mesh m = g.getMesh();
Material mat = g.getMaterial();
if (mat.getParam("DiffuseMap") != null){
mat.setTexture("DiffuseMap", null);
}
TangentBinormalGenerator.generate(m);
}
});
// Geometry debug = new Geometry(
// "Debug Teapot",
// TangentBinormalGenerator.genTbnLines(((Geometry) badModel).getMesh(), 0.03f)
// );
// debug.getMesh().setLineWidth(3);
// Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
// debug.setMaterial(debugMat);
// debug.setCullHint(Spatial.CullHint.Never);
// debug.getLocalTranslation().set(badModel.getLocalTranslation());
// debug.getLocalScale().set(badModel.getLocalScale());
// rootNode.attachChild(debug);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.8f, -0.6f, -0.08f).normalizeLocal());
dl.setColor(new ColorRGBA(1,1,1,1));
rootNode.addLight(dl);
lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
lightMdl.getMesh().setStatic();
rootNode.attachChild(lightMdl);
pl = new PointLight();
pl.setColor(ColorRGBA.White);
// rootNode.addLight(pl);
}
@Override
public void simpleUpdate(float tpf){
angle += tpf;
angle %= FastMath.TWO_PI;
pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 2f, FastMath.sin(angle) * 2f));
lightMdl.setLocalTranslation(pl.getPosition());
}
}
Loading…
Cancel
Save