diff --git a/androidgcs/AndroidManifest.xml b/androidgcs/AndroidManifest.xml
index f697bc43a..f11682869 100644
--- a/androidgcs/AndroidManifest.xml
+++ b/androidgcs/AndroidManifest.xml
@@ -26,7 +26,7 @@
@@ -42,6 +42,7 @@
+
@@ -68,7 +69,10 @@
android:name="Logger"
android:label="Logger"
android:theme="@android:style/Theme.Dialog" />
-
+
+
diff --git a/androidgcs/jni/OsgMainApp.cpp b/androidgcs/jni/OsgMainApp.cpp
index 681af1d7e..e1fb363b8 100644
--- a/androidgcs/jni/OsgMainApp.cpp
+++ b/androidgcs/jni/OsgMainApp.cpp
@@ -1,5 +1,5 @@
#include "OsgMainApp.hpp"
-
+#include
OsgMainApp::OsgMainApp(){
@@ -41,7 +41,17 @@ void OsgMainApp::loadModels(){
loadedModel->getOrCreateStateSet()->setAttribute ( prog );
- _root->addChild(loadedModel);
+ // Woohoo leaky code. This no longer works for multiple models
+ uavAttitudeAndScale = new osg::MatrixTransform();
+ uavAttitudeAndScale->setMatrix(osg::Matrixd::scale(0.2e0,0.2e0,0.2e0));
+
+ osg::MatrixTransform *rotateModelNED = new osg::MatrixTransform();
+ rotateModelNED->setMatrix(osg::Matrixd::scale(0.05e0,0.05e0,0.05e0) * osg::Matrixd::rotate(M_PI, osg::Vec3d(0,0,1)));
+ rotateModelNED->addChild( loadedModel );
+
+ uavAttitudeAndScale->addChild( rotateModelNED );
+
+ _root->addChild(uavAttitudeAndScale);
}
}
@@ -216,5 +226,15 @@ osg::Vec4f OsgMainApp::getClearColor(){
return _viewer->getCamera()->getClearColor();
}
-void OsgMainApp::setRPY(float x, float y, float z){
+void OsgMainApp::setQuat(float *q){
+ osg::Quat quat(q[1], q[2], q[3], q[0]);
+
+ // Have to rotate the axes from OP NED frame to OSG frame (X east, Y north, Z down)
+ double angle;
+ osg::Vec3d axis;
+ quat.getRotate(angle,axis);
+ quat.makeRotate(angle, osg::Vec3d(axis[1],axis[0],-axis[2]));
+ osg::Matrixd rot = osg::Matrixd::rotate(quat);
+
+ uavAttitudeAndScale->setMatrix(rot);
}
diff --git a/androidgcs/jni/OsgMainApp.hpp b/androidgcs/jni/OsgMainApp.hpp
index fbb6ee58c..a1a974659 100644
--- a/androidgcs/jni/OsgMainApp.hpp
+++ b/androidgcs/jni/OsgMainApp.hpp
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#include
#include
//osgText
@@ -178,7 +179,8 @@ public:
osg::Vec4f getClearColor();
//Manipulating the view
- void setRPY(float x, float y, float z);
+ void setQuat(float *q);
+ osg::MatrixTransform *uavAttitudeAndScale;
};
diff --git a/androidgcs/jni/osgNativeLib.cpp b/androidgcs/jni/osgNativeLib.cpp
index 734e80bd5..2cc115491 100644
--- a/androidgcs/jni/osgNativeLib.cpp
+++ b/androidgcs/jni/osgNativeLib.cpp
@@ -22,7 +22,7 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_loadObject(JNIEnv * env, jobject obj, jstring address);
JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_unLoadObject(JNIEnv * env, jobject obj, jint number);
JNIEXPORT jobjectArray JNICALL Java_org_openpilot_osg_osgNativeLib_getObjectNames(JNIEnv * env, jobject obj);
- JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_setRPY(JNIEnv * env, jobject obj, jfloat roll, jfloat pitch, jfloat yaw);
+ JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_setRPY(JNIEnv * env, jobject obj, jfloat q1, jfloat q2, jfloat q3, jfloat q4);
};
JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_init(JNIEnv * env, jobject obj, jint width, jint height){
@@ -113,6 +113,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_openpilot_osg_osgNativeLib_getObjectName
return fileNames;
}
-JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_setRPY(JNIEnv * env, jobject obj, jfloat roll, jfloat pitch, jfloat yaw){
- mainApp.setRPY(roll,pitch,yaw);
+JNIEXPORT void JNICALL Java_org_openpilot_osg_osgNativeLib_setRPY(JNIEnv * env, jobject obj, jfloat q1, jfloat q2, jfloat q3, jfloat q4){
+ float q[4] = {q1, q2, q3, q4};
+ mainApp.setQuat(q);
}
diff --git a/androidgcs/res/layout/gcs_home.xml b/androidgcs/res/layout/gcs_home.xml
index 82f638b98..1c0e24c35 100644
--- a/androidgcs/res/layout/gcs_home.xml
+++ b/androidgcs/res/layout/gcs_home.xml
@@ -77,6 +77,18 @@
android:drawableTop="@drawable/ic_alarms"
android:text="@string/alarms" />
+
+
Alarms
TxRate:
RxRate:
+ 3DView
diff --git a/androidgcs/src/org/openpilot/androidgcs/HomePage.java b/androidgcs/src/org/openpilot/androidgcs/HomePage.java
index 12833df2f..ed6007ab2 100644
--- a/androidgcs/src/org/openpilot/androidgcs/HomePage.java
+++ b/androidgcs/src/org/openpilot/androidgcs/HomePage.java
@@ -83,6 +83,15 @@ public class HomePage extends ObjectManagerActivity {
startActivity(new Intent(HomePage.this, SystemAlarmActivity.class));
}
});
+
+ Button osgViewer = (Button) findViewById(R.id.launch_osgViewer);
+ osgViewer.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ startActivity(new Intent(HomePage.this, OsgViewer.class));
+ }
+ });
+
}
}
diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java b/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
index 8cd89e8d8..014b94331 100644
--- a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
+++ b/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
@@ -83,7 +83,7 @@ public abstract class ObjectManagerActivity extends Activity {
private HashMap listeners;
/** Called when the activity is first created. */
@Override
- public void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
diff --git a/androidgcs/src/org/openpilot/osg/osgViewer.java b/androidgcs/src/org/openpilot/androidgcs/OsgViewer.java
similarity index 97%
rename from androidgcs/src/org/openpilot/osg/osgViewer.java
rename to androidgcs/src/org/openpilot/androidgcs/OsgViewer.java
index 5246209be..4aaa6a6a0 100644
--- a/androidgcs/src/org/openpilot/osg/osgViewer.java
+++ b/androidgcs/src/org/openpilot/androidgcs/OsgViewer.java
@@ -1,8 +1,9 @@
-package org.openpilot.osg;
+package org.openpilot.androidgcs;
-import org.openpilot.androidgcs.R;
+import org.openpilot.osg.ColorPickerDialog;
+import org.openpilot.osg.EGLview;
+import org.openpilot.osg.osgNativeLib;
-import android.app.Activity;
import android.app.AlertDialog;
import android.graphics.Color;
import android.graphics.PointF;
@@ -20,7 +21,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;
-public class osgViewer extends Activity implements View.OnTouchListener, View.OnKeyListener, ColorPickerDialog.OnColorChangeListener {
+public class OsgViewer extends ObjectManagerActivity implements View.OnTouchListener, View.OnKeyListener, ColorPickerDialog.OnColorChangeListener {
enum moveTypes { NONE , DRAG, MDRAG, ZOOM ,ACTUALIZE}
enum navType { PRINCIPAL , SECONDARY }
enum lightType { ON , OFF }