* Javadocs for com.jme3.material
* Formatted the blender loader files according to NetBeans * Removed any "I" prefixes on interfaces * Small javadoc fixes git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7592 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
d03683deca
commit
95cdde7f53
@ -64,8 +64,8 @@ import com.jme3.texture.Texture;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class BlenderKey extends ModelKey {
|
public class BlenderKey extends ModelKey {
|
||||||
protected static final int DEFAULT_FPS = 25;
|
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FPS = 25;
|
||||||
/**
|
/**
|
||||||
* Animation definitions. The key is the object name that owns the animation. The value is a map between animation
|
* Animation definitions. The key is the object name that owns the animation. The value is a map between animation
|
||||||
* name and its start and stop frames. Blender stores a pointer for animation within object. Therefore one object
|
* name and its start and stop frames. Blender stores a pointer for animation within object. Therefore one object
|
||||||
@ -111,7 +111,8 @@ public class BlenderKey extends ModelKey {
|
|||||||
/**
|
/**
|
||||||
* Constructor used by serialization mechanisms.
|
* Constructor used by serialization mechanisms.
|
||||||
*/
|
*/
|
||||||
public BlenderKey() {}
|
public BlenderKey() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates a key for the given file name.
|
* Constructor. Creates a key for the given file name.
|
||||||
@ -534,6 +535,7 @@ public class BlenderKey extends ModelKey {
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public static interface FeaturesToLoad {
|
public static interface FeaturesToLoad {
|
||||||
|
|
||||||
int SCENES = 0x0000FFFF;
|
int SCENES = 0x0000FFFF;
|
||||||
int OBJECTS = 0x0000000B;
|
int OBJECTS = 0x0000000B;
|
||||||
int ANIMATIONS = 0x00000004;
|
int ANIMATIONS = 0x00000004;
|
||||||
@ -549,6 +551,7 @@ public class BlenderKey extends ModelKey {
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public static class LoadingResults extends Spatial {
|
public static class LoadingResults extends Spatial {
|
||||||
|
|
||||||
/** Bitwise mask of features that are to be loaded. */
|
/** Bitwise mask of features that are to be loaded. */
|
||||||
private final int featuresToLoad;
|
private final int featuresToLoad;
|
||||||
/** The scenes from the file. */
|
/** The scenes from the file. */
|
||||||
@ -735,10 +738,12 @@ public class BlenderKey extends ModelKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateModelBound() {}
|
public void updateModelBound() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setModelBound(BoundingVolume modelBound) {}
|
public void setModelBound(BoundingVolume modelBound) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVertexCount() {
|
public int getVertexCount() {
|
||||||
@ -756,10 +761,12 @@ public class BlenderKey extends ModelKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void depthFirstTraversal(SceneGraphVisitor visitor) {}
|
public void depthFirstTraversal(SceneGraphVisitor visitor) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {}
|
protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue<Spatial> queue) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -768,6 +775,7 @@ public class BlenderKey extends ModelKey {
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public static class WorldData {
|
public static class WorldData {
|
||||||
|
|
||||||
/** The ambient light. */
|
/** The ambient light. */
|
||||||
private AmbientLight ambientLight;
|
private AmbientLight ambientLight;
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ import com.jme3.scene.plugins.blender.utils.JmeConverter;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class BlenderLoader implements AssetLoader {
|
public class BlenderLoader implements AssetLoader {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(BlenderLoader.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(BlenderLoader.class.getName());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,7 +141,7 @@ public class BlenderLoader implements AssetLoader {
|
|||||||
Object object = converter.toObject(block.getStructure(dataRepository));
|
Object object = converter.toObject(block.getStructure(dataRepository));
|
||||||
if (object instanceof Node) {
|
if (object instanceof Node) {
|
||||||
if ((blenderKey.getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0) {
|
if ((blenderKey.getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0) {
|
||||||
LOGGER.log(Level.INFO, ((Node)object).getName() + ": " + ((Node)object).getLocalTranslation().toString() + "--> " + (((Node)object).getParent() == null ? "null" : ((Node)object).getParent().getName()));
|
LOGGER.log(Level.INFO, "{0}: {1}--> {2}", new Object[]{((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName()});
|
||||||
if (((Node) object).getParent() == null) {
|
if (((Node) object).getParent() == null) {
|
||||||
loadingResults.addObject((Node) object);
|
loadingResults.addObject((Node) object);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ import com.jme3.scene.plugins.blender.utils.JmeConverter;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class BlenderModelLoader implements AssetLoader {
|
public class BlenderModelLoader implements AssetLoader {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(BlenderModelLoader.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(BlenderModelLoader.class.getName());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,7 +131,7 @@ public class BlenderModelLoader implements AssetLoader {
|
|||||||
if (block.getCode() == FileBlockHeader.BLOCK_OB00) {
|
if (block.getCode() == FileBlockHeader.BLOCK_OB00) {
|
||||||
Object object = converter.toObject(block.getStructure(dataRepository));
|
Object object = converter.toObject(block.getStructure(dataRepository));
|
||||||
if (object instanceof Node) {
|
if (object instanceof Node) {
|
||||||
LOGGER.log(Level.INFO, ((Node)object).getName() + ": " + ((Node)object).getLocalTranslation().toString() + "--> " + (((Node)object).getParent() == null ? "null" : ((Node)object).getParent().getName()));
|
LOGGER.log(Level.INFO, "{0}: {1}--> {2}", new Object[]{((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName()});
|
||||||
if (((Node) object).getParent() == null) {
|
if (((Node) object).getParent() == null) {
|
||||||
loadingResults.addObject((Node) object);
|
loadingResults.addObject((Node) object);
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,12 @@ import com.jme3.scene.plugins.blender.utils.DataRepository;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class DnaBlockData {
|
public class DnaBlockData {
|
||||||
|
|
||||||
private static final int SDNA_ID = 'S' << 24 | 'D' << 16 | 'N' << 8 | 'A'; //SDNA
|
private static final int SDNA_ID = 'S' << 24 | 'D' << 16 | 'N' << 8 | 'A'; //SDNA
|
||||||
private static final int NAME_ID = 'N' << 24 | 'A' << 16 | 'M' << 8 | 'E'; //NAME
|
private static final int NAME_ID = 'N' << 24 | 'A' << 16 | 'M' << 8 | 'E'; //NAME
|
||||||
private static final int TYPE_ID = 'T' << 24 | 'Y' << 16 | 'P' << 8 | 'E'; //TYPE
|
private static final int TYPE_ID = 'T' << 24 | 'Y' << 16 | 'P' << 8 | 'E'; //TYPE
|
||||||
private static final int TLEN_ID = 'T' << 24 | 'L' << 16 | 'E' << 8 | 'N'; //TLEN
|
private static final int TLEN_ID = 'T' << 24 | 'L' << 16 | 'E' << 8 | 'N'; //TLEN
|
||||||
private static final int STRC_ID = 'S' << 24 | 'T' << 16 | 'R' << 8 | 'C'; //STRC
|
private static final int STRC_ID = 'S' << 24 | 'T' << 16 | 'R' << 8 | 'C'; //STRC
|
||||||
|
|
||||||
/** Structures available inside the file. */
|
/** Structures available inside the file. */
|
||||||
private final Structure[] structures;
|
private final Structure[] structures;
|
||||||
/** A map that helps finding a structure by type. */
|
/** A map that helps finding a structure by type. */
|
||||||
@ -67,16 +67,16 @@ public class DnaBlockData {
|
|||||||
int identifier;
|
int identifier;
|
||||||
|
|
||||||
//reading 'SDNA' identifier
|
//reading 'SDNA' identifier
|
||||||
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
|
|
||||||
if (identifier != SDNA_ID) {
|
if (identifier != SDNA_ID) {
|
||||||
throw new BlenderFileException("Invalid identifier! '" + this.toString(SDNA_ID) + "' expected and found: " + this.toString(identifier));
|
throw new BlenderFileException("Invalid identifier! '" + this.toString(SDNA_ID) + "' expected and found: " + this.toString(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
//reading names
|
//reading names
|
||||||
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
if (identifier != NAME_ID) {
|
if (identifier != NAME_ID) {
|
||||||
throw new BlenderFileException("Invalid identifier! '" + this.toString(NAME_ID) + "' expected and found: " + this.toString(identifier));
|
throw new BlenderFileException("Invalid identifier! '" + this.toString(NAME_ID) + "' expected and found: " + this.toString(identifier));
|
||||||
}
|
}
|
||||||
@ -91,8 +91,8 @@ public class DnaBlockData {
|
|||||||
|
|
||||||
//reding types
|
//reding types
|
||||||
inputStream.alignPosition(4);
|
inputStream.alignPosition(4);
|
||||||
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
if (identifier != TYPE_ID) {
|
if (identifier != TYPE_ID) {
|
||||||
throw new BlenderFileException("Invalid identifier! '" + this.toString(TYPE_ID) + "' expected and found: " + this.toString(identifier));
|
throw new BlenderFileException("Invalid identifier! '" + this.toString(TYPE_ID) + "' expected and found: " + this.toString(identifier));
|
||||||
}
|
}
|
||||||
@ -107,8 +107,8 @@ public class DnaBlockData {
|
|||||||
|
|
||||||
//reading lengths
|
//reading lengths
|
||||||
inputStream.alignPosition(4);
|
inputStream.alignPosition(4);
|
||||||
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
if (identifier != TLEN_ID) {
|
if (identifier != TLEN_ID) {
|
||||||
throw new BlenderFileException("Invalid identifier! '" + this.toString(TLEN_ID) + "' expected and found: " + this.toString(identifier));
|
throw new BlenderFileException("Invalid identifier! '" + this.toString(TLEN_ID) + "' expected and found: " + this.toString(identifier));
|
||||||
}
|
}
|
||||||
@ -119,8 +119,8 @@ public class DnaBlockData {
|
|||||||
|
|
||||||
//reading structures
|
//reading structures
|
||||||
inputStream.alignPosition(4);
|
inputStream.alignPosition(4);
|
||||||
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
identifier = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
if (identifier != STRC_ID) {
|
if (identifier != STRC_ID) {
|
||||||
throw new BlenderFileException("Invalid identifier! '" + this.toString(STRC_ID) + "' expected and found: " + this.toString(identifier));
|
throw new BlenderFileException("Invalid identifier! '" + this.toString(STRC_ID) + "' expected and found: " + this.toString(identifier));
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* another structure.
|
* another structure.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
/*package*/class Field implements Cloneable {
|
/*package*/
|
||||||
|
class Field implements Cloneable {
|
||||||
|
|
||||||
private static final int NAME_LENGTH = 24;
|
private static final int NAME_LENGTH = 24;
|
||||||
private static final int TYPE_LENGTH = 16;
|
private static final int TYPE_LENGTH = 16;
|
||||||
|
|
||||||
/** The data repository. */
|
/** The data repository. */
|
||||||
public DataRepository dataRepository;
|
public DataRepository dataRepository;
|
||||||
/** The type of the field. */
|
/** The type of the field. */
|
||||||
|
@ -41,6 +41,7 @@ import com.jme3.scene.plugins.blender.utils.DataRepository;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class FileBlockHeader {
|
public class FileBlockHeader {
|
||||||
|
|
||||||
public static final int BLOCK_TE00 = 'T' << 24 | 'E' << 16; //TE00
|
public static final int BLOCK_TE00 = 'T' << 24 | 'E' << 16; //TE00
|
||||||
public static final int BLOCK_ME00 = 'M' << 24 | 'E' << 16; //ME00
|
public static final int BLOCK_ME00 = 'M' << 24 | 'E' << 16; //ME00
|
||||||
public static final int BLOCK_SR00 = 'S' << 24 | 'R' << 16; //SR00
|
public static final int BLOCK_SR00 = 'S' << 24 | 'R' << 16; //SR00
|
||||||
@ -53,13 +54,11 @@ public class FileBlockHeader {
|
|||||||
public static final int BLOCK_TX00 = 'T' << 24 | 'X' << 16; //TX00
|
public static final int BLOCK_TX00 = 'T' << 24 | 'X' << 16; //TX00
|
||||||
public static final int BLOCK_IP00 = 'I' << 24 | 'P' << 16; //IP00
|
public static final int BLOCK_IP00 = 'I' << 24 | 'P' << 16; //IP00
|
||||||
public static final int BLOCK_AC00 = 'A' << 24 | 'C' << 16; //AC00
|
public static final int BLOCK_AC00 = 'A' << 24 | 'C' << 16; //AC00
|
||||||
|
|
||||||
public static final int BLOCK_GLOB = 'G' << 24 | 'L' << 16 | 'O' << 8 | 'B'; //GLOB
|
public static final int BLOCK_GLOB = 'G' << 24 | 'L' << 16 | 'O' << 8 | 'B'; //GLOB
|
||||||
public static final int BLOCK_REND = 'R' << 24 | 'E' << 16 | 'N' << 8 | 'D'; //REND
|
public static final int BLOCK_REND = 'R' << 24 | 'E' << 16 | 'N' << 8 | 'D'; //REND
|
||||||
public static final int BLOCK_DATA = 'D' << 24 | 'A' << 16 | 'T' << 8 | 'A'; //DATA
|
public static final int BLOCK_DATA = 'D' << 24 | 'A' << 16 | 'T' << 8 | 'A'; //DATA
|
||||||
public static final int BLOCK_DNA1 = 'D' << 24 | 'N' << 16 | 'A' << 8 | '1'; //DNA1
|
public static final int BLOCK_DNA1 = 'D' << 24 | 'N' << 16 | 'A' << 8 | '1'; //DNA1
|
||||||
public static final int BLOCK_ENDB = 'E' << 24 | 'N' << 16 | 'D' << 8 | 'B'; //ENDB
|
public static final int BLOCK_ENDB = 'E' << 24 | 'N' << 16 | 'D' << 8 | 'B'; //ENDB
|
||||||
|
|
||||||
/** Identifier of the file-block [4 bytes]. */
|
/** Identifier of the file-block [4 bytes]. */
|
||||||
private int code;
|
private int code;
|
||||||
/** Total length of the data after the file-block-header [4 bytes]. */
|
/** Total length of the data after the file-block-header [4 bytes]. */
|
||||||
@ -87,8 +86,8 @@ public class FileBlockHeader {
|
|||||||
*/
|
*/
|
||||||
public FileBlockHeader(BlenderInputStream inputStream, DataRepository dataRepository) throws BlenderFileException {
|
public FileBlockHeader(BlenderInputStream inputStream, DataRepository dataRepository) throws BlenderFileException {
|
||||||
inputStream.alignPosition(4);
|
inputStream.alignPosition(4);
|
||||||
code = inputStream.readByte() << 24 | inputStream.readByte() << 16 |
|
code = inputStream.readByte() << 24 | inputStream.readByte() << 16
|
||||||
inputStream.readByte() << 8 | inputStream.readByte();
|
| inputStream.readByte() << 8 | inputStream.readByte();
|
||||||
size = inputStream.readInt();
|
size = inputStream.readInt();
|
||||||
oldMemoryAddress = inputStream.readPointer();
|
oldMemoryAddress = inputStream.readPointer();
|
||||||
sdnaIndex = inputStream.readInt();
|
sdnaIndex = inputStream.readInt();
|
||||||
|
@ -46,6 +46,7 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class Structure implements Cloneable {
|
public class Structure implements Cloneable {
|
||||||
|
|
||||||
/** The data repository. */
|
/** The data repository. */
|
||||||
private DataRepository dataRepository;
|
private DataRepository dataRepository;
|
||||||
/** The address of the block that fills the structure. */
|
/** The address of the block that fills the structure. */
|
||||||
@ -268,11 +269,13 @@ public class Structure implements Cloneable {
|
|||||||
* This enum enumerates all known data types that can be found in the blend file.
|
* This enum enumerates all known data types that can be found in the blend file.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
/*package*/static enum DataType {
|
/*package*/
|
||||||
CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, VOID, STRUCTURE, POINTER;
|
static enum DataType {
|
||||||
|
|
||||||
|
CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, VOID, STRUCTURE, POINTER;
|
||||||
/** The map containing the known primary types. */
|
/** The map containing the known primary types. */
|
||||||
private static final Map<String, DataType> PRIMARY_TYPES = new HashMap<String, DataType>(10);
|
private static final Map<String, DataType> PRIMARY_TYPES = new HashMap<String, DataType>(10);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PRIMARY_TYPES.put("char", CHARACTER);
|
PRIMARY_TYPES.put("char", CHARACTER);
|
||||||
PRIMARY_TYPES.put("uchar", CHARACTER);
|
PRIMARY_TYPES.put("uchar", CHARACTER);
|
||||||
|
@ -36,12 +36,14 @@ package com.jme3.scene.plugins.blender.exception;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class BlenderFileException extends Exception {
|
public class BlenderFileException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7573482836437866767L;
|
private static final long serialVersionUID = 7573482836437866767L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates an exception with no description.
|
* Constructor. Creates an exception with no description.
|
||||||
*/
|
*/
|
||||||
public BlenderFileException() {}
|
public BlenderFileException() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates an exception containing the given message.
|
* Constructor. Creates an exception containing the given message.
|
||||||
|
@ -46,12 +46,12 @@ import com.jme3.scene.plugins.blender.utils.BlenderInputStream;
|
|||||||
import com.jme3.scene.plugins.blender.utils.DataRepository;
|
import com.jme3.scene.plugins.blender.utils.DataRepository;
|
||||||
import com.jme3.scene.plugins.blender.utils.Pointer;
|
import com.jme3.scene.plugins.blender.utils.Pointer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class defines the methods to calculate certain aspects of animation and armature functionalities.
|
* This class defines the methods to calculate certain aspects of animation and armature functionalities.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ArmatureHelper extends com.jme3.scene.plugins.blender.helpers.v249.ArmatureHelper {
|
public class ArmatureHelper extends com.jme3.scene.plugins.blender.helpers.v249.ArmatureHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ArmatureHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ArmatureHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@ import com.jme3.scene.plugins.blender.exception.BlenderFileException;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class CameraHelper extends com.jme3.scene.plugins.blender.helpers.v249.CameraHelper {
|
public class CameraHelper extends com.jme3.scene.plugins.blender.helpers.v249.CameraHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(CameraHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(CameraHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +33,7 @@ public class CameraHelper extends com.jme3.scene.plugins.blender.helpers.v249.Ca
|
|||||||
Camera result = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
|
Camera result = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
|
||||||
int type = ((Number) structure.getFieldValue("type")).intValue();
|
int type = ((Number) structure.getFieldValue("type")).intValue();
|
||||||
if (type != 0 && type != 1) {
|
if (type != 0 && type != 1) {
|
||||||
LOGGER.log(Level.WARNING, "Unknown camera type: " + type + ". Perspective camera is being used!");
|
LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
|
||||||
type = 0;
|
type = 0;
|
||||||
}
|
}
|
||||||
//type==0 - perspective; type==1 - orthographic; perspective is used as default
|
//type==0 - perspective; type==1 - orthographic; perspective is used as default
|
||||||
|
@ -11,6 +11,7 @@ import com.jme3.scene.plugins.blender.utils.DataRepository;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ConstraintHelper extends com.jme3.scene.plugins.blender.helpers.v249.ConstraintHelper {
|
public class ConstraintHelper extends com.jme3.scene.plugins.blender.helpers.v249.ConstraintHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ConstraintHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ConstraintHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class CurvesHelper extends com.jme3.scene.plugins.blender.helpers.v249.CurvesHelper {
|
public class CurvesHelper extends com.jme3.scene.plugins.blender.helpers.v249.CurvesHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -6,6 +6,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class IpoHelper extends com.jme3.scene.plugins.blender.helpers.v249.IpoHelper {
|
public class IpoHelper extends com.jme3.scene.plugins.blender.helpers.v249.IpoHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -36,6 +36,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class LightHelper extends com.jme3.scene.plugins.blender.helpers.v249.LightHelper {
|
public class LightHelper extends com.jme3.scene.plugins.blender.helpers.v249.LightHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
package com.jme3.scene.plugins.blender.helpers;
|
package com.jme3.scene.plugins.blender.helpers;
|
||||||
|
|
||||||
public class MaterialHelper extends com.jme3.scene.plugins.blender.helpers.v249.MaterialHelper {
|
public class MaterialHelper extends com.jme3.scene.plugins.blender.helpers.v249.MaterialHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -36,6 +36,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class MeshHelper extends com.jme3.scene.plugins.blender.helpers.v249.MeshHelper {
|
public class MeshHelper extends com.jme3.scene.plugins.blender.helpers.v249.MeshHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -36,6 +36,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ModifierHelper extends com.jme3.scene.plugins.blender.helpers.v249.ModifierHelper {
|
public class ModifierHelper extends com.jme3.scene.plugins.blender.helpers.v249.ModifierHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -39,6 +39,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class NoiseHelper extends com.jme3.scene.plugins.blender.helpers.v249.NoiseHelper {
|
public class NoiseHelper extends com.jme3.scene.plugins.blender.helpers.v249.NoiseHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Stores the blender version number and loads the constants needed for computations.
|
* Constructor. Stores the blender version number and loads the constants needed for computations.
|
||||||
*
|
*
|
||||||
|
@ -36,6 +36,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ObjectHelper extends com.jme3.scene.plugins.blender.helpers.v249.ObjectHelper {
|
public class ObjectHelper extends com.jme3.scene.plugins.blender.helpers.v249.ObjectHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -5,6 +5,7 @@ package com.jme3.scene.plugins.blender.helpers;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class ParticlesHelper extends com.jme3.scene.plugins.blender.helpers.v249.ParticlesHelper {
|
public class ParticlesHelper extends com.jme3.scene.plugins.blender.helpers.v249.ParticlesHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -44,9 +44,11 @@ import com.jme3.texture.Texture;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class TextureHelper extends com.jme3.scene.plugins.blender.helpers.v249.TextureHelper {
|
public class TextureHelper extends com.jme3.scene.plugins.blender.helpers.v249.TextureHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(TextureHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(TextureHelper.class.getName());
|
||||||
public static final int TEX_POINTDENSITY = 14;
|
public static final int TEX_POINTDENSITY = 14;
|
||||||
public static final int TEX_VOXELDATA = 15;
|
public static final int TEX_VOXELDATA = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
|
@ -60,8 +60,8 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ArmatureHelper extends AbstractBlenderHelper {
|
public class ArmatureHelper extends AbstractBlenderHelper {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ArmatureHelper.class.getName());
|
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(ArmatureHelper.class.getName());
|
||||||
/**
|
/**
|
||||||
* The map of the bones. Maps a bone name to its index in the armature. Should be cleared after the object had been
|
* The map of the bones. Maps a bone name to its index in the armature. Should be cleared after the object had been
|
||||||
* read. TODO: probably bones can have identical names in different armatures
|
* read. TODO: probably bones can have identical names in different armatures
|
||||||
@ -289,6 +289,7 @@ public class ArmatureHelper extends AbstractBlenderHelper {
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
private static class BoneTransformationData {
|
private static class BoneTransformationData {
|
||||||
|
|
||||||
/** Inverse matrix of bone's parent bone. */
|
/** Inverse matrix of bone's parent bone. */
|
||||||
private Matrix4f totalInverseBoneParentMatrix;
|
private Matrix4f totalInverseBoneParentMatrix;
|
||||||
/** Bone's matrix in armature's space. */
|
/** Bone's matrix in armature's space. */
|
||||||
|
@ -13,10 +13,11 @@ import com.jme3.scene.plugins.blender.utils.AbstractBlenderHelper;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class CameraHelper extends AbstractBlenderHelper {
|
public class CameraHelper extends AbstractBlenderHelper {
|
||||||
private static final Logger LOGGER = Logger.getLogger(CameraHelper.class.getName());
|
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(CameraHelper.class.getName());
|
||||||
protected static final int DEFAULT_CAM_WIDTH = 100;
|
protected static final int DEFAULT_CAM_WIDTH = 100;
|
||||||
protected static final int DEFAULT_CAM_HEIGHT = 100;
|
protected static final int DEFAULT_CAM_HEIGHT = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
@ -37,7 +38,7 @@ public class CameraHelper extends AbstractBlenderHelper {
|
|||||||
Camera result = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
|
Camera result = new Camera(DEFAULT_CAM_WIDTH, DEFAULT_CAM_HEIGHT);
|
||||||
int type = ((Number) structure.getFieldValue("type")).intValue();
|
int type = ((Number) structure.getFieldValue("type")).intValue();
|
||||||
if (type != 0 && type != 1) {
|
if (type != 0 && type != 1) {
|
||||||
LOGGER.log(Level.WARNING, "Unknown camera type: " + type + ". Perspective camera is being used!");
|
LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
|
||||||
type = 0;
|
type = 0;
|
||||||
}
|
}
|
||||||
//type==0 - perspective; type==1 - orthographic; perspective is used as default
|
//type==0 - perspective; type==1 - orthographic; perspective is used as default
|
||||||
|
@ -24,18 +24,19 @@ import com.jme3.scene.plugins.blender.structures.Ipo;
|
|||||||
import com.jme3.scene.plugins.blender.utils.AbstractBlenderHelper;
|
import com.jme3.scene.plugins.blender.utils.AbstractBlenderHelper;
|
||||||
import com.jme3.scene.plugins.blender.utils.DataRepository;
|
import com.jme3.scene.plugins.blender.utils.DataRepository;
|
||||||
import com.jme3.scene.plugins.blender.utils.Pointer;
|
import com.jme3.scene.plugins.blender.utils.Pointer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class should be used for constraint calculations.
|
* This class should be used for constraint calculations.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ConstraintHelper extends AbstractBlenderHelper {
|
public class ConstraintHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A table containing implementations of influence functions for constraints. It should contain functions for
|
* A table containing implementations of influence functions for constraints. It should contain functions for
|
||||||
* blender at least 249 and higher.
|
* blender at least 249 and higher.
|
||||||
*/
|
*/
|
||||||
protected static AbstractInfluenceFunction[] influenceFunctions;
|
protected static AbstractInfluenceFunction[] influenceFunctions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constraints stored for object with the given old memory address.
|
* Constraints stored for object with the given old memory address.
|
||||||
*/
|
*/
|
||||||
@ -55,22 +56,26 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
//TODO: synchronization
|
//TODO: synchronization
|
||||||
influenceFunctions = new AbstractInfluenceFunction[ConstraintType.getLastDefinedTypeValue() + 1];
|
influenceFunctions = new AbstractInfluenceFunction[ConstraintType.getLastDefinedTypeValue() + 1];
|
||||||
//ACTION constraint (TODO: to implement)
|
//ACTION constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ACTION.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ACTION, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ACTION.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ACTION, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//CHILDOF constraint (TODO: to implement)
|
//CHILDOF constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_CHILDOF.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_CHILDOF, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_CHILDOF.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_CHILDOF, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//CLAMPTO constraint
|
//CLAMPTO constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_CLAMPTO.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_CLAMPTO, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_CLAMPTO.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_CLAMPTO, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
this.validateConstraintType(constraint.getData());
|
this.validateConstraintType(constraint.getData());
|
||||||
LOGGER.info(constraint.getName() + " not active! Curves not yet implemented!");//TODO: implement when curves are implemented
|
LOGGER.log(Level.INFO, "{0} not active! Curves not yet implemented!", constraint.getName());//TODO: implement when curves are implemented
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//DISTLIMIT constraint
|
//DISTLIMIT constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_DISTLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_DISTLIMIT, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_DISTLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_DISTLIMIT, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintStructure = constraint.getData();
|
Structure constraintStructure = constraint.getData();
|
||||||
@ -115,15 +120,17 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
//FOLLOWPATH constraint
|
//FOLLOWPATH constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_FOLLOWPATH.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_FOLLOWPATH, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_FOLLOWPATH.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_FOLLOWPATH, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
this.validateConstraintType(constraint.getData());
|
this.validateConstraintType(constraint.getData());
|
||||||
LOGGER.info(constraint.getName() + " not active! Curves not yet implemented!");//TODO: implement when curves are implemented
|
LOGGER.log(Level.INFO, "{0} not active! Curves not yet implemented!", constraint.getName());//TODO: implement when curves are implemented
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//KINEMATIC constraint (TODO: to implement)
|
//KINEMATIC constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_KINEMATIC.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_KINEMATIC, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_KINEMATIC.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_KINEMATIC, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintStructure = constraint.getData();
|
Structure constraintStructure = constraint.getData();
|
||||||
@ -225,10 +232,12 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//LOCKTRACK constraint (TODO: to implement)
|
//LOCKTRACK constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCKTRACK.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCKTRACK, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCKTRACK.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCKTRACK, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//LOCLIKE constraint
|
//LOCLIKE constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCLIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCLIKE, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCLIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCLIKE, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintData = constraint.getData();
|
Structure constraintData = constraint.getData();
|
||||||
@ -270,6 +279,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
//LOCLIMIT constraint
|
//LOCLIMIT constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCLIMIT, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_LOCLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_LOCLIMIT, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintStructure = constraint.getData();
|
Structure constraintStructure = constraint.getData();
|
||||||
@ -324,19 +334,24 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//MINMAX constraint (TODO: to implement)
|
//MINMAX constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_MINMAX.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_MINMAX, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_MINMAX.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_MINMAX, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//NULL constraint - does nothing
|
//NULL constraint - does nothing
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_NULL.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_NULL, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_NULL.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_NULL, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//PYTHON constraint (TODO: to implement)
|
//PYTHON constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_PYTHON.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_PYTHON, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_PYTHON.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_PYTHON, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//RIGIDBODYJOINT constraint (TODO: to implement)
|
//RIGIDBODYJOINT constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_RIGIDBODYJOINT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_RIGIDBODYJOINT, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_RIGIDBODYJOINT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_RIGIDBODYJOINT, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//ROTLIKE constraint
|
//ROTLIKE constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ROTLIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ROTLIKE, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ROTLIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ROTLIKE, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintData = constraint.getData();
|
Structure constraintData = constraint.getData();
|
||||||
@ -381,6 +396,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
//ROTLIMIT constraint
|
//ROTLIMIT constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ROTLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ROTLIMIT, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_ROTLIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_ROTLIMIT, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintStructure = constraint.getData();
|
Structure constraintStructure = constraint.getData();
|
||||||
@ -434,10 +450,12 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//SHRINKWRAP constraint (TODO: to implement)
|
//SHRINKWRAP constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SHRINKWRAP.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SHRINKWRAP, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SHRINKWRAP.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SHRINKWRAP, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//SIZELIKE constraint
|
//SIZELIKE constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SIZELIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SIZELIKE, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SIZELIKE.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SIZELIKE, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintData = constraint.getData();
|
Structure constraintData = constraint.getData();
|
||||||
@ -471,6 +489,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
|
|
||||||
//SIZELIMIT constraint
|
//SIZELIMIT constraint
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SIZELIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SIZELIMIT, dataRepository) {
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_SIZELIMIT.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_SIZELIMIT, dataRepository) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
Structure constraintStructure = constraint.getData();
|
Structure constraintStructure = constraint.getData();
|
||||||
@ -525,10 +544,12 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//STRETCHTO constraint (TODO: to implement)
|
//STRETCHTO constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_STRETCHTO.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_STRETCHTO, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_STRETCHTO.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_STRETCHTO, dataRepository) {
|
||||||
|
};
|
||||||
|
|
||||||
//TRANSFORM constraint (TODO: to implement)
|
//TRANSFORM constraint (TODO: to implement)
|
||||||
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_TRANSFORM.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_TRANSFORM, dataRepository) {};
|
influenceFunctions[ConstraintType.CONSTRAINT_TYPE_TRANSFORM.getConstraintId()] = new AbstractInfluenceFunction(ConstraintType.CONSTRAINT_TYPE_TRANSFORM, dataRepository) {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,6 +661,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
private static class CalculationBone extends Node {
|
private static class CalculationBone extends Node {
|
||||||
|
|
||||||
/** The name of the bone. Only to be used in toString method. */
|
/** The name of the bone. Only to be used in toString method. */
|
||||||
private String boneName;
|
private String boneName;
|
||||||
/** The bone's tracks. Will be altered at the end of calculation process. */
|
/** The bone's tracks. Will be altered at the end of calculation process. */
|
||||||
@ -650,7 +672,6 @@ public class ConstraintHelper extends AbstractBlenderHelper {
|
|||||||
private Quaternion startRotation;
|
private Quaternion startRotation;
|
||||||
/** The starting scale of the bone. */
|
/** The starting scale of the bone. */
|
||||||
private Vector3f startScale;
|
private Vector3f startScale;
|
||||||
|
|
||||||
private Vector3f[] translations;
|
private Vector3f[] translations;
|
||||||
private Quaternion[] rotations;
|
private Quaternion[] rotations;
|
||||||
private Vector3f[] scales;
|
private Vector3f[] scales;
|
||||||
|
@ -39,8 +39,8 @@ import com.jme3.util.BufferUtils;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class CurvesHelper extends AbstractBlenderHelper {
|
public class CurvesHelper extends AbstractBlenderHelper {
|
||||||
private static final Logger LOGGER = Logger.getLogger(CurvesHelper.class.getName());
|
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(CurvesHelper.class.getName());
|
||||||
/** This variable indicates if the Y asxis is the UP axis or not. */
|
/** This variable indicates if the Y asxis is the UP axis or not. */
|
||||||
protected boolean fixUpAxis;
|
protected boolean fixUpAxis;
|
||||||
/** Minimum basis U function degree for NURBS curves and surfaces. */
|
/** Minimum basis U function degree for NURBS curves and surfaces. */
|
||||||
|
@ -17,6 +17,7 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class IpoHelper extends AbstractBlenderHelper {
|
public class IpoHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
* This constructor parses the given blender version and stores the result. Some functionalities may differ in
|
||||||
* different blender versions.
|
* different blender versions.
|
||||||
@ -70,14 +71,13 @@ public class IpoHelper extends AbstractBlenderHelper {
|
|||||||
return new ConstIpo(constValue);
|
return new ConstIpo(constValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ipo constant curve. This is a curve with only one value and no specified type. This type of ipo cannot be used to
|
* Ipo constant curve. This is a curve with only one value and no specified type. This type of ipo cannot be used to
|
||||||
* calculate tracks. It should only be used to calculate single value for a given frame.
|
* calculate tracks. It should only be used to calculate single value for a given frame.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
private class ConstIpo extends Ipo {
|
private class ConstIpo extends Ipo {
|
||||||
|
|
||||||
/** The constant value of this ipo. */
|
/** The constant value of this ipo. */
|
||||||
private float constValue;
|
private float constValue;
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ import com.jme3.scene.plugins.blender.utils.DataRepository.LoadedFeatureDataType
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class LightHelper extends AbstractBlenderHelper {
|
public class LightHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(LightHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(LightHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,26 +62,26 @@ import com.jme3.texture.Texture.WrapMode;
|
|||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
|
|
||||||
public class MaterialHelper extends AbstractBlenderHelper {
|
public class MaterialHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(MaterialHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(MaterialHelper.class.getName());
|
||||||
protected static final float DEFAULT_SHININESS = 20.0f;
|
protected static final float DEFAULT_SHININESS = 20.0f;
|
||||||
|
|
||||||
public static final String TEXTURE_TYPE_COLOR = "ColorMap";
|
public static final String TEXTURE_TYPE_COLOR = "ColorMap";
|
||||||
public static final String TEXTURE_TYPE_DIFFUSE = "DiffuseMap";
|
public static final String TEXTURE_TYPE_DIFFUSE = "DiffuseMap";
|
||||||
public static final String TEXTURE_TYPE_NORMAL = "NormalMap";
|
public static final String TEXTURE_TYPE_NORMAL = "NormalMap";
|
||||||
public static final String TEXTURE_TYPE_SPECULAR = "SpecularMap";
|
public static final String TEXTURE_TYPE_SPECULAR = "SpecularMap";
|
||||||
public static final String TEXTURE_TYPE_GLOW = "GlowMap";
|
public static final String TEXTURE_TYPE_GLOW = "GlowMap";
|
||||||
public static final String TEXTURE_TYPE_ALPHA = "AlphaMap";
|
public static final String TEXTURE_TYPE_ALPHA = "AlphaMap";
|
||||||
|
|
||||||
public static final Integer ALPHA_MASK_NONE = Integer.valueOf(0);
|
public static final Integer ALPHA_MASK_NONE = Integer.valueOf(0);
|
||||||
public static final Integer ALPHA_MASK_CIRCLE = Integer.valueOf(1);
|
public static final Integer ALPHA_MASK_CIRCLE = Integer.valueOf(1);
|
||||||
public static final Integer ALPHA_MASK_CONE = Integer.valueOf(2);
|
public static final Integer ALPHA_MASK_CONE = Integer.valueOf(2);
|
||||||
public static final Integer ALPHA_MASK_HYPERBOLE = Integer.valueOf(3);
|
public static final Integer ALPHA_MASK_HYPERBOLE = Integer.valueOf(3);
|
||||||
protected final Map<Integer, IAlphaMask> alphaMasks = new HashMap<Integer, IAlphaMask>();
|
protected final Map<Integer, AlphaMask> alphaMasks = new HashMap<Integer, AlphaMask>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the material's diffuse shader.
|
* The type of the material's diffuse shader.
|
||||||
*/
|
*/
|
||||||
public static enum DiffuseShader {
|
public static enum DiffuseShader {
|
||||||
|
|
||||||
LAMBERT, ORENNAYAR, TOON, MINNAERT, FRESNEL
|
LAMBERT, ORENNAYAR, TOON, MINNAERT, FRESNEL
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
* The type of the material's specular shader.
|
* The type of the material's specular shader.
|
||||||
*/
|
*/
|
||||||
public static enum SpecularShader {
|
public static enum SpecularShader {
|
||||||
|
|
||||||
COOKTORRENCE, PHONG, BLINN, TOON, WARDISO
|
COOKTORRENCE, PHONG, BLINN, TOON, WARDISO
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Face cull mode. Should be excplicitly set before this helper is used. */
|
/** Face cull mode. Should be excplicitly set before this helper is used. */
|
||||||
protected FaceCullMode faceCullMode;
|
protected FaceCullMode faceCullMode;
|
||||||
|
|
||||||
@ -105,16 +105,19 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
public MaterialHelper(String blenderVersion) {
|
public MaterialHelper(String blenderVersion) {
|
||||||
super(blenderVersion);
|
super(blenderVersion);
|
||||||
// setting alpha masks
|
// setting alpha masks
|
||||||
alphaMasks.put(ALPHA_MASK_NONE, new IAlphaMask() {
|
alphaMasks.put(ALPHA_MASK_NONE, new AlphaMask() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setImageSize(int width, int height) {}
|
public void setImageSize(int width, int height) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getAlpha(float x, float y) {
|
public byte getAlpha(float x, float y) {
|
||||||
return (byte) 255;
|
return (byte) 255;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alphaMasks.put(ALPHA_MASK_CIRCLE, new IAlphaMask() {
|
alphaMasks.put(ALPHA_MASK_CIRCLE, new AlphaMask() {
|
||||||
|
|
||||||
private float r;
|
private float r;
|
||||||
private float[] center;
|
private float[] center;
|
||||||
|
|
||||||
@ -130,7 +133,8 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
return (byte) (d >= r ? 0 : 255);
|
return (byte) (d >= r ? 0 : 255);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alphaMasks.put(ALPHA_MASK_CONE, new IAlphaMask() {
|
alphaMasks.put(ALPHA_MASK_CONE, new AlphaMask() {
|
||||||
|
|
||||||
private float r;
|
private float r;
|
||||||
private float[] center;
|
private float[] center;
|
||||||
|
|
||||||
@ -146,7 +150,8 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
return (byte) (d >= r ? 0 : -255.0f * d / r + 255.0f);
|
return (byte) (d >= r ? 0 : -255.0f * d / r + 255.0f);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alphaMasks.put(ALPHA_MASK_HYPERBOLE, new IAlphaMask() {
|
alphaMasks.put(ALPHA_MASK_HYPERBOLE, new AlphaMask() {
|
||||||
|
|
||||||
private float r;
|
private float r;
|
||||||
private float[] center;
|
private float[] center;
|
||||||
|
|
||||||
@ -368,7 +373,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
int w = image.getWidth();
|
int w = image.getWidth();
|
||||||
int h = image.getHeight();
|
int h = image.getHeight();
|
||||||
ByteBuffer bb = BufferUtils.createByteBuffer(w * h * 4);
|
ByteBuffer bb = BufferUtils.createByteBuffer(w * h * 4);
|
||||||
IAlphaMask iAlphaMask = alphaMasks.get(alphaMaskIndex);
|
AlphaMask iAlphaMask = alphaMasks.get(alphaMaskIndex);
|
||||||
iAlphaMask.setImageSize(w, h);
|
iAlphaMask.setImageSize(w, h);
|
||||||
|
|
||||||
for (int x = 0; x < w; ++x) {
|
for (int x = 0; x < w; ++x) {
|
||||||
@ -678,7 +683,8 @@ public class MaterialHelper extends AbstractBlenderHelper {
|
|||||||
* An interface used in calculating alpha mask during particles' texture calculations.
|
* An interface used in calculating alpha mask during particles' texture calculations.
|
||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
protected static interface IAlphaMask {
|
protected static interface AlphaMask {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sets the size of the texture's image.
|
* This method sets the size of the texture's image.
|
||||||
* @param width
|
* @param width
|
||||||
|
@ -67,6 +67,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class MeshHelper extends AbstractBlenderHelper {
|
public class MeshHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
protected static final int MAXIMUM_WEIGHTS_PER_VERTEX = 4; // have no idea why 4, could someone please explain ?
|
protected static final int MAXIMUM_WEIGHTS_PER_VERTEX = 4; // have no idea why 4, could someone please explain ?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,6 +77,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class ModifierHelper extends AbstractBlenderHelper {
|
public class ModifierHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ModifierHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ModifierHelper.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
* ***** END GPL LICENSE BLOCK *****
|
* ***** END GPL LICENSE BLOCK *****
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.jme3.scene.plugins.blender.helpers.v249;
|
package com.jme3.scene.plugins.blender.helpers.v249;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -56,6 +55,7 @@ import com.jme3.scene.plugins.blender.utils.DataRepository;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class NoiseHelper extends AbstractBlenderHelper {
|
public class NoiseHelper extends AbstractBlenderHelper {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(NoiseHelper.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(NoiseHelper.class.getName());
|
||||||
|
|
||||||
/* return value */
|
/* return value */
|
||||||
@ -170,11 +170,12 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Map<Integer, AbstractNoiseFunc> noiseFunctions = new HashMap<Integer, AbstractNoiseFunc>();
|
protected static Map<Integer, AbstractNoiseFunc> noiseFunctions = new HashMap<Integer, AbstractNoiseFunc>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// orgBlenderNoise (*Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling.*)
|
// orgBlenderNoise (*Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling.*)
|
||||||
noiseFunctions.put(Integer.valueOf(0), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(0), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
return this.orgBlenderNoise(x, y, z);
|
return this.orgBlenderNoise(x, y, z);
|
||||||
@ -187,6 +188,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// orgPerlinNoise (*For use with BLI_gNoise/gTurbulence, returns signed noise.*)
|
// orgPerlinNoise (*For use with BLI_gNoise/gTurbulence, returns signed noise.*)
|
||||||
noiseFunctions.put(Integer.valueOf(1), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(1), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
return 0.5f + 0.5f * this.noise3Perlin(new float[]{x, y, z});
|
return 0.5f + 0.5f * this.noise3Perlin(new float[]{x, y, z});
|
||||||
@ -199,6 +201,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// newPerlin (* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise *)
|
// newPerlin (* for use with BLI_gNoise()/BLI_gTurbulence(), returns unsigned improved perlin noise *)
|
||||||
noiseFunctions.put(Integer.valueOf(2), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(2), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
return 0.5f + 0.5f * this.newPerlin(x, y, z);
|
return 0.5f + 0.5f * this.newPerlin(x, y, z);
|
||||||
@ -211,6 +214,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_F1
|
// voronoi_F1
|
||||||
noiseFunctions.put(Integer.valueOf(3), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(3), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float[] da = new float[4], pa = new float[12];
|
float[] da = new float[4], pa = new float[12];
|
||||||
@ -227,6 +231,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_F2
|
// voronoi_F2
|
||||||
noiseFunctions.put(Integer.valueOf(4), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(4), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float[] da = new float[4], pa = new float[12];
|
float[] da = new float[4], pa = new float[12];
|
||||||
@ -243,6 +248,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_F3
|
// voronoi_F3
|
||||||
noiseFunctions.put(Integer.valueOf(5), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(5), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float[] da = new float[4], pa = new float[12];
|
float[] da = new float[4], pa = new float[12];
|
||||||
@ -259,6 +265,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_F4
|
// voronoi_F4
|
||||||
noiseFunctions.put(Integer.valueOf(6), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(6), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float[] da = new float[4], pa = new float[12];
|
float[] da = new float[4], pa = new float[12];
|
||||||
@ -275,6 +282,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_F1F2
|
// voronoi_F1F2
|
||||||
noiseFunctions.put(Integer.valueOf(7), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(7), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float[] da = new float[4], pa = new float[12];
|
float[] da = new float[4], pa = new float[12];
|
||||||
@ -291,6 +299,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// voronoi_Cr
|
// voronoi_Cr
|
||||||
noiseFunctions.put(Integer.valueOf(8), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(8), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
float t = 10 * noiseFunctions.get(Integer.valueOf(7)).execute(x, y, z);// voronoi_F1F2
|
float t = 10 * noiseFunctions.get(Integer.valueOf(7)).execute(x, y, z);// voronoi_F1F2
|
||||||
@ -305,6 +314,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
});
|
});
|
||||||
// cellNoise
|
// cellNoise
|
||||||
noiseFunctions.put(Integer.valueOf(14), new AbstractNoiseFunc() {
|
noiseFunctions.put(Integer.valueOf(14), new AbstractNoiseFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z) {
|
public float execute(float x, float y, float z) {
|
||||||
int xi = (int) Math.floor(x);
|
int xi = (int) Math.floor(x);
|
||||||
@ -321,33 +331,37 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Distance metrics for voronoi. e parameter only used in Minkovsky. */
|
/** Distance metrics for voronoi. e parameter only used in Minkovsky. */
|
||||||
protected static Map<Integer, IDistanceFunc> distanceFunctions = new HashMap<Integer, NoiseHelper.IDistanceFunc>();
|
protected static Map<Integer, DistanceFunc> distanceFunctions = new HashMap<Integer, NoiseHelper.DistanceFunc>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// real distance
|
// real distance
|
||||||
distanceFunctions.put(Integer.valueOf(0), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(0), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
return (float) Math.sqrt(x * x + y * y + z * z);
|
return (float) Math.sqrt(x * x + y * y + z * z);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// distance squared
|
// distance squared
|
||||||
distanceFunctions.put(Integer.valueOf(1), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(1), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
return x * x + y * y + z * z;
|
return x * x + y * y + z * z;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// manhattan/taxicab/cityblock distance
|
// manhattan/taxicab/cityblock distance
|
||||||
distanceFunctions.put(Integer.valueOf(2), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(2), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
return FastMath.abs(x) + FastMath.abs(y) + FastMath.abs(z);
|
return FastMath.abs(x) + FastMath.abs(y) + FastMath.abs(z);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Chebychev
|
// Chebychev
|
||||||
distanceFunctions.put(Integer.valueOf(3), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(3), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
x = FastMath.abs(x);
|
x = FastMath.abs(x);
|
||||||
@ -358,7 +372,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// minkovsky preset exponent 0.5 (MinkovskyH)
|
// minkovsky preset exponent 0.5 (MinkovskyH)
|
||||||
distanceFunctions.put(Integer.valueOf(4), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(4), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
float d = (float) (Math.sqrt(FastMath.abs(x)) + Math.sqrt(FastMath.abs(y)) + Math.sqrt(FastMath.abs(z)));
|
float d = (float) (Math.sqrt(FastMath.abs(x)) + Math.sqrt(FastMath.abs(y)) + Math.sqrt(FastMath.abs(z)));
|
||||||
@ -366,7 +381,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// minkovsky preset exponent 4 (Minkovsky4)
|
// minkovsky preset exponent 4 (Minkovsky4)
|
||||||
distanceFunctions.put(Integer.valueOf(5), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(5), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
x *= x;
|
x *= x;
|
||||||
@ -376,17 +392,19 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Minkovsky, general case, slow, maybe too slow to be useful
|
// Minkovsky, general case, slow, maybe too slow to be useful
|
||||||
distanceFunctions.put(Integer.valueOf(6), new IDistanceFunc() {
|
distanceFunctions.put(Integer.valueOf(6), new DistanceFunc() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x, float y, float z, float e) {
|
public float execute(float x, float y, float z, float e) {
|
||||||
return (float) Math.pow(Math.pow(FastMath.abs(x), e) + Math.pow(FastMath.abs(y), e) + Math.pow(FastMath.abs(z), e), 1.0f / e);
|
return (float) Math.pow(Math.pow(FastMath.abs(x), e) + Math.pow(FastMath.abs(y), e) + Math.pow(FastMath.abs(z), e), 1.0f / e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
protected static Map<Integer, MusgraveFunction> musgraveFunctions = new HashMap<Integer, NoiseHelper.MusgraveFunction>();
|
||||||
|
|
||||||
protected static Map<Integer, IMusgraveFunction> musgraveFunctions = new HashMap<Integer, NoiseHelper.IMusgraveFunction>();
|
|
||||||
static {
|
static {
|
||||||
musgraveFunctions.put(Integer.valueOf(TEX_MFRACTAL), new IMusgraveFunction() {
|
musgraveFunctions.put(Integer.valueOf(TEX_MFRACTAL), new MusgraveFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(Structure tex, float x, float y, float z) {
|
public float execute(Structure tex, float x, float y, float z) {
|
||||||
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
||||||
@ -414,7 +432,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
musgraveFunctions.put(Integer.valueOf(TEX_RIDGEDMF), new IMusgraveFunction() {
|
musgraveFunctions.put(Integer.valueOf(TEX_RIDGEDMF), new MusgraveFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(Structure tex, float x, float y, float z) {
|
public float execute(Structure tex, float x, float y, float z) {
|
||||||
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
||||||
@ -456,7 +475,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
musgraveFunctions.put(Integer.valueOf(TEX_HYBRIDMF), new IMusgraveFunction() {
|
musgraveFunctions.put(Integer.valueOf(TEX_HYBRIDMF), new MusgraveFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(Structure tex, float x, float y, float z) {
|
public float execute(Structure tex, float x, float y, float z) {
|
||||||
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
||||||
@ -499,7 +519,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
musgraveFunctions.put(Integer.valueOf(TEX_FBM), new IMusgraveFunction() {
|
musgraveFunctions.put(Integer.valueOf(TEX_FBM), new MusgraveFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(Structure tex, float x, float y, float z) {
|
public float execute(Structure tex, float x, float y, float z) {
|
||||||
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
||||||
@ -528,7 +549,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
musgraveFunctions.put(Integer.valueOf(TEX_HTERRAIN), new IMusgraveFunction() {
|
musgraveFunctions.put(Integer.valueOf(TEX_HTERRAIN), new MusgraveFunction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(Structure tex, float x, float y, float z) {
|
public float execute(Structure tex, float x, float y, float z) {
|
||||||
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
float mg_H = ((Number) tex.getFieldValue("mg_H")).floatValue();
|
||||||
@ -792,18 +814,21 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IWaveForm {
|
interface IWaveForm {
|
||||||
|
|
||||||
float execute(float x);
|
float execute(float x);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static IWaveForm[] waveformFunctions = new IWaveForm[3];
|
protected static IWaveForm[] waveformFunctions = new IWaveForm[3];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
waveformFunctions[0] = new IWaveForm() {// tex_sin
|
waveformFunctions[0] = new IWaveForm() {// tex_sin
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x) {
|
public float execute(float x) {
|
||||||
return 0.5f + 0.5f * (float) Math.sin(x);
|
return 0.5f + 0.5f * (float) Math.sin(x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
waveformFunctions[1] = new IWaveForm() {// tex_saw
|
waveformFunctions[1] = new IWaveForm() {// tex_saw
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x) {
|
public float execute(float x) {
|
||||||
int n = (int) (x / FastMath.TWO_PI);
|
int n = (int) (x / FastMath.TWO_PI);
|
||||||
@ -815,6 +840,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
waveformFunctions[2] = new IWaveForm() {// tex_tri
|
waveformFunctions[2] = new IWaveForm() {// tex_tri
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float execute(float x) {
|
public float execute(float x) {
|
||||||
return 1.0f - 2.0f * FastMath.abs((float) Math.floor(x * 1.0f / FastMath.TWO_PI + 0.5f) - x * 1.0f / FastMath.TWO_PI);
|
return 1.0f - 2.0f * FastMath.abs((float) Math.floor(x * 1.0f / FastMath.TWO_PI + 0.5f) - x * 1.0f / FastMath.TWO_PI);
|
||||||
@ -891,7 +917,6 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
/**
|
/**
|
||||||
* THE FOLLOWING METHODS HELP IN NOISE COMPUTATIONS
|
* THE FOLLOWING METHODS HELP IN NOISE COMPUTATIONS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separated from orgBlenderNoise above, with scaling.
|
* Separated from orgBlenderNoise above, with scaling.
|
||||||
* @param noisesize
|
* @param noisesize
|
||||||
@ -1104,7 +1129,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
||||||
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
||||||
|
|
||||||
IMusgraveFunction mgravefunc = stype == TEX_MFRACTAL ? musgraveFunctions.get(Integer.valueOf(stype)) : musgraveFunctions.get(Integer.valueOf(TEX_FBM));
|
MusgraveFunction mgravefunc = stype == TEX_MFRACTAL ? musgraveFunctions.get(Integer.valueOf(stype)) : musgraveFunctions.get(Integer.valueOf(TEX_FBM));
|
||||||
|
|
||||||
texres.tin = nsOutscale * mgravefunc.execute(tex, texvec[0], texvec[1], texvec[2]);
|
texres.tin = nsOutscale * mgravefunc.execute(tex, texvec[0], texvec[1], texvec[2]);
|
||||||
if (texres.nor != null) {
|
if (texres.nor != null) {
|
||||||
@ -1126,7 +1151,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
||||||
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
||||||
|
|
||||||
IMusgraveFunction mgravefunc = stype == TEX_RIDGEDMF ? musgraveFunctions.get(Integer.valueOf(stype)) : musgraveFunctions.get(Integer.valueOf(TEX_HYBRIDMF));
|
MusgraveFunction mgravefunc = stype == TEX_RIDGEDMF ? musgraveFunctions.get(Integer.valueOf(stype)) : musgraveFunctions.get(Integer.valueOf(TEX_HYBRIDMF));
|
||||||
|
|
||||||
texres.tin = nsOutscale * mgravefunc.execute(tex, texvec[0], texvec[1], texvec[2]);
|
texres.tin = nsOutscale * mgravefunc.execute(tex, texvec[0], texvec[1], texvec[2]);
|
||||||
if (texres.nor != null) {
|
if (texres.nor != null) {
|
||||||
@ -1147,7 +1172,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
float contrast = ((Number) tex.getFieldValue("contrast")).floatValue();
|
||||||
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
float brightness = ((Number) tex.getFieldValue("bright")).floatValue();
|
||||||
|
|
||||||
IMusgraveFunction musgraveFunction = musgraveFunctions.get(Integer.valueOf(TEX_HTERRAIN));
|
MusgraveFunction musgraveFunction = musgraveFunctions.get(Integer.valueOf(TEX_HTERRAIN));
|
||||||
texres.tin = nsOutscale * musgraveFunction.execute(tex, texvec[0], texvec[1], texvec[2]);
|
texres.tin = nsOutscale * musgraveFunction.execute(tex, texvec[0], texvec[1], texvec[2]);
|
||||||
if (texres.nor != null) {
|
if (texres.nor != null) {
|
||||||
float offs = nabla / noisesize; // also scaling of texvec
|
float offs = nabla / noisesize; // also scaling of texvec
|
||||||
@ -1166,6 +1191,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
protected static abstract class AbstractNoiseFunc {
|
protected static abstract class AbstractNoiseFunc {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calculates the unsigned value of the noise.
|
* This method calculates the unsigned value of the noise.
|
||||||
* @param x
|
* @param x
|
||||||
@ -1196,7 +1222,7 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
protected static void voronoi(float x, float y, float z, float[] da, float[] pa, float me, int dtype) {
|
protected static void voronoi(float x, float y, float z, float[] da, float[] pa, float me, int dtype) {
|
||||||
float xd, yd, zd, d, p[];
|
float xd, yd, zd, d, p[];
|
||||||
|
|
||||||
IDistanceFunc distanceFunc = distanceFunctions.get(Integer.valueOf(dtype));
|
DistanceFunc distanceFunc = distanceFunctions.get(Integer.valueOf(dtype));
|
||||||
if (distanceFunc == null) {
|
if (distanceFunc == null) {
|
||||||
distanceFunc = distanceFunctions.get(Integer.valueOf(0));
|
distanceFunc = distanceFunctions.get(Integer.valueOf(0));
|
||||||
}
|
}
|
||||||
@ -1281,7 +1307,6 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
// b1 = (b0+1) & 255; \
|
// b1 = (b0+1) & 255; \
|
||||||
// r0 = t - (int)t; \
|
// r0 = t - (int)t; \
|
||||||
// r1 = r0 - 1.;
|
// r1 = r0 - 1.;
|
||||||
|
|
||||||
// vec[3]
|
// vec[3]
|
||||||
public float noise3Perlin(float[] vec) {
|
public float noise3Perlin(float[] vec) {
|
||||||
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
|
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
|
||||||
@ -1509,7 +1534,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
* This interface is used for distance calculation classes. Distance metrics for voronoi. e parameter only used in
|
* This interface is used for distance calculation classes. Distance metrics for voronoi. e parameter only used in
|
||||||
* Minkovsky.
|
* Minkovsky.
|
||||||
*/
|
*/
|
||||||
interface IDistanceFunc {
|
interface DistanceFunc {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method calculates the distance for voronoi algorithms.
|
* This method calculates the distance for voronoi algorithms.
|
||||||
* @param x
|
* @param x
|
||||||
@ -1525,7 +1551,8 @@ public class NoiseHelper extends AbstractBlenderHelper {
|
|||||||
float execute(float x, float y, float z, float e);
|
float execute(float x, float y, float z, float e);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IMusgraveFunction {
|
interface MusgraveFunction {
|
||||||
|
|
||||||
float execute(Structure tex, float x, float y, float z);
|
float execute(Structure tex, float x, float y, float z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,20 +21,17 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractInfluenceFunction {
|
public abstract class AbstractInfluenceFunction {
|
||||||
|
|
||||||
protected static final Logger LOGGER = Logger.getLogger(AbstractInfluenceFunction.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(AbstractInfluenceFunction.class.getName());
|
||||||
|
|
||||||
protected static final float IK_SOLVER_ERROR = 0.5f;
|
protected static final float IK_SOLVER_ERROR = 0.5f;
|
||||||
|
|
||||||
//DISTLIMIT
|
//DISTLIMIT
|
||||||
protected static final int LIMITDIST_INSIDE = 0;
|
protected static final int LIMITDIST_INSIDE = 0;
|
||||||
protected static final int LIMITDIST_OUTSIDE = 1;
|
protected static final int LIMITDIST_OUTSIDE = 1;
|
||||||
protected static final int LIMITDIST_ONSURFACE = 2;
|
protected static final int LIMITDIST_ONSURFACE = 2;
|
||||||
|
|
||||||
//CONSTRAINT_TYPE_LOCLIKE
|
//CONSTRAINT_TYPE_LOCLIKE
|
||||||
protected static final int LOCLIKE_X = 0x01;
|
protected static final int LOCLIKE_X = 0x01;
|
||||||
protected static final int LOCLIKE_Y = 0x02;
|
protected static final int LOCLIKE_Y = 0x02;
|
||||||
protected static final int LOCLIKE_Z = 0x04;
|
protected static final int LOCLIKE_Z = 0x04;
|
||||||
|
|
||||||
//ROTLIKE
|
//ROTLIKE
|
||||||
protected static final int ROTLIKE_X = 0x01;
|
protected static final int ROTLIKE_X = 0x01;
|
||||||
protected static final int ROTLIKE_Y = 0x02;
|
protected static final int ROTLIKE_Y = 0x02;
|
||||||
@ -43,7 +40,6 @@ public abstract class AbstractInfluenceFunction {
|
|||||||
protected static final int ROTLIKE_Y_INVERT = 0x20;
|
protected static final int ROTLIKE_Y_INVERT = 0x20;
|
||||||
protected static final int ROTLIKE_Z_INVERT = 0x40;
|
protected static final int ROTLIKE_Z_INVERT = 0x40;
|
||||||
protected static final int ROTLIKE_OFFSET = 0x80;
|
protected static final int ROTLIKE_OFFSET = 0x80;
|
||||||
|
|
||||||
//SIZELIKE
|
//SIZELIKE
|
||||||
protected static final int SIZELIKE_X = 0x01;
|
protected static final int SIZELIKE_X = 0x01;
|
||||||
protected static final int SIZELIKE_Y = 0x02;
|
protected static final int SIZELIKE_Y = 0x02;
|
||||||
@ -56,7 +52,6 @@ public abstract class AbstractInfluenceFunction {
|
|||||||
protected static final int LOCLIKE_Y_INVERT = 0x20;
|
protected static final int LOCLIKE_Y_INVERT = 0x20;
|
||||||
protected static final int LOCLIKE_Z_INVERT = 0x40;
|
protected static final int LOCLIKE_Z_INVERT = 0x40;
|
||||||
protected static final int LOCLIKE_OFFSET = 0x80;
|
protected static final int LOCLIKE_OFFSET = 0x80;
|
||||||
|
|
||||||
//LOCLIMIT, SIZELIMIT
|
//LOCLIMIT, SIZELIMIT
|
||||||
protected static final int LIMIT_XMIN = 0x01;
|
protected static final int LIMIT_XMIN = 0x01;
|
||||||
protected static final int LIMIT_XMAX = 0x02;
|
protected static final int LIMIT_XMAX = 0x02;
|
||||||
@ -64,12 +59,10 @@ public abstract class AbstractInfluenceFunction {
|
|||||||
protected static final int LIMIT_YMAX = 0x08;
|
protected static final int LIMIT_YMAX = 0x08;
|
||||||
protected static final int LIMIT_ZMIN = 0x10;
|
protected static final int LIMIT_ZMIN = 0x10;
|
||||||
protected static final int LIMIT_ZMAX = 0x20;
|
protected static final int LIMIT_ZMAX = 0x20;
|
||||||
|
|
||||||
//ROTLIMIT
|
//ROTLIMIT
|
||||||
protected static final int LIMIT_XROT = 0x01;
|
protected static final int LIMIT_XROT = 0x01;
|
||||||
protected static final int LIMIT_YROT = 0x02;
|
protected static final int LIMIT_YROT = 0x02;
|
||||||
protected static final int LIMIT_ZROT = 0x04;
|
protected static final int LIMIT_ZROT = 0x04;
|
||||||
|
|
||||||
/** The type of the constraint. */
|
/** The type of the constraint. */
|
||||||
protected ConstraintType constraintType;
|
protected ConstraintType constraintType;
|
||||||
/** The data repository. */
|
/** The data repository. */
|
||||||
@ -108,7 +101,8 @@ public abstract class AbstractInfluenceFunction {
|
|||||||
* @param constraint
|
* @param constraint
|
||||||
* the constraint
|
* the constraint
|
||||||
*/
|
*/
|
||||||
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {}
|
public void affectAnimation(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the bone traces for the bone that is affected by the given constraint.
|
* This method returns the bone traces for the bone that is affected by the given constraint.
|
||||||
|
@ -13,10 +13,10 @@ import com.jme3.scene.plugins.blender.utils.DynamicArray;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class BezierCurve {
|
public class BezierCurve {
|
||||||
|
|
||||||
public static final int X_VALUE = 0;
|
public static final int X_VALUE = 0;
|
||||||
public static final int Y_VALUE = 1;
|
public static final int Y_VALUE = 1;
|
||||||
public static final int Z_VALUE = 2;
|
public static final int Z_VALUE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the curve. Describes the data it modifies.
|
* The type of the curve. Describes the data it modifies.
|
||||||
* Used in ipos calculations.
|
* Used in ipos calculations.
|
||||||
|
@ -12,15 +12,14 @@ import com.jme3.scene.plugins.blender.utils.Pointer;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class Constraint {
|
public class Constraint {
|
||||||
|
|
||||||
/** The type of this constraint. */
|
/** The type of this constraint. */
|
||||||
private final ConstraintType type;
|
private final ConstraintType type;
|
||||||
/** The name of this constraint. */
|
/** The name of this constraint. */
|
||||||
private final String name;
|
private final String name;
|
||||||
/** The old memory address of the constraint's owner. */
|
/** The old memory address of the constraint's owner. */
|
||||||
private final Long boneOMA;
|
private final Long boneOMA;
|
||||||
|
|
||||||
private final Space ownerSpace;
|
private final Space ownerSpace;
|
||||||
|
|
||||||
private final Space targetSpace;
|
private final Space targetSpace;
|
||||||
/** The structure with constraint's data. */
|
/** The structure with constraint's data. */
|
||||||
private final Structure data;
|
private final Structure data;
|
||||||
@ -136,6 +135,7 @@ public class Constraint {
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public static enum Space {
|
public static enum Space {
|
||||||
|
|
||||||
CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_PARLOCAL, CONSTRAINT_SPACE_INVALID;
|
CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_PARLOCAL, CONSTRAINT_SPACE_INVALID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public enum ConstraintType {
|
public enum ConstraintType {
|
||||||
/* Invalid/legacy constraint */
|
/* Invalid/legacy constraint */
|
||||||
|
|
||||||
CONSTRAINT_TYPE_NULL(0, "bNullConstraint"),
|
CONSTRAINT_TYPE_NULL(0, "bNullConstraint"),
|
||||||
/* Unimplemented non longer :) - during constraints recode, Aligorith */
|
/* Unimplemented non longer :) - during constraints recode, Aligorith */
|
||||||
CONSTRAINT_TYPE_CHILDOF(1, "bChildOfConstraint"),
|
CONSTRAINT_TYPE_CHILDOF(1, "bChildOfConstraint"),
|
||||||
@ -44,15 +45,15 @@ public enum ConstraintType {
|
|||||||
CONSTRAINT_TYPE_TRANSFORM(19, "bTransformConstraint"),
|
CONSTRAINT_TYPE_TRANSFORM(19, "bTransformConstraint"),
|
||||||
/* shrinkwrap (loc/rot) constraint */
|
/* shrinkwrap (loc/rot) constraint */
|
||||||
CONSTRAINT_TYPE_SHRINKWRAP(20, "bShrinkwrapConstraint");
|
CONSTRAINT_TYPE_SHRINKWRAP(20, "bShrinkwrapConstraint");
|
||||||
|
|
||||||
/** The constraint's id (in blender known as 'type'). */
|
/** The constraint's id (in blender known as 'type'). */
|
||||||
private int constraintId;
|
private int constraintId;
|
||||||
/** The name of constraint class used by blender. */
|
/** The name of constraint class used by blender. */
|
||||||
private String className;
|
private String className;
|
||||||
/** The map containing class names and types of constraints. */
|
/** The map containing class names and types of constraints. */
|
||||||
private static Map<String, ConstraintType> typesMap = new HashMap<String, ConstraintType>(ConstraintType.values().length);
|
private static final Map<String, ConstraintType> typesMap = new HashMap<String, ConstraintType>(ConstraintType.values().length);
|
||||||
/** The map containing class names and types of constraints. */
|
/** The map containing class names and types of constraints. */
|
||||||
private static Map<Integer, ConstraintType> idsMap = new HashMap<Integer, ConstraintType>(ConstraintType.values().length);
|
private static final Map<Integer, ConstraintType> idsMap = new HashMap<Integer, ConstraintType>(ConstraintType.values().length);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_NULL.constraintId), CONSTRAINT_TYPE_NULL);
|
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_NULL.constraintId), CONSTRAINT_TYPE_NULL);
|
||||||
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_CHILDOF.constraintId), CONSTRAINT_TYPE_CHILDOF);
|
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_CHILDOF.constraintId), CONSTRAINT_TYPE_CHILDOF);
|
||||||
@ -75,6 +76,7 @@ public enum ConstraintType {
|
|||||||
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_TRANSFORM.constraintId), CONSTRAINT_TYPE_TRANSFORM);
|
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_TRANSFORM.constraintId), CONSTRAINT_TYPE_TRANSFORM);
|
||||||
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_SHRINKWRAP.constraintId), CONSTRAINT_TYPE_SHRINKWRAP);
|
idsMap.put(Integer.valueOf(CONSTRAINT_TYPE_SHRINKWRAP.constraintId), CONSTRAINT_TYPE_SHRINKWRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Stores constraint type and class name.
|
* Constructor. Stores constraint type and class name.
|
||||||
* @param constraintId
|
* @param constraintId
|
||||||
|
@ -10,6 +10,7 @@ import com.jme3.math.Vector3f;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class Ipo {
|
public class Ipo {
|
||||||
|
|
||||||
public static final int AC_LOC_X = 1;
|
public static final int AC_LOC_X = 1;
|
||||||
public static final int AC_LOC_Y = 2;
|
public static final int AC_LOC_Y = 2;
|
||||||
public static final int AC_LOC_Z = 3;
|
public static final int AC_LOC_Z = 3;
|
||||||
@ -23,7 +24,6 @@ public class Ipo {
|
|||||||
public static final int AC_QUAT_X = 26;
|
public static final int AC_QUAT_X = 26;
|
||||||
public static final int AC_QUAT_Y = 27;
|
public static final int AC_QUAT_Y = 27;
|
||||||
public static final int AC_QUAT_Z = 28;
|
public static final int AC_QUAT_Z = 28;
|
||||||
|
|
||||||
/** A list of bezier curves for this interpolation object. */
|
/** A list of bezier curves for this interpolation object. */
|
||||||
private BezierCurve[] bezierCurves;
|
private BezierCurve[] bezierCurves;
|
||||||
/** Each ipo contains one bone track. */
|
/** Each ipo contains one bone track. */
|
||||||
@ -166,8 +166,8 @@ public class Ipo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
translations[index] = new Vector3f(translation[0], translation[1], translation[2]);
|
translations[index] = new Vector3f(translation[0], translation[1], translation[2]);
|
||||||
rotations[index] = bObjectRotation ? new Quaternion().fromAngles(objectRotation) :
|
rotations[index] = bObjectRotation ? new Quaternion().fromAngles(objectRotation)
|
||||||
new Quaternion(quaternionRotation[0], quaternionRotation[1], quaternionRotation[2], quaternionRotation[3]);
|
: new Quaternion(quaternionRotation[0], quaternionRotation[1], quaternionRotation[2], quaternionRotation[3]);
|
||||||
scales[index] = new Vector3f(scale[0], scale[1], scale[2]);
|
scales[index] = new Vector3f(scale[0], scale[1], scale[2]);
|
||||||
}
|
}
|
||||||
calculatedTrack = new BoneTrack(boneIndex, times, translations, rotations, scales);
|
calculatedTrack = new BoneTrack(boneIndex, times, translations, rotations, scales);
|
||||||
|
@ -7,16 +7,17 @@ package com.jme3.scene.plugins.blender.structures;
|
|||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public class Modifier {
|
public class Modifier {
|
||||||
|
|
||||||
public static final String ARRAY_MODIFIER_DATA = "ArrayModifierData";
|
public static final String ARRAY_MODIFIER_DATA = "ArrayModifierData";
|
||||||
public static final String ARMATURE_MODIFIER_DATA = "ArmatureModifierData";
|
public static final String ARMATURE_MODIFIER_DATA = "ArmatureModifierData";
|
||||||
public static final String PARTICLE_MODIFIER_DATA = "ParticleSystemModifierData";
|
public static final String PARTICLE_MODIFIER_DATA = "ParticleSystemModifierData";
|
||||||
|
|
||||||
/** Blender's type of modifier. */
|
/** Blender's type of modifier. */
|
||||||
private String type;
|
private String type;
|
||||||
/** JME modifier representation object. */
|
/** JME modifier representation object. */
|
||||||
private Object jmeModifierRepresentation;
|
private Object jmeModifierRepresentation;
|
||||||
/** Various additional data used by modifiers.*/
|
/** Various additional data used by modifiers.*/
|
||||||
private Object additionalData;
|
private Object additionalData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates modifier object.
|
* Constructor. Creates modifier object.
|
||||||
* @param type
|
* @param type
|
||||||
|
@ -42,6 +42,7 @@ import com.jme3.util.BufferUtils;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBlenderHelper {
|
public abstract class AbstractBlenderHelper {
|
||||||
|
|
||||||
/** The version of the blend file. */
|
/** The version of the blend file. */
|
||||||
protected final int blenderVersion;
|
protected final int blenderVersion;
|
||||||
|
|
||||||
@ -58,7 +59,8 @@ public abstract class AbstractBlenderHelper {
|
|||||||
/**
|
/**
|
||||||
* This method clears the state of the helper so that it can be used for different calculations of another feature.
|
* This method clears the state of the helper so that it can be used for different calculations of another feature.
|
||||||
*/
|
*/
|
||||||
public void clearState() { }
|
public void clearState() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be used to check if the text is blank. Avoid using text.trim().length()==0. This causes that more strings are
|
* This method should be used to check if the text is blank. Avoid using text.trim().length()==0. This causes that more strings are
|
||||||
|
@ -52,7 +52,8 @@ import com.jme3.scene.plugins.blender.exception.BlenderFileException;
|
|||||||
* the type of material element
|
* the type of material element
|
||||||
*/
|
*/
|
||||||
//TODO: ujednolicić wyrzucane wyjątki
|
//TODO: ujednolicić wyrzucane wyjątki
|
||||||
public interface IBlenderConverter<NodeType, CameraType, LightType, ObjectType, MeshType, MaterialType> {
|
public interface BlenderConverter<NodeType, CameraType, LightType, ObjectType, MeshType, MaterialType> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method reads converts the given structure into scene. The given structure needs to be filled with the
|
* This method reads converts the given structure into scene. The given structure needs to be filled with the
|
||||||
* appropriate data.
|
* appropriate data.
|
@ -46,8 +46,8 @@ import com.jme3.scene.plugins.blender.exception.BlenderFileException;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class BlenderInputStream extends InputStream {
|
public class BlenderInputStream extends InputStream {
|
||||||
private static final Logger LOGGER = Logger.getLogger(BlenderInputStream.class.getName());
|
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(BlenderInputStream.class.getName());
|
||||||
/** The default size of the blender buffer. */
|
/** The default size of the blender buffer. */
|
||||||
private static final int DEFAULT_BUFFER_SIZE = 1048576; //1MB
|
private static final int DEFAULT_BUFFER_SIZE = 1048576; //1MB
|
||||||
/** The application's asset manager. */
|
/** The application's asset manager. */
|
||||||
@ -148,8 +148,8 @@ public class BlenderInputStream extends InputStream {
|
|||||||
gis = new GZIPInputStream(new ByteArrayInputStream(cachedBuffer));
|
gis = new GZIPInputStream(new ByteArrayInputStream(cachedBuffer));
|
||||||
this.readStreamToCache(gis);
|
this.readStreamToCache(gis);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("IO errors occured where they should NOT! " +
|
throw new IllegalStateException("IO errors occured where they should NOT! "
|
||||||
"The data is already buffered at this point!", e);
|
+ "The data is already buffered at this point!", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (gis != null) {
|
if (gis != null) {
|
||||||
|
@ -54,6 +54,7 @@ import com.jme3.scene.plugins.blender.structures.Modifier;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class DataRepository {
|
public class DataRepository {
|
||||||
|
|
||||||
/** The blender key. */
|
/** The blender key. */
|
||||||
private BlenderKey blenderKey;
|
private BlenderKey blenderKey;
|
||||||
/** The header of the file block. */
|
/** The header of the file block. */
|
||||||
@ -218,7 +219,6 @@ public class DataRepository {
|
|||||||
return (T) helpers.get(clazz.getSimpleName());
|
return (T) helpers.get(clazz.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method adds a loaded feature to the map. The key is its unique old memory address.
|
* This method adds a loaded feature to the map. The key is its unique old memory address.
|
||||||
* @param oldMemoryAddress
|
* @param oldMemoryAddress
|
||||||
@ -385,8 +385,8 @@ public class DataRepository {
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public static enum LoadedFeatureDataType {
|
public static enum LoadedFeatureDataType {
|
||||||
LOADED_STRUCTURE(0), LOADED_FEATURE(1);
|
|
||||||
|
|
||||||
|
LOADED_STRUCTURE(0), LOADED_FEATURE(1);
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
private LoadedFeatureDataType(int index) {
|
private LoadedFeatureDataType(int index) {
|
||||||
|
@ -40,6 +40,7 @@ import com.jme3.scene.plugins.blender.exception.BlenderFileException;
|
|||||||
* the type of stored data in the array
|
* the type of stored data in the array
|
||||||
*/
|
*/
|
||||||
public class DynamicArray<T> implements Cloneable {
|
public class DynamicArray<T> implements Cloneable {
|
||||||
|
|
||||||
/** An array object that holds the required data. */
|
/** An array object that holds the required data. */
|
||||||
private T[] array;
|
private T[] array;
|
||||||
/**
|
/**
|
||||||
|
@ -55,9 +55,9 @@ import com.jme3.scene.plugins.blender.helpers.ObjectHelper;
|
|||||||
* This class converts blender file blocks into jMonkeyEngine data structures.
|
* This class converts blender file blocks into jMonkeyEngine data structures.
|
||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class JmeConverter implements IBlenderConverter<Node, Camera, Light, Object, List<Geometry>, Material> {
|
public class JmeConverter implements BlenderConverter<Node, Camera, Light, Object, List<Geometry>, Material> {
|
||||||
private static final Logger LOGGER = Logger.getLogger(JmeConverter.class.getName());
|
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(JmeConverter.class.getName());
|
||||||
private final DataRepository dataRepository;
|
private final DataRepository dataRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,8 +123,8 @@ public class JmeConverter implements IBlenderConverter<Node, Camera, Light, Obje
|
|||||||
@Override
|
@Override
|
||||||
public Object toObject(Structure structure) throws BlenderFileException {
|
public Object toObject(Structure structure) throws BlenderFileException {
|
||||||
int lay = ((Number) structure.getFieldValue("lay")).intValue();
|
int lay = ((Number) structure.getFieldValue("lay")).intValue();
|
||||||
if((lay & dataRepository.getBlenderKey().getLayersToLoad()) == 0 ||
|
if ((lay & dataRepository.getBlenderKey().getLayersToLoad()) == 0
|
||||||
(dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) == 0) {
|
|| (dataRepository.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class);
|
ObjectHelper objectHelper = dataRepository.getHelper(ObjectHelper.class);
|
||||||
|
@ -43,6 +43,7 @@ import com.jme3.scene.plugins.blender.exception.BlenderFileException;
|
|||||||
* @author Marcin Roguski
|
* @author Marcin Roguski
|
||||||
*/
|
*/
|
||||||
public class Pointer {
|
public class Pointer {
|
||||||
|
|
||||||
/** The data repository. */
|
/** The data repository. */
|
||||||
private DataRepository dataRepository;
|
private DataRepository dataRepository;
|
||||||
/** The level of the pointer. */
|
/** The level of the pointer. */
|
||||||
|
@ -347,7 +347,6 @@ public final class Bone implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Set user transform.
|
* Set user transform.
|
||||||
* Combine the given transforms to bone's current transforms
|
* Combine the given transforms to bone's current transforms
|
||||||
* @see setUserControl
|
|
||||||
*/
|
*/
|
||||||
public void setUserTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
public void setUserTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
||||||
if (!userControl) {
|
if (!userControl) {
|
||||||
@ -378,10 +377,9 @@ public final class Bone implements Savable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns teh local transform of this bone combined with the given position and rotation
|
* Returns the local transform of this bone combined with the given position and rotation
|
||||||
* @param position a position
|
* @param position a position
|
||||||
* @param rotation a rotation
|
* @param rotation a rotation
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Transform getCombinedTransform(Vector3f position, Quaternion rotation){
|
public Transform getCombinedTransform(Vector3f position, Quaternion rotation){
|
||||||
rotation.mult(localPos, tmpTransform.getTranslation()).addLocal(position);
|
rotation.mult(localPos, tmpTransform.getTranslation()).addLocal(position);
|
||||||
|
@ -234,13 +234,11 @@ public abstract class CompactArray<T> {
|
|||||||
* deserialize object
|
* deserialize object
|
||||||
* @param compactIndex compacted object index
|
* @param compactIndex compacted object index
|
||||||
* @param store
|
* @param store
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
protected abstract T deserialize(int compactIndex, T store);
|
protected abstract T deserialize(int compactIndex, T store);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* serialized size of one object element
|
* serialized size of one object element
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
protected abstract int getTupleSize();
|
protected abstract int getTupleSize();
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
The <code>com.jme3.application</code> provides a toolset for jME3 applications
|
The <code>com.jme3.application</code> provides a toolset for jME3 applications
|
||||||
to interact with various components of the engine. Typically, the
|
to interact with various components of the engine. Typically, the
|
||||||
{@link com.jme3.app.Application} class will be extended and the update() method
|
{@link com.jme3.app.Application} class will be extended and the update() method
|
||||||
implemented to provide functionality for the main loop. <br/>
|
implemented to provide functionality for the main loop. <br>
|
||||||
<p>
|
<p>
|
||||||
An <code>Application</code> will typically provide the following services:
|
An <code>Application</code> will typically provide the following services:
|
||||||
<ul>
|
<ul>
|
||||||
@ -37,42 +37,42 @@ An <code>Application</code> will typically provide the following services:
|
|||||||
|
|
||||||
<h3>Usage</h3>
|
<h3>Usage</h3>
|
||||||
|
|
||||||
An example use of the Application class is as follows<br/>
|
An example use of the Application class is as follows<br>
|
||||||
<br/>
|
<br>
|
||||||
|
|
||||||
<code>
|
<code>
|
||||||
public class ExampleUse extends Application {<br/>
|
public class ExampleUse extends Application {<br>
|
||||||
<br/>
|
<br>
|
||||||
private Node rootNode = new Node("Root Node");<br/>
|
private Node rootNode = new Node("Root Node");<br>
|
||||||
<br/>
|
<br>
|
||||||
public static void main(String[] args){<br/>
|
public static void main(String[] args){<br>
|
||||||
ExampleUse app = new ExampleUse();<br/>
|
ExampleUse app = new ExampleUse();<br>
|
||||||
app.start();<br/>
|
app.start();<br>
|
||||||
}<br/>
|
}<br>
|
||||||
<br/>
|
<br>
|
||||||
@Override<br/>
|
@Override<br>
|
||||||
public void initialize(){<br/>
|
public void initialize(){<br>
|
||||||
super.initialize();<br/>
|
super.initialize();<br>
|
||||||
<br/>
|
<br>
|
||||||
// attach root node to viewport<br/>
|
// attach root node to viewport<br>
|
||||||
viewPort.attachScene(rootNode);<br/>
|
viewPort.attachScene(rootNode);<br>
|
||||||
}<br/>
|
}<br>
|
||||||
<br/>
|
<br>
|
||||||
@Override<br/>
|
@Override<br>
|
||||||
public void update(){<br/>
|
public void update(){<br>
|
||||||
super.update();<br/>
|
super.update();<br>
|
||||||
<br/>
|
<br>
|
||||||
float tpf = timer.getTimePerFrame();<br/>
|
float tpf = timer.getTimePerFrame();<br>
|
||||||
<br/>
|
<br>
|
||||||
// update rootNode<br/>
|
// update rootNode<br>
|
||||||
rootNode.updateLogicalState(tpf);<br/>
|
rootNode.updateLogicalState(tpf);<br>
|
||||||
rootNode.updateGeometricState();<br/>
|
rootNode.updateGeometricState();<br>
|
||||||
<br/>
|
<br>
|
||||||
// render the viewports<br/>
|
// render the viewports<br>
|
||||||
renderManager.render(tpf);<br/>
|
renderManager.render(tpf);<br>
|
||||||
}<br/>
|
}<br>
|
||||||
}<br/>
|
}<br>
|
||||||
<br/>
|
<br>
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -173,7 +173,6 @@ public class AppStateManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls render for all attached states, do not call directly.
|
* Calls render for all attached states, do not call directly.
|
||||||
* @param rm The RenderManager
|
|
||||||
*/
|
*/
|
||||||
public void postRender(){
|
public void postRender(){
|
||||||
AppState[] array = getArray();
|
AppState[] array = getArray();
|
||||||
|
@ -54,7 +54,7 @@ public interface AssetLocator {
|
|||||||
*
|
*
|
||||||
* @param manager
|
* @param manager
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return The {@link AssetInfo} that was located, or null if not found.
|
||||||
*/
|
*/
|
||||||
public AssetInfo locate(AssetManager manager, AssetKey key);
|
public AssetInfo locate(AssetManager manager, AssetKey key);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public interface AssetManager {
|
|||||||
* TGA and DDS.
|
* TGA and DDS.
|
||||||
*
|
*
|
||||||
* @param name The name of the texture to load.
|
* @param name The name of the texture to load.
|
||||||
* @return
|
* @return The texture that was loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -168,7 +168,7 @@ public interface AssetManager {
|
|||||||
/**
|
/**
|
||||||
* Load audio file, supported types are WAV or OGG.
|
* Load audio file, supported types are WAV or OGG.
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return The audio data loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -178,7 +178,7 @@ public interface AssetManager {
|
|||||||
* Load audio file, supported types are WAV or OGG.
|
* Load audio file, supported types are WAV or OGG.
|
||||||
* The file is loaded without stream-mode.
|
* The file is loaded without stream-mode.
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return The audio data loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -188,7 +188,7 @@ public interface AssetManager {
|
|||||||
* Loads a named model. Models can be jME3 object files (J3O) or
|
* Loads a named model. Models can be jME3 object files (J3O) or
|
||||||
* OgreXML/OBJ files.
|
* OgreXML/OBJ files.
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return The model that was loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -198,7 +198,7 @@ public interface AssetManager {
|
|||||||
* Loads a named model. Models can be jME3 object files (J3O) or
|
* Loads a named model. Models can be jME3 object files (J3O) or
|
||||||
* OgreXML/OBJ files.
|
* OgreXML/OBJ files.
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return The model that was loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -207,7 +207,7 @@ public interface AssetManager {
|
|||||||
/**
|
/**
|
||||||
* Load a material (J3M) file.
|
* Load a material (J3M) file.
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return The material that was loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
@ -225,7 +225,7 @@ public interface AssetManager {
|
|||||||
* and are with the extension "fnt".
|
* and are with the extension "fnt".
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return The font loaded
|
||||||
*
|
*
|
||||||
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
* @see AssetManager#loadAsset(com.jme3.asset.AssetKey)
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ public class TextureKey extends AssetKey<Texture> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable smart caching for textures
|
* Enable smart caching for textures
|
||||||
* @return
|
* @return true to enable smart cache
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean useSmartCache(){
|
public boolean useSmartCache(){
|
||||||
|
@ -48,7 +48,7 @@ public interface AudioRenderer {
|
|||||||
/**
|
/**
|
||||||
* Sets the environment, used for reverb effects.
|
* Sets the environment, used for reverb effects.
|
||||||
*
|
*
|
||||||
* @see PointAudioSource#setReverbEnabled(boolean)
|
* @see AudioNode#setReverbEnabled(boolean)
|
||||||
* @param env The environment to set.
|
* @param env The environment to set.
|
||||||
*/
|
*/
|
||||||
public void setEnvironment(Environment env);
|
public void setEnvironment(Environment env);
|
||||||
|
@ -259,12 +259,8 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
* <code>transform</code> modifies the center of the box to reflect the
|
* <code>transform</code> modifies the center of the box to reflect the
|
||||||
* change made via a rotation, translation and scale.
|
* change made via a rotation, translation and scale.
|
||||||
*
|
*
|
||||||
* @param rotate
|
* @param trans
|
||||||
* the rotation change.
|
* the transform to apply
|
||||||
* @param translate
|
|
||||||
* the translation change.
|
|
||||||
* @param scale
|
|
||||||
* the size change.
|
|
||||||
* @param store
|
* @param store
|
||||||
* box to store result in
|
* box to store result in
|
||||||
*/
|
*/
|
||||||
@ -570,7 +566,7 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
* intersects determines if this Bounding Box intersects with another given
|
* intersects determines if this Bounding Box intersects with another given
|
||||||
* bounding volume. If so, true is returned, otherwise, false is returned.
|
* bounding volume. If so, true is returned, otherwise, false is returned.
|
||||||
*
|
*
|
||||||
* @see com.jme.bounding.BoundingVolume#intersects(com.jme.bounding.BoundingVolume)
|
* @see BoundingVolume#intersects(com.jme3.bounding.BoundingVolume)
|
||||||
*/
|
*/
|
||||||
public boolean intersects(BoundingVolume bv) {
|
public boolean intersects(BoundingVolume bv) {
|
||||||
return bv.intersectsBoundingBox(this);
|
return bv.intersectsBoundingBox(this);
|
||||||
@ -579,7 +575,7 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
/**
|
/**
|
||||||
* determines if this bounding box intersects a given bounding sphere.
|
* determines if this bounding box intersects a given bounding sphere.
|
||||||
*
|
*
|
||||||
* @see com.jme.bounding.BoundingVolume#intersectsSphere(com.jme.bounding.BoundingSphere)
|
* @see BoundingVolume#intersectsSphere(com.jme3.bounding.BoundingSphere)
|
||||||
*/
|
*/
|
||||||
public boolean intersectsSphere(BoundingSphere bs) {
|
public boolean intersectsSphere(BoundingSphere bs) {
|
||||||
assert Vector3f.isValidVector(center) && Vector3f.isValidVector(bs.center);
|
assert Vector3f.isValidVector(center) && Vector3f.isValidVector(bs.center);
|
||||||
@ -600,7 +596,7 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
* two boxes intersect in any way, true is returned. Otherwise, false is
|
* two boxes intersect in any way, true is returned. Otherwise, false is
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
* @see com.jme.bounding.BoundingVolume#intersectsBoundingBox(com.jme.bounding.BoundingBox)
|
* @see BoundingVolume#intersectsBoundingBox(com.jme3.bounding.BoundingBox)
|
||||||
*/
|
*/
|
||||||
public boolean intersectsBoundingBox(BoundingBox bb) {
|
public boolean intersectsBoundingBox(BoundingBox bb) {
|
||||||
assert Vector3f.isValidVector(center) && Vector3f.isValidVector(bb.center);
|
assert Vector3f.isValidVector(center) && Vector3f.isValidVector(bb.center);
|
||||||
@ -632,7 +628,7 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
* determines if this bounding box intersects with a given ray object. If an
|
* determines if this bounding box intersects with a given ray object. If an
|
||||||
* intersection has occurred, true is returned, otherwise false is returned.
|
* intersection has occurred, true is returned, otherwise false is returned.
|
||||||
*
|
*
|
||||||
* @see com.jme.bounding.BoundingVolume#intersects(com.jme.math.Ray)
|
* @see BoundingVolume#intersects(com.jme3.math.Ray)
|
||||||
*/
|
*/
|
||||||
public boolean intersects(Ray ray) {
|
public boolean intersects(Ray ray) {
|
||||||
assert Vector3f.isValidVector(center);
|
assert Vector3f.isValidVector(center);
|
||||||
@ -766,10 +762,11 @@ public class BoundingBox extends BoundingVolume {
|
|||||||
/**
|
/**
|
||||||
* C code ported from http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt
|
* C code ported from http://www.cs.lth.se/home/Tomas_Akenine_Moller/code/tribox3.txt
|
||||||
*
|
*
|
||||||
* @param v1
|
* @param v1 The first point in the triangle
|
||||||
* @param v2
|
* @param v2 The second point in the triangle
|
||||||
* @param v3
|
* @param v3 The third point in the triangle
|
||||||
* @return
|
* @return True if the bounding box intersects the triangle, false
|
||||||
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean intersects(Vector3f v1, Vector3f v2, Vector3f v3){
|
public boolean intersects(Vector3f v1, Vector3f v2, Vector3f v3){
|
||||||
return Intersection.intersect(this, v1, v2, v3);
|
return Intersection.intersect(this, v1, v2, v3);
|
||||||
|
@ -387,12 +387,8 @@ public class BoundingSphere extends BoundingVolume {
|
|||||||
* <code>transform</code> modifies the center of the sphere to reflect the
|
* <code>transform</code> modifies the center of the sphere to reflect the
|
||||||
* change made via a rotation, translation and scale.
|
* change made via a rotation, translation and scale.
|
||||||
*
|
*
|
||||||
* @param rotate
|
* @param trans
|
||||||
* the rotation change.
|
* the transform to apply
|
||||||
* @param translate
|
|
||||||
* the translation change.
|
|
||||||
* @param scale
|
|
||||||
* the size change.
|
|
||||||
* @param store
|
* @param store
|
||||||
* sphere to store result in
|
* sphere to store result in
|
||||||
* @return BoundingVolume
|
* @return BoundingVolume
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
package com.jme3.input.controls;
|
package com.jme3.input.controls;
|
||||||
|
|
||||||
|
import com.jme3.input.MouseInput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <code>MouseButtonTrigger</code> is used as a mapping to receive events
|
* A <code>MouseButtonTrigger</code> is used as a mapping to receive events
|
||||||
* from mouse buttons. It is generally expected for a mouse to have at least
|
* from mouse buttons. It is generally expected for a mouse to have at least
|
||||||
|
@ -160,7 +160,8 @@ public abstract class Light implements Savable, Cloneable {
|
|||||||
this.color.set(color);
|
this.color.set(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
/*
|
||||||
* Returns true if the light is enabled
|
* Returns true if the light is enabled
|
||||||
*
|
*
|
||||||
* @return true if the light is enabled
|
* @return true if the light is enabled
|
||||||
|
@ -193,8 +193,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones this material. The result
|
* Clones this material. The result is returned.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Material clone() {
|
public Material clone() {
|
||||||
@ -219,10 +218,27 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently active technique.
|
||||||
|
* <p>
|
||||||
|
* The technique is selected automatically by the {@link RenderManager}
|
||||||
|
* based on system capabilities. Users may select their own
|
||||||
|
* technique by using
|
||||||
|
* {@link #selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) }.
|
||||||
|
*
|
||||||
|
* @return the currently active technique.
|
||||||
|
*
|
||||||
|
* @see #selectTechnique(java.lang.String, com.jme3.renderer.RenderManager)
|
||||||
|
*/
|
||||||
public Technique getActiveTechnique() {
|
public Technique getActiveTechnique() {
|
||||||
return technique;
|
return technique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the transparent value marker is set on this material.
|
||||||
|
* @return True if the transparent value marker is set on this material.
|
||||||
|
* @see #setTransparent(boolean)
|
||||||
|
*/
|
||||||
public boolean isTransparent() {
|
public boolean isTransparent() {
|
||||||
return transparent;
|
return transparent;
|
||||||
}
|
}
|
||||||
@ -296,6 +312,13 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parameter set on this material with the given name,
|
||||||
|
* returns <code>null</code> if the parameter is not set.
|
||||||
|
*
|
||||||
|
* @param name The parameter name to look up.
|
||||||
|
* @return The MatParam if set, or null if not set.
|
||||||
|
*/
|
||||||
public MatParam getParam(String name) {
|
public MatParam getParam(String name) {
|
||||||
MatParam param = paramValues.get(name);
|
MatParam param = paramValues.get(name);
|
||||||
if (param instanceof MatParam) {
|
if (param instanceof MatParam) {
|
||||||
@ -304,6 +327,13 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the texture parameter set on this material with the given name,
|
||||||
|
* returns <code>null</code> if the parameter is not set.
|
||||||
|
*
|
||||||
|
* @param name The parameter name to look up.
|
||||||
|
* @return The MatParamTexture if set, or null if not set.
|
||||||
|
*/
|
||||||
public MatParamTexture getTextureParam(String name) {
|
public MatParamTexture getTextureParam(String name) {
|
||||||
MatParam param = paramValues.get(name);
|
MatParam param = paramValues.get(name);
|
||||||
if (param instanceof MatParamTexture) {
|
if (param instanceof MatParamTexture) {
|
||||||
@ -312,6 +342,13 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a collection of all parameters set on this material.
|
||||||
|
*
|
||||||
|
* @return a collection of all parameters set on this material.
|
||||||
|
*
|
||||||
|
* @see #setParam(java.lang.String, com.jme3.shader.VarType, java.lang.Object)
|
||||||
|
*/
|
||||||
public Collection<MatParam> getParams() {
|
public Collection<MatParam> getParams() {
|
||||||
return paramValues.values();
|
return paramValues.values();
|
||||||
}
|
}
|
||||||
@ -342,10 +379,11 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a parameter to the material shader
|
* Pass a parameter to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the parameter defined in the material definition (j3md)
|
* @param name the name of the parameter defined in the material definition (j3md)
|
||||||
* @param type the type of the parameter @see com.jme3.shaderVarType
|
* @param type the type of the parameter {@link VarType}
|
||||||
* @param value the value of the param
|
* @param value the value of the parameter
|
||||||
*/
|
*/
|
||||||
public void setParam(String name, VarType type, Object value) {
|
public void setParam(String name, VarType type, Object value) {
|
||||||
name = checkSetParam(type, name);
|
name = checkSetParam(type, name);
|
||||||
@ -363,7 +401,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a parameter from this material. The param must exist
|
* Clear a parameter from this material. The parameter must exist
|
||||||
* @param name the name of the parameter to clear
|
* @param name the name of the parameter to clear
|
||||||
*/
|
*/
|
||||||
public void clearParam(String name) {
|
public void clearParam(String name) {
|
||||||
@ -416,9 +454,18 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
sortingId = -1;
|
sortingId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a texture parameter.
|
||||||
|
*
|
||||||
|
* @param name The name of the parameter
|
||||||
|
* @param type The variable type {@link VarType}
|
||||||
|
* @param value The texture value of the parameter.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException is value is null
|
||||||
|
*/
|
||||||
public void setTextureParam(String name, VarType type, Texture value) {
|
public void setTextureParam(String name, VarType type, Texture value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new NullPointerException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
name = checkSetParam(type, name);
|
name = checkSetParam(type, name);
|
||||||
@ -438,8 +485,10 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a texture to the material shader
|
* Pass a texture to the material shader.
|
||||||
* @param name the name of the texture defined in the material definition (j3md) (for example Texture for Lighting.j3md)
|
*
|
||||||
|
* @param name the name of the texture defined in the material definition
|
||||||
|
* (j3md) (for example Texture for Lighting.j3md)
|
||||||
* @param value the Texture object previously loaded by the asset manager
|
* @param value the Texture object previously loaded by the asset manager
|
||||||
*/
|
*/
|
||||||
public void setTexture(String name, Texture value) {
|
public void setTexture(String name, Texture value) {
|
||||||
@ -471,7 +520,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a Matrix4f to the material shader
|
* Pass a Matrix4f to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the matrix defined in the material definition (j3md)
|
* @param name the name of the matrix defined in the material definition (j3md)
|
||||||
* @param value the Matrix4f object
|
* @param value the Matrix4f object
|
||||||
*/
|
*/
|
||||||
@ -480,7 +530,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a boolean to the material shader
|
* Pass a boolean to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the boolean defined in the material definition (j3md)
|
* @param name the name of the boolean defined in the material definition (j3md)
|
||||||
* @param value the boolean value
|
* @param value the boolean value
|
||||||
*/
|
*/
|
||||||
@ -489,7 +540,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a float to the material shader
|
* Pass a float to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the float defined in the material definition (j3md)
|
* @param name the name of the float defined in the material definition (j3md)
|
||||||
* @param value the float value
|
* @param value the float value
|
||||||
*/
|
*/
|
||||||
@ -498,7 +550,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass an int to the material shader
|
* Pass an int to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the int defined in the material definition (j3md)
|
* @param name the name of the int defined in the material definition (j3md)
|
||||||
* @param value the int value
|
* @param value the int value
|
||||||
*/
|
*/
|
||||||
@ -507,7 +560,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a Color to the material shader
|
* Pass a Color to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the color defined in the material definition (j3md)
|
* @param name the name of the color defined in the material definition (j3md)
|
||||||
* @param value the ColorRGBA value
|
* @param value the ColorRGBA value
|
||||||
*/
|
*/
|
||||||
@ -516,7 +570,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a Vector2f to the material shader
|
* Pass a Vector2f to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the Vector2f defined in the material definition (j3md)
|
* @param name the name of the Vector2f defined in the material definition (j3md)
|
||||||
* @param value the Vector2f value
|
* @param value the Vector2f value
|
||||||
*/
|
*/
|
||||||
@ -525,7 +580,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a Vector3f to the material shader
|
* Pass a Vector3f to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the Vector3f defined in the material definition (j3md)
|
* @param name the name of the Vector3f defined in the material definition (j3md)
|
||||||
* @param value the Vector3f value
|
* @param value the Vector3f value
|
||||||
*/
|
*/
|
||||||
@ -534,7 +590,8 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass a Vector4f to the material shader
|
* Pass a Vector4f to the material shader.
|
||||||
|
*
|
||||||
* @param name the name of the Vector4f defined in the material definition (j3md)
|
* @param name the name of the Vector4f defined in the material definition (j3md)
|
||||||
* @param value the Vector4f value
|
* @param value the Vector4f value
|
||||||
*/
|
*/
|
||||||
@ -567,9 +624,6 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
* // or the direction of the light (for directional lights).<br/>
|
* // or the direction of the light (for directional lights).<br/>
|
||||||
* // g_LightPosition.w is the inverse radius (1/r) of the light (for attenuation) <br/>
|
* // g_LightPosition.w is the inverse radius (1/r) of the light (for attenuation) <br/>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* @param shader
|
|
||||||
* @param lightList
|
|
||||||
*/
|
*/
|
||||||
protected void updateLightListUniforms(Shader shader, Geometry g, int numLights) {
|
protected void updateLightListUniforms(Shader shader, Geometry g, int numLights) {
|
||||||
if (numLights == 0){ // this shader does not do lighting, ignore.
|
if (numLights == 0){ // this shader does not do lighting, ignore.
|
||||||
@ -719,6 +773,29 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the technique to use for rendering this material.
|
||||||
|
* <p>
|
||||||
|
* If <code>name</code> is "Default", then one of the
|
||||||
|
* {@link MaterialDef#getDefaultTechniques() default techniques}
|
||||||
|
* on the material will be selected. Otherwise, the named technique
|
||||||
|
* will be found in the material definition.
|
||||||
|
* <p>
|
||||||
|
* Any candidate technique for selection (either default or named)
|
||||||
|
* must be verified to be compatible with the system, for that, the
|
||||||
|
* <code>renderManager</code> is queried for capabilities.
|
||||||
|
*
|
||||||
|
* @param name The name of the technique to select, pass "Default" to
|
||||||
|
* select one of the default techniques.
|
||||||
|
* @param renderManager The {@link RenderManager render manager}
|
||||||
|
* to query for capabilities.
|
||||||
|
*
|
||||||
|
* @throws IllegalArgumentException If "Default" is passed and no default
|
||||||
|
* techniques are available on the material definition, or if a name
|
||||||
|
* is passed but there's no technique by that name.
|
||||||
|
* @throws UnsupportedOperationException If no candidate technique supports
|
||||||
|
* the system capabilities.
|
||||||
|
*/
|
||||||
public void selectTechnique(String name, RenderManager renderManager) {
|
public void selectTechnique(String name, RenderManager renderManager) {
|
||||||
// check if already created
|
// check if already created
|
||||||
Technique tech = techniques.get(name);
|
Technique tech = techniques.get(name);
|
||||||
@ -730,7 +807,7 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
if (name.equals("Default")) {
|
if (name.equals("Default")) {
|
||||||
List<TechniqueDef> techDefs = def.getDefaultTechniques();
|
List<TechniqueDef> techDefs = def.getDefaultTechniques();
|
||||||
if (techDefs == null || techDefs.isEmpty()) {
|
if (techDefs == null || techDefs.isEmpty()) {
|
||||||
throw new IllegalStateException("No default techniques are available on material '" + def.getName() + "'");
|
throw new IllegalArgumentException("No default techniques are available on material '" + def.getName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
TechniqueDef lastTech = null;
|
TechniqueDef lastTech = null;
|
||||||
@ -794,8 +871,13 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Pre-load" the material, including textures and shaders, to the
|
* Preloads this material for the given render manager.
|
||||||
* renderer.
|
* <p>
|
||||||
|
* Preloading the material can ensure that when the material is first
|
||||||
|
* used for rendering, there won't be any delay since the material has
|
||||||
|
* been already been setup for rendering.
|
||||||
|
*
|
||||||
|
* @param rm The render manager to preload for
|
||||||
*/
|
*/
|
||||||
public void preload(RenderManager rm) {
|
public void preload(RenderManager rm) {
|
||||||
autoSelectTechnique(rm);
|
autoSelectTechnique(rm);
|
||||||
@ -844,9 +926,11 @@ public class Material implements Cloneable, Savable, Comparable<Material> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called after selectTechnique()
|
* Called by {@link RenderManager} to render the geometry by
|
||||||
* @param geom
|
* using this material.
|
||||||
* @param r
|
*
|
||||||
|
* @param geom The geometry to render
|
||||||
|
* @param rm The render manager requesting the rendering
|
||||||
*/
|
*/
|
||||||
public void render(Geometry geom, RenderManager rm) {
|
public void render(Geometry geom, RenderManager rm) {
|
||||||
autoSelectTechnique(rm);
|
autoSelectTechnique(rm);
|
||||||
|
@ -176,6 +176,15 @@ public class Technique implements Savable {
|
|||||||
updateUniformParam(paramName, type, value, false);
|
updateUniformParam(paramName, type, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the technique must be reloaded.
|
||||||
|
* <p>
|
||||||
|
* If a technique needs to reload, then the {@link Material} should
|
||||||
|
* call {@link #makeCurrent(com.jme3.asset.AssetManager) } on this
|
||||||
|
* technique.
|
||||||
|
*
|
||||||
|
* @return true if the technique must be reloaded.
|
||||||
|
*/
|
||||||
public boolean isNeedReload() {
|
public boolean isNeedReload() {
|
||||||
return needReload;
|
return needReload;
|
||||||
}
|
}
|
||||||
@ -183,8 +192,10 @@ public class Technique implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Prepares the technique for use by loading the shader and setting
|
* Prepares the technique for use by loading the shader and setting
|
||||||
* the proper defines based on material parameters.
|
* the proper defines based on material parameters.
|
||||||
|
*
|
||||||
|
* @param assetManager The asset manager to use for loading shaders.
|
||||||
*/
|
*/
|
||||||
public void makeCurrent(AssetManager manager) {
|
public void makeCurrent(AssetManager assetManager) {
|
||||||
// check if reload is needed..
|
// check if reload is needed..
|
||||||
if (def.isUsingShaders()) {
|
if (def.isUsingShaders()) {
|
||||||
DefineList newDefines = new DefineList();
|
DefineList newDefines = new DefineList();
|
||||||
@ -203,7 +214,7 @@ public class Technique implements Savable {
|
|||||||
defines.clear();
|
defines.clear();
|
||||||
defines.addFrom(newDefines);
|
defines.addFrom(newDefines);
|
||||||
// defines changed, recompile needed
|
// defines changed, recompile needed
|
||||||
loadShader(manager);
|
loadShader(assetManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,8 +225,8 @@ public class Technique implements Savable {
|
|||||||
allDefines.addFrom(def.getShaderPresetDefines());
|
allDefines.addFrom(def.getShaderPresetDefines());
|
||||||
allDefines.addFrom(defines);
|
allDefines.addFrom(defines);
|
||||||
|
|
||||||
ShaderKey key = new ShaderKey(def.getVertName(),
|
ShaderKey key = new ShaderKey(def.getVertexShaderName(),
|
||||||
def.getFragName(),
|
def.getFragmentShaderName(),
|
||||||
allDefines,
|
allDefines,
|
||||||
def.getShaderLanguage());
|
def.getShaderLanguage());
|
||||||
shader = manager.loadShader(key);
|
shader = manager.loadShader(key);
|
||||||
|
@ -38,6 +38,7 @@ import com.jme3.export.InputCapsule;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
import com.jme3.renderer.Caps;
|
import com.jme3.renderer.Caps;
|
||||||
|
import com.jme3.renderer.Renderer;
|
||||||
import com.jme3.shader.DefineList;
|
import com.jme3.shader.DefineList;
|
||||||
import com.jme3.shader.UniformBinding;
|
import com.jme3.shader.UniformBinding;
|
||||||
import com.jme3.shader.VarType;
|
import com.jme3.shader.VarType;
|
||||||
@ -47,12 +48,49 @@ import java.util.EnumSet;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes a technique definition.
|
||||||
|
*
|
||||||
|
* @author Kirill Vainer
|
||||||
|
*/
|
||||||
public class TechniqueDef implements Savable {
|
public class TechniqueDef implements Savable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes light rendering mode.
|
||||||
|
*/
|
||||||
public enum LightMode {
|
public enum LightMode {
|
||||||
|
/**
|
||||||
|
* Disable light-based rendering
|
||||||
|
*/
|
||||||
Disable,
|
Disable,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable light rendering by using a single pass.
|
||||||
|
* <p>
|
||||||
|
* An array of light positions and light colors is passed to the shader
|
||||||
|
* containing the world light list for the geometry being rendered.
|
||||||
|
*/
|
||||||
SinglePass,
|
SinglePass,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable light rendering by using multi-pass rendering.
|
||||||
|
* <p>
|
||||||
|
* The geometry will be rendered once for each light. Each time the
|
||||||
|
* light position and light color uniforms are updated to contain
|
||||||
|
* the values for the current light. The ambient light color uniform
|
||||||
|
* is only set to the ambient light color on the first pass, future
|
||||||
|
* passes have it set to black.
|
||||||
|
*/
|
||||||
MultiPass,
|
MultiPass,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable light rendering by using the
|
||||||
|
* {@link Renderer#setLighting(com.jme3.light.LightList) renderer's setLighting}
|
||||||
|
* method.
|
||||||
|
* <p>
|
||||||
|
* The specific details of rendering the lighting is up to the
|
||||||
|
* renderer implementation.
|
||||||
|
*/
|
||||||
FixedPipeline,
|
FixedPipeline,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,16 +116,257 @@ public class TechniqueDef implements Savable {
|
|||||||
private HashMap<String, String> defineParams;
|
private HashMap<String, String> defineParams;
|
||||||
private ArrayList<UniformBinding> worldBinds;
|
private ArrayList<UniformBinding> worldBinds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new technique definition.
|
||||||
|
* <p>
|
||||||
|
* Used internally by the J3M/J3MD loader.
|
||||||
|
*
|
||||||
|
* @param name The name of the technique, should be set to <code>null</code>
|
||||||
|
* for default techniques.
|
||||||
|
*/
|
||||||
public TechniqueDef(String name){
|
public TechniqueDef(String name){
|
||||||
this.name = name == null ? "Default" : name;
|
this.name = name == null ? "Default" : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use this constructor.
|
* Serialization only. Do not use.
|
||||||
*/
|
*/
|
||||||
public TechniqueDef(){
|
public TechniqueDef(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of this technique as specified in the J3MD file.
|
||||||
|
* Default techniques have the name "Default".
|
||||||
|
*
|
||||||
|
* @return the name of this technique
|
||||||
|
*/
|
||||||
|
public String getName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the light mode.
|
||||||
|
* @return the light mode.
|
||||||
|
* @see LightMode
|
||||||
|
*/
|
||||||
|
public LightMode getLightMode() {
|
||||||
|
return lightMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the light mode
|
||||||
|
*
|
||||||
|
* @param lightMode the light mode
|
||||||
|
*
|
||||||
|
* @see LightMode
|
||||||
|
*/
|
||||||
|
public void setLightMode(LightMode lightMode) {
|
||||||
|
this.lightMode = lightMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shadow mode.
|
||||||
|
* @return the shadow mode.
|
||||||
|
*/
|
||||||
|
public ShadowMode getShadowMode() {
|
||||||
|
return shadowMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the shadow mode.
|
||||||
|
*
|
||||||
|
* @param shadowMode the shadow mode.
|
||||||
|
*
|
||||||
|
* @see ShadowMode
|
||||||
|
*/
|
||||||
|
public void setShadowMode(ShadowMode shadowMode) {
|
||||||
|
this.shadowMode = shadowMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the render state that this technique is using
|
||||||
|
* @return the render state that this technique is using
|
||||||
|
* @see #setRenderState(com.jme3.material.RenderState)
|
||||||
|
*/
|
||||||
|
public RenderState getRenderState() {
|
||||||
|
return renderState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the render state that this technique is using.
|
||||||
|
*
|
||||||
|
* @param renderState the render state that this technique is using.
|
||||||
|
*
|
||||||
|
* @see RenderState
|
||||||
|
*/
|
||||||
|
public void setRenderState(RenderState renderState) {
|
||||||
|
this.renderState = renderState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this technique uses shaders, false otherwise.
|
||||||
|
*
|
||||||
|
* @return true if this technique uses shaders, false otherwise.
|
||||||
|
*
|
||||||
|
* @see #setShaderFile(java.lang.String, java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean isUsingShaders(){
|
||||||
|
return usesShaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Caps renderer capabilities} that are required
|
||||||
|
* by this technique.
|
||||||
|
*
|
||||||
|
* @return the required renderer capabilities
|
||||||
|
*/
|
||||||
|
public EnumSet<Caps> getRequiredCaps() {
|
||||||
|
return requiredCaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the shaders that this technique definition will use.
|
||||||
|
*
|
||||||
|
* @param vertexShader The name of the vertex shader
|
||||||
|
* @param fragmentShader The name of the fragment shader
|
||||||
|
* @param shaderLanguage The shader language
|
||||||
|
*/
|
||||||
|
public void setShaderFile(String vertexShader, String fragmentShader, String shaderLanguage){
|
||||||
|
this.vertName = vertexShader;
|
||||||
|
this.fragName = fragmentShader;
|
||||||
|
this.shaderLang = shaderLanguage;
|
||||||
|
|
||||||
|
Caps langCap = Caps.valueOf(shaderLanguage);
|
||||||
|
requiredCaps.add(langCap);
|
||||||
|
|
||||||
|
usesShaders = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the define name which the given material parameter influences.
|
||||||
|
*
|
||||||
|
* @param paramName The parameter name to look up
|
||||||
|
* @return The define name
|
||||||
|
*
|
||||||
|
* @see #addShaderParamDefine(java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public String getShaderParamDefine(String paramName){
|
||||||
|
if (defineParams == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return defineParams.get(paramName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a define linked to a material parameter.
|
||||||
|
* <p>
|
||||||
|
* Any time the material parameter on the parent material is altered,
|
||||||
|
* the appropriate define on the technique will be modified as well.
|
||||||
|
* See the method
|
||||||
|
* {@link DefineList#set(java.lang.String, com.jme3.shader.VarType, java.lang.Object) }
|
||||||
|
* on the exact details of how the material parameter changes the define.
|
||||||
|
*
|
||||||
|
* @param paramName The name of the material parameter to link to.
|
||||||
|
* @param defineName The name of the define parameter, e.g. USE_LIGHTING
|
||||||
|
*/
|
||||||
|
public void addShaderParamDefine(String paramName, String defineName){
|
||||||
|
if (defineParams == null)
|
||||||
|
defineParams = new HashMap<String, String>();
|
||||||
|
|
||||||
|
defineParams.put(paramName, defineName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link DefineList} for the preset defines.
|
||||||
|
*
|
||||||
|
* @return the {@link DefineList} for the preset defines.
|
||||||
|
*
|
||||||
|
* @see #addShaderPresetDefine(java.lang.String, com.jme3.shader.VarType, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public DefineList getShaderPresetDefines() {
|
||||||
|
return presetDefines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a preset define.
|
||||||
|
* <p>
|
||||||
|
* Preset defines do not depend upon any parameters to be activated,
|
||||||
|
* they are always passed to the shader as long as this technique is used.
|
||||||
|
*
|
||||||
|
* @param defineName The name of the define parameter, e.g. USE_LIGHTING
|
||||||
|
* @param type The type of the define. See
|
||||||
|
* {@link DefineList#set(java.lang.String, com.jme3.shader.VarType, java.lang.Object) }
|
||||||
|
* to see why it matters.
|
||||||
|
*
|
||||||
|
* @param value The value of the define
|
||||||
|
*/
|
||||||
|
public void addShaderPresetDefine(String defineName, VarType type, Object value){
|
||||||
|
if (presetDefines == null)
|
||||||
|
presetDefines = new DefineList();
|
||||||
|
|
||||||
|
presetDefines.set(defineName, type, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the fragment shader used by the technique, or null
|
||||||
|
* if no fragment shader is specified.
|
||||||
|
*
|
||||||
|
* @return the name of the fragment shader to be used.
|
||||||
|
*/
|
||||||
|
public String getFragmentShaderName() {
|
||||||
|
return fragName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the vertex shader used by the technique, or null
|
||||||
|
* if no vertex shader is specified.
|
||||||
|
*
|
||||||
|
* @return the name of the vertex shader to be used.
|
||||||
|
*/
|
||||||
|
public String getVertexShaderName() {
|
||||||
|
return vertName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shader language of the shaders used in this technique.
|
||||||
|
*
|
||||||
|
* @return the shader language of the shaders used in this technique.
|
||||||
|
*/
|
||||||
|
public String getShaderLanguage() {
|
||||||
|
return shaderLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new world parameter by the given name.
|
||||||
|
*
|
||||||
|
* @param name The world parameter to add.
|
||||||
|
* @return True if the world parameter name was found and added
|
||||||
|
* to the list of world parameters, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean addWorldParam(String name) {
|
||||||
|
if (worldBinds == null){
|
||||||
|
worldBinds = new ArrayList<UniformBinding>();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
worldBinds.add( UniformBinding.valueOf(name) );
|
||||||
|
return true;
|
||||||
|
} catch (IllegalArgumentException ex){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of world parameters that are used by this
|
||||||
|
* technique definition.
|
||||||
|
*
|
||||||
|
* @return The list of world parameters
|
||||||
|
*/
|
||||||
|
public List<UniformBinding> getWorldBindings() {
|
||||||
|
return worldBinds;
|
||||||
|
}
|
||||||
|
|
||||||
public void write(JmeExporter ex) throws IOException{
|
public void write(JmeExporter ex) throws IOException{
|
||||||
OutputCapsule oc = ex.getCapsule(this);
|
OutputCapsule oc = ex.getCapsule(this);
|
||||||
oc.write(name, "name", null);
|
oc.write(name, "name", null);
|
||||||
@ -118,105 +397,4 @@ public class TechniqueDef implements Savable {
|
|||||||
usesShaders = ic.readBoolean("usesShaders", false);
|
usesShaders = ic.readBoolean("usesShaders", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LightMode getLightMode() {
|
|
||||||
return lightMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLightMode(LightMode lightMode) {
|
|
||||||
this.lightMode = lightMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShadowMode getShadowMode() {
|
|
||||||
return shadowMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShadowMode(ShadowMode shadowMode) {
|
|
||||||
this.shadowMode = shadowMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderState getRenderState() {
|
|
||||||
return renderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRenderState(RenderState renderState) {
|
|
||||||
this.renderState = renderState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUsingShaders(){
|
|
||||||
return usesShaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumSet<Caps> getRequiredCaps() {
|
|
||||||
return requiredCaps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShaderFile(String vert, String frag, String lang){
|
|
||||||
this.vertName = vert;
|
|
||||||
this.fragName = frag;
|
|
||||||
this.shaderLang = lang;
|
|
||||||
|
|
||||||
Caps langCap = Caps.valueOf(lang);
|
|
||||||
requiredCaps.add(langCap);
|
|
||||||
|
|
||||||
usesShaders = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DefineList getShaderPresetDefines() {
|
|
||||||
return presetDefines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShaderParamDefine(String paramName){
|
|
||||||
if (defineParams == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return defineParams.get(paramName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addShaderParamDefine(String paramName, String defineName){
|
|
||||||
if (defineParams == null)
|
|
||||||
defineParams = new HashMap<String, String>();
|
|
||||||
|
|
||||||
defineParams.put(paramName, defineName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addShaderPresetDefine(String defineName, VarType type, Object value){
|
|
||||||
if (presetDefines == null)
|
|
||||||
presetDefines = new DefineList();
|
|
||||||
|
|
||||||
presetDefines.set(defineName, type, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFragName() {
|
|
||||||
return fragName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVertName() {
|
|
||||||
return vertName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getShaderLanguage() {
|
|
||||||
return shaderLang;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean addWorldParam(String name) {
|
|
||||||
if (worldBinds == null){
|
|
||||||
worldBinds = new ArrayList<UniformBinding>();
|
|
||||||
}
|
|
||||||
for (UniformBinding binding : UniformBinding.values()) {
|
|
||||||
if (binding.name().equals(name)) {
|
|
||||||
worldBinds.add(binding);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UniformBinding> getWorldBindings() {
|
|
||||||
return worldBinds;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
The <code>com.jme3.material</code> package contains classes for manipulating
|
The <code>com.jme3.material</code> package contains classes for manipulating
|
||||||
jMonkeyEngine materials.
|
jMonkeyEngine materials.
|
||||||
Materials are applied to {@link com.jme3.scene.Geoemtry geometries} in the
|
Materials are applied to {@link com.jme3.scene.Geometry geometries} in the
|
||||||
scene.
|
scene.
|
||||||
Each geometry has a single material which is used to render that
|
Each geometry has a single material which is used to render that
|
||||||
geometry.
|
geometry.
|
||||||
|
@ -1197,8 +1197,7 @@ public final class Matrix4f implements Savable, Cloneable {
|
|||||||
*
|
*
|
||||||
* @param vec
|
* @param vec
|
||||||
* vec to multiply against.
|
* vec to multiply against.
|
||||||
* @param store
|
*
|
||||||
* a vector to store the result in. created if null is passed.
|
|
||||||
* @return the rotated vector.
|
* @return the rotated vector.
|
||||||
*/
|
*/
|
||||||
public Vector4f multAcross(Vector4f vec) {
|
public Vector4f multAcross(Vector4f vec) {
|
||||||
|
@ -455,7 +455,8 @@ public final class Ray implements Savable, Cloneable, Collidable {
|
|||||||
* <code>getLimit</code> returns the limit or the ray, aka the length.
|
* <code>getLimit</code> returns the limit or the ray, aka the length.
|
||||||
* If the limit is not infinity, then this ray is a line with length <code>
|
* If the limit is not infinity, then this ray is a line with length <code>
|
||||||
* limit</code>.
|
* limit</code>.
|
||||||
* @return
|
*
|
||||||
|
* @return the limit or the ray, aka the length.
|
||||||
*/
|
*/
|
||||||
public float getLimit(){
|
public float getLimit(){
|
||||||
return limit;
|
return limit;
|
||||||
|
@ -277,7 +277,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the curve tension
|
* returns the curve tension
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public float getCurveTension() {
|
public float getCurveTension() {
|
||||||
return curveTension;
|
return curveTension;
|
||||||
@ -297,7 +296,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if the spline cycle
|
* returns true if the spline cycle
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isCycle() {
|
public boolean isCycle() {
|
||||||
return cycle;
|
return cycle;
|
||||||
@ -326,7 +324,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return the total lenght of the spline
|
* return the total lenght of the spline
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public float getTotalLength() {
|
public float getTotalLength() {
|
||||||
return totalLength;
|
return totalLength;
|
||||||
@ -334,7 +331,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* return the type of the spline
|
* return the type of the spline
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public SplineType getType() {
|
public SplineType getType() {
|
||||||
return type;
|
return type;
|
||||||
@ -351,7 +347,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns this spline control points
|
* returns this spline control points
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public List<Vector3f> getControlPoints() {
|
public List<Vector3f> getControlPoints() {
|
||||||
return controlPoints;
|
return controlPoints;
|
||||||
@ -359,7 +354,6 @@ public class Spline implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a list of float representing the segments lenght
|
* returns a list of float representing the segments lenght
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public List<Float> getSegmentsLength() {
|
public List<Float> getSegmentsLength() {
|
||||||
return segmentsLength;
|
return segmentsLength;
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.jme3.math;
|
package com.jme3.math;
|
||||||
|
|
||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
@ -50,15 +49,13 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
private Vector3f pointa = new Vector3f();
|
private Vector3f pointa = new Vector3f();
|
||||||
private Vector3f pointb = new Vector3f();
|
private Vector3f pointb = new Vector3f();
|
||||||
private Vector3f pointc = new Vector3f();
|
private Vector3f pointc = new Vector3f();
|
||||||
|
|
||||||
private transient Vector3f center;
|
private transient Vector3f center;
|
||||||
private transient Vector3f normal;
|
private transient Vector3f normal;
|
||||||
|
|
||||||
private float projection;
|
private float projection;
|
||||||
|
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
public Triangle() {}
|
public Triangle() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor instantiates a new <Code>Triangle</code> object with the
|
* Constructor instantiates a new <Code>Triangle</code> object with the
|
||||||
@ -84,10 +81,14 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
*/
|
*/
|
||||||
public Vector3f get(int i) {
|
public Vector3f get(int i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return pointa;
|
case 0:
|
||||||
case 1: return pointb;
|
return pointa;
|
||||||
case 2: return pointc;
|
case 1:
|
||||||
default: return null;
|
return pointb;
|
||||||
|
case 2:
|
||||||
|
return pointc;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +113,15 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
*/
|
*/
|
||||||
public void set(int i, Vector3f point) {
|
public void set(int i, Vector3f point) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: pointa.set(point); break;
|
case 0:
|
||||||
case 1: pointb.set(point); break;
|
pointa.set(point);
|
||||||
case 2: pointc.set(point); break;
|
break;
|
||||||
|
case 1:
|
||||||
|
pointb.set(point);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pointc.set(point);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,13 +130,18 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
* <code>set</code> sets one of the triangles points to that specified as
|
* <code>set</code> sets one of the triangles points to that specified as
|
||||||
* a parameter.
|
* a parameter.
|
||||||
* @param i the index to place the point.
|
* @param i the index to place the point.
|
||||||
* @param point the point to set.
|
|
||||||
*/
|
*/
|
||||||
public void set(int i, float x, float y, float z) {
|
public void set(int i, float x, float y, float z) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: pointa.set(x,y,z); break;
|
case 0:
|
||||||
case 1: pointb.set(x,y,z); break;
|
pointa.set(x, y, z);
|
||||||
case 2: pointc.set(x,y,z); break;
|
break;
|
||||||
|
case 1:
|
||||||
|
pointb.set(x, y, z);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pointc.set(x, y, z);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +168,11 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void calculateCenter() {
|
public void calculateCenter() {
|
||||||
if (center == null)
|
if (center == null) {
|
||||||
center = new Vector3f(pointa);
|
center = new Vector3f(pointa);
|
||||||
else center.set(pointa);
|
} else {
|
||||||
|
center.set(pointa);
|
||||||
|
}
|
||||||
center.addLocal(pointb).addLocal(pointc).multLocal(FastMath.ONE_THIRD);
|
center.addLocal(pointb).addLocal(pointc).multLocal(FastMath.ONE_THIRD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,9 +181,11 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void calculateNormal() {
|
public void calculateNormal() {
|
||||||
if (normal == null)
|
if (normal == null) {
|
||||||
normal = new Vector3f(pointb);
|
normal = new Vector3f(pointb);
|
||||||
else normal.set(pointb);
|
} else {
|
||||||
|
normal.set(pointb);
|
||||||
|
}
|
||||||
normal.subtractLocal(pointa).crossLocal(pointc.x - pointa.x, pointc.y - pointa.y, pointc.z - pointa.z);
|
normal.subtractLocal(pointa).crossLocal(pointc.x - pointa.x, pointc.y - pointa.y, pointc.z - pointa.z);
|
||||||
normal.normalizeLocal();
|
normal.normalizeLocal();
|
||||||
}
|
}
|
||||||
@ -247,10 +263,11 @@ public class Triangle extends AbstractTriangle implements Savable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3f computeTriangleNormal(Vector3f v1, Vector3f v2, Vector3f v3, Vector3f store) {
|
public static Vector3f computeTriangleNormal(Vector3f v1, Vector3f v2, Vector3f v3, Vector3f store) {
|
||||||
if (store == null)
|
if (store == null) {
|
||||||
store = new Vector3f(v2);
|
store = new Vector3f(v2);
|
||||||
else
|
} else {
|
||||||
store.set(v2);
|
store.set(v2);
|
||||||
|
}
|
||||||
|
|
||||||
store.subtractLocal(v1).crossLocal(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z);
|
store.subtractLocal(v1).crossLocal(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z);
|
||||||
return store.normalizeLocal();
|
return store.normalizeLocal();
|
||||||
|
@ -320,7 +320,8 @@ public final class Vector2f implements Savable, Cloneable {
|
|||||||
* <code>distanceSquared</code> calculates the distance squared between
|
* <code>distanceSquared</code> calculates the distance squared between
|
||||||
* this vector and vector v.
|
* this vector and vector v.
|
||||||
*
|
*
|
||||||
* @param v the second vector to determine the distance squared.
|
* @param otherX The X coordinate of the v vector
|
||||||
|
* @param otherY The Y coordinate of the v vector
|
||||||
* @return the distance squared between the two vectors.
|
* @return the distance squared between the two vectors.
|
||||||
*/
|
*/
|
||||||
public float distanceSquared(float otherX, float otherY) {
|
public float distanceSquared(float otherX, float otherY) {
|
||||||
|
@ -677,7 +677,7 @@ public final class Vector4f implements Savable, Cloneable {
|
|||||||
* the y value to subtract.
|
* the y value to subtract.
|
||||||
* @param subtractZ
|
* @param subtractZ
|
||||||
* the z value to subtract.
|
* the z value to subtract.
|
||||||
* @param subtract@
|
* @param subtractW
|
||||||
* the w value to subtract.
|
* the w value to subtract.
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
|
@ -189,9 +189,10 @@ public abstract class Filter implements Savable {
|
|||||||
public abstract void cleanUpFilter(Renderer r);
|
public abstract void cleanUpFilter(Renderer r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method should return the material used for this filter.
|
* Returns the material used for this filter.
|
||||||
* this method is called every frames
|
* this method is called every frame.
|
||||||
* @return
|
*
|
||||||
|
* @return the material used for this filter.
|
||||||
*/
|
*/
|
||||||
public abstract Material getMaterial();
|
public abstract Material getMaterial();
|
||||||
|
|
||||||
@ -232,16 +233,14 @@ public abstract class Filter implements Savable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this method if you want to load extra properties when the filter is loaded else only basic properties of the filter will be loaded
|
* Override this method if you want to load extra properties when the filter
|
||||||
* This method should always begin by super.read(ex);
|
* is loaded else only basic properties of the filter will be loaded
|
||||||
* @param ex
|
* This method should always begin by super.read(im);
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
InputCapsule ic = im.getCapsule(this);
|
InputCapsule ic = im.getCapsule(this);
|
||||||
name = ic.readString("name", "");
|
name = ic.readString("name", "");
|
||||||
enabled = ic.readBoolean("enabled", true);
|
enabled = ic.readBoolean("enabled", true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -269,8 +268,9 @@ public abstract class Filter implements Savable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this method and retrun true if your Filter need the depth texture
|
* Override this method and return true if your Filter need the depth texture
|
||||||
* @return
|
*
|
||||||
|
* @return true if your Filter need the depth texture
|
||||||
*/
|
*/
|
||||||
public boolean isRequiresDepthTexture() {
|
public boolean isRequiresDepthTexture() {
|
||||||
return false;
|
return false;
|
||||||
@ -278,7 +278,8 @@ public abstract class Filter implements Savable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this method and return false if your Filter does not need the scene texture
|
* Override this method and return false if your Filter does not need the scene texture
|
||||||
* @return
|
*
|
||||||
|
* @return false if your Filter does not need the scene texture
|
||||||
*/
|
*/
|
||||||
public boolean isRequiresSceneTexture() {
|
public boolean isRequiresSceneTexture() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -599,7 +599,6 @@ public class Camera implements Savable, Cloneable {
|
|||||||
* <code>setLocation</code> sets the position of the camera.
|
* <code>setLocation</code> sets the position of the camera.
|
||||||
*
|
*
|
||||||
* @param location the position of the camera.
|
* @param location the position of the camera.
|
||||||
* @see Camera#setLocation(com.jme.math.Vector3f)
|
|
||||||
*/
|
*/
|
||||||
public void setLocation(Vector3f location) {
|
public void setLocation(Vector3f location) {
|
||||||
this.location.set(location);
|
this.location.set(location);
|
||||||
@ -660,7 +659,8 @@ public class Camera implements Savable, Cloneable {
|
|||||||
* @param left the left axis of the camera.
|
* @param left the left axis of the camera.
|
||||||
* @param up the up axis of the camera.
|
* @param up the up axis of the camera.
|
||||||
* @param direction the direction the camera is facing.
|
* @param direction the direction the camera is facing.
|
||||||
* @see Camera#setAxes(com.jme.math.Vector3f,com.jme.math.Vector3f,com.jme.math.Vector3f)
|
*
|
||||||
|
* @see Camera#setAxes(com.jme3.math.Quaternion)
|
||||||
*/
|
*/
|
||||||
public void setAxes(Vector3f left, Vector3f up, Vector3f direction) {
|
public void setAxes(Vector3f left, Vector3f up, Vector3f direction) {
|
||||||
this.rotation.fromAxes(left, up, direction);
|
this.rotation.fromAxes(left, up, direction);
|
||||||
|
@ -154,9 +154,8 @@ public abstract class GLObject implements Cloneable {
|
|||||||
/**
|
/**
|
||||||
* This should create a deep clone. For a shallow clone, use
|
* This should create a deep clone. For a shallow clone, use
|
||||||
* createDestructableClone().
|
* createDestructableClone().
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected GLObject clone(){
|
protected GLObject clone(){
|
||||||
try{
|
try{
|
||||||
GLObject obj = (GLObject) super.clone();
|
GLObject obj = (GLObject) super.clone();
|
||||||
|
@ -181,9 +181,6 @@ public class RenderManager {
|
|||||||
/**
|
/**
|
||||||
* Creates a new viewport, to display the given camera's content.
|
* Creates a new viewport, to display the given camera's content.
|
||||||
* The view will be processed before the primary viewport.
|
* The view will be processed before the primary viewport.
|
||||||
* @param viewName
|
|
||||||
* @param cam
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public ViewPort createPreView(String viewName, Camera cam) {
|
public ViewPort createPreView(String viewName, Camera cam) {
|
||||||
ViewPort vp = new ViewPort(viewName, cam);
|
ViewPort vp = new ViewPort(viewName, cam);
|
||||||
@ -491,9 +488,6 @@ public class RenderManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Render scene graph
|
* Render scene graph
|
||||||
* @param s
|
|
||||||
* @param r
|
|
||||||
* @param cam
|
|
||||||
*/
|
*/
|
||||||
public void renderScene(Spatial scene, ViewPort vp) {
|
public void renderScene(Spatial scene, ViewPort vp) {
|
||||||
if (scene.getParent() == null) {
|
if (scene.getParent() == null) {
|
||||||
|
@ -99,7 +99,7 @@ public interface Renderer {
|
|||||||
public void onFrame();
|
public void onFrame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param transform The world transform to use. This changes
|
* @param worldMatrix The world transform to use. This changes
|
||||||
* the world matrix given in the shader.
|
* the world matrix given in the shader.
|
||||||
*/
|
*/
|
||||||
public void setWorldMatrix(Matrix4f worldMatrix);
|
public void setWorldMatrix(Matrix4f worldMatrix);
|
||||||
@ -171,7 +171,6 @@ public interface Renderer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a texture from the GPU.
|
* Deletes a texture from the GPU.
|
||||||
* @param tex
|
|
||||||
*/
|
*/
|
||||||
public void deleteImage(Image image);
|
public void deleteImage(Image image);
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ public class GeometryList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a spatial to the list. List size is doubled if there is no room.
|
* Adds a geometry to the list. List size is doubled if there is no room.
|
||||||
*
|
*
|
||||||
* @param s
|
* @param g
|
||||||
* The spatial to add.
|
* The geometry to add.
|
||||||
*/
|
*/
|
||||||
public void add(Geometry g) {
|
public void add(Geometry g) {
|
||||||
if (size == geometries.length) {
|
if (size == geometries.length) {
|
||||||
|
@ -177,7 +177,7 @@ public class Geometry extends Spatial {
|
|||||||
* this geometry. The location of the geometry is based on the location of
|
* this geometry. The location of the geometry is based on the location of
|
||||||
* all this node's parents.
|
* all this node's parents.
|
||||||
*
|
*
|
||||||
* @see com.jme.scene.Spatial#updateWorldBound()
|
* @see Spatial#updateWorldBound()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void updateWorldBound() {
|
protected void updateWorldBound() {
|
||||||
@ -282,7 +282,6 @@ public class Geometry extends Spatial {
|
|||||||
* Exception: if the mesh is marked as being a software
|
* Exception: if the mesh is marked as being a software
|
||||||
* animated mesh, (bind pose is set) then the positions
|
* animated mesh, (bind pose is set) then the positions
|
||||||
* and normals are deep copied.
|
* and normals are deep copied.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Geometry clone(boolean cloneMaterial){
|
public Geometry clone(boolean cloneMaterial){
|
||||||
@ -308,8 +307,8 @@ public class Geometry extends Spatial {
|
|||||||
* Exception: if the mesh is marked as being a software
|
* Exception: if the mesh is marked as being a software
|
||||||
* animated mesh, (bind pose is set) then the positions
|
* animated mesh, (bind pose is set) then the positions
|
||||||
* and normals are deep copied.
|
* and normals are deep copied.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Geometry clone(){
|
public Geometry clone(){
|
||||||
return clone(true);
|
return clone(true);
|
||||||
}
|
}
|
||||||
@ -318,7 +317,6 @@ public class Geometry extends Spatial {
|
|||||||
* Creates a deep clone of the geometry,
|
* Creates a deep clone of the geometry,
|
||||||
* this creates an identical copy of the mesh
|
* this creates an identical copy of the mesh
|
||||||
* with the vertexbuffer data duplicated.
|
* with the vertexbuffer data duplicated.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Spatial deepClone(){
|
public Spatial deepClone(){
|
||||||
|
@ -526,7 +526,7 @@ public class Node extends Spatial implements Savable {
|
|||||||
* @return Non-null, but possibly 0-element, list of matching Spatials (also Instances extending Spatials).
|
* @return Non-null, but possibly 0-element, list of matching Spatials (also Instances extending Spatials).
|
||||||
*
|
*
|
||||||
* @see java.util.regex.Pattern
|
* @see java.util.regex.Pattern
|
||||||
* @see Spatial#matches(Class<? extends Spatial>, String)
|
* @see Spatial#matches(java.lang.Class, java.lang.String)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Spatial>List<T> descendantMatches(
|
public <T extends Spatial>List<T> descendantMatches(
|
||||||
@ -546,7 +546,7 @@ public class Node extends Spatial implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Convenience wrapper.
|
* Convenience wrapper.
|
||||||
*
|
*
|
||||||
* @see #descendantMatches(Class<? extends Spatial>, String)
|
* @see #descendantMatches(java.lang.Class, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public <T extends Spatial>List<T> descendantMatches(
|
public <T extends Spatial>List<T> descendantMatches(
|
||||||
Class<T> spatialSubclass) {
|
Class<T> spatialSubclass) {
|
||||||
@ -556,7 +556,7 @@ public class Node extends Spatial implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Convenience wrapper.
|
* Convenience wrapper.
|
||||||
*
|
*
|
||||||
* @see #descendantMatches(Class<? extends Spatial>, String)
|
* @see #descendantMatches(java.lang.Class, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public <T extends Spatial>List<T> descendantMatches(String nameRegex) {
|
public <T extends Spatial>List<T> descendantMatches(String nameRegex) {
|
||||||
return descendantMatches(null, nameRegex);
|
return descendantMatches(null, nameRegex);
|
||||||
|
@ -784,9 +784,6 @@ public abstract class Spatial implements Savable, Cloneable, Collidable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>setLocalScale</code> sets the local scale of this node.
|
* <code>setLocalScale</code> sets the local scale of this node.
|
||||||
*
|
|
||||||
* @param localScale
|
|
||||||
* the new local scale
|
|
||||||
*/
|
*/
|
||||||
public void setLocalScale(float x, float y, float z) {
|
public void setLocalScale(float x, float y, float z) {
|
||||||
localTransform.setScale(x, y, z);
|
localTransform.setScale(x, y, z);
|
||||||
|
@ -664,11 +664,6 @@ public class VertexBuffer extends GLObject implements Savable, Cloneable {
|
|||||||
* of the parameters. The buffer will be of the type specified by
|
* of the parameters. The buffer will be of the type specified by
|
||||||
* {@link Format format} and would be able to contain the given number
|
* {@link Format format} and would be able to contain the given number
|
||||||
* of elements with the given number of components in each element.
|
* of elements with the given number of components in each element.
|
||||||
*
|
|
||||||
* @param format
|
|
||||||
* @param components
|
|
||||||
* @param numElements
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static Buffer createBuffer(Format format, int components, int numElements){
|
public static Buffer createBuffer(Format format, int components, int numElements){
|
||||||
if (components < 1 || components > 4)
|
if (components < 1 || components > 4)
|
||||||
|
@ -48,7 +48,7 @@ public interface Control extends Savable {
|
|||||||
* Creates a clone of the Control, the given Spatial is the cloned
|
* Creates a clone of the Control, the given Spatial is the cloned
|
||||||
* version of the spatial to which this control is attached to.
|
* version of the spatial to which this control is attached to.
|
||||||
* @param spatial
|
* @param spatial
|
||||||
* @return
|
* @return A clone of this control for the spatial
|
||||||
*/
|
*/
|
||||||
public Control cloneForSpatial(Spatial spatial);
|
public Control cloneForSpatial(Spatial spatial);
|
||||||
|
|
||||||
|
@ -76,14 +76,14 @@ public class LightControl extends AbstractControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param camera The Camera to be synced.
|
* @param light The light to be synced.
|
||||||
*/
|
*/
|
||||||
public LightControl(Light light) {
|
public LightControl(Light light) {
|
||||||
this.light = light;
|
this.light = light;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param camera The Camera to be synced.
|
* @param light The light to be synced.
|
||||||
*/
|
*/
|
||||||
public LightControl(Light light, ControlDirection controlDir) {
|
public LightControl(Light light, ControlDirection controlDir) {
|
||||||
this.light = light;
|
this.light = light;
|
||||||
|
@ -380,7 +380,6 @@ public final class Shader extends GLObject implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Returns true if this program and all it's shaders have been compiled,
|
* Returns true if this program and all it's shaders have been compiled,
|
||||||
* linked and validated successfuly.
|
* linked and validated successfuly.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isUsable(){
|
public boolean isUsable(){
|
||||||
return usable;
|
return usable;
|
||||||
@ -417,7 +416,6 @@ public final class Shader extends GLObject implements Savable {
|
|||||||
/**
|
/**
|
||||||
* Called by the object manager to reset all object IDs. This causes
|
* Called by the object manager to reset all object IDs. This causes
|
||||||
* the shader to be reuploaded to the GPU incase the display was restarted.
|
* the shader to be reuploaded to the GPU incase the display was restarted.
|
||||||
* @param r
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void resetObject() {
|
public void resetObject() {
|
||||||
|
@ -37,6 +37,7 @@ 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.renderer.Renderer;
|
import com.jme3.renderer.Renderer;
|
||||||
|
import com.jme3.system.JmeCanvasContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a rendering context within the engine.
|
* Represents a rendering context within the engine.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user