Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2cac2f40d | |||
| fa6950d5c9 | |||
| 0df8b37ddd | |||
| d481df0f96 | |||
| ae93dca1b9 | |||
| 0fdef7c01c | |||
| 481fe1f428 |
@@ -24,7 +24,7 @@ import ve.ucv.ciens.ccg.nxtar.systems.GameLogicSystemBase;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.systems.GeometrySystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.GeometrySystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ public abstract class ScenarioGlobals{
|
|||||||
gameWorld.setSystem(gameLogicSystem);
|
gameWorld.setSystem(gameLogicSystem);
|
||||||
gameWorld.setSystem(playerSystem, true);
|
gameWorld.setSystem(playerSystem, true);
|
||||||
gameWorld.setSystem(new MarkerRenderingSystem(modelBatch), true);
|
gameWorld.setSystem(new MarkerRenderingSystem(modelBatch), true);
|
||||||
gameWorld.setSystem(new RobotArmRenderingSystem(modelBatch), true);
|
gameWorld.setSystem(new ObjectRenderingSystem(modelBatch), true);
|
||||||
gameWorld.setSystem(new FadeEffectRenderingSystem(), true);
|
gameWorld.setSystem(new FadeEffectRenderingSystem(), true);
|
||||||
|
|
||||||
gameWorld.initialize();
|
gameWorld.initialize();
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ import com.badlogic.gdx.Gdx;
|
|||||||
public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBase {
|
public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBase {
|
||||||
private static final String TAG = "BOMB_GAME_AUTO_PERFORMER";
|
private static final String TAG = "BOMB_GAME_AUTO_PERFORMER";
|
||||||
private static final String CLASS_NAME = BombGameAutomaticActionPerformer.class.getSimpleName();
|
private static final String CLASS_NAME = BombGameAutomaticActionPerformer.class.getSimpleName();
|
||||||
private static final int MARKER_NEARBY_FLOOR_MIN_LUMINANCE = 50;
|
private static final int GOAL_FLOOR_MIN_LUMINANCE = 75;
|
||||||
|
private static final int MARKER_NEARBY_FLOOR_MIN_LUMINANCE = 45;
|
||||||
|
|
||||||
private enum action_state_t{
|
private enum action_state_t{
|
||||||
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
||||||
@@ -43,7 +44,6 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
private int numCombinationBombs;
|
private int numCombinationBombs;
|
||||||
private int numInclinationBombs;
|
private int numInclinationBombs;
|
||||||
private int numWireBombs;
|
private int numWireBombs;
|
||||||
private int totalBombs;
|
|
||||||
|
|
||||||
public BombGameAutomaticActionSummary(){
|
public BombGameAutomaticActionSummary(){
|
||||||
reset();
|
reset();
|
||||||
@@ -63,21 +63,14 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
|
|
||||||
public void addCombinationBomb(){
|
public void addCombinationBomb(){
|
||||||
numCombinationBombs++;
|
numCombinationBombs++;
|
||||||
totalBombs++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInclinationBomb(){
|
public void addInclinationBomb(){
|
||||||
numInclinationBombs++;
|
numInclinationBombs++;
|
||||||
totalBombs++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWireBomb(){
|
public void addWireBomb(){
|
||||||
numWireBombs++;
|
numWireBombs++;
|
||||||
totalBombs++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBombsSeen(){
|
|
||||||
return totalBombs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +78,6 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
this.numCombinationBombs = 0;
|
this.numCombinationBombs = 0;
|
||||||
this.numInclinationBombs = 0;
|
this.numInclinationBombs = 0;
|
||||||
this.numWireBombs = 0;
|
this.numWireBombs = 0;
|
||||||
this.totalBombs = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +86,6 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
private List<Integer> detectedMarkers;
|
private List<Integer> detectedMarkers;
|
||||||
private float then;
|
private float then;
|
||||||
private float now;
|
private float now;
|
||||||
private int stops;
|
|
||||||
private GroupManager manager;
|
private GroupManager manager;
|
||||||
private BombGameAutomaticActionSummary summary;
|
private BombGameAutomaticActionSummary summary;
|
||||||
|
|
||||||
@@ -112,7 +103,7 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
public boolean performAutomaticAction(int lightSensorReading, MarkerData markers) throws IllegalStateException, IllegalArgumentException{
|
public boolean performAutomaticAction(int lightSensorReading, MarkerData markers) throws IllegalStateException, IllegalArgumentException{
|
||||||
BombComponent bomb;
|
BombComponent bomb;
|
||||||
boolean finish = false;
|
boolean finish = false;
|
||||||
boolean markerAlreadyDetected = false;
|
boolean markerDetected = false;
|
||||||
int detectedCode = -1;
|
int detectedCode = -1;
|
||||||
ImmutableBag<Entity> entities = null;
|
ImmutableBag<Entity> entities = null;
|
||||||
float deltaT;
|
float deltaT;
|
||||||
@@ -134,8 +125,7 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
switch(state){
|
switch(state){
|
||||||
case START:
|
case START:
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is START.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is START.");
|
||||||
// Reset everything, then look to the left and start moving forward.
|
summary.reset();
|
||||||
this.reset();
|
|
||||||
nextAction = automatic_action_t.ROTATE_90;
|
nextAction = automatic_action_t.ROTATE_90;
|
||||||
state = action_state_t.WALK_FORWARD;
|
state = action_state_t.WALK_FORWARD;
|
||||||
finish = false;
|
finish = false;
|
||||||
@@ -143,22 +133,17 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
|
|
||||||
case WALK_FORWARD:
|
case WALK_FORWARD:
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is WALK_FORWARD.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is WALK_FORWARD.");
|
||||||
// Check if all stops have been found.
|
if(lightSensorReading >= GOAL_FLOOR_MIN_LUMINANCE){
|
||||||
if(stops >= BombGameEntityCreator.NUM_BOMBS){
|
|
||||||
// If all stops have been found then stop the robot and finish the automatic action.
|
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Found goal.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Found goal.");
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
state = action_state_t.FINISHING;
|
state = action_state_t.FINISHING;
|
||||||
}else{
|
}else{
|
||||||
// If there are stops to be found yet then check if the light sensor found a stop.
|
if(lightSensorReading >= MARKER_NEARBY_FLOOR_MIN_LUMINANCE && lightSensorReading < GOAL_FLOOR_MIN_LUMINANCE){
|
||||||
if(lightSensorReading >= MARKER_NEARBY_FLOOR_MIN_LUMINANCE){
|
|
||||||
// If a stop have been found then check if there is a marker nearby.
|
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): There is a marker nearby.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): There is a marker nearby.");
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
state = action_state_t.DETECT_MARKER;
|
state = action_state_t.DETECT_MARKER;
|
||||||
then = Gdx.graphics.getDeltaTime();
|
then = Gdx.graphics.getDeltaTime();
|
||||||
}else{
|
}else{
|
||||||
// If the light sensor didn't find a stop the keep moving.
|
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Walking.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Walking.");
|
||||||
nextAction = automatic_action_t.GO_FORWARD;
|
nextAction = automatic_action_t.GO_FORWARD;
|
||||||
}
|
}
|
||||||
@@ -168,18 +153,18 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
|
|
||||||
case DETECT_MARKER:
|
case DETECT_MARKER:
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is DETECT_MARKER.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is DETECT_MARKER.");
|
||||||
for(int i = 0; !markerAlreadyDetected && i < ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS; i++){
|
for(int i = 0; !markerDetected && i < ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS; i++){
|
||||||
// Check if this marker has not been detected already.
|
// Check if this marker has not been detected already.
|
||||||
for(Integer code : detectedMarkers){
|
for(Integer code : detectedMarkers){
|
||||||
if(markers.markerCodes[i] == code){
|
if(markers.markerCodes[i] == code){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Marker already detected.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Marker already detected.");
|
||||||
markerAlreadyDetected = true;
|
markerDetected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the marker has not been detected before then examine it.
|
// If the marker has not been detected before then examine it.
|
||||||
if(!markerAlreadyDetected){
|
if(!markerDetected){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): New marker detected.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): New marker detected.");
|
||||||
detectedCode = markers.markerCodes[i];
|
detectedCode = markers.markerCodes[i];
|
||||||
entities = manager.getEntities(Integer.toString(detectedCode));
|
entities = manager.getEntities(Integer.toString(detectedCode));
|
||||||
@@ -212,21 +197,17 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If found a marker and it has not been detected before then add it to the detected markers list.
|
if(!markerDetected && detectedCode != -1)
|
||||||
if(!markerAlreadyDetected && detectedCode != -1)
|
|
||||||
detectedMarkers.add(detectedCode);
|
detectedMarkers.add(detectedCode);
|
||||||
|
|
||||||
if(lightSensorReading < MARKER_NEARBY_FLOOR_MIN_LUMINANCE){
|
if(lightSensorReading < MARKER_NEARBY_FLOOR_MIN_LUMINANCE){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Switching to WALK_FORWARD.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Switching to WALK_FORWARD.");
|
||||||
// If cleared the stop mark on the floor then start moving is search for the next mark.
|
|
||||||
state = action_state_t.WALK_FORWARD;
|
state = action_state_t.WALK_FORWARD;
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
then = 0.0f;
|
then = 0.0f;
|
||||||
now = 0.0f;
|
now = 0.0f;
|
||||||
stops++;
|
|
||||||
}else{
|
}else{
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Clearing MARKER_NEARBY_FLOOR.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Clearing MARKER_NEARBY_FLOOR.");
|
||||||
// Wait for two seconds to make sure the marker can be correctly detected.
|
|
||||||
now += Gdx.graphics.getDeltaTime();
|
now += Gdx.graphics.getDeltaTime();
|
||||||
deltaT = now - then;
|
deltaT = now - then;
|
||||||
if(deltaT >= 2.0f){
|
if(deltaT >= 2.0f){
|
||||||
@@ -242,7 +223,6 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
|
|
||||||
case FINISHING:
|
case FINISHING:
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is FINISHING.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is FINISHING.");
|
||||||
// Recenter the camera.
|
|
||||||
state = action_state_t.END;
|
state = action_state_t.END;
|
||||||
nextAction = automatic_action_t.RECENTER;
|
nextAction = automatic_action_t.RECENTER;
|
||||||
finish = false;
|
finish = false;
|
||||||
@@ -250,10 +230,12 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
|
|
||||||
case END:
|
case END:
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is END.");
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is END.");
|
||||||
// Finish the automatic action.
|
|
||||||
nextAction = automatic_action_t.NO_ACTION;
|
nextAction = automatic_action_t.NO_ACTION;
|
||||||
state = action_state_t.START;
|
state = action_state_t.START;
|
||||||
finish = true;
|
finish = true;
|
||||||
|
now = 0.0f;
|
||||||
|
then = 0.0f;
|
||||||
|
detectedMarkers.clear();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -295,6 +277,5 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
state = action_state_t.START;
|
state = action_state_t.START;
|
||||||
nextAction = automatic_action_t.NO_ACTION;
|
nextAction = automatic_action_t.NO_ACTION;
|
||||||
then = 0.0f;
|
then = 0.0f;
|
||||||
stops = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,9 +126,6 @@ public class BombGameAutomaticActionSummaryOverlay extends SummaryOverlayBase{
|
|||||||
font.draw(batch, String.format("Combination bombs: %d", bombGameSummary.getNumCombinationBombs()), combinationX, combinationY);
|
font.draw(batch, String.format("Combination bombs: %d", bombGameSummary.getNumCombinationBombs()), combinationX, combinationY);
|
||||||
font.draw(batch, String.format("Wire bombs: %d", bombGameSummary.getNumWireBombs()), wireX, wireY);
|
font.draw(batch, String.format("Wire bombs: %d", bombGameSummary.getNumWireBombs()), wireX, wireY);
|
||||||
|
|
||||||
font.draw(batch, "Bombs found: " + bombGameSummary.getBombsSeen(), wireX, inclinationY + inclinationBomb.getHeight() + font.getCapHeight() + 20.0f);
|
|
||||||
font.draw(batch, "Bombs expected: " + BombGameEntityCreator.NUM_BOMBS, wireX, inclinationY + inclinationBomb.getHeight() + 10.0f);
|
|
||||||
|
|
||||||
if(!Ouya.runningOnOuya)
|
if(!Ouya.runningOnOuya)
|
||||||
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10);
|
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.systems.FadeEffectRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.FadeEffectRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
@@ -98,7 +98,7 @@ public class InGameState extends BaseState{
|
|||||||
// Game related fields.
|
// Game related fields.
|
||||||
private World gameWorld;
|
private World gameWorld;
|
||||||
private MarkerRenderingSystem markerRenderingSystem;
|
private MarkerRenderingSystem markerRenderingSystem;
|
||||||
private RobotArmRenderingSystem robotArmRenderingSystem;
|
private ObjectRenderingSystem objectRenderingSystem;
|
||||||
private RobotArmPositioningSystem robotArmPositioningSystem;
|
private RobotArmPositioningSystem robotArmPositioningSystem;
|
||||||
private FadeEffectRenderingSystem fadeEffectRenderingSystem;
|
private FadeEffectRenderingSystem fadeEffectRenderingSystem;
|
||||||
private PlayerSystemBase playerSystem;
|
private PlayerSystemBase playerSystem;
|
||||||
@@ -249,11 +249,11 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
robotArmPositioningSystem = gameWorld.getSystem(RobotArmPositioningSystem.class);
|
robotArmPositioningSystem = gameWorld.getSystem(RobotArmPositioningSystem.class);
|
||||||
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
||||||
robotArmRenderingSystem = gameWorld.getSystem(RobotArmRenderingSystem.class);
|
objectRenderingSystem = gameWorld.getSystem(ObjectRenderingSystem.class);
|
||||||
fadeEffectRenderingSystem = gameWorld.getSystem(FadeEffectRenderingSystem.class);
|
fadeEffectRenderingSystem = gameWorld.getSystem(FadeEffectRenderingSystem.class);
|
||||||
playerSystem = ScenarioGlobals.getPlayerSystem();
|
playerSystem = ScenarioGlobals.getPlayerSystem();
|
||||||
|
|
||||||
if(robotArmPositioningSystem == null || markerRenderingSystem == null || robotArmRenderingSystem == null || fadeEffectRenderingSystem == null)
|
if(robotArmPositioningSystem == null || markerRenderingSystem == null || objectRenderingSystem == null || fadeEffectRenderingSystem == null)
|
||||||
throw new IllegalStateException("One or more essential systems are null.");
|
throw new IllegalStateException("One or more essential systems are null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,9 +357,9 @@ public class InGameState extends BaseState{
|
|||||||
markerRenderingSystem.end();
|
markerRenderingSystem.end();
|
||||||
|
|
||||||
if(controlMode.getValue() == robot_control_mode_t.ARM_CONTROL.getValue() || Ouya.runningOnOuya){
|
if(controlMode.getValue() == robot_control_mode_t.ARM_CONTROL.getValue() || Ouya.runningOnOuya){
|
||||||
robotArmRenderingSystem.begin(perspectiveCamera);
|
objectRenderingSystem.begin(perspectiveCamera);
|
||||||
robotArmRenderingSystem.process();
|
objectRenderingSystem.process();
|
||||||
robotArmRenderingSystem.end();
|
objectRenderingSystem.end();
|
||||||
}
|
}
|
||||||
}frameBuffer.end();
|
}frameBuffer.end();
|
||||||
|
|
||||||
@@ -1343,7 +1343,7 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean axisMoved(Controller controller, int axisCode, float value){
|
public boolean axisMoved(Controller controller, int axisCode, float value){
|
||||||
GamepadUserInput userInput = null;
|
GamepadUserInput userInput;
|
||||||
|
|
||||||
if(Math.abs(value) > Ouya.STICK_DEADZONE){
|
if(Math.abs(value) > Ouya.STICK_DEADZONE){
|
||||||
userInput = new GamepadUserInput();
|
userInput = new GamepadUserInput();
|
||||||
@@ -1357,22 +1357,9 @@ public class InGameState extends BaseState{
|
|||||||
userInput.axisRightY = value;
|
userInput.axisRightY = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(Math.abs(value) <= Ouya.STICK_DEADZONE){
|
|
||||||
userInput = new GamepadUserInput();
|
|
||||||
if(axisCode == Ouya.AXIS_LEFT_X){
|
|
||||||
userInput.axisLeftX = 0.0f;
|
|
||||||
}else if(axisCode == Ouya.AXIS_LEFT_Y){
|
|
||||||
userInput.axisLeftY = 0.0f;
|
|
||||||
}else if(axisCode == Ouya.AXIS_RIGHT_X){
|
|
||||||
userInput.axisRightX = 0.0f;
|
|
||||||
}else if(axisCode == Ouya.AXIS_RIGHT_Y){
|
|
||||||
userInput.axisRightY = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(userInput != null){
|
|
||||||
robotArmPositioningSystem.setUserInput(userInput);
|
robotArmPositioningSystem.setUserInput(userInput);
|
||||||
robotArmPositioningSystem.process();
|
robotArmPositioningSystem.process();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
package ve.ucv.ciens.ccg.nxtar.systems;
|
package ve.ucv.ciens.ccg.nxtar.systems;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.EnvironmentComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.EnvironmentComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.GeometryComponent;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.RenderModelComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.RenderModelComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.ShaderComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.ShaderComponent;
|
||||||
@@ -26,49 +25,27 @@ import com.artemis.ComponentMapper;
|
|||||||
import com.artemis.Entity;
|
import com.artemis.Entity;
|
||||||
import com.artemis.annotations.Mapper;
|
import com.artemis.annotations.Mapper;
|
||||||
import com.artemis.systems.EntityProcessingSystem;
|
import com.artemis.systems.EntityProcessingSystem;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
import com.badlogic.gdx.graphics.PerspectiveCamera;
|
||||||
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
|
|
||||||
import com.badlogic.gdx.graphics.g3d.Material;
|
|
||||||
import com.badlogic.gdx.graphics.g3d.Model;
|
|
||||||
import com.badlogic.gdx.graphics.g3d.ModelBatch;
|
import com.badlogic.gdx.graphics.g3d.ModelBatch;
|
||||||
import com.badlogic.gdx.graphics.g3d.ModelInstance;
|
|
||||||
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
|
|
||||||
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
|
|
||||||
import com.badlogic.gdx.math.Vector3;
|
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Entity processing system in charge of rendering 3D objects using OpenGL. The
|
* <p>Entity processing system in charge of rendering 3D objects using OpenGL. The
|
||||||
* entities to be rendered must have a geometry, shader and mesh component associated.</p>
|
* entities to be rendered must have a geometry, shader and mesh component associated.</p>
|
||||||
*/
|
*/
|
||||||
public class RobotArmRenderingSystem extends EntityProcessingSystem implements Disposable{
|
public class ObjectRenderingSystem extends EntityProcessingSystem {
|
||||||
@Mapper ComponentMapper<ShaderComponent> shaderMapper;
|
@Mapper ComponentMapper<ShaderComponent> shaderMapper;
|
||||||
@Mapper ComponentMapper<RenderModelComponent> modelMapper;
|
@Mapper ComponentMapper<RenderModelComponent> modelMapper;
|
||||||
@Mapper ComponentMapper<EnvironmentComponent> environmentMapper;
|
@Mapper ComponentMapper<EnvironmentComponent> environmentMapper;
|
||||||
@Mapper ComponentMapper<GeometryComponent> geometryMapper;
|
|
||||||
|
|
||||||
private PerspectiveCamera camera;
|
private PerspectiveCamera camera;
|
||||||
private ModelBatch batch;
|
private ModelBatch batch;
|
||||||
private Model lineModel;
|
|
||||||
private ModelInstance lineInstance;
|
|
||||||
private Vector3 temp;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public RobotArmRenderingSystem(ModelBatch batch) {
|
public ObjectRenderingSystem(ModelBatch batch) {
|
||||||
super(Aspect.getAspectForAll(ShaderComponent.class, RenderModelComponent.class, EnvironmentComponent.class).exclude(MarkerCodeComponent.class));
|
super(Aspect.getAspectForAll(ShaderComponent.class, RenderModelComponent.class, EnvironmentComponent.class).exclude(MarkerCodeComponent.class));
|
||||||
|
|
||||||
camera = null;
|
camera = null;
|
||||||
this.batch = batch;
|
this.batch = batch;
|
||||||
// MeshBuilder builder = new MeshBuilder();
|
|
||||||
// builder.begin(new VertexAttributes(new VertexAttribute(Usage.Position, 4, "a_position"), new VertexAttribute(Usage.Color, 4, "a_color")), GL20.GL_LINES);{
|
|
||||||
// builder.line(new Vector3(0.0f, 0.0f, RobotArmPositioningSystem.MIN_Z), Color.YELLOW, new Vector3(0.0f, 0.0f, RobotArmPositioningSystem.MAX_Z), Color.YELLOW);
|
|
||||||
// }lineMesh = builder.end();
|
|
||||||
// lineModel = ModelBuilder.createFromMesh(lineMesh, GL20.GL_LINES, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.YELLOW)));
|
|
||||||
// lineModel = new ModelBuilder().createArrow(new Vector3(0.0f, 0.0f, RobotArmPositioningSystem.MIN_Z), new Vector3(0.0f, 0.0f, RobotArmPositioningSystem.MAX_Z), new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.YELLOW)), Usage.Position | Usage.Color | Usage.Normal);
|
|
||||||
lineModel = new ModelBuilder().createBox(0.01f, 0.01f, 3.5f, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.YELLOW)), Usage.Position | Usage.Color | Usage.Normal);
|
|
||||||
lineInstance = new ModelInstance(lineModel);
|
|
||||||
temp = new Vector3();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(PerspectiveCamera camera) throws RuntimeException{
|
public void begin(PerspectiveCamera camera) throws RuntimeException{
|
||||||
@@ -89,27 +66,13 @@ public class RobotArmRenderingSystem extends EntityProcessingSystem implements D
|
|||||||
EnvironmentComponent environment;
|
EnvironmentComponent environment;
|
||||||
ShaderComponent shaderComponent;
|
ShaderComponent shaderComponent;
|
||||||
RenderModelComponent renderModelComponent;
|
RenderModelComponent renderModelComponent;
|
||||||
GeometryComponent geometry;
|
|
||||||
|
|
||||||
// Get the necessary components.
|
// Get the necessary components.
|
||||||
renderModelComponent = modelMapper.get(e);
|
renderModelComponent = modelMapper.get(e);
|
||||||
shaderComponent = shaderMapper.get(e);
|
shaderComponent = shaderMapper.get(e);
|
||||||
environment = environmentMapper.get(e);
|
environment = environmentMapper.get(e);
|
||||||
geometry = geometryMapper.getSafe(e);
|
|
||||||
|
|
||||||
if(geometry != null){
|
|
||||||
temp.set(geometry.position.x, geometry.position.y, -2.5f);
|
|
||||||
lineInstance.transform.idt().setToTranslation(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render this entity.
|
// Render this entity.
|
||||||
batch.render(renderModelComponent.instance, environment.environment, shaderComponent.shader);
|
batch.render(renderModelComponent.instance, environment.environment, shaderComponent.shader);
|
||||||
batch.render(lineInstance, environment.environment, shaderComponent.shader);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
if(lineModel != null)
|
|
||||||
lineModel.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,8 +39,8 @@ public class RobotArmPositioningSystem extends EntityProcessingSystem {
|
|||||||
private static final String CLASS_NAME = RobotArmPositioningSystem.class.getSimpleName();
|
private static final String CLASS_NAME = RobotArmPositioningSystem.class.getSimpleName();
|
||||||
private static final float INTERPOLATION_STEP = 0.05f;
|
private static final float INTERPOLATION_STEP = 0.05f;
|
||||||
private static final float STEP_SIZE = 0.05f;
|
private static final float STEP_SIZE = 0.05f;
|
||||||
public static final float MAX_Z = -4.5f;
|
private static final float MAX_Z = -4.5f;
|
||||||
public static final float MIN_Z = -1.0f;
|
private static final float MIN_Z = -1.0f;
|
||||||
|
|
||||||
@Mapper ComponentMapper<GeometryComponent> geometryMapper;
|
@Mapper ComponentMapper<GeometryComponent> geometryMapper;
|
||||||
@Mapper ComponentMapper<AutomaticMovementComponent> autoMapper;
|
@Mapper ComponentMapper<AutomaticMovementComponent> autoMapper;
|
||||||
|
|||||||
Reference in New Issue
Block a user