Commit 90c2c164 authored by Xavier's avatar Xavier

Orbit views

parent 19058cf7
...@@ -109,6 +109,8 @@ ...@@ -109,6 +109,8 @@
var value_orbit_i = Math.PI/9; var value_orbit_i = Math.PI/9;
var value_orbit_w = Math.PI; var value_orbit_w = Math.PI;
var value_orbit_raan = 0; var value_orbit_raan = 0;
var locked_view = false;
//----------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------
...@@ -138,7 +140,17 @@ ...@@ -138,7 +140,17 @@
onRenderFcts.push(function(){ onRenderFcts.push(function(){
renderer.render( scene, camera ); renderer.render( scene, camera );
}) })
//////////////////////////////////////////////////////////////////////////////////
// VIEWS //
//////////////////////////////////////////////////////////////////////////////////
onRenderFcts.push(function(){
if(locked_view){
camera.position = value_spacecraft.clone().normalize().multiplyScalar(getCamDistance());
camera.lookAt(scene.position);
}
})
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// loop runner // // loop runner //
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
......
...@@ -159,3 +159,16 @@ function updateModelState(new_state){ ...@@ -159,3 +159,16 @@ function updateModelState(new_state){
//} //}
//} //}
} }
function changeView(view_mode){
switch(view_mode){
case "Free"://free
locked_view = false;
break;
case "Locked"://locked
locked_view = true;
break;
}
}
function getCamDistance(){
return Math.sqrt(camera.position.x*camera.position.x+camera.position.y*camera.position.y+camera.position.z*camera.position.z);
}
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
# Project target. # Project target.
target=android-19 target=android-19
android.library.reference.1=../android-support-v7-appcompat android.library.reference.1=../android-support-v7-appcompat
android.library.reference.2=../crosswalk-webview-7.36.154.8-arm android.library.reference.2=../crosswalk-webview-7.36.154.8-x86
...@@ -17,21 +17,6 @@ ...@@ -17,21 +17,6 @@
android:orientation="vertical" > android:orientation="vertical" >
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="3dp" >
<TextView
android:id="@+id/textViewFPS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fps_zero"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white" />
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/SimControlFrame" android:id="@+id/SimControlFrame"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -62,7 +47,37 @@ ...@@ -62,7 +47,37 @@
android:src="@drawable/stop" /> android:src="@drawable/stop" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<FrameLayout
android:id="@+id/spinnerlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonMissionNew"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/view_selector"
android:minHeight="30dp"
android:text="@string/menu_views_ref_frame_xyz"
android:textAppearance="?android:attr/textAppearanceSmall" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/spinnerlayout"
android:layout_marginLeft="3dp" >
<TextView
android:id="@+id/textViewFPS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fps_zero"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white" />
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/frameLayoutProgress" android:id="@+id/frameLayoutProgress"
...@@ -94,6 +109,5 @@ ...@@ -94,6 +109,5 @@
android:src="@drawable/ic_launcher" /> android:src="@drawable/ic_launcher" />
</FrameLayout> </FrameLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
<FrameLayout <FrameLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
android:layout_below="@id/spinnerlayout"
android:layout_marginLeft="3dp" > android:layout_marginLeft="3dp" >
<TextView <TextView
...@@ -62,6 +63,21 @@ ...@@ -62,6 +63,21 @@
android:src="@drawable/stop" /> android:src="@drawable/stop" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<FrameLayout
android:id="@+id/spinnerlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonMissionNew"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:background="@drawable/view_selector"
android:minHeight="45dp"
android:text="@string/menu_views_ref_frame_xyz"
android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/frameLayoutProgress" android:id="@+id/frameLayoutProgress"
......
...@@ -48,10 +48,26 @@ ...@@ -48,10 +48,26 @@
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<FrameLayout
android:id="@+id/spinnerlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonMissionNew"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:background="@drawable/view_selector"
android:minHeight="45dp"
android:text="@string/menu_views_ref_frame_xyz"
android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>
<FrameLayout <FrameLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@id/spinnerlayout"
android:layout_marginTop="3dp" > android:layout_marginTop="3dp" >
<TextView <TextView
...@@ -95,6 +111,5 @@ ...@@ -95,6 +111,5 @@
android:src="@drawable/ic_launcher" /> android:src="@drawable/ic_launcher" />
</FrameLayout> </FrameLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -48,10 +48,26 @@ ...@@ -48,10 +48,26 @@
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<FrameLayout
android:id="@+id/spinnerlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonMissionNew"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:background="@drawable/view_selector"
android:minHeight="30dp"
android:text="@string/menu_views_ref_frame_xyz"
android:textAppearance="?android:attr/textAppearanceSmall" />
</FrameLayout>
<FrameLayout <FrameLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@id/spinnerlayout"
android:layout_marginTop="3dp" > android:layout_marginTop="3dp" >
<TextView <TextView
......
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="cs.si.stavor.fragments.HudFragment" >
<item
android:id="@+id/menu_orbviews_free"
android:title="@string/menu_orbviews_free"
app:showAsAction="never"/>
<item
android:id="@+id/menu_orbviews_locked"
android:title="@string/menu_orbviews_locked"
app:showAsAction="never"/>
</menu>
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
<string name="menu_views_earth">Tierra</string> <string name="menu_views_earth">Tierra</string>
<string name="menu_views_sun">Sol</string> <string name="menu_views_sun">Sol</string>
<string name="menu_orbviews_free">Libre</string>
<string name="menu_orbviews_locked">Agarrado</string>
<string name="about">Acerca de</string> <string name="about">Acerca de</string>
<string name="cs_site">http://c-s.fr/</string> <string name="cs_site">http://c-s.fr/</string>
<string name="about_table_project">Proyecto</string> <string name="about_table_project">Proyecto</string>
......
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
<string name="menu_views_earth">Terre</string> <string name="menu_views_earth">Terre</string>
<string name="menu_views_sun">Soleil</string> <string name="menu_views_sun">Soleil</string>
<string name="menu_orbviews_free">Libre</string>
<string name="menu_orbviews_locked">Saisi</string>
<string name="about">À propos</string> <string name="about">À propos</string>
<string name="cs_site">http://c-s.fr/</string> <string name="cs_site">http://c-s.fr/</string>
<string name="about_table_project">Projet</string> <string name="about_table_project">Projet</string>
......
...@@ -134,5 +134,8 @@ ...@@ -134,5 +134,8 @@
<string name="key_views_earth">Earth</string> <string name="key_views_earth">Earth</string>
<string name="key_views_sun">Sun</string> <string name="key_views_sun">Sun</string>
<string name="key_orbviews_free">Free</string>
<string name="key_orbviews_locked">Locked</string>
</resources> </resources>
\ No newline at end of file
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
<string name="menu_views_earth">Earth</string> <string name="menu_views_earth">Earth</string>
<string name="menu_views_sun">Sun</string> <string name="menu_views_sun">Sun</string>
<string name="menu_orbviews_free">Free</string>
<string name="menu_orbviews_locked">Locked</string>
<string name="about">About</string> <string name="about">About</string>
<string name="cs_site">http://c-s.fr/</string> <string name="cs_site">http://c-s.fr/</string>
<string name="about_table_project">Project</string> <string name="about_table_project">Project</string>
......
...@@ -222,6 +222,7 @@ public class MainActivity extends ActionBarActivity implements ...@@ -222,6 +222,7 @@ public class MainActivity extends ActionBarActivity implements
if (dataFragment == null) { if (dataFragment == null) {
flagActivityFirstExec=true; flagActivityFirstExec=true;
((StavorApplication)getApplication()).modelViewId = R.id.menu_views_ref_frame_xyz; ((StavorApplication)getApplication()).modelViewId = R.id.menu_views_ref_frame_xyz;
((StavorApplication)getApplication()).modelOrbitViewId = R.id.menu_orbviews_free;
// add the fragment // add the fragment
dataFragment = new RetainedFragment(); dataFragment = new RetainedFragment();
fm.beginTransaction().add(dataFragment, "data").commit(); fm.beginTransaction().add(dataFragment, "data").commit();
......
...@@ -21,6 +21,7 @@ public class StavorApplication extends Application { ...@@ -21,6 +21,7 @@ public class StavorApplication extends Application {
public SQLiteDatabase db; public SQLiteDatabase db;
public int modelViewId = R.id.menu_views_ref_frame_xyz; public int modelViewId = R.id.menu_views_ref_frame_xyz;
public int modelOrbitViewId = R.id.menu_orbviews_free;
WebAppInterface jsInterface; WebAppInterface jsInterface;
......
...@@ -5,6 +5,7 @@ import org.xwalk.core.XWalkView; ...@@ -5,6 +5,7 @@ import org.xwalk.core.XWalkView;
import cs.si.stavor.R; import cs.si.stavor.R;
import cs.si.stavor.MainActivity; import cs.si.stavor.MainActivity;
import cs.si.stavor.StavorApplication;
import cs.si.stavor.model.Browsers; import cs.si.stavor.model.Browsers;
import cs.si.stavor.simulator.Simulator; import cs.si.stavor.simulator.Simulator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
...@@ -12,12 +13,16 @@ import android.app.Activity; ...@@ -12,12 +13,16 @@ import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.app.Fragment; import android.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
...@@ -50,6 +55,7 @@ public final class OrbitFragment extends Fragment { ...@@ -50,6 +55,7 @@ public final class OrbitFragment extends Fragment {
private Simulator simulator; private Simulator simulator;
LinearLayout browserLayout; LinearLayout browserLayout;
Button views_menu;
/** /**
* WebView from XWalk project to increase compatibility of WebGL * WebView from XWalk project to increase compatibility of WebGL
...@@ -81,6 +87,16 @@ public final class OrbitFragment extends Fragment { ...@@ -81,6 +87,16 @@ public final class OrbitFragment extends Fragment {
browserLayout.addView(mXwalkView); browserLayout.addView(mXwalkView);
views_menu = (Button) rootView.findViewById(R.id.buttonMissionNew);
views_menu.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
showPopup(arg0);
}
});
views_menu.setText(titleOfViewId(((StavorApplication)getActivity().getApplication()).modelOrbitViewId));
//Play/Pause/Stop buttons //Play/Pause/Stop buttons
ImageButton but_play = (ImageButton)rootView.findViewById(R.id.imageButtonPlay); ImageButton but_play = (ImageButton)rootView.findViewById(R.id.imageButtonPlay);
...@@ -124,6 +140,52 @@ public final class OrbitFragment extends Fragment { ...@@ -124,6 +140,52 @@ public final class OrbitFragment extends Fragment {
fps.setAlpha((float)1.0); fps.setAlpha((float)1.0);
} }
private String titleOfViewId(int id){
switch (id) {
case R.id.menu_orbviews_free:
return getString(R.string.menu_orbviews_free);
case R.id.menu_orbviews_locked:
return getString(R.string.menu_orbviews_locked);
default:
return getString(R.string.menu_orbviews_free);
}
}
/**
* Shows the visualization Views menu
* @param v
*/
private void showPopup(View v) {
PopupMenu popup = new PopupMenu(getActivity(), v);
// This activity implements OnMenuItemClickListener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
String com_view = (String)item.getTitle();
String command;
((StavorApplication)getActivity().getApplication()).modelOrbitViewId = item.getItemId();
switch (item.getItemId()) {
case R.id.menu_orbviews_free:
command = getString(R.string.key_orbviews_free);
break;
case R.id.menu_orbviews_locked:
command = getString(R.string.key_orbviews_locked);
break;
default:
return false;
}
views_menu.setText(com_view);
mXwalkView.load("javascript:changeView('"+command+"')", null);
return true;
}
});
popup.inflate(R.menu.views_orb);
popup.show();
}
@Override @Override
public void onDestroyView(){ public void onDestroyView(){
simulator.setBrowserLoaded(false); simulator.setBrowserLoaded(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment