use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class SceneLoader method loadConnections.
private void loadConnections(FbxElement element) {
for (FbxElement e : element.children) {
if (e.id.equals("C")) {
String type = (String) e.properties.get(0);
long objId, refId;
FbxObject obj, ref;
switch(type) {
case "OO":
objId = (Long) e.properties.get(1);
refId = (Long) e.properties.get(2);
obj = allObjects.get(objId);
ref = allObjects.get(refId);
if (ref != null) {
ref.link(obj);
} else if (refId == 0) {
obj.linkToZero();
}
break;
case "OP":
objId = (Long) e.properties.get(1);
refId = (Long) e.properties.get(2);
String propName = (String) e.properties.get(3);
obj = allObjects.get(objId);
ref = allObjects.get(refId);
if (ref != null)
ref.link(obj, propName);
break;
}
}
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class SceneLoader method parseLight.
private void parseLight(Attributes attribs) throws SAXException {
if (node == null || node.getParent() == null) {
throw new SAXException("dotScene parse error: light can only appear under a node");
}
checkTopNode("node");
String lightType = parseString(attribs.getValue("type"), "point");
if (lightType.equals("point")) {
light = new PointLight();
} else if (lightType.equals("directional") || lightType.equals("sun")) {
light = new DirectionalLight();
// Assuming "normal" property is not provided
((DirectionalLight) light).setDirection(Vector3f.UNIT_Z);
} else if (lightType.equals("spotLight") || lightType.equals("spot")) {
light = new SpotLight();
} else if (lightType.equals("omni")) {
// XXX: It doesn't seem any exporters actually emit this type?
light = new AmbientLight();
} else {
logger.log(Level.WARNING, "No matching jME3 LightType found for OGRE LightType: {0}", lightType);
}
logger.log(Level.FINEST, "{0} created.", light);
if (!parseBool(attribs.getValue("visible"), true)) {
// set to disabled
}
// "attach" it to the parent of this node
if (light != null) {
node.getParent().addLight(light);
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class MaterialLoader method readTextureImage.
private void readTextureImage(String content) {
// texture image def
String path = null;
// find extension
int extStart = content.lastIndexOf(".");
for (int i = extStart; i < content.length(); i++) {
char c = content.charAt(i);
if (Character.isWhitespace(c)) {
// extension ends here
path = content.substring(0, i).trim();
content = content.substring(i + 1).trim();
break;
}
}
if (path == null) {
path = content.trim();
content = "";
}
Scanner lnScan = new Scanner(content);
String mips = null;
String type = null;
if (lnScan.hasNext()) {
// more params
type = lnScan.next();
// if (!lnScan.hasNext("\n") && lnScan.hasNext()){
// mips = lnScan.next();
// if (lnScan.hasNext()){
// even more params..
// will have to ignore
// }
// }
}
boolean genMips = true;
boolean cubic = false;
if (type != null && type.equals("0"))
genMips = false;
if (type != null && type.equals("cubic")) {
cubic = true;
}
TextureKey texKey = new TextureKey(folderName + path, false);
texKey.setGenerateMips(genMips);
if (cubic) {
texKey.setTextureTypeHint(Texture.Type.CubeMap);
}
try {
Texture loadedTexture = assetManager.loadTexture(texKey);
textures[texUnit].setImage(loadedTexture.getImage());
textures[texUnit].setMinFilter(loadedTexture.getMinFilter());
textures[texUnit].setMagFilter(loadedTexture.getMagFilter());
textures[texUnit].setAnisotropicFilter(loadedTexture.getAnisotropicFilter());
textures[texUnit].setKey(loadedTexture.getKey());
// XXX: Is this really neccessary?
textures[texUnit].setWrap(WrapMode.Repeat);
if (texName != null) {
textures[texUnit].setName(texName);
texName = null;
} else {
textures[texUnit].setName(texKey.getName());
}
} catch (AssetNotFoundException ex) {
logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[] { texKey, matName });
textures[texUnit].setImage(PlaceholderAssets.getPlaceholderImage(assetManager));
textures[texUnit].setKey(texKey);
}
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class MeshLoader method pushTexCoord.
private void pushTexCoord(Attributes attribs) throws SAXException {
if (texCoordIndex >= 8) {
// More than 8 not supported by ogre.
return;
}
Type type = TEXCOORD_TYPES[texCoordIndex];
VertexBuffer tcvb = mesh.getBuffer(type);
FloatBuffer buf = (FloatBuffer) tcvb.getData();
buf.put(parseFloat(attribs.getValue("u")));
if (tcvb.getNumComponents() >= 2) {
buf.put(parseFloat(attribs.getValue("v")));
if (tcvb.getNumComponents() >= 3) {
buf.put(parseFloat(attribs.getValue("w")));
if (tcvb.getNumComponents() == 4) {
buf.put(parseFloat(attribs.getValue("x")));
}
}
}
texCoordIndex++;
}
use of com.jme3.effect.ParticleMesh.Type in project jmonkeyengine by jMonkeyEngine.
the class J3MOutputCapsule method formatMatParam.
private String formatMatParam(MatParam param) {
VarType type = param.getVarType();
Object val = param.getValue();
switch(type) {
case Boolean:
case Float:
case Int:
return val.toString();
case Vector2:
Vector2f v2 = (Vector2f) val;
return v2.getX() + " " + v2.getY();
case Vector3:
Vector3f v3 = (Vector3f) val;
return v3.getX() + " " + v3.getY() + " " + v3.getZ();
case Vector4:
// can be either ColorRGBA, Vector4f or Quaternion
if (val instanceof Vector4f) {
Vector4f v4 = (Vector4f) val;
return v4.getX() + " " + v4.getY() + " " + v4.getZ() + " " + v4.getW();
} else if (val instanceof ColorRGBA) {
ColorRGBA color = (ColorRGBA) val;
return color.getRed() + " " + color.getGreen() + " " + color.getBlue() + " " + color.getAlpha();
} else if (val instanceof Quaternion) {
Quaternion quat = (Quaternion) val;
return quat.getX() + " " + quat.getY() + " " + quat.getZ() + " " + quat.getW();
} else {
throw new UnsupportedOperationException("Unexpected Vector4 type: " + val);
}
default:
// parameter type not supported in J3M
return null;
}
}
Aggregations