- some javadoc fixes in TextureAtlas

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9052 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent d83815847a
commit bfa0bf6a1e
  1. 61
      engine/src/tools/jme3tools/optimize/TextureAtlas.java

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2010 jMonkeyEngine * Copyright (c) 2009-2012 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -58,7 +58,7 @@ import java.util.logging.Logger;
/** /**
* *
* @author Lukasz Bruun - lukasz.dk, normenhansen * @author normenhansen, Lukasz Bruun - lukasz.dk
*/ */
public class TextureAtlas { public class TextureAtlas {
@ -78,9 +78,9 @@ public class TextureAtlas {
} }
/** /**
* Add a geometries DiffuseMap (or ColorMap), NormalMap and SpecularMap to the atlas * Add a geometries DiffuseMap (or ColorMap), NormalMap and SpecularMap to the atlas.
* @param geometry * @param geometry
* @return false if the atlas is full * @return false if the atlas is full.
*/ */
public boolean addGeometry(Geometry geometry) { public boolean addGeometry(Geometry geometry) {
Texture diffuse = getMaterialTexture(geometry, "DiffuseMap"); Texture diffuse = getMaterialTexture(geometry, "DiffuseMap");
@ -109,9 +109,9 @@ public class TextureAtlas {
/** /**
* Add a texture for a specific map name * Add a texture for a specific map name
* @param texture A texture to add to the atlas * @param texture A texture to add to the atlas.
* @param mapName A freely chosen map name that can be later retrieved as a Texture. The first map name supplied will be the master map. * @param mapName A freely chosen map name that can be later retrieved as a Texture. The first map name supplied will be the master map.
* @return false if the atlas is full * @return false if the atlas is full.
*/ */
public boolean addTexture(Texture texture, String mapName) { public boolean addTexture(Texture texture, String mapName) {
if (texture == null) { if (texture == null) {
@ -121,21 +121,21 @@ public class TextureAtlas {
if (texture.getImage() != null && name != null) { if (texture.getImage() != null && name != null) {
return addImage(texture.getImage(), name, mapName, null); return addImage(texture.getImage(), name, mapName, null);
} else { } else {
throw new IllegalStateException("Source texture has no asset name"); throw new IllegalStateException("Texture has no asset name");
} }
} }
/** /**
* Add a texture for a specific map name at the location of another existing texture (on the master map). * Add a texture for a specific map name at the location of another existing texture on the master map.
* @param texture A texture to add to the atlas. * @param texture A texture to add to the atlas.
* @param mapName A freely chosen map name that can be later retrieved as a Texture. * @param mapName A freely chosen map name that can be later retrieved as a Texture.
* @param sourceTexture The base texture for determining the location. * @param masterTexture The master texture for determining the location, it has to exist in tha master map.
* @return false if the atlas is full * @return false if the atlas is full
*/ */
public void addTexture(Texture texture, String mapName, Texture sourceTexture) { public void addTexture(Texture texture, String mapName, Texture masterTexture) {
String sourceTextureName = textureName(sourceTexture); String sourceTextureName = textureName(masterTexture);
if (sourceTextureName == null) { if (sourceTextureName == null) {
throw new IllegalStateException("Source texture has no asset name"); throw new IllegalStateException("Master texture has no asset name");
} else { } else {
addTexture(texture, mapName, sourceTextureName); addTexture(texture, mapName, sourceTextureName);
} }
@ -145,8 +145,7 @@ public class TextureAtlas {
* Add a texture for a specific map name at the location of another existing texture (on the master map). * Add a texture for a specific map name at the location of another existing texture (on the master map).
* @param texture A texture to add to the atlas. * @param texture A texture to add to the atlas.
* @param mapName A freely chosen map name that can be later retrieved as a Texture. * @param mapName A freely chosen map name that can be later retrieved as a Texture.
* @param sourceTextureName Name of the base texture for the location. * @param sourceTextureName Name of the master map used for the location.
* @return false if the atlas is full
*/ */
public void addTexture(Texture texture, String mapName, String sourceTextureName) { public void addTexture(Texture texture, String mapName, String sourceTextureName) {
if (texture == null) { if (texture == null) {
@ -272,7 +271,7 @@ public class TextureAtlas {
} }
/** /**
* Gets a new atlas texture for the given map name. * Creates a new atlas texture for the given map name.
* @param mapName * @param mapName
* @return * @return
*/ */
@ -295,7 +294,7 @@ public class TextureAtlas {
* Applies the texture coordinates to the given geometry * Applies the texture coordinates to the given geometry
* if its DiffuseMap or ColorMap exists in the atlas. * if its DiffuseMap or ColorMap exists in the atlas.
* @param geom The geometry to change the texture coordinate buffer on. * @param geom The geometry to change the texture coordinate buffer on.
* @return true if texture has been found and coords have been changed, false otherwise * @return true if texture has been found and coords have been changed, false otherwise.
*/ */
public boolean applyCoords(Geometry geom) { public boolean applyCoords(Geometry geom) {
return applyCoords(geom, 0, geom.getMesh()); return applyCoords(geom, 0, geom.getMesh());
@ -305,9 +304,9 @@ public class TextureAtlas {
* Applies the texture coordinates to the given output mesh * Applies the texture coordinates to the given output mesh
* if the DiffuseMap or ColorMap of the input geometry exist in the atlas. * if the DiffuseMap or ColorMap of the input geometry exist in the atlas.
* @param geom The geometry to change the texture coordinate buffer on. * @param geom The geometry to change the texture coordinate buffer on.
* @param offset Target buffer offset * @param offset Target buffer offset.
* @param outMesh The mesh to set the coords in (can be same as input) * @param outMesh The mesh to set the coords in (can be same as input).
* @return true if texture has been found and coords have been changed, false otherwise * @return true if texture has been found and coords have been changed, false otherwise.
*/ */
public boolean applyCoords(Geometry geom, int offset, Mesh outMesh) { public boolean applyCoords(Geometry geom, int offset, Mesh outMesh) {
Mesh inMesh = geom.getMesh(); Mesh inMesh = geom.getMesh();
@ -342,9 +341,9 @@ public class TextureAtlas {
/** /**
* Create a texture atlas for the given root node, containing DiffuseMap, NormalMap and SpecularMap. * Create a texture atlas for the given root node, containing DiffuseMap, NormalMap and SpecularMap.
* @param root The rootNode to create the atlas for * @param root The rootNode to create the atlas for.
* @param atlasSize The size of the atlas (width and height) * @param atlasSize The size of the atlas (width and height).
* @return Null if the atlas cannot be created because not all textures fit * @return Null if the atlas cannot be created because not all textures fit.
*/ */
public static TextureAtlas createAtlas(Spatial root, int atlasSize) { public static TextureAtlas createAtlas(Spatial root, int atlasSize) {
List<Geometry> geometries = new ArrayList<Geometry>(); List<Geometry> geometries = new ArrayList<Geometry>();
@ -363,9 +362,9 @@ public class TextureAtlas {
* Creates one geometry out of the given root spatial and merges all single * Creates one geometry out of the given root spatial and merges all single
* textures into one texture of the given size. * textures into one texture of the given size.
* @param spat The root spatial of the scene to batch * @param spat The root spatial of the scene to batch
* @param mgr An assetmanager that can be used to create the material * @param mgr An assetmanager that can be used to create the material.
* @param atlasSize A size for the atlas texture, it has to be large enough to hold all single textures * @param atlasSize A size for the atlas texture, it has to be large enough to hold all single textures.
* @return A new geometry that uses the generated texture atlas and merges all meshes of the root spatial, null if the atlas cannot be created because not all textures fit * @return A new geometry that uses the generated texture atlas and merges all meshes of the root spatial, null if the atlas cannot be created because not all textures fit.
*/ */
public static Geometry makeAtlasBatch(Spatial spat, AssetManager mgr, int atlasSize) { public static Geometry makeAtlasBatch(Spatial spat, AssetManager mgr, int atlasSize) {
List<Geometry> geometries = new ArrayList<Geometry>(); List<Geometry> geometries = new ArrayList<Geometry>();
@ -512,8 +511,8 @@ public class TextureAtlas {
} }
/** /**
* Get the transformed texture location for a given input location * Get the transformed texture location for a given input location.
* @param previousLocation * @param previousLocation.
* @return * @return
*/ */
public Vector2f getLocation(Vector2f previousLocation) { public Vector2f getLocation(Vector2f previousLocation) {
@ -529,10 +528,10 @@ public class TextureAtlas {
} }
/** /**
* Transforms a whole texture coordinates buffer * Transforms a whole texture coordinates buffer.
* @param inBuf The input texture buffer * @param inBuf The input texture buffer.
* @param offset The offset in the output buffer * @param offset The offset in the output buffer
* @param outBuf The output buffer * @param outBuf The output buffer.
*/ */
public void transformTextureCoords(FloatBuffer inBuf, int offset, FloatBuffer outBuf) { public void transformTextureCoords(FloatBuffer inBuf, int offset, FloatBuffer outBuf) {
Vector2f tex = new Vector2f(); Vector2f tex = new Vector2f();
@ -545,7 +544,7 @@ public class TextureAtlas {
tex.x = inBuf.get(i * 2 + 0); tex.x = inBuf.get(i * 2 + 0);
tex.y = inBuf.get(i * 2 + 1); tex.y = inBuf.get(i * 2 + 1);
Vector2f location = getLocation(tex); Vector2f location = getLocation(tex);
//TODO: replace with proper texture wrapping for atlases.. //TODO: add proper texture wrapping for atlases..
outBuf.put(offset + i * 2 + 0, location.x); outBuf.put(offset + i * 2 + 0, location.x);
outBuf.put(offset + i * 2 + 1, location.y); outBuf.put(offset + i * 2 + 1, location.y);
} }

Loading…
Cancel
Save