Skip to content

Commit

Permalink
WIP #12: Damcon teams are pickable.
Browse files Browse the repository at this point in the history
- They only start showing up when you first change the power level,
  which presumably fires an onChange() console event. That's actually
  fine because it's good to test their addition.
- I don't see the DAMCON team moving; I assume that's not yet
  implemented.
- I made them blue temporarily.  They should have coloration similar to
  systems but have a box or billboard rather than a sphere as a model
  before I start using the same colors as the nodes.
- Also definitely need an onHover effect.  It's easy to know what you're
  hovering over, but without billboards, effects are going to be limited
  to changes in transparency or lighting.
- Whatever we do for "damcon team is selected" -- flashing or otherwise
  -- needs to be distinct from the on-hover effect.
  • Loading branch information
jacobmaxfrank committed Jan 19, 2016
1 parent dde81cc commit 0d4c4db
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.dhleong.acl.util.GridCoord;

public class FakeEngineeringConsoleManager extends BaseEngineeringConsoleManager {

private static final int MAX_COOLANT = 8;
private Map<ShipSystem, Integer> energyAllocated = new HashMap<>();
private Map<ShipSystem, Integer> coolantAllocated = new HashMap<>();
Expand Down
4 changes: 2 additions & 2 deletions src/com/brindyblitz/artemis/engconsole/ui/damcon/Damcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public void onChange() {
for (EngineeringConsoleManager.EnhancedDamconStatus damconStatus : engineeringConsoleManager.getDamconTeams()) {
InternalTeam it = internalTeams.get(damconStatus.getTeamNumber());
if (it == null) {
it = new InternalTeam(damconStatus.getX(), damconStatus.getY(), damconStatus.getZ());
it = new InternalTeam(damconStatus);
internalTeams.put(damconStatus.getTeamNumber(), it);
nodesToSelectabls.put(it.getBranchGroup(), it);
nodesToSelectabls.put(it.getShape(), it);
damcon_branchgroup.addChild(it.getBranchGroup());
}
it.updatePos(damconStatus.getX(), damconStatus.getY(), damconStatus.getZ());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ protected void updateSelection() {
super.updateSelection();
}

// TODO: > can I pull these 2 methods up to Internal? Node vs. shape vs. group issue, same as elsewhere, worth cleaning up


public Shape3D getShape() {
return this.sphere.getShape(Sphere.BODY);
}

private boolean isSystemNode() {
return this.vesselNode.getSystem() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public void setSelected(boolean selected) {

protected void updateSelection() {
// TODO: > bug here. Transparency of something is jumping on first node selection after launch. Investigate.
// Same if I select a damcon team too, soemthing in depth buffer/render order is changing with pick

// 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);
Expand All @@ -65,4 +67,8 @@ protected void updateSelection() {
public BranchGroup getBranchGroup() {
return branchGroup;
}

public Shape3D getShape() {
return this.sphere.getShape(Sphere.BODY);
}
}
34 changes: 24 additions & 10 deletions src/com/brindyblitz/artemis/engconsole/ui/damcon/InternalTeam.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package com.brindyblitz.artemis.engconsole.ui.damcon;

import javax.media.j3d.Appearance;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Material;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.TransparencyAttributes;
import javax.media.j3d.*;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager;
import com.sun.j3d.utils.geometry.Sphere;
import com.brindyblitz.artemis.engconsole.EngineeringConsoleManager.EnhancedDamconStatus;

public class InternalTeam extends InternalSelectable {
private TransformGroup transformGroup;
private EnhancedDamconStatus status;

// TODO: use a Box instead of a sphere or something (set every side to be pickable or use billboards)

public InternalTeam(float x, float y, float z) {
alpha = 0.5f;
public InternalTeam(EngineeringConsoleManager.EnhancedDamconStatus damcon_status) {
this.status = damcon_status;

alpha = 0.1f;

this.branchGroup = new BranchGroup();

Expand All @@ -30,7 +29,7 @@ public InternalTeam(float x, float y, float z) {
setPickable(shape);

this.transformGroup = new TransformGroup();
updatePos(x, y, z);
updatePos(this.status.getX(), this.status.getY(), this.status.getZ());
this.transformGroup.addChild(sphere);
this.transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

Expand All @@ -51,4 +50,19 @@ public void updateHealth(float pct) {
super.updateHealth(pct);
sphere.setAppearance(appearanceFromHealthPercentage(pct, false));
}

@Override
public Appearance appearanceFromHealthPercentage(float pct, boolean invisible) {
Appearance app = super.appearanceFromHealthPercentage(pct, invisible);
if (!invisible) {
// TODO: > damcon team coloration?
app.setMaterial(new Material(BLACK, new Color3f(0f, 0f, 1f), BLACK, BLACK, SHININESS));
}
return app;
}

@Override
public String toString() {
return this.status.toString();
}
}

0 comments on commit 0d4c4db

Please sign in to comment.