-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #12: Further refactor of Internals
- I still haven't tested DAMCON selectability. I'll try adding it to the FakeEngineeringConsoleManager if I have a chance. - The DAMCON team rendering currently shares a Sphere with the internal nodes, but they should probably be a box or something. - See TODOs for many other WIP/unimplemented features
- Loading branch information
1 parent
5bf7764
commit dde81cc
Showing
6 changed files
with
136 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 6 additions & 29 deletions
35
src/com/brindyblitz/artemis/engconsole/ui/damcon/Internal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,22 @@ | ||
package com.brindyblitz.artemis.engconsole.ui.damcon; | ||
|
||
|
||
import com.brindyblitz.artemis.engconsole.ui.SystemStatusSlider; | ||
import net.dhleong.acl.vesseldata.VesselNode; | ||
|
||
import javax.media.j3d.Appearance; | ||
import javax.vecmath.Color3f; | ||
import javax.vecmath.Point3f; | ||
import java.awt.*; | ||
|
||
public abstract class Internal { | ||
protected static final float SCALE = 0.0034f; | ||
protected static final float SHININESS = 0f; | ||
|
||
protected float alpha; | ||
protected boolean selected = false; | ||
protected float healthPct = 1f; | ||
|
||
protected static Point3f vesselNodePosition(VesselNode vn) { | ||
Point3f p = new Point3f(-vn.getX(), vn.getY(), vn.getZ()); | ||
protected static Point3f internalPositionToWorldSpace(float x, float y, float z) { | ||
Point3f p = new Point3f(-x, y, z); | ||
p.scale(SCALE); | ||
return p; | ||
} | ||
|
||
protected abstract Appearance appearanceFromHealthPercentage(float pct); | ||
|
||
public void updateHealth(float pct) { | ||
this.healthPct = pct; | ||
} | ||
|
||
protected void updateSelection() { | ||
|
||
} | ||
|
||
protected Color3f getColorFromHealth(float pct) { | ||
Color color = Color.getHSBColor( | ||
SystemStatusSlider.getEmptyHue(true) - (SystemStatusSlider.getEmptyHue(true) - SystemStatusSlider.getFullHue(true)) * pct, 1, 1); | ||
return new Color3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); | ||
} | ||
|
||
public void setSelected(boolean selected) { | ||
this.selected = selected; | ||
updateSelection(); | ||
protected static Point3f internalPositionToWorldSpace(VesselNode vn) { | ||
return internalPositionToWorldSpace(vn.getX(), vn.getY(), vn.getZ()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalSelectable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.brindyblitz.artemis.engconsole.ui.damcon; | ||
|
||
import com.brindyblitz.artemis.engconsole.ui.SystemStatusSlider; | ||
import com.sun.j3d.utils.geometry.Sphere; | ||
|
||
import javax.media.j3d.*; | ||
import javax.vecmath.Color3f; | ||
import java.awt.*; | ||
|
||
public abstract class InternalSelectable extends Internal { | ||
protected static final float RADIUS = 0.05f; | ||
protected static final float SHININESS = 0f; | ||
protected static final Color3f BLACK = new Color3f(0f, 0f, 0f); | ||
|
||
protected boolean selected = false; | ||
protected float healthPct = 1f; | ||
|
||
protected Sphere sphere; | ||
protected BranchGroup branchGroup; | ||
|
||
protected Appearance appearanceFromHealthPercentage(float pct, boolean invisible) { | ||
Appearance app = new Appearance(); | ||
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ); | ||
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); | ||
app.setMaterial(new Material(BLACK, getColorFromHealth(pct), BLACK, BLACK, SHININESS)); | ||
// TODO: FILE ISSUE > when hovering, make opaque or circle or something | ||
TransparencyAttributes transparency = new TransparencyAttributes(TransparencyAttributes.NICEST, invisible ? 1f : alpha); | ||
app.setTransparencyAttributes(transparency); | ||
return app; | ||
} | ||
|
||
protected void setPickable(Shape3D shape) { | ||
shape.setCapability(Shape3D.ENABLE_PICK_REPORTING); | ||
shape.setPickable(true); | ||
} | ||
|
||
public void updateHealth(float pct) { | ||
this.healthPct = pct; | ||
} | ||
|
||
protected Color3f getColorFromHealth(float pct) { | ||
Color color = Color.getHSBColor( | ||
SystemStatusSlider.getEmptyHue(true) - (SystemStatusSlider.getEmptyHue(true) - SystemStatusSlider.getFullHue(true)) * pct, 1, 1); | ||
return new Color3f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f); | ||
} | ||
|
||
public void setSelected(boolean selected) { | ||
this.selected = selected; | ||
updateSelection(); | ||
} | ||
|
||
protected void updateSelection() { | ||
// TODO: > bug here. Transparency of something is jumping on first node selection after launch. Investigate. | ||
// It actually looks like the depth of the nodes is being put behind the model for some reason | ||
if (selected) { | ||
Appearance app = appearanceFromHealthPercentage(healthPct, false); | ||
TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.NICEST, 0f); | ||
app.setTransparencyAttributes(ta); | ||
sphere.setAppearance(app); | ||
} else { | ||
updateHealth(healthPct); | ||
} | ||
} | ||
|
||
public BranchGroup getBranchGroup() { | ||
return branchGroup; | ||
} | ||
} |
Oops, something went wrong.