* Applied abies fix to Sky rotation

* Blender importer now puts transparent materials in the transparent queue bucket
 * Blender importer creates RGBA8 textures as a result of blending
 * Blender importer - all textures are now mipmapped by default 
 * Lighting shader now supports lightmap
 * Fixed GLSL 1.5 warnings
 * Ogre3D materials now use glow color as emissive color 
 * MaterialLoader will now only load first texture unit instead of last
 * All XML loaders are now namespace aware by default so that android can properly load XML

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7792 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent ef6b7157b9
commit f41584e966
  1. 12
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MaterialHelper.java
  2. 4
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/MeshHelper.java
  3. 9
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java
  4. 4
      engine/src/core-data/Common/MatDefs/Blur/RadialBlur15.frag
  5. 18
      engine/src/core-data/Common/MatDefs/Light/Lighting.frag
  6. 8
      engine/src/core-data/Common/MatDefs/Light/Lighting.j3md
  7. 7
      engine/src/core-data/Common/MatDefs/Light/Lighting.vert
  8. 5
      engine/src/core-data/Common/MatDefs/Misc/Sky.frag
  9. 2
      engine/src/core-data/Common/MatDefs/Misc/Sky.j3md
  10. 4
      engine/src/core-data/Common/MatDefs/Misc/Sky.vert
  11. 9
      engine/src/core-data/Common/MatDefs/Post/bloomExtract15.frag
  12. 2
      engine/src/core-data/Common/MatDefs/SSAO/ssao15.frag
  13. 2
      engine/src/core-data/Common/MatDefs/SSAO/ssaoBlur15.frag
  14. 19
      engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM.vert
  15. 2
      engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM15.frag
  16. 62
      engine/src/core/com/jme3/animation/BoneAnimation.java
  17. 4
      engine/src/core/com/jme3/shader/plugins/GLSLLoader.java
  18. 48
      engine/src/ogre/com/jme3/scene/plugins/ogre/MaterialLoader.java
  19. 21
      engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java
  20. 14
      engine/src/ogre/com/jme3/scene/plugins/ogre/SceneLoader.java
  21. 16
      engine/src/ogre/com/jme3/scene/plugins/ogre/SkeletonLoader.java

@ -58,6 +58,7 @@ import com.jme3.shader.VarType;
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Image.Format; import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.Texture.WrapMode; import com.jme3.texture.Texture.WrapMode;
import com.jme3.util.BufferUtils; import com.jme3.util.BufferUtils;
@ -199,6 +200,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
result.getAdditionalRenderState().setFaceCullMode(faceCullMode); result.getAdditionalRenderState().setFaceCullMode(faceCullMode);
if (transparent) { if (transparent) {
result.setTransparent(true);
result.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); result.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
} }
@ -249,9 +251,16 @@ public class MaterialHelper extends AbstractBlenderHelper {
Pointer pTex = (Pointer) textureLink.getFieldValue("tex"); Pointer pTex = (Pointer) textureLink.getFieldValue("tex");
Structure tex = pTex.fetchData(dataRepository.getInputStream()).get(0); Structure tex = pTex.fetchData(dataRepository.getInputStream()).get(0);
Texture texture = textureHelper.getTexture(tex, dataRepository); Texture texture = textureHelper.getTexture(tex, dataRepository);
// NOTE: Enable mipmaps FOR ALL TEXTURES EVER
texture.setMinFilter(MinFilter.Trilinear);
if (texture != null) { if (texture != null) {
if ((mapto & 0x01) != 0) {// Col if ((mapto & 0x01) != 0) {// Col
result.setBoolean("UseMaterialColors", Boolean.FALSE); // Map to COLOR channel or DIFFUSE
// Set diffuse to white so it doesn't get multiplied by texture
result.setColor("Diffuse", ColorRGBA.White);
//result.setBoolean("UseMaterialColors", Boolean.FALSE);
// blending the texture with material color and texture's defined color // blending the texture with material color and texture's defined color
int blendType = ((Number) textureLink.getFieldValue("blendtype")).intValue(); int blendType = ((Number) textureLink.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureLink.getFieldValue("r")).floatValue(), ((Number) textureLink.getFieldValue("g")).floatValue(), ((Number) textureLink.getFieldValue("b")).floatValue() }; float[] color = new float[] { ((Number) textureLink.getFieldValue("r")).floatValue(), ((Number) textureLink.getFieldValue("g")).floatValue(), ((Number) textureLink.getFieldValue("b")).floatValue() };
@ -271,6 +280,7 @@ public class MaterialHelper extends AbstractBlenderHelper {
} }
} }
if ((mapto & 0x04) != 0) {// Spec if ((mapto & 0x04) != 0) {// Spec
// Map to SPECULAR
result.setTexture(TEXTURE_TYPE_SPECULAR, texture); result.setTexture(TEXTURE_TYPE_SPECULAR, texture);
} }
if ((mapto & 0x40) != 0) {// Emit if ((mapto & 0x40) != 0) {// Emit

@ -45,6 +45,7 @@ import com.jme3.material.Material;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
@ -365,6 +366,9 @@ public class MeshHelper extends AbstractBlenderHelper {
material = nonTexturedMaterials[materialNumber]; material = nonTexturedMaterials[materialNumber];
} }
geometry.setMaterial(material); geometry.setMaterial(material);
if (material.isTransparent()){
geometry.setQueueBucket(Bucket.Transparent);
}
} else { } else {
geometry.setMaterial(dataRepository.getDefaultMaterial()); geometry.setMaterial(dataRepository.getDefaultMaterial());
} }

@ -1033,9 +1033,9 @@ public class TextureHelper extends AbstractBlenderHelper {
data.rewind(); data.rewind();
int width = texture.getImage().getWidth(); int width = texture.getImage().getWidth();
int height = texture.getImage().getHeight(); int height = texture.getImage().getHeight();
ByteBuffer newData = BufferUtils.createByteBuffer(width * height * 3); ByteBuffer newData = BufferUtils.createByteBuffer(width * height * 4);
float[] resultPixel = new float[3]; float[] resultPixel = new float[4];
int dataIndex = 0; int dataIndex = 0;
while (data.hasRemaining()) { while (data.hasRemaining()) {
float tin = this.setupMaterialColor(data, format, neg, materialColorClone); float tin = this.setupMaterialColor(data, format, neg, materialColorClone);
@ -1043,8 +1043,9 @@ public class TextureHelper extends AbstractBlenderHelper {
newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f));
newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f));
newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f));
newData.put(dataIndex++, (byte) (1.0 * 255.0f));
} }
return new Texture2D(new Image(Format.RGB8, width, height, newData)); return new Texture2D(new Image(Format.RGBA8, width, height, newData));
} }
/** /**
@ -1144,7 +1145,7 @@ public class TextureHelper extends AbstractBlenderHelper {
case RGBA16: case RGBA16:
case RGBA16F: case RGBA16F:
case RGBA32F: case RGBA32F:
LOGGER.warning("Image type not yet supported for blending: " + imageFormat); LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}", imageFormat);
break; break;
default: default:
throw new IllegalStateException("Unknown image format type: " + imageFormat); throw new IllegalStateException("Unknown image format type: " + imageFormat);

@ -4,7 +4,9 @@ uniform COLORTEXTURE m_Texture;
uniform float m_SampleDist; uniform float m_SampleDist;
uniform float m_SampleStrength; uniform float m_SampleStrength;
uniform float m_Samples[10]; uniform float m_Samples[10];
in vec2 texCoord; in vec2 texCoord;
out vec4 outFragColor;
void main(void) void main(void)
{ {
@ -43,6 +45,6 @@ void main(void)
t = clamp( t ,0.0,1.0); //0 <= t <= 1 t = clamp( t ,0.0,1.0); //0 <= t <= 1
//Blend the original color with the averaged pixels //Blend the original color with the averaged pixels
gl_FragColor =mix( colorRes, sum, t ); outFragColor =mix( colorRes, sum, t );
} }

@ -3,6 +3,9 @@
//#define HQ_ATTENUATION //#define HQ_ATTENUATION
varying vec2 texCoord; varying vec2 texCoord;
#ifdef SEPARATE_TEXCOORD
varying vec2 texCoord2;
#endif
varying vec4 AmbientSum; varying vec4 AmbientSum;
varying vec4 DiffuseSum; varying vec4 DiffuseSum;
@ -25,6 +28,10 @@ varying vec4 SpecularSum;
#ifdef PARALLAXMAP #ifdef PARALLAXMAP
uniform sampler2D m_ParallaxMap; uniform sampler2D m_ParallaxMap;
#endif #endif
#ifdef LIGHTMAP
uniform sampler2D m_LightMap;
#endif
#ifdef NORMALMAP #ifdef NORMALMAP
uniform sampler2D m_NormalMap; uniform sampler2D m_NormalMap;
@ -170,6 +177,17 @@ void main(){
vec4 specularColor = vec4(1.0); vec4 specularColor = vec4(1.0);
#endif #endif
#ifdef LIGHTMAP
vec3 lightMapColor;
#ifdef SEPARATE_TEXCOORD
lightMapColor = texture2D(m_LightMap, texCoord2).rgb;
#else
lightMapColor = texture2D(m_LightMap, texCoord).rgb;
#endif
specularColor.rgb *= lightMapColor;
diffuseColor.rgb *= lightMapColor;
#endif
#ifdef VERTEX_LIGHTING #ifdef VERTEX_LIGHTING
vec2 light = vec2(AmbientSum.a, SpecularSum.a); vec2 light = vec2(AmbientSum.a, SpecularSum.a);
#ifdef COLORRAMP #ifdef COLORRAMP

@ -70,6 +70,12 @@ MaterialDef Phong Lighting {
// Texture of the glowing parts of the material // Texture of the glowing parts of the material
Texture2D GlowMap Texture2D GlowMap
// Set to Use Lightmap
Texture2D LightMap
// Set to use TexCoord2 for the lightmap sampling
Boolean SeparateTexCoord
// The glow color of the object // The glow color of the object
Color GlowColor Color GlowColor
@ -120,6 +126,8 @@ MaterialDef Phong Lighting {
PARALLAXMAP : ParallaxMap PARALLAXMAP : ParallaxMap
ALPHAMAP : AlphaMap ALPHAMAP : AlphaMap
COLORRAMP : ColorRamp COLORRAMP : ColorRamp
LIGHTMAP : LightMap
SEPARATE_TEXCOORD : SeparateTexCoord
USE_REFLECTION : EnvMap USE_REFLECTION : EnvMap
SPHERE_MAP : SphereMap SPHERE_MAP : SphereMap

@ -16,6 +16,10 @@ uniform vec4 g_LightPosition;
uniform vec4 g_AmbientLightColor; uniform vec4 g_AmbientLightColor;
varying vec2 texCoord; varying vec2 texCoord;
#ifdef SEPARATE_TEXCOORD
varying vec2 texCoord2;
attribute vec2 inTexCoord2;
#endif
varying vec4 AmbientSum; varying vec4 AmbientSum;
varying vec4 DiffuseSum; varying vec4 DiffuseSum;
@ -118,6 +122,9 @@ void main(){
vec4 pos = vec4(inPosition, 1.0); vec4 pos = vec4(inPosition, 1.0);
gl_Position = g_WorldViewProjectionMatrix * pos; gl_Position = g_WorldViewProjectionMatrix * pos;
texCoord = inTexCoord; texCoord = inTexCoord;
#ifdef SEPARATE_TEXCOORD
texCoord2 = inTexCoord2;
#endif
vec3 wvPosition = (g_WorldViewMatrix * pos).xyz; vec3 wvPosition = (g_WorldViewMatrix * pos).xyz;
vec3 wvNormal = normalize(g_NormalMatrix * inNormal); vec3 wvNormal = normalize(g_NormalMatrix * inNormal);

@ -5,12 +5,7 @@ uniform ENVMAP m_Texture;
varying vec3 direction; varying vec3 direction;
void main() { void main() {
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
//gl_FragDepth = 1.0;
vec3 dir = normalize(direction); vec3 dir = normalize(direction);
gl_FragColor = Optics_GetEnvColor(m_Texture, direction); gl_FragColor = Optics_GetEnvColor(m_Texture, direction);
//gl_FragColor = vec4(textureCube(m_Texture, dir).xyz, 1.0);
//gl_FragColor = vec4((dir * vec3(0.5)) + vec3(0.5), 1.0);
} }

@ -13,9 +13,9 @@ MaterialDef Sky Plane {
} }
WorldParameters { WorldParameters {
NormalMatrix
ViewMatrix ViewMatrix
ProjectionMatrix ProjectionMatrix
WorldMatrix
} }
Defines { Defines {

@ -1,6 +1,5 @@
uniform mat4 g_ViewMatrix; uniform mat4 g_ViewMatrix;
uniform mat4 g_ProjectionMatrix; uniform mat4 g_ProjectionMatrix;
uniform mat3 g_NormalMatrix;
uniform vec3 m_NormalScale; uniform vec3 m_NormalScale;
@ -20,5 +19,6 @@ void main(){
pos.w = 1.0; pos.w = 1.0;
gl_Position = g_ProjectionMatrix * pos; gl_Position = g_ProjectionMatrix * pos;
direction = normalize(inNormal * m_NormalScale); vec4 normal = vec4(inNormal * m_NormalScale, 0.0);
direction = normalize( (g_WorldMatrix * normal).xyz );
} }

@ -6,18 +6,17 @@ uniform float m_ExposurePow;
uniform float m_ExposureCutoff; uniform float m_ExposureCutoff;
in vec2 texCoord; in vec2 texCoord;
out vec4 outFragColor;
#ifdef HAS_GLOWMAP #ifdef HAS_GLOWMAP
uniform sampler2D m_GlowMap; uniform sampler2D m_GlowMap;
#endif #endif
void main(){ void main(){
vec4 color; vec4 color = vec4(0.0);
#ifdef DO_EXTRACT #ifdef DO_EXTRACT
color = getColor(m_Texture, texCoord); color = getColor(m_Texture, texCoord);
if ( (color.r + color.g + color.b) / 3.0 < m_ExposureCutoff ) { if ( (color.r + color.g + color.b) / 3.0 >= m_ExposureCutoff ) {
color = vec4(0.0);
}else{
color = pow(color, vec4(m_ExposurePow)); color = pow(color, vec4(m_ExposurePow));
} }
#endif #endif
@ -28,5 +27,5 @@ void main(){
color += glowColor; color += glowColor;
#endif #endif
gl_FragColor = color; outFragColor = color;
} }

@ -14,7 +14,7 @@ uniform float m_Scale;
uniform float m_Bias; uniform float m_Bias;
uniform vec2[4] m_Samples; uniform vec2[4] m_Samples;
varying vec2 texCoord; in vec2 texCoord;
float depthv; float depthv;

@ -10,7 +10,7 @@ uniform float m_XScale;
uniform float m_YScale; uniform float m_YScale;
uniform vec2 m_FrustumNearFar; uniform vec2 m_FrustumNearFar;
varying vec2 texCoord; in vec2 texCoord;
vec4 getResult(vec4 color){ vec4 getResult(vec4 color){

@ -1,3 +1,8 @@
///////////
uniform mat4 m_LightViewProjectionMatrix0; uniform mat4 m_LightViewProjectionMatrix0;
uniform mat4 m_LightViewProjectionMatrix1; uniform mat4 m_LightViewProjectionMatrix1;
uniform mat4 m_LightViewProjectionMatrix2; uniform mat4 m_LightViewProjectionMatrix2;
@ -6,14 +11,14 @@ uniform mat4 m_LightViewProjectionMatrix3;
uniform mat4 g_WorldViewProjectionMatrix; uniform mat4 g_WorldViewProjectionMatrix;
uniform mat4 g_WorldMatrix; uniform mat4 g_WorldMatrix;
varying vec4 projCoord0; out vec4 projCoord0;
varying vec4 projCoord1; out vec4 projCoord1;
varying vec4 projCoord2; out vec4 projCoord2;
varying vec4 projCoord3; out vec4 projCoord3;
varying float shadowPosition; out float shadowPosition;
attribute vec3 inPosition; in vec3 inPosition;
const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0, const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
@ -22,8 +27,8 @@ const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0,
void main(){ void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0); gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
shadowPosition = gl_Position.z; shadowPosition = gl_Position.z;
// get the vertex in world space // get the vertex in world space
vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0); vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0);

@ -1,4 +1,4 @@
#extension GL_ARB_texture_gather : enable #extension GL_ARB_texture_gather : enable
#extension GL_ARB_gpu_shader5 : enable #extension GL_ARB_gpu_shader5 : enable
#ifdef HARDWARE_SHADOWS #ifdef HARDWARE_SHADOWS

@ -124,37 +124,37 @@ public final class BoneAnimation implements Savable, Cloneable {
} }
@Override @Override
public BoneAnimation clone() { public BoneAnimation clone() {
BoneAnimation result; BoneAnimation result;
try { try {
result = (BoneAnimation)super.clone(); result = (BoneAnimation) super.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
result = new BoneAnimation(name, length); result = new BoneAnimation(name, length);
} }
if(result.tracks == null) { if (result.tracks == null) {
result.tracks = new BoneTrack[tracks.length]; result.tracks = new BoneTrack[tracks.length];
} }
for (int i = 0; i < tracks.length; ++i) { for (int i = 0; i < tracks.length; ++i) {
int tablesLength = tracks[i].getTimes().length; int tablesLength = tracks[i].getTimes().length;
float[] times = tracks[i].getTimes().clone(); float[] times = tracks[i].getTimes().clone();
Vector3f[] sourceTranslations = tracks[i].getTranslations(); Vector3f[] sourceTranslations = tracks[i].getTranslations();
Quaternion[] sourceRotations = tracks[i].getRotations(); Quaternion[] sourceRotations = tracks[i].getRotations();
Vector3f[] sourceScales = tracks[i].getScales(); Vector3f[] sourceScales = tracks[i].getScales();
Vector3f[] translations = new Vector3f[tablesLength]; Vector3f[] translations = new Vector3f[tablesLength];
Quaternion[] rotations = new Quaternion[tablesLength]; Quaternion[] rotations = new Quaternion[tablesLength];
Vector3f[] scales = new Vector3f[tablesLength]; Vector3f[] scales = new Vector3f[tablesLength];
for (int j = 0; j < tablesLength; ++j) { for (int j = 0; j < tablesLength; ++j) {
translations[j] = sourceTranslations[j].clone(); translations[j] = sourceTranslations[j].clone();
rotations[j] = sourceRotations[j].clone(); rotations[j] = sourceRotations[j].clone();
scales[j] = sourceScales != null ? sourceScales[j].clone() : new Vector3f(1.0f, 1.0f, 1.0f); scales[j] = sourceScales != null ? sourceScales[j].clone() : new Vector3f(1.0f, 1.0f, 1.0f);
} }
// times do not change, no need to clone them // times do not change, no need to clone them
result.tracks[i] = new BoneTrack(tracks[i].getTargetBoneIndex(), times, result.tracks[i] = new BoneTrack(tracks[i].getTargetBoneIndex(), times,
translations, rotations, scales); translations, rotations, scales);
} }
return result; return result;
} }
@Override @Override

@ -146,11 +146,11 @@ public class GLSLLoader implements AssetLoader {
private DependencyNode nextIndependentNode(List<DependencyNode> checkedNodes){ private DependencyNode nextIndependentNode(List<DependencyNode> checkedNodes){
Collection<DependencyNode> allNodes = dependCache.values(); Collection<DependencyNode> allNodes = dependCache.values();
if (allNodes == null || allNodes.size() == 0) if (allNodes == null || allNodes.isEmpty())
return null; return null;
for (DependencyNode node : allNodes){ for (DependencyNode node : allNodes){
if (node.dependsOn.size() == 0){ if (node.dependsOn.isEmpty()){
return node; return node;
} }
} }

@ -63,7 +63,7 @@ public class MaterialLoader implements AssetLoader {
private String folderName; private String folderName;
private AssetManager assetManager; private AssetManager assetManager;
private Scanner scan; private Scanner scan;
private ColorRGBA ambient, diffuse, specular; private ColorRGBA ambient, diffuse, specular, emissive;
private Texture texture; private Texture texture;
private String texName; private String texName;
private String matName; private String matName;
@ -72,6 +72,7 @@ public class MaterialLoader implements AssetLoader {
private boolean blend = false; private boolean blend = false;
private boolean twoSide = false; private boolean twoSide = false;
private boolean noLight = false; private boolean noLight = false;
private boolean readTexUnit = false;
private String readString(String end){ private String readString(String end){
scan.useDelimiter(end); scan.useDelimiter(end);
@ -191,7 +192,7 @@ public class MaterialLoader implements AssetLoader {
} }
} }
private void readTextureUnit(){ private void readTextureUnit(boolean skipIt){
// name is optional // name is optional
if (!scan.hasNext("\\{")){ if (!scan.hasNext("\\{")){
texName = readString("\\{"); texName = readString("\\{");
@ -200,10 +201,16 @@ public class MaterialLoader implements AssetLoader {
} }
scan.next(); // skip "{" scan.next(); // skip "{"
texture = new Texture2D(); if (!skipIt){
texture = new Texture2D();
}
while (!scan.hasNext("\\}")){ while (!scan.hasNext("\\}")){
readTextureUnitStatement(); if (skipIt){
readString("\n");
}else{
readTextureUnitStatement();
}
} }
scan.next(); // skip "}" scan.next(); // skip "}"
} }
@ -231,6 +238,8 @@ public class MaterialLoader implements AssetLoader {
}else{ }else{
ambient = readColor(); ambient = readColor();
} }
}else if (keyword.equals("emissive")){
emissive = readColor();
}else if (keyword.equals("specular")){ }else if (keyword.equals("specular")){
specular = new ColorRGBA(); specular = new ColorRGBA();
specular.r = scan.nextFloat(); specular.r = scan.nextFloat();
@ -247,7 +256,11 @@ public class MaterialLoader implements AssetLoader {
shinines = unknown; shinines = unknown;
} }
}else if (keyword.equals("texture_unit")){ }else if (keyword.equals("texture_unit")){
readTextureUnit(); readTextureUnit(readTexUnit);
// After reading the first texunit, ignore the rest
if (!readTexUnit) {
readTexUnit = true;
}
}else if (keyword.equals("scene_blend")){ }else if (keyword.equals("scene_blend")){
if (scan.hasNextInt()){ if (scan.hasNextInt()){
readString("\n"); // blender2ogre workaround readString("\n"); // blender2ogre workaround
@ -292,6 +305,10 @@ public class MaterialLoader implements AssetLoader {
name = readString("\\{"); name = readString("\\{");
} }
scan.next(); // skip "{" scan.next(); // skip "{"
// Has not yet read a tex unit for this pass
readTexUnit = false;
while (!scan.hasNext("\\}")){ while (!scan.hasNext("\\}")){
readPassStatement(); readPassStatement();
} }
@ -370,11 +387,12 @@ public class MaterialLoader implements AssetLoader {
} }
if (!noLight){ if (!noLight){
if (shinines > 0f) if (shinines > 0f) {
mat.setFloat("Shininess", shinines); mat.setFloat("Shininess", shinines);
else } else {
mat.setFloat("Shininess", 16f); // set shininess to some value anyway.. mat.setFloat("Shininess", 16f); // set shininess to some value anyway..
}
if (vcolor) if (vcolor)
mat.setBoolean("UseVertexColor", true); mat.setBoolean("UseVertexColor", true);
@ -399,16 +417,26 @@ public class MaterialLoader implements AssetLoader {
}else{ }else{
mat.setColor("Specular", ColorRGBA.Black); mat.setColor("Specular", ColorRGBA.Black);
} }
if (emissive != null){
mat.setColor("GlowColor", emissive);
}
}else{ }else{
if (vcolor) if (vcolor) {
mat.setBoolean("VertexColor", true); mat.setBoolean("VertexColor", true);
}
if (texture != null) if (texture != null) {
mat.setTexture("ColorMap", texture); mat.setTexture("ColorMap", texture);
}
if(diffuse != null){ if(diffuse != null){
mat.setColor("Color", diffuse); mat.setColor("Color", diffuse);
} }
if (emissive != null){
mat.setColor("GlowColor", emissive);
}
} }
noLight = false; noLight = false;

@ -269,7 +269,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
sharedMesh = new Mesh(); sharedMesh = new Mesh();
vertCount = parseInt(vertexcount); vertCount = parseInt(vertexcount);
usesSharedVerts = false; usesSharedVerts = false;
geom = null; geom = null;
mesh = sharedMesh; mesh = sharedMesh;
} }
@ -586,7 +586,6 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
if (count == null) { if (count == null) {
count = attribs.getValue("count"); count = attribs.getValue("count");
} }
startGeometry(count); startGeometry(count);
} else if (qName.equals("vertexbuffer")) { } else if (qName.equals("vertexbuffer")) {
startVertexBuffer(attribs); startVertexBuffer(attribs);
@ -617,6 +616,8 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// ok // ok
} else if (qName.equals("skeletonlink")) { } else if (qName.equals("skeletonlink")) {
startSkeleton(attribs.getValue("name")); startSkeleton(attribs.getValue("name"));
} else if (qName.equals("submeshnames")) {
// ok
} else if (qName.equals("submeshname")) { } else if (qName.equals("submeshname")) {
startSubmeshName(attribs.getValue("index"), attribs.getValue("name")); startSubmeshName(attribs.getValue("index"), attribs.getValue("name"));
} else if (qName.equals("mesh")) { } else if (qName.equals("mesh")) {
@ -696,7 +697,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
for (int i = 0; i < geoms.size(); i++) { for (int i = 0; i < geoms.size(); i++) {
Geometry g = geoms.get(i); Geometry g = geoms.get(i);
Mesh m = g.getMesh(); Mesh m = g.getMesh();
if (sharedMesh != null && isUsingSharedVerts(geom)) { if (sharedMesh != null && isUsingSharedVerts(g)) {
m.setBound(sharedMesh.getBound().clone()); m.setBound(sharedMesh.getBound().clone());
} }
model.attachChild(geoms.get(i)); model.attachChild(geoms.get(i));
@ -797,14 +798,12 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// Added by larynx 25.06.2011 // Added by larynx 25.06.2011
// Android needs the namespace aware flag set to true // Android needs the namespace aware flag set to true
XMLReader xr; // Kirill 30.06.2011
if (JmeSystem.getFullName().toUpperCase().contains("ANDROID")) { // Now, hack is applied for both desktop and android to avoid
SAXParserFactory factory = SAXParserFactory.newInstance(); // checking with JmeSystem.
factory.setNamespaceAware(true); SAXParserFactory factory = SAXParserFactory.newInstance();
xr = factory.newSAXParser().getXMLReader(); factory.setNamespaceAware(true);
} else { XMLReader xr = factory.newSAXParser().getXMLReader();
xr = XMLReaderFactory.createXMLReader();
}
xr.setContentHandler(this); xr.setContentHandler(this);
xr.setErrorHandler(this); xr.setErrorHandler(this);

@ -358,14 +358,12 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
// Added by larynx 25.06.2011 // Added by larynx 25.06.2011
// Android needs the namespace aware flag set to true // Android needs the namespace aware flag set to true
XMLReader xr; // Kirill 30.06.2011
if (JmeSystem.getFullName().toUpperCase().contains("ANDROID")) { // Now, hack is applied for both desktop and android to avoid
SAXParserFactory factory = SAXParserFactory.newInstance(); // checking with JmeSystem.
factory.setNamespaceAware(true); SAXParserFactory factory = SAXParserFactory.newInstance();
xr = factory.newSAXParser().getXMLReader(); factory.setNamespaceAware(true);
} else { XMLReader xr = factory.newSAXParser().getXMLReader();
xr = XMLReaderFactory.createXMLReader();
}
xr.setContentHandler(this); xr.setContentHandler(this);
xr.setErrorHandler(this); xr.setErrorHandler(this);

@ -261,15 +261,13 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
// Added by larynx 25.06.2011 // Added by larynx 25.06.2011
// Android needs the namespace aware flag set to true // Android needs the namespace aware flag set to true
XMLReader xr; // Kirill 30.06.2011
if (JmeSystem.getFullName().toUpperCase().contains("ANDROID")) { // Now, hack is applied for both desktop and android to avoid
SAXParserFactory factory = SAXParserFactory.newInstance(); // checking with JmeSystem.
factory.setNamespaceAware(true); SAXParserFactory factory = SAXParserFactory.newInstance();
xr = factory.newSAXParser().getXMLReader(); factory.setNamespaceAware(true);
} else { XMLReader xr = factory.newSAXParser().getXMLReader();
xr = XMLReaderFactory.createXMLReader();
}
xr.setContentHandler(this); xr.setContentHandler(this);
xr.setErrorHandler(this); xr.setErrorHandler(this);
InputStreamReader r = new InputStreamReader(in); InputStreamReader r = new InputStreamReader(in);

Loading…
Cancel
Save