mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Tango: updated UI
This commit is contained in:
@@ -298,7 +298,11 @@ int RTABMapApp::openDatabase(const std::string & databasePath, bool databaseInMe
|
||||
optTexture_ = cv::Mat();
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(!databaseSource.empty())
|
||||
@@ -1051,6 +1055,7 @@ int RTABMapApp::Render()
|
||||
pcl::fromPCLPointCloud2(optMesh_->cloud, *mesh.cloud);
|
||||
pcl::fromPCLPointCloud2(optMesh_->cloud, *mesh.normals);
|
||||
mesh.polygons = optMesh_->tex_polygons[0];
|
||||
mesh.pose.setIdentity();
|
||||
if(optMesh_->tex_coordinates.size())
|
||||
{
|
||||
mesh.texCoords = optMesh_->tex_coordinates[0];
|
||||
@@ -1568,7 +1573,7 @@ int RTABMapApp::Render()
|
||||
if(rtabmapEvents.size())
|
||||
{
|
||||
// send statistics to GUI
|
||||
LOGW("Posting PostRenderEvent! %fs", renderingTime_);
|
||||
LOGI("New data added to map, rendering time: %fs", renderingTime_);
|
||||
UEventsManager::post(new PostRenderEvent(rtabmapEvents.back()));
|
||||
rtabmapEvents.pop_back();
|
||||
|
||||
@@ -1740,6 +1745,10 @@ void RTABMapApp::setOrthoCropFactor(float value)
|
||||
{
|
||||
main_scene_.setOrthoCropFactor(value);
|
||||
}
|
||||
void RTABMapApp::setGridRotation(float value)
|
||||
{
|
||||
main_scene_.setGridRotation(value);
|
||||
}
|
||||
void RTABMapApp::setLighting(bool enabled)
|
||||
{
|
||||
main_scene_.setLighting(enabled);
|
||||
@@ -2764,7 +2773,11 @@ bool RTABMapApp::postExportation(bool visualize)
|
||||
{
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(rtabmap_ && rtabmap_->getMemory())
|
||||
@@ -2801,7 +2814,11 @@ bool RTABMapApp::writeExportedMesh(const std::string & directory, const std::str
|
||||
pcl::TextureMesh::Ptr textureMesh(new pcl::TextureMesh);
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(rtabmap_ && rtabmap_->getMemory())
|
||||
|
||||
@@ -121,6 +121,7 @@ class RTABMapApp : public UEventsHandler {
|
||||
void setPointSize(float value);
|
||||
void setFOV(float angle);
|
||||
void setOrthoCropFactor(float value);
|
||||
void setGridRotation(float value);
|
||||
void setLighting(bool enabled);
|
||||
void setBackfaceCulling(bool enabled);
|
||||
void setWireframe(bool enabled);
|
||||
|
||||
@@ -180,6 +180,12 @@ Java_com_introlab_rtabmap_RTABMapLib_setOrthoCropFactor(
|
||||
return app.setOrthoCropFactor(value);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_introlab_rtabmap_RTABMapLib_setGridRotation(
|
||||
JNIEnv*, jobject, float value)
|
||||
{
|
||||
return app.setGridRotation(value);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_introlab_rtabmap_RTABMapLib_setLighting(
|
||||
JNIEnv*, jobject, bool enabled)
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ private:
|
||||
bool isVisible() const {return visible_;}
|
||||
bool hasMesh() const {return polygons_.size()!=0;}
|
||||
bool hasTexture() const {return textures_ != 0;}
|
||||
float getMinHeight() const {return minHeight_;}
|
||||
const pcl::PointXYZ & aabbMinModel() const {return aabbMinModel_;}
|
||||
const pcl::PointXYZ & aabbMaxModel() const {return aabbMaxModel_;}
|
||||
const pcl::PointXYZ & aabbMinWorld() const {return aabbMinWorld_;}
|
||||
@@ -126,6 +127,7 @@ private:
|
||||
bool visible_;
|
||||
bool hasNormals_;
|
||||
std::vector<unsigned int> organizedToDenseIndices_;
|
||||
float minHeight_; // odom frame
|
||||
|
||||
float gainR_;
|
||||
float gainG_;
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
|
||||
#include <tango-gl/conversions.h>
|
||||
#include <tango-gl/gesture_camera.h>
|
||||
#include <tango-gl/util.h>
|
||||
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
#include <rtabmap/utilite/UStl.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/core/util3d_filtering.h>
|
||||
#include <rtabmap/core/util3d_transforms.h>
|
||||
#include <rtabmap/core/util3d_surface.h>
|
||||
#include <pcl/common/transforms.h>
|
||||
#include <pcl/common/common.h>
|
||||
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
@@ -32,7 +36,7 @@
|
||||
// add an offset in z to our origin. We'll set this offset to 1.3 meters based
|
||||
// on the average height of a human standing with a Tango device. This allows us
|
||||
// to place a grid roughly on the ground for most users.
|
||||
const glm::vec3 kHeightOffset = glm::vec3(0.0f, 1.3f, 0.0f);
|
||||
const glm::vec3 kHeightOffset = glm::vec3(0.0f, -1.3f, 0.0f);
|
||||
|
||||
// Color of the motion tracking trajectory.
|
||||
const tango_gl::Color kTraceColor(0.66f, 0.66f, 0.66f);
|
||||
@@ -130,7 +134,7 @@ void Scene::InitGLContent()
|
||||
trace_->ClearVertexArray();
|
||||
trace_->SetColor(kTraceColor);
|
||||
grid_->SetColor(kGridColor);
|
||||
grid_->SetPosition(-kHeightOffset);
|
||||
grid_->SetPosition(kHeightOffset);
|
||||
box_->SetShader();
|
||||
box_->SetColor(1,0,0);
|
||||
|
||||
@@ -194,6 +198,10 @@ void Scene::clear()
|
||||
graph_ = 0;
|
||||
}
|
||||
pointClouds_.clear();
|
||||
if(grid_)
|
||||
{
|
||||
grid_->SetPosition(kHeightOffset);
|
||||
}
|
||||
}
|
||||
|
||||
//Should only be called in OpenGL thread!
|
||||
@@ -565,6 +573,15 @@ void Scene::setOrthoCropFactor(float value)
|
||||
{
|
||||
gesture_camera_->SetOrthoCropFactor(value);
|
||||
}
|
||||
void Scene::setGridRotation(float angleDeg)
|
||||
{
|
||||
float angleRad = angleDeg * DEGREE_2_RADIANS;
|
||||
if(grid_)
|
||||
{
|
||||
glm::quat rot = glm::rotate(glm::quat(1,0,0,0), angleRad, glm::vec3(0, 1, 0));
|
||||
grid_->SetRotation(rot);
|
||||
}
|
||||
}
|
||||
|
||||
rtabmap::Transform Scene::GetOpenGLCameraPose(float * fov) const
|
||||
{
|
||||
@@ -669,6 +686,58 @@ void Scene::addMesh(
|
||||
PointCloudDrawable * drawable = new PointCloudDrawable(mesh, createWireframe);
|
||||
drawable->setPose(pose);
|
||||
pointClouds_.insert(std::make_pair(id, drawable));
|
||||
|
||||
if(!mesh.pose.isNull() && mesh.cloud->size() && (!mesh.cloud->isOrganized() || mesh.indices->size()))
|
||||
{
|
||||
UTimer time;
|
||||
float height = 0.0f;
|
||||
Eigen::Affine3f affinePose = mesh.pose.toEigen3f();
|
||||
if(mesh.polygons.size())
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.polygons.size(); ++i)
|
||||
{
|
||||
for(unsigned int j=0; j<mesh.polygons[i].vertices.size(); ++j)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(mesh.polygons[i].vertices[j]), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mesh.cloud->isOrganized())
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.indices->size(); ++i)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(mesh.indices->at(i)), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.cloud->size(); ++i)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(i), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(grid_->GetPosition().y == kHeightOffset.y || grid_->GetPosition().y > height)
|
||||
{
|
||||
grid_->SetPosition(glm::vec3(0,height,0));
|
||||
}
|
||||
LOGD("compute min height %f s", time.ticks());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ class Scene {
|
||||
void setPointSize(float size) {pointSize_ = size;}
|
||||
void setFOV(float angle);
|
||||
void setOrthoCropFactor(float value);
|
||||
void setGridRotation(float angleDeg);
|
||||
void setLighting(bool enabled) {lighting_ = enabled;}
|
||||
void setBackfaceCulling(bool enabled) {backfaceCulling_ = enabled;}
|
||||
void setWireframe(bool enabled) {wireFrame_ = enabled;}
|
||||
|
||||
12
app/android/res/drawable/custom_seekbar.xml
Normal file
12
app/android/res/drawable/custom_seekbar.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:endColor="#00ffffff"
|
||||
android:startColor="#ff686868"
|
||||
android:useLevel="false" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<ToggleButton
|
||||
@@ -35,7 +35,7 @@
|
||||
android:layout_above="@+id/light_button"
|
||||
android:layout_alignLeft="@+id/light_button"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/wireframe"
|
||||
@@ -48,7 +48,7 @@
|
||||
android:layout_above="@+id/backface_button"
|
||||
android:layout_alignLeft="@+id/backface_button"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/light_off"
|
||||
@@ -58,56 +58,33 @@
|
||||
android:id="@+id/backface_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/first_person_button"
|
||||
android:layout_alignLeft="@+id/first_person_button"
|
||||
android:layout_above="@+id/camera_button"
|
||||
android:layout_alignRight="@+id/camera_button"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/backface_off"
|
||||
android:textOn="@string/backface_on" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/first_person_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/third_person_button"
|
||||
android:layout_alignLeft="@+id/third_person_button"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/first_person"
|
||||
android:textOn="@string/first_person" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/third_person_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/top_down_button"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/third_person"
|
||||
android:textOn="@string/third_person" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/top_down_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
<com.introlab.rtabmap.NDSpinner
|
||||
android:id="@+id/camera_button"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:paddingRight="5dp"
|
||||
android:textOff="@string/top_down"
|
||||
android:textOn="@string/top_down" />
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/camera_button"
|
||||
android:spinnerMode="dropdown"/>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/pause_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/first_person_button"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="61dp"
|
||||
android:layout_alignParentRight="true"
|
||||
@@ -135,10 +112,8 @@
|
||||
android:id="@+id/close_visualization_button"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/top_down_button"
|
||||
android:layout_alignBottom="@+id/top_down_button"
|
||||
android:layout_above="@+id/camera_button"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="@string/close_visualization" />
|
||||
|
||||
<SeekBar
|
||||
@@ -146,10 +121,23 @@
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:rotation="270"
|
||||
android:layout_above="@+id/light_button"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignBaseline="@+id/first_person_button"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="-50dp" />
|
||||
android:layout_marginLeft="-50dp"
|
||||
android:progressDrawable="@drawable/custom_seekbar" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar_grid"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignBottom="@+id/camera_button"
|
||||
android:layout_marginLeft="35dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:progressDrawable="@drawable/custom_seekbar" />
|
||||
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
9
app/android/res/values/arrays.xml
Normal file
9
app/android/res/values/arrays.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
<resources>
|
||||
<string-array name="camera_view_array">
|
||||
<item>First View</item>
|
||||
<item>Third-P. View</item>
|
||||
<item>Top View</item>
|
||||
<item>Ortho View</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -8,9 +8,7 @@
|
||||
<string name="sketchfab">Upload to Sketchfab…</string>
|
||||
<string name="status">"Status: "</string>
|
||||
<string name="words">"Words: "</string>
|
||||
<string name="first_person">First</string>
|
||||
<string name="third_person">Third</string>
|
||||
<string name="top_down">Top</string>
|
||||
<string name="camera_button">First View</string>
|
||||
<string name="pause">Pause</string>
|
||||
<string name="resume">Resume</string>
|
||||
<string name="backface_on">Backface</string>
|
||||
@@ -36,7 +34,7 @@
|
||||
<string name="memory">"Used Memory (MB): "</string>
|
||||
<string name="hypothesis">"Hypothesis (%): "</string>
|
||||
<string name="fps">"FPS (rendering): "</string>
|
||||
|
||||
|
||||
<!-- Preference keys: BEGIN -->
|
||||
<string name="pref_key_tags">pref_key_tags</string>
|
||||
<string name="pref_default_tags">rtabmap 3dscan tango</string>
|
||||
|
||||
43
app/android/src/com/introlab/rtabmap/NDSpinner.java
Normal file
43
app/android/src/com/introlab/rtabmap/NDSpinner.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.introlab.rtabmap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Spinner;
|
||||
|
||||
|
||||
/** Spinner extension that calls onItemSelected even when the selection is the same as its previous value
|
||||
Author: Mattia Ruggiero
|
||||
https://stackoverflow.com/questions/5335306/how-can-i-get-an-event-in-android-spinner-when-the-current-selected-item-is-sele
|
||||
*/
|
||||
public class NDSpinner extends Spinner {
|
||||
|
||||
public NDSpinner(Context context)
|
||||
{ super(context); }
|
||||
|
||||
public NDSpinner(Context context, AttributeSet attrs)
|
||||
{ super(context, attrs); }
|
||||
|
||||
public NDSpinner(Context context, AttributeSet attrs, int defStyle)
|
||||
{ super(context, attrs, defStyle); }
|
||||
|
||||
@Override
|
||||
public void setSelection(int position, boolean animate) {
|
||||
boolean sameSelected = position == getSelectedItemPosition();
|
||||
super.setSelection(position, animate);
|
||||
if (sameSelected) {
|
||||
// Spinner does not call the OnItemSelectedListener if the same item is selected, so do it manually now
|
||||
//getOnItemSelectedListener().onItemSelected(this, getSelectedView(), position, getSelectedItemId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(int position) {
|
||||
boolean sameSelected = position == getSelectedItemPosition();
|
||||
super.setSelection(position);
|
||||
if (sameSelected) {
|
||||
// Spinner does not call the OnItemSelectedListener if the same item is selected, so do it manually now
|
||||
getOnItemSelectedListener().onItemSelected(this, getSelectedView(), position, getSelectedItemId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,6 +89,9 @@ import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -96,6 +99,7 @@ import android.widget.NumberPicker;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
@@ -104,7 +108,7 @@ import com.google.atap.tangoservice.Tango;
|
||||
|
||||
// The main activity of the application. This activity shows debug information
|
||||
// and a glSurfaceView that renders graphic content.
|
||||
public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
public class RTABMapActivity extends Activity implements OnClickListener, OnItemSelectedListener {
|
||||
|
||||
// Tag for debug logging.
|
||||
public static final String TAG = RTABMapActivity.class.getSimpleName();
|
||||
@@ -134,7 +138,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
|
||||
public static final long NOTOUCH_TIMEOUT = 5000; // 5 sec
|
||||
private boolean mHudVisible = true;
|
||||
private boolean mTipOrthoShown_ = false;
|
||||
private int mSavedRenderingType = 0;
|
||||
private boolean mMenuOpened = false;
|
||||
|
||||
@@ -182,9 +185,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
private MenuItem mItemStatusVisibility;
|
||||
private MenuItem mItemDebugVisibility;
|
||||
|
||||
private ToggleButton mButtonFirst;
|
||||
private ToggleButton mButtonThird;
|
||||
private ToggleButton mButtonTop;
|
||||
private NDSpinner mButtonCameraView;
|
||||
private ToggleButton mButtonPause;
|
||||
private ToggleButton mButtonLighting;
|
||||
private ToggleButton mButtonWireframe;
|
||||
@@ -193,6 +194,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
private Button mButtonSaveOnDevice;
|
||||
private Button mButtonShareOnSketchfab;
|
||||
private SeekBar mSeekBarFov;
|
||||
private SeekBar mSeekBarGrid;
|
||||
|
||||
private String mOpenedDatabasePath = "";
|
||||
private String mWorkingDirectory = "";
|
||||
@@ -267,9 +269,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mActionBarHeight = getActionBarHeight();
|
||||
|
||||
// Buttons for selecting camera view and Set up button click listeners.
|
||||
mButtonFirst = (ToggleButton)findViewById(R.id.first_person_button);
|
||||
mButtonThird = (ToggleButton)findViewById(R.id.third_person_button);
|
||||
mButtonTop = (ToggleButton)findViewById(R.id.top_down_button);
|
||||
mButtonCameraView = (NDSpinner)findViewById(R.id.camera_button);
|
||||
mButtonPause = (ToggleButton)findViewById(R.id.pause_button);
|
||||
mButtonLighting = (ToggleButton)findViewById(R.id.light_button);
|
||||
mButtonWireframe = (ToggleButton)findViewById(R.id.wireframe_button);
|
||||
@@ -277,9 +277,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mButtonCloseVisualization = (Button)findViewById(R.id.close_visualization_button);
|
||||
mButtonSaveOnDevice = (Button)findViewById(R.id.button_saveOnDevice);
|
||||
mButtonShareOnSketchfab = (Button)findViewById(R.id.button_shareToSketchfab);
|
||||
mButtonFirst.setOnClickListener(this);
|
||||
mButtonThird.setOnClickListener(this);
|
||||
mButtonTop.setOnClickListener(this);
|
||||
mButtonCameraView.setOnItemSelectedListener(this);
|
||||
mButtonPause.setOnClickListener(this);
|
||||
mButtonLighting.setOnClickListener(this);
|
||||
mButtonWireframe.setOnClickListener(this);
|
||||
@@ -287,7 +285,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mButtonCloseVisualization.setOnClickListener(this);
|
||||
mButtonSaveOnDevice.setOnClickListener(this);
|
||||
mButtonShareOnSketchfab.setOnClickListener(this);
|
||||
mButtonFirst.setChecked(true);
|
||||
mButtonLighting.setChecked(false);
|
||||
mButtonLighting.setVisibility(View.INVISIBLE);
|
||||
mButtonWireframe.setChecked(false);
|
||||
@@ -300,17 +297,28 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mButtonBackfaceShown.setVisibility(mItemRenderingMesh.isChecked() || mItemRenderingTextureMesh.isChecked()?View.VISIBLE:View.INVISIBLE);
|
||||
}
|
||||
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.camera_view_array, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mButtonCameraView.setAdapter(adapter);
|
||||
mButtonCameraView.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
resetNoTouchTimer();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mSeekBarFov = (SeekBar)findViewById(R.id.seekBar_fov);
|
||||
mSeekBarFov.setMax(45);
|
||||
mSeekBarFov.setProgress(20);
|
||||
mSeekBarFov.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
|
||||
if(mButtonFirst.isChecked())
|
||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||
{
|
||||
RTABMapLib.setFOV((float)progressValue+45.0f);
|
||||
}
|
||||
else if(mButtonTop.isChecked())
|
||||
else if(mButtonCameraView.getSelectedItemPosition() == 3)
|
||||
{
|
||||
RTABMapLib.setOrthoCropFactor((float)(120-progressValue)/20.0f - 3.0f);
|
||||
}
|
||||
@@ -325,6 +333,25 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
mSeekBarGrid = (SeekBar)findViewById(R.id.seekBar_grid);
|
||||
mSeekBarGrid.setMax(180);
|
||||
mSeekBarGrid.setProgress(90);
|
||||
mSeekBarGrid.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
|
||||
RTABMapLib.setGridRotation(((float)progressValue-90.0f)/2.0f);
|
||||
resetNoTouchTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
mToast = Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT);
|
||||
|
||||
@@ -714,13 +741,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
updateStatusTexts();
|
||||
|
||||
RTABMapLib.setCamera(type);
|
||||
mButtonFirst.setChecked(type==0);
|
||||
mButtonThird.setChecked(type==1);
|
||||
mButtonTop.setChecked(type==2 || type==3);
|
||||
mButtonTop.setText(type==3?"Ortho":"Top");
|
||||
mButtonTop.setTextOn(type==3?"Ortho":"Top");
|
||||
mButtonTop.setTextOff(type==3?"Ortho":"Top");
|
||||
mButtonCameraView.setSelection(type, true);
|
||||
mSeekBarFov.setVisibility(type!=0 && type!=3?View.INVISIBLE:View.VISIBLE);
|
||||
mSeekBarGrid.setVisibility(mSeekBarGrid.isEnabled() && type==3?View.VISIBLE:View.INVISIBLE);
|
||||
if(type==0)
|
||||
{
|
||||
mSeekBarFov.setMax(45);
|
||||
@@ -731,28 +754,12 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mSeekBarFov.setMax(120);
|
||||
mSeekBarFov.setProgress(80);
|
||||
}
|
||||
|
||||
if(type==2 && !mTipOrthoShown_)
|
||||
{
|
||||
mToast.makeText(this, "Tip: Click again on Top to set Ortho mode.", mToast.LENGTH_LONG).show();
|
||||
mTipOrthoShown_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Handle button clicks.
|
||||
switch (v.getId()) {
|
||||
case R.id.first_person_button:
|
||||
setCamera(0);
|
||||
|
||||
break;
|
||||
case R.id.third_person_button:
|
||||
setCamera(1);
|
||||
break;
|
||||
case R.id.top_down_button:
|
||||
setCamera(mButtonFirst.isChecked() || mButtonThird.isChecked() || mButtonTop.getTextOn().equals("Ortho")?2:3);
|
||||
break;
|
||||
case R.id.pause_button:
|
||||
pauseMapping();
|
||||
break;
|
||||
@@ -792,6 +799,15 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
}
|
||||
resetNoTouchTimer();
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
|
||||
setCamera(pos);
|
||||
resetNoTouchTimer();
|
||||
}
|
||||
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
resetNoTouchTimer();
|
||||
}
|
||||
|
||||
private void setAndroidOrientation() {
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
@@ -1146,9 +1162,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
}
|
||||
|
||||
updateState(State.STATE_VISUALIZING_WHILE_LOADING);
|
||||
if(mButtonFirst.isChecked())
|
||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||
{
|
||||
setCamera(1);
|
||||
setCamera(2);
|
||||
}
|
||||
mToast.makeText(getActivity(), String.format("Optimized mesh detected in the database, it is shown while the database is loading..."), mToast.LENGTH_LONG).show();
|
||||
mProgressDialog.dismiss();
|
||||
@@ -1438,11 +1454,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
mItemDataRecorderMode.setEnabled(mButtonPause.isChecked());
|
||||
break;
|
||||
}
|
||||
mButtonFirst.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||
mButtonThird.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||
mButtonTop.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||
mButtonCameraView.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
|
||||
mButtonBackfaceShown.setVisibility(mHudVisible && (mItemRenderingMesh.isChecked() || mItemRenderingTextureMesh.isChecked())?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarFov.setVisibility(mHudVisible && (mButtonFirst.isChecked() || (mButtonTop.isChecked() && mButtonTop.getTextOn().equals("Ortho")))?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarFov.setVisibility(mHudVisible && (mButtonCameraView.getSelectedItemPosition() == 0 || mButtonCameraView.getSelectedItemPosition() == 3)?View.VISIBLE:View.INVISIBLE);
|
||||
mSeekBarGrid.setVisibility(mHudVisible && mSeekBarGrid.isEnabled() && mButtonCameraView.getSelectedItemPosition() == 3?View.VISIBLE:View.INVISIBLE);
|
||||
}
|
||||
|
||||
private void pauseMapping() {
|
||||
@@ -1682,6 +1697,8 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
else if(itemId == R.id.grid_visible)
|
||||
{
|
||||
item.setChecked(!item.isChecked());
|
||||
mSeekBarGrid.setEnabled(item.isChecked());
|
||||
mSeekBarGrid.setVisibility(mHudVisible && mSeekBarGrid.isEnabled()&&mButtonCameraView.getSelectedItemPosition() == 3?View.VISIBLE:View.INVISIBLE);
|
||||
RTABMapLib.setGridVisible(item.isChecked());
|
||||
}
|
||||
else if (itemId == R.id.save)
|
||||
@@ -2069,7 +2086,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
}
|
||||
updateState(State.STATE_VISUALIZING);
|
||||
RTABMapLib.postExportation(true);
|
||||
if(mButtonFirst.isChecked())
|
||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||
{
|
||||
setCamera(2);
|
||||
}
|
||||
@@ -2441,9 +2458,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
|
||||
}
|
||||
else if(!mItemTrajectoryMode.isChecked())
|
||||
{
|
||||
if(mButtonFirst.isChecked())
|
||||
if(mButtonCameraView.getSelectedItemPosition() == 0)
|
||||
{
|
||||
setCamera(1);
|
||||
setCamera(2);
|
||||
}
|
||||
// creating meshes...
|
||||
updateState(State.STATE_IDLE);
|
||||
|
||||
@@ -80,6 +80,7 @@ public class RTABMapLib
|
||||
public static native void setPointSize(float value);
|
||||
public static native void setFOV(float value);
|
||||
public static native void setOrthoCropFactor(float value);
|
||||
public static native void setGridRotation(float value);
|
||||
public static native void setLighting(boolean enabled);
|
||||
public static native void setBackfaceCulling(boolean enabled);
|
||||
public static native void setWireframe(boolean enabled);
|
||||
|
||||
Reference in New Issue
Block a user