Skip to content

Commit

Permalink
OS X bug fixes; however emissive light is broken on OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisleung committed Feb 11, 2008
1 parent a64656a commit 3a0f137
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
19 changes: 13 additions & 6 deletions src/powerreader/Pick.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.j3d.Raster;
import javax.media.j3d.SceneGraphPath;
import javax.vecmath.Point3f;

import com.sun.j3d.utils.picking.*;
Expand Down Expand Up @@ -102,13 +103,19 @@ public void mouseClicked(MouseEvent e) {
PickResult result = pickCanvas.pickClosest();

if (result != null) {
Shape3D s3 = (Shape3D)result.getNode(PickResult.SHAPE3D);

if (s3 != null) {

// Get the textobject picked
TextObject3d tObj = (TextObject3d) s3.getParent().getParent().getParent();

// Retrieve the picked text object
TextObject3d tObj = null;
SceneGraphPath pickedPath = result.getSceneGraphPath();

for(int i = 0; i< pickedPath.nodeCount(); i++) {
if (pickedPath.getNode(i) instanceof TextObject3d) {
tObj = (TextObject3d) pickedPath.getNode(i);
}
}

if (tObj != null) {

// Get its hierarchy object of the word
WordHashMap map = WordHashMap.getInstance();
HierarchyObject pickedObject = map.getHirarchyObject(tObj);
Expand Down
10 changes: 8 additions & 2 deletions src/util/HierarchyObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ public class HierarchyObject {
// Ordered list of children
private ArrayList m_children;

// Stores whether this object is being rendered or not
private boolean m_render;

/**
* Creates a new instance of HierarchyObject
* @param newLevel Level of the hierarchy object
* @param newType Tpe of the hierarchy as string
* @param newNode Reference to the scene graph node
*/
public HierarchyObject(int newLevel, String newType) {
m_render = true;
m_level = newLevel;
m_type = newType;
m_children = new ArrayList();
Expand Down Expand Up @@ -206,14 +210,16 @@ public void color(boolean highLight) {
}

public void disableRender() {
if(this.getParent() != null) {
if(m_render == true) {
this.getParent().getTransformGroup().removeChild(m_branchGroup);
m_render = false;
}
}

public void enabledRender() {
if(this.getParent() != null && m_branchGroup.getParent() == null) {
if(this.getParent() != null && m_render == false) {
this.getParent().getTransformGroup().addChild(m_branchGroup);
m_render = true;
}
}
}
1 change: 1 addition & 0 deletions src/util/RawTextParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void parse() {
node.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
node.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
node.setCapability(BranchGroup.ALLOW_DETACH);
node.setCapability(BranchGroup.ENABLE_PICK_REPORTING);

BufferedReader input = null;
String line = null;
Expand Down
14 changes: 7 additions & 7 deletions src/util/TextObject3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ public class TextObject3d extends TransformGroup {
public TextObject3d(String text) {
super();

this.setCapability(TransformGroup.ENABLE_PICK_REPORTING);

// face it in the scene graph
Transform3D rotation = new Transform3D();
TransformGroup rotation_group = new TransformGroup( rotation );
rotation_group.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
this.addChild( rotation_group );

// Set up 3d geometry
Expand Down Expand Up @@ -107,17 +110,17 @@ public TextObject3d(String text) {

nextLocation.x += up.x + nextLocationIncrementWordSentence.x;

m_textShape = new Shape3D();
m_textShape.setGeometry(textGeom);
m_textShape.setAppearance(m_textAppearanceBaseColor);
m_textShape.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
m_textShape = new Shape3D(textGeom,m_textAppearanceBaseColor);
m_textShape.setAppearanceOverrideEnable(true);
m_textShape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
m_textShape.setCapability(Shape3D.ENABLE_PICK_REPORTING);

// attach it
theText = new TransformGroup();
theText.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
theText.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
theText.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
theText.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
theText.addChild(m_textShape);
rotation_group.addChild( theText );

Expand All @@ -132,9 +135,6 @@ public static Appearance createAppearance(Color3f color) {
// create the 3d text
Appearance textAppear = new Appearance();
Material textMaterial = new Material();
textMaterial.setCapability(Material.ALLOW_COMPONENT_WRITE);
textMaterial.setCapability(Material.ALLOW_COMPONENT_READ);
textMaterial.setCapability(Material.EMISSIVE);
textMaterial.setEmissiveColor(color);
textAppear.setMaterial(textMaterial);
return textAppear;
Expand Down

0 comments on commit 3a0f137

Please sign in to comment.