Skip to content

Commit

Permalink
Some Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal66 committed Sep 21, 2019
1 parent 242b55f commit 78213a9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 48 deletions.
22 changes: 7 additions & 15 deletions TechDemo/src/main/java/de/rwth/setups/CollectItemsSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ public void _b_addWorldsToRenderer(GL1Renderer renderer, GLFactory objectFactory
Obj itemToCollect = new Obj();
itemToCollect.setComp(new ProximitySensor(camera, 3f) {
@Override
public void onObjectIsCloseToCamera(GLCamera myCamera2, Obj obj,
MeshComponent m, float currentDistance) {
public void onObjectIsCloseToCamera(GLCamera myCamera2, Obj obj, MeshComponent m, float currentDistance) {
catchedNumber++;
new CommandShowToast(getActivity()/*myTargetActivity*/, "You got me "
+ catchedNumber + " times").execute();
itemMesh.setPosition(Vec.getNewRandomPosInXYPlane(
camera.getPosition(), 5, 20));
itemMesh.setPosition(Vec.getNewRandomPosInXYPlane(camera.getPosition(), 5, 20));
}
});

Expand All @@ -82,22 +80,18 @@ public void onObjectIsCloseToCamera(GLCamera myCamera2, Obj obj,
}

@Override
public void _c_addActionsToEvents(EventManager eventManager,
CustomGLSurfaceView arView, SystemUpdater worldUpdater) {
ActionMoveCameraBuffered move = new ActionMoveCameraBuffered(camera, 5,
25);
public void _c_addActionsToEvents(EventManager eventManager, CustomGLSurfaceView arView, SystemUpdater worldUpdater) {
ActionMoveCameraBuffered move = new ActionMoveCameraBuffered(camera, 5, 25);
arView.addOnTouchMoveAction(move);
eventManager.addOnTrackballAction(move);
Action rot = new ActionRotateCameraBuffered(camera);
worldUpdater.addObjectToUpdateCycle(rot);
eventManager.addOnOrientationChangedAction(rot);
eventManager.addOnLocationChangedAction(new ActionCalcRelativePos(
world, camera));
eventManager.addOnLocationChangedAction(new ActionCalcRelativePos(world, camera));
}

@Override
public void _d_addElementsToUpdateThread(SystemUpdater worldUpdater) {

worldUpdater.addObjectToUpdateCycle(world);
}

Expand All @@ -107,10 +101,8 @@ public void _e2_addElementsToGuiSetup(GuiSetup guiSetup, Activity context) {

@Override
public void _f_addInfoScreen(InfoScreenSettings infoScreenData) {
infoScreenData
.addText("There will an object spawned close to you which you have to collect!");
infoScreenData
.addTextWithIcon(
infoScreenData.addText("There will an object spawned close to you which you have to collect!");
infoScreenData.addTextWithIcon(
R.drawable.infoboxblue,
"Step into the red area to collect the object. A counter will signalize how often you collected the object. Instead of actually walking to the object you can simulate movement by using the trackball or the touchscreen.");
}
Expand Down
13 changes: 4 additions & 9 deletions TechDemo/src/main/java/de/rwth/setups/DebugSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,22 +395,17 @@ public boolean execute() {
addCameraButtons(guiSetup);
}

private Command newCommandAddAnimation(final Wrapper meshWrapper,
final GLAnimation animation) {
private Command newCommandAddAnimation(final Wrapper meshWrapper, final GLAnimation animation) {
return new Command() {

@Override
public boolean execute() {
if (meshWrapper.getObject() instanceof MeshComponent) {
((MeshComponent) meshWrapper.getObject())
.addAnimation(animation);
Log.e(LOG_TAG,
"Added " + animation + " to "
+ meshWrapper.getObject());
((MeshComponent) meshWrapper.getObject()).addAnimation(animation);
Log.e(LOG_TAG, "Added " + animation + " to " + meshWrapper.getObject());
return true;
}
Log.e(LOG_TAG,
"Cant add animation to " + meshWrapper.getObject());
Log.e(LOG_TAG, "Cant add animation to " + meshWrapper.getObject());
return false;
}
};
Expand Down
12 changes: 4 additions & 8 deletions TechDemo/src/main/java/de/rwth/setups/TimeModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public void setMyParent(Updateable parent) {
public boolean update(float timeDelta, Updateable parent) {
setMyParent(parent);
if (different(myCurrentFactor, myNewFactor))
myCurrentFactor = Calculus.morphToNewValue(timeDelta
* myAdjustmentSpeed, myNewFactor, myCurrentFactor);
myCurrentFactor = Calculus.morphToNewValue(timeDelta * myAdjustmentSpeed, myNewFactor, myCurrentFactor);
else
myCurrentFactor = myNewFactor;
if (myCurrentFactor == 0)
Expand All @@ -67,17 +66,14 @@ private boolean different(float a, float b) {

@Override
public boolean accept(Visitor visitor) {
if (myChild != null)
return myChild.accept(visitor);

if (myChild != null) return myChild.accept(visitor);
Log.e(LOG_TAG, "Child was not set");
return false;
}

@Override
public void render(/*GL10 gl,*/ GLES20 unused, Renderable parent) {
if (myChild != null)
myChild.render(,/*gl,*/ parent);
public void render(GLES20 unused, Renderable parent) {
if (myChild != null) myChild.render(unused, parent);
else
Log.e(LOG_TAG, "Child was not set");
}
Expand Down
4 changes: 2 additions & 2 deletions droidar/src/main/java/gl/GL1Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ public void enableLights(GLES20 unused) {
if (!myLights.isEmpty()) {
glEnable(GLES10.GL_LIGHTING);
for (int i = 0; i < myLights.size(); i++) {
myLights.get(i).switchOn(/*gl*/);
myLights.get(i).switchOn(unused);
}
}
}

public void disableLights(GLES20 unused) {
glDisable(GLES10.GL_LIGHTING);
for (int i = 0; i < myLights.size(); i++) {
myLights.get(i).switchOff(/*gl*/unused);
myLights.get(i).switchOff(unused);
}
}

Expand Down
2 changes: 0 additions & 2 deletions droidar/src/main/java/system/CameraView.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public void setPreviewAccordingToScreenOrientation(int width, int height) {
Display display = ((WindowManager) this.getContext().getSystemService(Activity.WINDOW_SERVICE)).getDefaultDisplay();
/*
* int rotation = display.getRotation();
*
* this does not work on older devices so use reflection
*/
int rotation = 0;
Expand Down Expand Up @@ -106,7 +105,6 @@ public void setPreviewAccordingToScreenOrientation(int width, int height) {
private void setDisplayOrientation(int inDegree) {
/*
* myCamera.setDisplayOrientation(inDegree);
*
* does not work on older devices so use reflection
*/
try {
Expand Down
10 changes: 4 additions & 6 deletions droidar/src/main/java/util/Calculus.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public static float varyValueByPercent(float value, int percentToVary) {
* @param mOffset
* @return
*/
public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
int mOffset) {
public static boolean invertM(float[] mInv, int mInvOffset, float[] m, int mOffset) {
// Invert a 4 x 4 matrix using Cramer's Rule

// transpose matrix
Expand Down Expand Up @@ -120,6 +119,7 @@ public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
}

public interface TermResultListener {
@android.webkit.JavascriptInterface
void returnResult(String result);
}

Expand All @@ -132,13 +132,11 @@ public interface TermResultListener {
* @param resultListener
*/
@Deprecated
public static void calculateTermResult(Context context, String inputTerm,
TermResultListener resultListener) {
public static void calculateTermResult(Context context, String inputTerm, TermResultListener resultListener) {
WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(resultListener, "JavaCallback");
webView.loadUrl("javascript:window.JavaCallback" + ".returnResult("
+ inputTerm + ")");
webView.loadUrl("javascript:window.JavaCallback" + ".returnResult("+ inputTerm + ")");
}

public static float[] createIdentityMatrix() {
Expand Down
9 changes: 3 additions & 6 deletions droidar/src/main/java/worldData/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public boolean add(RenderableEntity x) {
if (x == null) {
return false;
}
if (container == null)
container = new EfficientList<>();
if (container == null) container = new EfficientList<>();
/*
* check if obj already added before adding it to the world!
*/
Expand All @@ -61,9 +60,9 @@ public boolean add(RenderableEntity x) {
return container.add(x);
}

private void glLoadScreenPosition(/*GL10 gl*/GLES20 unused) {
private void glLoadScreenPosition(GLES20 unused) {
if (myScreenPosition != null)
/*gl.*/glTranslatef(myScreenPosition.x, myScreenPosition.y, myScreenPosition.z);
glTranslatef(myScreenPosition.x, myScreenPosition.y, myScreenPosition.z);
}

// private void glLoadRotation(GL10 gl) {
Expand Down Expand Up @@ -94,9 +93,7 @@ public void render(GLES20 unused, Renderable parent) {
glLoadScale(unused);

// TODO remove the coordinate axes here:

CoordinateAxis.draw(unused);

drawElements(unused, myCamera);
}

Expand Down

0 comments on commit 78213a9

Please sign in to comment.