summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorphil <[email protected]>2016-12-04 21:11:48 +1300
committerphil <[email protected]>2016-12-04 21:11:48 +1300
commit202a4451274540febde059e5eb26e1327815ea61 (patch)
treeedf09d6eef9276a26148676f9e45fc197ba55c28 /src
parentcf6947faef1e6f65fe9900b56a637b9b7f0f83e4 (diff)
ObjFile can now have an Appearance constructor method overriden to
supply for example a ShaderAppearance
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFile.java15
-rw-r--r--src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFileMaterials.java4
2 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFile.java b/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFile.java
index abbc2e4..5b54ab7 100644
--- a/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFile.java
+++ b/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFile.java
@@ -51,6 +51,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import org.jogamp.java3d.Appearance;
import org.jogamp.java3d.BranchGroup;
import org.jogamp.java3d.Shape3D;
import org.jogamp.vecmath.Point3f;
@@ -1180,12 +1181,11 @@ public class ObjectFile implements Loader {
// Put geometry into Shape3d
Shape3D shape = new Shape3D();
- // issue 638; default to BY_COPY for consistency
//PJ: gl2es2 requires by ref, and nio is much faster
shape.setGeometry(gi.getGeometryArray(true, false, true));
String matName = (String)groupMaterials.get(curname);
- materials.assignMaterial(matName, shape);
+ materials.assignMaterial(matName, shape, createAppearance());
group.addChild(shape);
scene.addNamedObject(curname, shape);
@@ -1203,6 +1203,17 @@ public class ObjectFile implements Loader {
/**
+ * Override to provide a custom appearance, for example
+ * a ShaderAppearance with shaders
+ * @return
+ */
+ public Appearance createAppearance()
+ {
+ return new Appearance();
+ }
+
+
+ /**
* The Object File is loaded from the already opened file.
* To attach the model to your scene, call getSceneGroup() on
* the Scene object passed back, and attach the returned
diff --git a/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFileMaterials.java b/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFileMaterials.java
index 09c3660..0645071 100644
--- a/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFileMaterials.java
+++ b/src/main/java/org/jogamp/java3d/loaders/objectfile/ObjectFileMaterials.java
@@ -98,14 +98,14 @@ class ObjectFileMaterials implements ImageObserver {
}
- void assignMaterial(String matName, Shape3D shape) {
+ void assignMaterial(String matName, Shape3D shape, Appearance a) {
ObjectFileMaterial p = null;
if ((DEBUG & 1) != 0) System.out.println("Color " + matName);
Material m = new Material();
p = (ObjectFileMaterial)materials.get(matName);
- Appearance a = new Appearance();
+
if (p != null) {
// Set ambient & diffuse color