diff options
author | Chien Yang <[email protected]> | 2005-02-18 00:44:21 +0000 |
---|---|---|
committer | Chien Yang <[email protected]> | 2005-02-18 00:44:21 +0000 |
commit | 9b01770b9e1620874f13ee50dec15433b7e9b2e3 (patch) | |
tree | 4a9ee40fab1bdc9c3ce7b0aad9719b6726bb7e1d /src/classes | |
parent | 8320961901a3ed274677a81d9f12b83762570266 (diff) |
Added transparency level support in object file loader.
Submitted by Frederic(pepe).
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@42 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java | 2 | ||||
-rw-r--r-- | src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java index d3fcd67..5dbd3bf 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java @@ -230,7 +230,7 @@ public class ObjectFile implements Loader { // 16=Tokens // 32=Token details (use with 16) // 64=limits of model coordinates - private static final int DEBUG = 1; + private static final int DEBUG = 0; /** * Flag sent to constructor. The object's vertices will be changed diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java index 8dd3b2c..7e3600f 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java @@ -94,7 +94,6 @@ class ObjectFileMaterials implements ImageObserver { private String basePath; private boolean fromUrl; - private class ObjectFileMaterial { public Color3f Ka; @@ -104,6 +103,7 @@ class ObjectFileMaterials implements ImageObserver { public float Ns; public Texture2D t; public boolean transparent; + public float transparencyLevel; public void ObjectFileMaterial() { Ka = null; @@ -152,7 +152,7 @@ class ObjectFileMaterials implements ImageObserver { if (p.transparent) a.setTransparencyAttributes( new TransparencyAttributes(TransparencyAttributes.NICEST, - 0.0f)); + p.transparencyLevel)); } a.setMaterial(m); if ((DEBUG & 1) != 0) System.out.println(m); @@ -222,7 +222,6 @@ class ObjectFileMaterials implements ImageObserver { private void readIllum(ObjectFileParser st) throws ParsingErrorException { - float f; st.getNumber(); cur.illum = (int)st.nval; @@ -230,6 +229,15 @@ class ObjectFileMaterials implements ImageObserver { st.skipToNextLine(); } // End of readSpecular + private void readTransparency(ObjectFileParser st) throws ParsingErrorException { + + st.getNumber(); + cur.transparencyLevel = (float)st.nval; + if ( cur.transparencyLevel < 1.0f ){ + cur.transparent = true; + } + st.skipToNextLine(); + } // End of readTransparency private void readShininess(ObjectFileParser st) throws ParsingErrorException { float f; @@ -342,7 +350,7 @@ class ObjectFileMaterials implements ImageObserver { } else if (st.sval.equals("illum")) { readIllum(st); } else if (st.sval.equals("d")) { - st.skipToNextLine(); + readTransparency(st); } else if (st.sval.equals("ns")) { readShininess(st); } else if (st.sval.equals("tf")) { |