use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class Spatial method deepClone.
/**
* @return Similar to Spatial.clone() except will create a deep clone of all
* geometries' meshes. Normally this method shouldn't be used. Instead, use
* Spatial.clone()
*
* @see Spatial#clone()
*/
public Spatial deepClone() {
// Setup the cloner for the type of cloning we want to do.
Cloner cloner = new Cloner();
// First, we definitely do not want to clone our own parent
cloner.setClonedValue(parent, null);
Spatial clone = cloner.clone(this);
// Because we've nulled the parent out we need to make sure
// the transforms and stuff get refreshed.
clone.setTransformRefresh();
clone.setLightListRefresh();
clone.setMatParamOverrideRefresh();
return clone;
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class VertexBuffer method clone.
/**
* Creates a deep clone of this VertexBuffer but overrides the
* {@link Type}.
*
* @param overrideType The type of the cloned VertexBuffer
* @return A deep clone of the buffer
*/
public VertexBuffer clone(Type overrideType) {
VertexBuffer vb = new VertexBuffer(overrideType);
vb.components = components;
vb.componentsLength = componentsLength;
// Make sure to pass a read-only buffer to clone so that
// the position information doesn't get clobbered by another
// reading thread during cloning (and vice versa) since this is
// a purely read-only operation.
vb.data = BufferUtils.clone(getDataReadOnly());
vb.format = format;
vb.handleRef = new Object();
vb.id = -1;
vb.normalized = normalized;
vb.instanceSpan = instanceSpan;
vb.offset = offset;
vb.stride = stride;
vb.updateNeeded = true;
vb.usage = usage;
return vb;
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class GLRenderer method setupTextureParams.
@SuppressWarnings("fallthrough")
private void setupTextureParams(int unit, Texture tex) {
Image image = tex.getImage();
int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1);
boolean haveMips = true;
if (image != null) {
haveMips = image.isGeneratedMipmapsRequired() || image.hasMipmaps();
}
LastTextureState curState = image.getLastTextureState();
if (curState.magFilter != tex.getMagFilter()) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, convertMagFilter(tex.getMagFilter()));
curState.magFilter = tex.getMagFilter();
}
if (curState.minFilter != tex.getMinFilter()) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, convertMinFilter(tex.getMinFilter(), haveMips));
curState.minFilter = tex.getMinFilter();
}
int desiredAnisoFilter = tex.getAnisotropicFilter() == 0 ? defaultAnisotropicFilter : tex.getAnisotropicFilter();
if (caps.contains(Caps.TextureFilterAnisotropic) && curState.anisoFilter != desiredAnisoFilter) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameterf(target, GLExt.GL_TEXTURE_MAX_ANISOTROPY_EXT, desiredAnisoFilter);
curState.anisoFilter = desiredAnisoFilter;
}
switch(tex.getType()) {
case ThreeDimensional:
case // cubemaps use 3D coords
CubeMap:
if (gl2 != null && curState.rWrap != tex.getWrap(WrapAxis.R)) {
bindTextureAndUnit(target, image, unit);
gl2.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
curState.rWrap = tex.getWrap(WrapAxis.R);
}
//There is no break statement on purpose here
case TwoDimensional:
case TwoDimensionalArray:
if (curState.tWrap != tex.getWrap(WrapAxis.T)) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T)));
image.getLastTextureState().tWrap = tex.getWrap(WrapAxis.T);
}
if (curState.sWrap != tex.getWrap(WrapAxis.S)) {
bindTextureAndUnit(target, image, unit);
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S)));
curState.sWrap = tex.getWrap(WrapAxis.S);
}
break;
default:
throw new UnsupportedOperationException("Unknown texture type: " + tex.getType());
}
ShadowCompareMode texCompareMode = tex.getShadowCompareMode();
if (gl2 != null && curState.shadowCompareMode != texCompareMode) {
bindTextureAndUnit(target, image, unit);
if (texCompareMode != ShadowCompareMode.Off) {
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL2.GL_COMPARE_REF_TO_TEXTURE);
if (texCompareMode == ShadowCompareMode.GreaterOrEqual) {
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_GEQUAL);
} else {
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_FUNC, GL.GL_LEQUAL);
}
} else {
gl2.glTexParameteri(target, GL2.GL_TEXTURE_COMPARE_MODE, GL.GL_NONE);
}
curState.shadowCompareMode = texCompareMode;
}
// If at this point we didn't bind the texture, bind it now
bindTextureOnly(target, image, unit);
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class WAVLoader method load.
private AudioData load(AssetInfo info, InputStream inputStream, boolean stream) throws IOException {
this.in = new ResettableInputStream(info, inputStream);
inOffset = 0;
int sig = in.readInt();
if (sig != i_RIFF)
throw new IOException("File is not a WAVE file");
// skip size
in.readInt();
if (in.readInt() != i_WAVE)
throw new IOException("WAVE File does not contain audio");
inOffset += 4 * 3;
readStream = stream;
if (readStream) {
audioStream = new AudioStream();
audioData = audioStream;
} else {
audioBuffer = new AudioBuffer();
audioData = audioBuffer;
}
while (true) {
int type = in.readInt();
int len = in.readInt();
inOffset += 4 * 2;
switch(type) {
case i_fmt:
readFormatChunk(len);
inOffset += len;
break;
case i_data:
// Compute duration based on data chunk size
duration = (float) (len / bytesPerSec);
if (readStream) {
readDataChunkForStream(inOffset, len);
} else {
readDataChunkForBuffer(len);
}
return audioData;
default:
int skipped = in.skipBytes(len);
if (skipped <= 0) {
return null;
}
inOffset += skipped;
break;
}
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class J3MLoader method readParam.
// <TYPE> <NAME> [ "(" <FFBINDING> ")" ] [-LINEAR] [ ":" <DEFAULTVAL> ]
private void readParam(String statement) throws IOException {
String name;
String defaultVal = null;
ColorSpace colorSpace = null;
String[] split = statement.split(":");
// Parse default val
if (split.length == 1) {
// Doesn't contain default value
} else {
if (split.length != 2) {
throw new IOException("Parameter statement syntax incorrect");
}
statement = split[0].trim();
defaultVal = split[1].trim();
}
if (statement.endsWith("-LINEAR")) {
colorSpace = ColorSpace.Linear;
statement = statement.substring(0, statement.length() - "-LINEAR".length());
}
// Parse ffbinding
int startParen = statement.indexOf("(");
if (startParen != -1) {
// get content inside parentheses
int endParen = statement.indexOf(")", startParen);
String bindingStr = statement.substring(startParen + 1, endParen).trim();
// don't care about bindingStr
statement = statement.substring(0, startParen);
}
// Parse type + name
split = statement.split(whitespacePattern);
if (split.length != 2) {
throw new IOException("Parameter statement syntax incorrect");
}
VarType type;
if (split[0].equals("Color")) {
type = VarType.Vector4;
} else {
type = VarType.valueOf(split[0]);
}
name = split[1];
Object defaultValObj = null;
if (defaultVal != null) {
defaultValObj = readValue(type, defaultVal);
}
if (type.isTextureType()) {
materialDef.addMaterialParamTexture(type, name, colorSpace);
} else {
materialDef.addMaterialParam(type, name, defaultValObj);
}
}
Aggregations