├── AndroidManifest.xml ├── README.md ├── assets ├── TeaClass.obj ├── arrow_1.obj ├── arrow_2.obj ├── cube.obj ├── female.obj ├── fs.txt ├── helloText.obj ├── male.obj ├── male_new.obj ├── nanosuit.obj └── vs.txt ├── image_folder ├── arrow1.png ├── arrow2.png ├── cube.png ├── jubu1.png ├── jubu2.png ├── jubu3.png ├── locate.png ├── main.png └── man.png ├── java └── com │ └── sacc │ └── gaodemap │ ├── MainActivity.java │ └── opengl │ └── cube │ ├── Cube.java │ ├── MapRender.java │ ├── Model.java │ └── OpenGLUtils.java ├── jniLibs ├── arm64-v8a │ └── libAMapSDK_MAP_v6_5_0.so ├── armeabi-v7a │ └── libAMapSDK_MAP_v6_5_0.so ├── armeabi │ └── libAMapSDK_MAP_v6_5_0.so ├── x86 │ └── libAMapSDK_MAP_v6_5_0.so └── x86_64 │ └── libAMapSDK_MAP_v6_5_0.so └── res ├── drawable-v24 └── ic_launcher_foreground.xml ├── drawable ├── blue.png ├── btn_default_small.xml ├── btn_default_small_normal.9.png ├── btn_default_small_normal_disable.9.png ├── btn_default_small_pressed.9.png ├── btn_map_poi.xml ├── btn_nav_drag_down.xml ├── btn_nav_drag_down_normal.png ├── btn_nav_drag_down_pressed.png ├── btn_poi_search_normal.png ├── btn_route_next.xml ├── btn_route_pre.xml ├── green.jpg ├── groundoverlay.png ├── guangao.png ├── heart.png ├── ic_launcher_background.xml ├── left_back.9.png ├── marker_blue.png ├── metallic.png ├── mode_driving.xml ├── mode_driving_focused.9.png ├── mode_driving_off.9.png ├── mode_driving_on.9.png ├── mode_transit.xml ├── mode_transit_focused.9.png ├── mode_transit_off.9.png ├── mode_transit_on.9.png ├── mode_walk.xml ├── mode_walk_focused.9.png ├── mode_walk_off.9.png ├── mode_walk_on.9.png ├── next.png ├── next_disable.png ├── point.png ├── prev.png ├── prev_disable.png ├── purple_pin.png ├── text_search.xml ├── text_search_default.9.png ├── text_search_pressed.9.png ├── text_search_selected.9.png ├── white.png └── whiteborder.xml ├── layout ├── activity_main.xml └── basicmap_activity.xml ├── mipmap-anydpi-v26 ├── ic_launcher.xml └── ic_launcher_round.xml ├── mipmap-hdpi ├── amap_bus.png ├── amap_car.png ├── amap_end.png ├── amap_man.png ├── amap_ride.png ├── amap_start.png ├── amap_through.png ├── amap_train.png ├── amap_truck.png ├── arrow_right_blue.png ├── back.png ├── badge_sa.png ├── badge_wa.png ├── bg_bottom_bar.9.png ├── border_bg.9.png ├── bus.png ├── car.png ├── custom_info_bubble.9.png ├── custtexture.png ├── dir1.png ├── dir10.png ├── dir11.png ├── dir12.png ├── dir13.png ├── dir14.png ├── dir15.png ├── dir16.png ├── dir2.png ├── dir3.png ├── dir4.png ├── dir5.png ├── dir6.png ├── dir7.png ├── dir8.png ├── dir9.png ├── dir_end.png ├── dir_start.png ├── dir_station.png ├── direct_mapsearch.9.png ├── direct_mapsearch_pressed.9.png ├── divider.png ├── down.png ├── downarrow.png ├── end.png ├── gps_point.png ├── ic_launcher.png ├── ic_launcher_round.png ├── icon_poisearch.png ├── location_marker.png ├── man.png ├── map_alr.png ├── map_alr_night.png ├── map_indoor_select.png ├── map_link_dott.png ├── marker_other_highlight.png ├── navi_map_gps_locked.png ├── offline_back.png ├── offline_common_bar_bg.9.png ├── offlinearrow_but_normal.9.png ├── offlinearrow_but_pressed.9.png ├── offlinearrow_down.png ├── offlinearrow_download.png ├── offlinearrow_start.png ├── offlinearrow_stop.png ├── offlinearrow_tab1_normal.9.png ├── offlinearrow_tab1_pressed.9.png ├── offlinearrow_tab2_normal.9.png ├── offlinearrow_tab2_pressed.9.png ├── poi_marker_1.png ├── poi_marker_10.png ├── poi_marker_2.png ├── poi_marker_3.png ├── poi_marker_4.png ├── poi_marker_5.png ├── poi_marker_6.png ├── poi_marker_7.png ├── poi_marker_8.png ├── poi_marker_9.png ├── poi_marker_pressed.png ├── point1.png ├── point2.png ├── point3.png ├── point4.png ├── point5.png ├── point6.png ├── rightarrow.png ├── route_bus_normal.png ├── route_bus_select.png ├── route_drive_normal.png ├── route_drive_select.png ├── route_walk_normal.png ├── route_walk_select.png ├── search_bar_blue.9.png ├── search_icon_white.png ├── search_input.png ├── search_input_half.9.png ├── search_plate_global.9.png ├── start.png ├── start_uri.png ├── title_background.9.png └── up.png ├── mipmap-mdpi ├── arrow.png ├── bus.png ├── car.png ├── custom_info_bubble.9.png ├── end.png ├── ic_launcher.png ├── ic_launcher_round.png ├── icon_car.png ├── man.png └── start.png ├── mipmap-xhdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-xxhdpi ├── ic_launcher.png └── ic_launcher_round.png ├── mipmap-xxxhdpi ├── ic_launcher.png └── ic_launcher_round.png └── values ├── colors.xml ├── dimens.xml ├── strings.xml └── stroke_text_view_attrs.xml /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 3DMap 2 | 基于3D高德地图OpenGL接口的功能扩展 3 | 4 | ### 需求如下: 5 | 1.展示当前地理位置 6 | 2.可以查找指定地址位置 7 | 3.可显示当前位置到指定地理位置导航信息 8 | 4.可显示当前位置到指定地理位置交通路线(步行、骑行、公交) 9 | 10 | ### 新增和实现需求如下: 11 | 1,指定路线,在该路线上绘制动态三维指示箭头 12 | 2,加载三维人体模型到当前位置 13 | 3,引入光照,增强体验感 14 | 4,扩展功能模块:三维动态广告牌 15 | 16 | ##### 俯视图 17 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/main.png) 18 | #### 三维指示图标1 19 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/arrow1.png) 20 | ##### 三维指示图标2 21 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/arrow2.png) 22 | ##### 三维人物模型 23 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/man.png) 24 | ##### 动态广告牌 25 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/cube.png) 26 | ##### 局部展示1 27 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/jubu1.png) 28 | ##### 局部展示2 29 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/jubu2.png) 30 | ##### 局部展示3 31 | ![Image text](https://github.com/ProEthan/3DMap/blob/master/image_folder/jubu3.png) 32 | -------------------------------------------------------------------------------- /assets/TeaClass.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/TeaClass.obj -------------------------------------------------------------------------------- /assets/arrow_1.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/arrow_1.obj -------------------------------------------------------------------------------- /assets/arrow_2.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/arrow_2.obj -------------------------------------------------------------------------------- /assets/cube.obj: -------------------------------------------------------------------------------- 1 | v -0.2 -0.2 0.2 2 | v 0.2 -0.2 0.2 3 | v 0.2 0.2 0.2 4 | v 0.2 0.2 0.2 5 | v -0.2 0.2 0.2 6 | v -0.2 -0.2 0.2 7 | 8 | v -0.2 -0.2 0.6 9 | v 0.2 -0.2 0.6 10 | v 0.2 0.2 0.6 11 | v 0.2 0.2 0.6 12 | v -0.2 0.2 0.6 13 | v -0.2 -0.2 0.6 14 | 15 | v -0.2 0.2 0.6 16 | v -0.2 0.2 0.2 17 | v -0.2 -0.2 0.2 18 | v -0.2 -0.2 0.2 19 | v -0.2 -0.2 0.6 20 | v -0.2 0.2 0.6 21 | 22 | v 0.2 0.2 0.6 23 | v 0.2 0.2 0.2 24 | v 0.2 -0.2 0.2 25 | v 0.2 -0.2 0.2 26 | v 0.2 -0.2 0.6 27 | v 0.2 0.2 0.6 28 | 29 | v -0.2 -0.2 0.2 30 | v 0.2 -0.2 0.2 31 | v 0.2 -0.2 0.6 32 | v 0.2 -0.2 0.6 33 | v -0.2 -0.2 0.6 34 | v -0.2 -0.2 0.2 35 | 36 | v -0.2 0.2 0.2 37 | v 0.2 0.2 0.2 38 | v 0.2 0.2 0.6 39 | v 0.2 0.2 0.6 40 | v -0.2 0.2 0.6 41 | v -0.2 0.2 0.2 42 | vn -0.0195023 -0.967191 -0.253077 43 | vn -0.615487 -0.784297 0.0757749 44 | vn -0.649548 -0.758488 -0.0537508 45 | vn -0.974574 -0.193976 0.111953 46 | vn -0.559015 0.807656 0.187721 47 | vn 0.00194232 0.982416 0.18646 48 | vn 0.576043 0.81491 -0.0660424 49 | vn 0.607588 -0.699542 -0.376 50 | vn 0.0287994 -0.997304 -0.0690602 51 | vn -0.959194 -0.170771 0.225251 52 | vn -0.688786 0.604588 0.399546 53 | vn -0.173486 0.984913 0.00949216 54 | vn -0.0195023 -0.967191 -0.253077 55 | vn -0.615487 -0.784297 0.0757749 56 | vn -0.649548 -0.758488 -0.0537508 57 | vn -0.974574 -0.193976 0.111953 58 | vn -0.559015 0.807656 0.187721 59 | vn 0.00194232 0.982416 0.18646 60 | vn 0.576043 0.81491 -0.0660424 61 | vn 0.607588 -0.699542 -0.376 62 | vn 0.0287994 -0.997304 -0.0690602 63 | vn -0.959194 -0.170771 0.225251 64 | vn -0.688786 0.604588 0.399546 65 | vn -0.173486 0.984913 0.00949216 66 | vn -0.0195023 -0.967191 -0.253077 67 | vn -0.615487 -0.784297 0.0757749 68 | vn -0.649548 -0.758488 -0.0537508 69 | vn -0.974574 -0.193976 0.111953 70 | vn -0.559015 0.807656 0.187721 71 | vn 0.00194232 0.982416 0.18646 72 | vn 0.576043 0.81491 -0.0660424 73 | vn 0.607588 -0.699542 -0.376 74 | vn 0.0287994 -0.997304 -0.0690602 75 | vn -0.959194 -0.170771 0.225251 76 | vn -0.688786 0.604588 0.399546 77 | vn -0.173486 0.984913 0.00949216 78 | vt 0.0 0.0 79 | vt 1.0 0.0 80 | vt 1.0 1.0 81 | vt 1.0 1.0 82 | vt 0.0 1.0 83 | vt 0.0 0.0 84 | 85 | vt 0.0 0.0 86 | vt 1.0 0.0 87 | vt 1.0 1.0 88 | vt 1.0 1.0 89 | vt 0.0 1.0 90 | vt 0.0 0.0 91 | 92 | vt 1.0 0.0 93 | vt 1.0 1.0 94 | vt 0.0 1.0 95 | vt 0.0 1.0 96 | vt 0.0 0.0 97 | vt 1.0 0.0 98 | 99 | vt 1.0 0.0 100 | vt 1.0 1.0 101 | vt 0.0 1.0 102 | vt 0.0 1.0 103 | vt 0.0 0.0 104 | vt 1.0 0.0 105 | 106 | vt 0.0 1.0 107 | vt 1.0 1.0 108 | vt 1.0 0.0 109 | vt 1.0 0.0 110 | vt 0.0 0.0 111 | vt 0.0 1.0 112 | 113 | vt 0.0 1.0 114 | vt 1.0 1.0 115 | vt 1.0 0.0 116 | vt 1.0 0.0 117 | vt 0.0 0.0 118 | vt 0.0 1.0 119 | f 1/1/1 2/2/2 3/3/3 120 | f 4/4/4 5/5/5 6/6/6 121 | f 7/7/7 8/8/8 9/9/9 122 | f 10/10/10 11/11/11 12/12/12 123 | f 13/13/13 14/14/14 15/15/15 124 | f 16/16/16 17/17/17 18/18/18 125 | f 19/19/19 20/20/20 21/21/21 126 | f 22/22/22 23/23/23 24/24/24 127 | f 25/25/25 26/26/26 27/27/27 128 | f 28/28/28 29/29/29 30/30/30 129 | f 31/31/31 32/32/32 33/33/33 130 | f 34/34/34 35/35/35 36/36/36 -------------------------------------------------------------------------------- /assets/female.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/female.obj -------------------------------------------------------------------------------- /assets/fs.txt: -------------------------------------------------------------------------------- 1 | varying highp vec2 TexCoords; 2 | varying vec3 Normal; 3 | varying vec3 FragPos; 4 | 5 | uniform sampler2D inputImageTexture; 6 | 7 | uniform vec3 lightPos; 8 | uniform vec3 lightColor; 9 | 10 | void main(){ 11 | // ambient 12 | float ambientStrength = 0.1; 13 | vec3 ambient = ambientStrength * lightColor; 14 | 15 | // diffuse 16 | vec3 norm = normalize(Normal); 17 | vec3 lightDir = normalize(lightPos - FragPos); 18 | float diff = max(dot(norm, lightDir), 0.0); 19 | vec3 diffuse = diff * lightColor; 20 | 21 | vec3 result = (ambient + diffuse) * texture2D(inputImageTexture, TexCoords).rgb 22 | gl_FragColor = vec4(result, 1.0); 23 | } -------------------------------------------------------------------------------- /assets/helloText.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/helloText.obj -------------------------------------------------------------------------------- /assets/male_new.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/assets/male_new.obj -------------------------------------------------------------------------------- /assets/vs.txt: -------------------------------------------------------------------------------- 1 | attribute vec3 aPos; 2 | attribute vec3 aNormal; 3 | attribute vec4 aTexCoords; 4 | 5 | uniform mat4 model; 6 | uniform mat4 view; 7 | uniform mat4 projection; 8 | 9 | varying vec2 TexCoords; 10 | varying vec3 Normal; 11 | varying vec3 FragPos; 12 | 13 | void main(){ 14 | // 世界坐标位置 15 | FragPos = vec3(model * vec4(aPos, 1.0)); 16 | // 纹理坐标 17 | TexCoords = aTexCoords.xy; 18 | // 法向量 19 | Normal = aNormal; 20 | // 摄影机坐标位置 21 | gl_Position = projection * view * vec4(FragPos, 1.0); 22 | } -------------------------------------------------------------------------------- /image_folder/arrow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/arrow1.png -------------------------------------------------------------------------------- /image_folder/arrow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/arrow2.png -------------------------------------------------------------------------------- /image_folder/cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/cube.png -------------------------------------------------------------------------------- /image_folder/jubu1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/jubu1.png -------------------------------------------------------------------------------- /image_folder/jubu2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/jubu2.png -------------------------------------------------------------------------------- /image_folder/jubu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/jubu3.png -------------------------------------------------------------------------------- /image_folder/locate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/locate.png -------------------------------------------------------------------------------- /image_folder/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/main.png -------------------------------------------------------------------------------- /image_folder/man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/image_folder/man.png -------------------------------------------------------------------------------- /java/com/sacc/gaodemap/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sacc.gaodemap; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.opengl.GLSurfaceView; 8 | import android.os.Bundle; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.widget.Button; 12 | 13 | import com.amap.api.maps.AMap; 14 | import com.amap.api.maps.MapView; 15 | import com.amap.api.maps.UiSettings; 16 | import com.amap.api.maps.model.MyLocationStyle; 17 | import com.sacc.gaodemap.opengl.cube.MapRender; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | 23 | public class MainActivity extends Activity implements View.OnClickListener{ 24 | private MapView mapView; 25 | private AMap aMap; 26 | private Button basicmap; 27 | private Button rsmap; 28 | private Button nightmap; 29 | private Button navimap; 30 | private Button downloadmap; 31 | private Button autoDirection; 32 | 33 | private int autoDircNum=0; // 0代表当前为不锁定方向,1代表锁定方向为设备方向 34 | 35 | private UiSettings mUiSettings;//定义一个UiSettings对象 36 | 37 | MyLocationStyle myLocationStyle; 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState){ 41 | super.onCreate(savedInstanceState); 42 | setContentView(R.layout.basicmap_activity); 43 | 44 | mapView=findViewById(R.id.map); 45 | mapView.onCreate(savedInstanceState); 46 | 47 | init(); 48 | } 49 | 50 | private void init() { 51 | if(aMap==null){ 52 | aMap = mapView.getMap(); 53 | } 54 | myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类 55 | myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); 56 | myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 57 | 58 | aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style 59 | aMap.getUiSettings().setMyLocationButtonEnabled(true); //设置默认定位按钮是否显示,非必需设置。 60 | aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 61 | 62 | mUiSettings = aMap.getUiSettings();//实例化UiSettings类对象 63 | mUiSettings.setCompassEnabled(true); // 指南针 64 | mUiSettings.setScaleControlsEnabled(true); // 比例尺 65 | 66 | 67 | 68 | basicmap = (Button)findViewById(R.id.basicmap); 69 | basicmap.setOnClickListener(this); 70 | rsmap = (Button)findViewById(R.id.rsmap); 71 | rsmap.setOnClickListener(this); 72 | nightmap = (Button)findViewById(R.id.nightmap); 73 | nightmap.setOnClickListener(this); 74 | navimap = (Button)findViewById(R.id.navimap); 75 | navimap.setOnClickListener(this); 76 | downloadmap = (Button)findViewById(R.id.downloadmap); 77 | downloadmap.setOnClickListener(this); 78 | autoDirection = (Button)findViewById(R.id.autoDirection); 79 | autoDirection.setOnClickListener(this); 80 | 81 | Bitmap bitmap_cube = BitmapFactory.decodeResource(getResources(), R.drawable.guangao); 82 | Bitmap bitmap_arrow1 = BitmapFactory.decodeResource(getResources(), R.drawable.green); 83 | Bitmap bitmap_arrow2 = BitmapFactory.decodeResource(getResources(), R.drawable.blue); 84 | Bitmap bitmap_man = BitmapFactory.decodeResource(getResources(), R.drawable.white); 85 | String arrow_1 = "arrow_1.obj"; 86 | String arrow_2 = "arrow_2.obj"; 87 | String man = "nanosuit.obj"; 88 | InputStream inputStream_arrow_1 = null; 89 | InputStream inputStream_arrow_2 = null; 90 | InputStream inputStream_man = null; 91 | try { 92 | inputStream_arrow_1 = getResources().getAssets().open(arrow_1); 93 | inputStream_arrow_2 = getResources().getAssets().open(arrow_2); 94 | inputStream_man = getResources().getAssets().open(man); 95 | } catch (IOException e) { 96 | System.out.println("---------------------------------------"); 97 | e.printStackTrace(); 98 | } 99 | 100 | aMap.setCustomRenderer(new MapRender(aMap, bitmap_man, bitmap_cube, bitmap_arrow1,bitmap_arrow2, inputStream_arrow_1, inputStream_arrow_2, inputStream_man)); 101 | aMap.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY); 102 | } 103 | 104 | @Override 105 | public boolean onTouchEvent(MotionEvent e){ 106 | return true; 107 | } 108 | 109 | /** 110 | * 方法必须重写 111 | */ 112 | @Override 113 | protected void onResume() { 114 | super.onResume(); 115 | mapView.onResume(); 116 | } 117 | 118 | /** 119 | * 方法必须重写 120 | */ 121 | @Override 122 | protected void onPause() { 123 | super.onPause(); 124 | mapView.onPause(); 125 | } 126 | 127 | /** 128 | * 方法必须重写 129 | */ 130 | @Override 131 | protected void onSaveInstanceState(Bundle outState) { 132 | super.onSaveInstanceState(outState); 133 | mapView.onSaveInstanceState(outState); 134 | } 135 | 136 | /** 137 | * 方法必须重写 138 | */ 139 | @Override 140 | protected void onDestroy() { 141 | super.onDestroy(); 142 | mapView.onDestroy(); 143 | } 144 | public void onClickBt(View view) { 145 | if(aMap != null) { 146 | aMap.runOnDrawFrame(); 147 | } 148 | } 149 | 150 | 151 | @Override 152 | public void onClick(View v) { 153 | switch (v.getId()) { 154 | case R.id.basicmap: 155 | aMap.setMapType(AMap.MAP_TYPE_NORMAL);// 矢量地图模式 156 | break; 157 | case R.id.rsmap: 158 | aMap.setMapType(AMap.MAP_TYPE_SATELLITE);// 卫星地图模式 159 | break; 160 | case R.id.nightmap: 161 | aMap.setMapType(AMap.MAP_TYPE_NIGHT);//夜景地图模式 162 | break; 163 | case R.id.navimap: 164 | aMap.setMapType(AMap.MAP_TYPE_NAVI);//导航地图模式 165 | break; 166 | case R.id.downloadmap: 167 | //在Activity页面调用startActvity启动离线地图组件 168 | startActivity(new Intent(this.getApplicationContext(), 169 | com.amap.api.maps.offlinemap.OfflineMapActivity.class)); 170 | break; 171 | case R.id.autoDirection: 172 | if(autoDircNum==0){ 173 | System.out.println("0000"); 174 | 175 | if(aMap==null){ 176 | aMap = mapView.getMap(); 177 | } 178 | myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类 179 | myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE); 180 | myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 181 | 182 | aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style 183 | aMap.getUiSettings().setMyLocationButtonEnabled(true); //设置默认定位按钮是否显示,非必需设置。 184 | aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 185 | 186 | mUiSettings = aMap.getUiSettings();//实例化UiSettings类对象 187 | mUiSettings.setCompassEnabled(true); // 指南针 188 | mUiSettings.setScaleControlsEnabled(true); // 比例尺 189 | 190 | 191 | 192 | basicmap = (Button)findViewById(R.id.basicmap); 193 | basicmap.setOnClickListener(this); 194 | rsmap = (Button)findViewById(R.id.rsmap); 195 | rsmap.setOnClickListener(this); 196 | nightmap = (Button)findViewById(R.id.nightmap); 197 | nightmap.setOnClickListener(this); 198 | navimap = (Button)findViewById(R.id.navimap); 199 | navimap.setOnClickListener(this); 200 | downloadmap = (Button)findViewById(R.id.downloadmap); 201 | downloadmap.setOnClickListener(this); 202 | autoDirection = (Button)findViewById(R.id.autoDirection); 203 | autoDirection.setOnClickListener(this); 204 | 205 | autoDircNum=1; 206 | }else{ 207 | System.out.println("1111"); 208 | 209 | if(aMap==null){ 210 | aMap = mapView.getMap(); 211 | } 212 | myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类 213 | myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); 214 | myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。 215 | 216 | aMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style 217 | aMap.getUiSettings().setMyLocationButtonEnabled(true); //设置默认定位按钮是否显示,非必需设置。 218 | aMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。 219 | 220 | mUiSettings = aMap.getUiSettings();//实例化UiSettings类对象 221 | mUiSettings.setCompassEnabled(true); // 指南针 222 | mUiSettings.setScaleControlsEnabled(true); // 比例尺 223 | 224 | 225 | 226 | basicmap = (Button)findViewById(R.id.basicmap); 227 | basicmap.setOnClickListener(this); 228 | rsmap = (Button)findViewById(R.id.rsmap); 229 | rsmap.setOnClickListener(this); 230 | nightmap = (Button)findViewById(R.id.nightmap); 231 | nightmap.setOnClickListener(this); 232 | navimap = (Button)findViewById(R.id.navimap); 233 | navimap.setOnClickListener(this); 234 | downloadmap = (Button)findViewById(R.id.downloadmap); 235 | downloadmap.setOnClickListener(this); 236 | autoDirection = (Button)findViewById(R.id.autoDirection); 237 | autoDirection.setOnClickListener(this); 238 | 239 | autoDircNum=0; 240 | } 241 | break; 242 | } 243 | 244 | } 245 | } 246 | -------------------------------------------------------------------------------- /java/com/sacc/gaodemap/opengl/cube/Cube.java: -------------------------------------------------------------------------------- 1 | package com.sacc.gaodemap.opengl.cube; 2 | 3 | import android.app.Activity; 4 | import android.content.res.Resources; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.opengl.GLES20; 8 | import android.view.View; 9 | import android.widget.Button; 10 | 11 | import com.sacc.gaodemap.R; 12 | 13 | import java.io.FileInputStream; 14 | import java.io.FileNotFoundException; 15 | import java.io.InputStream; 16 | import java.nio.ByteBuffer; 17 | import java.nio.ByteOrder; 18 | import java.nio.FloatBuffer; 19 | 20 | public class Cube { 21 | public static final float TEXTURE_NO_ROTATION[] = { 22 | 0.0f, 0.0f, 23 | 1.0f, 0.0f, 24 | 1.0f, 1.0f, 25 | 1.0f, 1.0f, 26 | 0.0f, 1.0f, 27 | 0.0f, 0.0f, 28 | 29 | 0.0f, 0.0f, 30 | 1.0f, 0.0f, 31 | 1.0f, 1.0f, 32 | 1.0f, 1.0f, 33 | 0.0f, 1.0f, 34 | 0.0f, 0.0f, 35 | 36 | 1.0f, 0.0f, 37 | 1.0f, 1.0f, 38 | 0.0f, 1.0f, 39 | 0.0f, 1.0f, 40 | 0.0f, 0.0f, 41 | 1.0f, 0.0f, 42 | 43 | 1.0f, 0.0f, 44 | 1.0f, 1.0f, 45 | 0.0f, 1.0f, 46 | 0.0f, 1.0f, 47 | 0.0f, 0.0f, 48 | 1.0f, 0.0f, 49 | 50 | 0.0f, 1.0f, 51 | 1.0f, 1.0f, 52 | 1.0f, 0.0f, 53 | 1.0f, 0.0f, 54 | 0.0f, 0.0f, 55 | 0.0f, 1.0f, 56 | 57 | 0.0f, 1.0f, 58 | 1.0f, 1.0f, 59 | 1.0f, 0.0f, 60 | 1.0f, 0.0f, 61 | 0.0f, 0.0f, 62 | 0.0f, 1.0f 63 | }; 64 | 65 | 66 | 67 | public Cube(float width, float height, float depth, Bitmap bitmap) { 68 | 69 | // 地图坐标系比较大,将值放大以免太小看不见 70 | width *= 200; 71 | height *= 200; 72 | depth *= 200; 73 | 74 | 75 | width /= 2; 76 | height /= 2; 77 | 78 | //尽量不要让z轴有负数出现 79 | float vertices1[] = { 80 | -width, -height, 2 * depth, 81 | width, -height, 2 * depth, 82 | width, height, 2 * depth, 83 | width, height, 2 * depth, 84 | -width, height, 2 * depth, 85 | -width, -height, 2 * depth, 86 | 87 | -width, -height, 3 * depth, 88 | width, -height, 3 * depth, 89 | width, height, 3 * depth, 90 | width, height, 3 * depth, 91 | -width, height, 3 * depth, 92 | -width, -height, 3 * depth, 93 | 94 | -width, height, 3 * depth, 95 | -width, height, 2 * depth, 96 | -width, -height, 2 * depth, 97 | -width, -height, 2 * depth, 98 | -width, -height, 3 * depth, 99 | -width, height, 3 * depth, 100 | 101 | width, height, 3 * depth, 102 | width, height, 2 * depth, 103 | width, -height, 2 * depth, 104 | width, -height, 2 * depth, 105 | width, -height, 3 * depth, 106 | width, height, 3 * depth, 107 | 108 | -width, -height, 2 * depth, 109 | width, -height, 2 * depth, 110 | width, -height, 3 * depth, 111 | width, -height, 3 * depth, 112 | -width, -height, 3 * depth, 113 | -width, -height, 2 * depth, 114 | 115 | -width, height, 2 * depth, 116 | width, height, 2 * depth, 117 | width, height, 3 * depth, 118 | width, height, 3 * depth, 119 | -width, height, 3 * depth, 120 | -width, height, 2 * depth, 121 | 122 | }; 123 | 124 | textureId = OpenGLUtils.loadTexture(bitmap, textureId, true); // 加载纹理 125 | 126 | 127 | // 纹理数组缓冲器 128 | mGLTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4) 129 | .order(ByteOrder.nativeOrder()) 130 | .asFloatBuffer(); 131 | mGLTextureBuffer.put(TEXTURE_NO_ROTATION).position(0); 132 | 133 | // 顶点数组缓冲器 134 | vertextBuffer = ByteBuffer.allocateDirect(vertices1.length * 4) 135 | .order(ByteOrder.nativeOrder()) 136 | .asFloatBuffer(); 137 | vertextBuffer.put(vertices1).position(0); 138 | 139 | } 140 | 141 | 142 | 143 | private FloatBuffer vertextBuffer; 144 | private FloatBuffer mGLTextureBuffer; 145 | 146 | private int textureId = -1; 147 | protected int mGLProgId; 148 | protected int mGLAttribPosition; 149 | protected int mGLUniformTexture; 150 | protected int mGLAttribTextureCoordinate; 151 | 152 | private Bitmap bitmap; 153 | 154 | private int mMatrixHandler; 155 | 156 | 157 | 158 | class MyShader { 159 | 160 | 161 | String vertexShader = 162 | "attribute vec3 position;\n" + // 顶点着色器的顶点坐标,由外部程序传入 163 | "attribute vec4 inputTextureCoordinate;\n" + // 传入的纹理坐标 164 | "uniform mat4 model;"+ 165 | "uniform mat4 view;"+ 166 | "uniform mat4 projection;"+ 167 | " \n" + 168 | "varying vec2 textureCoordinate;\n" + 169 | " \n" + 170 | "void main()\n" + 171 | "{\n" + 172 | " vec3 FragPos = vec3(model * vec4(position, 1.0));\n"+ 173 | " gl_Position = projection * view * vec4(FragPos, 1.0);\n" + 174 | " textureCoordinate = inputTextureCoordinate.xy;\n" + // 最终顶点位置 175 | "}"; 176 | 177 | String fragmentShader = 178 | "varying highp vec2 textureCoordinate;\n" + // 最终顶点位置,上面顶点着色器的varying变量会传递到这里 179 | " \n" + 180 | "uniform sampler2D inputImageTexture;\n" + // 外部传入的图片纹理 即代表整张图片的数据 181 | " \n" + 182 | "void main()\n" + 183 | "{\n" + 184 | " gl_FragColor = texture2D(inputImageTexture, textureCoordinate);\n" + // 调用函数 进行纹理贴图 185 | "}"; 186 | 187 | public void create() { 188 | 189 | mGLProgId = OpenGLUtils.loadProgram(vertexShader, fragmentShader); // 编译链接着色器,创建着色器程序 190 | mGLAttribPosition = GLES20.glGetAttribLocation(mGLProgId, "position"); // 顶点着色器的顶点坐标 191 | mGLUniformTexture = GLES20.glGetUniformLocation(mGLProgId, "inputImageTexture"); // 传入的图片纹理 192 | mGLAttribTextureCoordinate = GLES20.glGetAttribLocation(mGLProgId, "inputTextureCoordinate"); // 顶点着色器的纹理坐标 193 | 194 | } 195 | } 196 | 197 | MyShader shader; 198 | 199 | public void initShader() { 200 | shader = new MyShader(); 201 | shader.create(); 202 | } 203 | 204 | public void drawES20(float[] model, float[] view, float[] projection) { 205 | 206 | GLES20.glUseProgram(mGLProgId); 207 | 208 | GLES20.glEnable(GLES20.GL_DEPTH_TEST); 209 | 210 | int mModelHandler = GLES20.glGetUniformLocation(mGLProgId,"model"); 211 | GLES20.glUniformMatrix4fv(mModelHandler,1,false, model, 0); 212 | int mViewHandler = GLES20.glGetUniformLocation(mGLProgId,"view"); 213 | GLES20.glUniformMatrix4fv(mViewHandler,1,false, view, 0); 214 | int mProjectionHandler = GLES20.glGetUniformLocation(mGLProgId,"projection"); 215 | GLES20.glUniformMatrix4fv(mProjectionHandler,1,false, projection, 0); 216 | 217 | // 顶点着色器的顶点坐标 218 | vertextBuffer.position(0);GLES20.glEnableVertexAttribArray(mGLAttribPosition); 219 | GLES20.glVertexAttribPointer(mGLAttribPosition, 3, GLES20.GL_FLOAT, false, 0, vertextBuffer); 220 | 221 | // 顶点着色器的纹理坐标 222 | mGLTextureBuffer.position(0);GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate); 223 | GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, mGLTextureBuffer); 224 | 225 | // 传入的图片纹理 226 | if (textureId != OpenGLUtils.NO_TEXTURE) { 227 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 228 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); 229 | GLES20.glUniform1i(mGLUniformTexture, 0); 230 | } 231 | 232 | GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36); 233 | 234 | GLES20.glDisableVertexAttribArray(mGLAttribPosition); 235 | GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate); 236 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /java/com/sacc/gaodemap/opengl/cube/MapRender.java: -------------------------------------------------------------------------------- 1 | package com.sacc.gaodemap.opengl.cube; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.PointF; 5 | import android.opengl.Matrix; 6 | 7 | import com.amap.api.maps.AMap; 8 | import com.amap.api.maps.CameraUpdateFactory; 9 | import com.amap.api.maps.CustomRenderer; 10 | import com.amap.api.maps.model.LatLng; 11 | 12 | import java.io.InputStream; 13 | import java.util.Arrays; 14 | import java.util.LinkedList; 15 | import java.util.Queue; 16 | 17 | import javax.microedition.khronos.egl.EGLConfig; 18 | import javax.microedition.khronos.opengles.GL10; 19 | 20 | public class MapRender implements CustomRenderer { 21 | 22 | private float[] translate_vector = new float[4]; 23 | public static float SCALE = 0.005F;// 缩放暂时使用这个 24 | 25 | private LatLng center = new LatLng(39.90403, 116.407525);// 北京市经纬度 26 | 27 | private Cube cube; 28 | 29 | private Model man, arrow_1, arrow_2; 30 | 31 | private AMap aMap; 32 | 33 | float width, height; 34 | 35 | private Bitmap bitmap_man,bitmap_arrow1,bitmap_arrow2,bitmap_cube; 36 | 37 | private InputStream inputStream_arrow_1, inputStream_arrow_2, inputStream_man; 38 | 39 | private float[] mMatrixCurrent= //原始矩阵 40 | {1,0,0,0, 41 | 0,1,0,0, 42 | 0,0,1,0, 43 | 0,0,0,1}; 44 | private float[] mMatrixCurrent_cube1= //原始矩阵 45 | {1,0,0,0, 46 | 0,1,0,0, 47 | 0,0,1,0, 48 | 0,0,0,1}; 49 | private float[] mMatrixCurrent_cube2= //原始矩阵 50 | {1,0,0,0, 51 | 0,1,0,0, 52 | 0,0,1,0, 53 | 0,0,0,1}; 54 | 55 | public MapRender(AMap aMap, Bitmap bitmap_man, Bitmap bitmap_cube,Bitmap bitmap_arrow1,Bitmap bitmap_arrow2, InputStream inputStream_arrow_1, InputStream inputStream_arrow_2, InputStream inputStream_man) { 56 | this.aMap = aMap; 57 | this.bitmap_man=bitmap_man; 58 | this.bitmap_arrow1=bitmap_arrow1; 59 | this.bitmap_arrow2=bitmap_arrow2; 60 | this.bitmap_cube=bitmap_cube; 61 | this.inputStream_arrow_1=inputStream_arrow_1; 62 | this.inputStream_arrow_2=inputStream_arrow_2; 63 | this.inputStream_man=inputStream_man; 64 | aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center,15)); 65 | 66 | mQueue=new LinkedList(); 67 | } 68 | 69 | float[] model = new float[16]; 70 | float[] projection = new float[16]; 71 | float[] view = new float[16]; 72 | 73 | @Override 74 | public void onDrawFrame(GL10 gl) { 75 | 76 | // 摄影机坐标下物体的偏移 77 | PointF pointF = aMap.getProjection().toOpenGLLocation(center); 78 | // 设置投影矩阵 79 | projection = aMap.getProjectionMatrix(); 80 | // 初始化摄影机矩阵 81 | view = aMap.getViewMatrix(); 82 | // 设置摄影机坐标下物体的偏移矩阵 83 | Matrix.translateM(view, 0 , pointF.x , pointF.y , 0); 84 | 85 | 86 | // --------------指向标1的模型矩阵------------------ 87 | float[] mMatrixAdjustDirection_arrow1 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 88 | Matrix.setIdentityM(model, 0); 89 | // 平移 90 | Matrix.translateM(model, 0 , -590.0f , -2080.0f , -0.0f); 91 | // 调整方向 92 | Matrix.rotateM(mMatrixAdjustDirection_arrow1,0,-180.0f,1.0f, 0.0f, 0.0f); 93 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow1,0); 94 | // 绕y轴旋转 95 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 96 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 97 | // 调整大小 98 | int scale = 3; 99 | Matrix.scaleM(model, 0 , scale, scale, scale); 100 | // -----------绘制---------- 101 | arrow_2.drawES20(model,view,projection); 102 | 103 | 104 | // --------------指向标2的模型矩阵------------------ 105 | float[] mMatrixAdjustDirection_arrow2 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 106 | Matrix.setIdentityM(model, 0); 107 | // 平移 108 | Matrix.translateM(model, 0 , -520.0f , -1080.0f , -0.0f); 109 | // 调整方向 110 | Matrix.rotateM(mMatrixAdjustDirection_arrow2,0,-180.0f,1.0f, 0.0f, 0.0f); 111 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow2,0); 112 | // 绕y轴旋转 113 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 114 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 115 | // 调整大小 116 | scale = 3; 117 | Matrix.scaleM(model, 0 , scale, scale, scale); 118 | // --------绘制---------- 119 | arrow_2.drawES20(model,view,projection); 120 | 121 | float[] mMatrixAdjustDirection_arrow3 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 122 | Matrix.setIdentityM(model, 0); 123 | // 平移 124 | Matrix.translateM(model, 0 , -620.0f , -3080.0f , -0.0f); 125 | // 调整方向 126 | Matrix.rotateM(mMatrixAdjustDirection_arrow3,0,-180.0f,1.0f, 0.0f, 0.0f); 127 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow3,0); 128 | // 绕y轴旋转 129 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 130 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 131 | // 调整大小 132 | scale = 3; 133 | Matrix.scaleM(model, 0 , scale, scale, scale); 134 | // --------绘制---------- 135 | arrow_2.drawES20(model,view,projection); 136 | 137 | float[] mMatrixAdjustDirection_arrow4 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 138 | Matrix.setIdentityM(model, 0); 139 | // 平移 140 | Matrix.translateM(model, 0 , -620.0f , -3780.0f , -0.0f); 141 | // 调整方向 142 | Matrix.rotateM(mMatrixAdjustDirection_arrow4,0,-180.0f,1.0f, 0.0f, 0.0f); 143 | Matrix.rotateM(mMatrixAdjustDirection_arrow4,0,90.0f,0.0f, 0.0f, 1.0f); 144 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow4,0); 145 | // 绕y轴旋转 146 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 147 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 148 | // 调整大小 149 | scale = 3; 150 | Matrix.scaleM(model, 0 , scale, scale, scale); 151 | // --------绘制---------- 152 | arrow_1.drawES20(model,view,projection); 153 | 154 | float[] mMatrixAdjustDirection_arrow5 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 155 | Matrix.setIdentityM(model, 0); 156 | // 平移 157 | Matrix.translateM(model, 0 , -1620.0f , -3780.0f , -0.0f); 158 | // 调整方向 159 | Matrix.rotateM(mMatrixAdjustDirection_arrow5,0,-180.0f,1.0f, 0.0f, 0.0f); 160 | Matrix.rotateM(mMatrixAdjustDirection_arrow5,0,90.0f,0.0f, 0.0f, 1.0f); 161 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow5,0); 162 | // 绕y轴旋转 163 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 164 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 165 | // 调整大小 166 | scale = 3; 167 | Matrix.scaleM(model, 0 , scale, scale, scale); 168 | // --------绘制---------- 169 | arrow_1.drawES20(model,view,projection); 170 | 171 | float[] mMatrixAdjustDirection_arrow6 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 172 | Matrix.setIdentityM(model, 0); 173 | // 平移 174 | Matrix.translateM(model, 0 , -2620.0f , -3680.0f , -0.0f); 175 | // 调整方向 176 | Matrix.rotateM(mMatrixAdjustDirection_arrow6,0,-180.0f,1.0f, 0.0f, 0.0f); 177 | Matrix.rotateM(mMatrixAdjustDirection_arrow6,0,90.0f,0.0f, 0.0f, 1.0f); 178 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow6,0); 179 | // 绕y轴旋转 180 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 181 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 182 | // 调整大小 183 | scale = 3; 184 | Matrix.scaleM(model, 0 , scale, scale, scale); 185 | // --------绘制---------- 186 | arrow_1.drawES20(model,view,projection); 187 | 188 | float[] mMatrixAdjustDirection_arrow7 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 189 | Matrix.setIdentityM(model, 0); 190 | // 平移 191 | Matrix.translateM(model, 0 , -3620.0f , -3680.0f , -0.0f); 192 | // 调整方向 193 | Matrix.rotateM(mMatrixAdjustDirection_arrow7,0,-180.0f,1.0f, 0.0f, 0.0f); 194 | Matrix.rotateM(mMatrixAdjustDirection_arrow7,0,90.0f,0.0f, 0.0f, 1.0f); 195 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow7,0); 196 | // 绕y轴旋转 197 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 198 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 199 | // 调整大小 200 | scale = 3; 201 | Matrix.scaleM(model, 0 , scale, scale, scale); 202 | // --------绘制---------- 203 | arrow_1.drawES20(model,view,projection); 204 | 205 | float[] mMatrixAdjustDirection_arrow8 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 206 | Matrix.setIdentityM(model, 0); 207 | // 平移 208 | Matrix.translateM(model, 0 , -4620.0f , -3680.0f , -0.0f); 209 | // 调整方向 210 | Matrix.rotateM(mMatrixAdjustDirection_arrow8,0,-180.0f,1.0f, 0.0f, 0.0f); 211 | Matrix.rotateM(mMatrixAdjustDirection_arrow8,0,90.0f,0.0f, 0.0f, 1.0f); 212 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow8,0); 213 | // 绕y轴旋转 214 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 215 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 216 | // 调整大小 217 | scale = 3; 218 | Matrix.scaleM(model, 0 , scale, scale, scale); 219 | // --------绘制---------- 220 | arrow_1.drawES20(model,view,projection); 221 | 222 | float[] mMatrixAdjustDirection_arrow9 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 223 | Matrix.setIdentityM(model, 0); 224 | // 平移 225 | Matrix.translateM(model, 0 , -5620.0f , -3680.0f , -0.0f); 226 | // 调整方向 227 | Matrix.rotateM(mMatrixAdjustDirection_arrow9,0,-180.0f,1.0f, 0.0f, 0.0f); 228 | Matrix.rotateM(mMatrixAdjustDirection_arrow9,0,90.0f,0.0f, 0.0f, 1.0f); 229 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow9,0); 230 | // 绕y轴旋转 231 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 232 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 233 | // 调整大小 234 | scale = 3; 235 | Matrix.scaleM(model, 0 , scale, scale, scale); 236 | // --------绘制---------- 237 | arrow_1.drawES20(model,view,projection); 238 | 239 | float[] mMatrixAdjustDirection_arrow10 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 240 | Matrix.setIdentityM(model, 0); 241 | // 平移 242 | Matrix.translateM(model, 0 , -6620.0f , -3580.0f , -0.0f); 243 | // 调整方向 244 | Matrix.rotateM(mMatrixAdjustDirection_arrow10,0,-180.0f,1.0f, 0.0f, 0.0f); 245 | Matrix.rotateM(mMatrixAdjustDirection_arrow10,0,90.0f,0.0f, 0.0f, 1.0f); 246 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow10,0); 247 | // 绕y轴旋转 248 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 249 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 250 | // 调整大小 251 | scale = 3; 252 | Matrix.scaleM(model, 0 , scale, scale, scale); 253 | // --------绘制---------- 254 | arrow_1.drawES20(model,view,projection); 255 | 256 | float[] mMatrixAdjustDirection_arrow11 = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 257 | Matrix.setIdentityM(model, 0); 258 | // 平移 259 | Matrix.translateM(model, 0 , -7500.0f , -3580.0f , -0.0f); 260 | // 调整方向 261 | Matrix.rotateM(mMatrixAdjustDirection_arrow11,0,-180.0f,1.0f, 0.0f, 0.0f); 262 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_arrow11,0); 263 | // 绕y轴旋转 264 | Matrix.rotateM(mMatrixCurrent,0,0.1f,0.0f, 1.0f, 0.0f); 265 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent,0); 266 | // 调整大小 267 | scale = 3; 268 | Matrix.scaleM(model, 0 , scale, scale, scale); 269 | // -----------绘制---------- 270 | arrow_1.drawES20(model,view,projection); 271 | 272 | 273 | // ------------------人的模型矩阵-------------------- 274 | float[] mMatrixAdjustDirection_man = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}; 275 | Matrix.setIdentityM(model, 0); 276 | // 向x轴负方向平移 277 | Matrix.translateM(model, 0 , -500.0f , -370.0f , -50.0f); 278 | // 调整方向 279 | Matrix.rotateM(mMatrixAdjustDirection_man,0,90.0f,1.0f, 0.0f, 0.0f); 280 | Matrix.multiplyMM(model,0,model,0,mMatrixAdjustDirection_man,0); 281 | // 调整大小 282 | scale = 10; 283 | Matrix.scaleM(model, 0 , scale, scale, scale); 284 | // -------绘制---------- 285 | man.drawES20(model,view,projection); 286 | 287 | 288 | 289 | // --------------------绘制箱子------------------------ 290 | // --------箱子1-------- 291 | // 模型矩阵进行相应的变换 292 | Matrix.setIdentityM(model, 0); 293 | // 平移 294 | Matrix.translateM(model, 0 , -5000.0f , -6080.0f , -0.0f); 295 | // 绕z轴旋转 296 | Matrix.rotateM(mMatrixCurrent_cube1,0,0.2f,0.0f, 0.0f, 1.0f); 297 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent_cube1,0); 298 | // 调整大小 299 | scale = 13; 300 | Matrix.scaleM(model, 0 , scale, scale, scale); 301 | cube.drawES20(model,view,projection); 302 | 303 | // --------箱子2-------- 304 | // 模型矩阵进行相应的变换 305 | Matrix.setIdentityM(model, 0); 306 | // 平移 307 | Matrix.translateM(model, 0 , -3000.0f , -6080.0f , -0.0f); 308 | // 绕z轴旋转 309 | Matrix.rotateM(mMatrixCurrent_cube1,0,0.2f,0.0f, 0.0f, 1.0f); 310 | Matrix.multiplyMM(model,0,model,0,mMatrixCurrent_cube1,0); 311 | // 调整大小 312 | scale = 13; 313 | Matrix.scaleM(model, 0 , scale, scale, scale); 314 | cube.drawES20(model,view,projection); 315 | 316 | } 317 | 318 | @Override 319 | public void onSurfaceChanged(GL10 gl, int width, int height) { 320 | this.width = width; 321 | this.height = height; 322 | } 323 | 324 | @Override 325 | public void onSurfaceCreated(GL10 gl, EGLConfig config) { 326 | //创建cube 327 | cube = new Cube(0.2f,0.2f,0.2f, bitmap_cube); 328 | cube.initShader(); 329 | 330 | arrow_1 = new Model(inputStream_arrow_1, bitmap_arrow1); 331 | arrow_1.initShader(); 332 | 333 | arrow_2 = new Model(inputStream_arrow_2, bitmap_arrow2); 334 | arrow_2.initShader(); 335 | 336 | man = new Model(inputStream_man, bitmap_man); 337 | man.initShader(); 338 | 339 | } 340 | 341 | @Override 342 | public void OnMapReferencechanged() { 343 | 344 | } 345 | 346 | Queue mQueue; //变换矩阵队列 347 | 348 | //保护现场 349 | public void pushMatrix(){ 350 | mQueue.offer(Arrays.copyOf(mMatrixCurrent,16)); 351 | } 352 | 353 | //恢复现场 354 | public void popMatrix(){ 355 | mMatrixCurrent=mQueue.poll(); 356 | } 357 | 358 | } 359 | -------------------------------------------------------------------------------- /java/com/sacc/gaodemap/opengl/cube/Model.java: -------------------------------------------------------------------------------- 1 | package com.sacc.gaodemap.opengl.cube; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.PointF; 5 | import android.opengl.GLES20; 6 | import android.util.Log; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.InputStream; 10 | import java.io.InputStreamReader; 11 | import java.nio.ByteBuffer; 12 | import java.nio.ByteOrder; 13 | import java.nio.FloatBuffer; 14 | import java.nio.ShortBuffer; 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.HashSet; 18 | 19 | import static javax.microedition.khronos.opengles.GL10.GL_TRIANGLE_STRIP; 20 | import static javax.microedition.khronos.opengles.GL10.GL_UNSIGNED_SHORT; 21 | 22 | public class Model { 23 | public Model(InputStream in, Bitmap bitmap){ 24 | 25 | this.in = in; 26 | 27 | this.textureId = OpenGLUtils.loadTexture(bitmap, this.textureId, true); // 加载纹理 28 | 29 | loadFromFile(); 30 | 31 | // 纹理数组缓冲器 32 | this.mGLTextureBuffer = ByteBuffer.allocateDirect(this.texCoords.length * 4) 33 | .order(ByteOrder.nativeOrder()) 34 | .asFloatBuffer(); 35 | this.mGLTextureBuffer.put(this.texCoords).position(0); 36 | 37 | // 顶点数组缓冲器 38 | this.vertextBuffer = ByteBuffer.allocateDirect(this.vertices.length * 4) 39 | .order(ByteOrder.nativeOrder()) 40 | .asFloatBuffer(); 41 | this.vertextBuffer.put(this.vertices).position(0); 42 | 43 | // 法向量数组缓冲器 44 | this.normalBuffer = ByteBuffer.allocateDirect(this.normals.length * 4) 45 | .order(ByteOrder.nativeOrder()) 46 | .asFloatBuffer(); 47 | this.normalBuffer.put(this.normals).position(0); 48 | 49 | // // 索引数组缓冲器 50 | // ByteBuffer cc= ByteBuffer.allocateDirect(index.length*2); 51 | // cc.order(ByteOrder.nativeOrder()); 52 | // indexBuffer=cc.asShortBuffer(); 53 | // indexBuffer.put(index); 54 | // indexBuffer.position(0); 55 | 56 | System.out.println(a); 57 | } 58 | 59 | private FloatBuffer vertextBuffer; 60 | private FloatBuffer mGLTextureBuffer; 61 | private FloatBuffer normalBuffer; 62 | private ShortBuffer indexBuffer; 63 | 64 | private InputStream in; 65 | 66 | private int textureId = -1; 67 | 68 | private int mGLProgId; 69 | 70 | private int mGLAttribPosition; 71 | private int mGLUniformTexture; 72 | private int mGLAttribTextureCoordinate; 73 | private int mGLAttributeNormal; 74 | 75 | private int mMatrixHandler; 76 | 77 | private float[] vertices; 78 | private float[] texCoords; 79 | private float[] normals; 80 | // private short[] index; 81 | 82 | private int a; 83 | 84 | class Shader { 85 | 86 | String vertexShader = 87 | "attribute vec3 aPos;\n" + // 顶点着色器的顶点坐标,由外部程序传入 88 | "attribute vec2 aTexCoords;\n" + // 传入的纹理坐标 89 | "attribute vec3 aNormal;"+ 90 | " \n"+ 91 | "uniform mat4 model;"+ 92 | "uniform mat4 view;"+ 93 | "uniform mat4 projection;"+ 94 | " \n" + 95 | "varying highp vec2 TexCoords;\n" + 96 | "varying vec3 Normal;\n" + 97 | "varying vec3 FragPos;\n" + 98 | " \n" + 99 | "void main()\n" + 100 | "{\n" + 101 | " FragPos = vec3(model * vec4(aPos, 1.0));\n"+ 102 | " TexCoords = aTexCoords;\n"+ 103 | " Normal = mat3(model) * aNormal;\n" + 104 | " gl_Position = projection * view * vec4(FragPos, 1.0);\n" + // 最终顶点位置 105 | "}"; 106 | 107 | String fragmentShader = 108 | "varying highp vec2 TexCoords;\n" + 109 | "varying vec3 Normal;\n" + 110 | "varying vec3 FragPos;\n" + 111 | " \n" + 112 | "uniform sampler2D inputImageTexture;\n" + // 外部传入的图片纹理 即代表整张图片的数据 113 | "uniform vec3 lightPos;\n" + 114 | "uniform vec3 lightColor;\n" + 115 | " \n" + 116 | "void main()\n" + 117 | "{\n" + 118 | " vec3 ambient = (0.2, 0.1, 0.1) * texture2D(inputImageTexture, TexCoords).rgb;\n" + 119 | " vec3 norm = normalize(Normal);\n" + 120 | " vec3 lightDir = normalize(lightPos - FragPos);\n" + 121 | " float diff = max(0.2 * dot(norm, lightDir), 0.5);\n" + 122 | " vec3 diffuse = (0.5, 0.5, 0.5) * diff * texture2D(inputImageTexture, TexCoords).rgb;;\n" + 123 | " vec3 result = ambient + diffuse;\n" + 124 | " gl_FragColor = vec4(result, 1.0);\n" + 125 | "}"; 126 | 127 | public void create() { 128 | 129 | mGLProgId = OpenGLUtils.loadProgram(vertexShader, fragmentShader); // 编译链接着色器,创建着色器程序 130 | 131 | mGLAttribPosition = GLES20.glGetAttribLocation(mGLProgId, "aPos"); // 顶点着色器的顶点坐标 132 | mGLAttribTextureCoordinate = GLES20.glGetAttribLocation(mGLProgId, "aTexCoords"); // 顶点着色器的纹理坐标 133 | mGLAttributeNormal = GLES20.glGetAttribLocation(mGLProgId, "aNormal"); // 顶点着色器的法向量坐标 134 | 135 | mGLUniformTexture = GLES20.glGetUniformLocation(mGLProgId, "inputImageTexture"); // 传入的图片纹理 136 | 137 | } 138 | } 139 | 140 | Shader shader; 141 | 142 | public void initShader() { 143 | shader = new Shader(); 144 | shader.create(); 145 | } 146 | 147 | private final float[] lightPos = {0.0f, 0.0f, 100.0f}; 148 | private final float[] lightColor = {0.2f, 0.2f, 0.2f}; 149 | 150 | public void drawES20(float[] model, float[] view, float[] projection) { 151 | 152 | GLES20.glUseProgram(mGLProgId); 153 | 154 | GLES20.glEnable(GLES20.GL_DEPTH_TEST); 155 | 156 | 157 | int lightPosHandler = GLES20.glGetUniformLocation(mGLProgId,"lightPos"); 158 | GLES20.glUniform3f(lightPosHandler,200.0f, -100.0f, 2000.0f); 159 | int lightColorHandler = GLES20.glGetUniformLocation(mGLProgId,"lightColor"); 160 | GLES20.glUniform3f(lightColorHandler,0.2f, 0.2f, 0.2f); 161 | 162 | int mModelHandler = GLES20.glGetUniformLocation(mGLProgId,"model"); 163 | GLES20.glUniformMatrix4fv(mModelHandler,1,false, model, 0); 164 | int mViewHandler = GLES20.glGetUniformLocation(mGLProgId,"view"); 165 | GLES20.glUniformMatrix4fv(mViewHandler,1,false, view, 0); 166 | int mProjectionHandler = GLES20.glGetUniformLocation(mGLProgId,"projection"); 167 | GLES20.glUniformMatrix4fv(mProjectionHandler,1,false, projection, 0); 168 | 169 | 170 | 171 | // 顶点着色器的顶点坐标 172 | vertextBuffer.position(0); 173 | GLES20.glEnableVertexAttribArray(mGLAttribPosition); 174 | GLES20.glVertexAttribPointer(mGLAttribPosition, 3, GLES20.GL_FLOAT, false, 0, vertextBuffer); 175 | 176 | // 顶点着色器的纹理坐标 177 | mGLTextureBuffer.position(0); 178 | GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate); 179 | GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, mGLTextureBuffer); 180 | 181 | // 顶点着色器的法向量坐标 182 | normalBuffer.position(0); 183 | GLES20.glEnableVertexAttribArray(mGLAttributeNormal); 184 | GLES20.glVertexAttribPointer(mGLAttributeNormal, 3, GLES20.GL_FLOAT, false, 0, normalBuffer); 185 | 186 | // 传入的图片纹理 187 | if (textureId != OpenGLUtils.NO_TEXTURE) { 188 | GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 189 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); 190 | GLES20.glUniform1i(mGLUniformTexture, 0); 191 | } 192 | 193 | GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertices.length / 3); 194 | // GLES20.glDrawElements(GLES20.GL_TRIANGLES, index.length, GLES20.GL_UNSIGNED_SHORT, indexBuffer); 195 | 196 | GLES20.glDisableVertexAttribArray(mGLAttribPosition); 197 | GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate); 198 | GLES20.glDisableVertexAttribArray(mGLAttributeNormal); 199 | GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 200 | } 201 | 202 | public void loadFromFile() { 203 | //原始顶点坐标列表--直接从obj文件中加载 204 | ArrayList alv = new ArrayList(); 205 | //法向量坐标 206 | ArrayList aln = new ArrayList(); 207 | //顶点组装面索引列表--根据面的信息从文件中加载 208 | ArrayList alFaceIndex = new ArrayList<>(); 209 | 210 | //结果顶点坐标列表--按面组织好 211 | ArrayList alvResult = new ArrayList(); 212 | //结果法向量坐标列表--按面组织好 213 | ArrayList alnResult = new ArrayList(); 214 | 215 | //原始纹理坐标列表 216 | ArrayList alt = new ArrayList(); 217 | //结果纹理坐标列表 218 | ArrayList altResult = new ArrayList(); 219 | 220 | try { 221 | InputStreamReader isr = new InputStreamReader(in); 222 | BufferedReader br = new BufferedReader(isr); 223 | String temps = null; 224 | 225 | //扫面文件,根据行类型的不同执行不同的处理逻辑 226 | while ((temps = br.readLine()) != null) { 227 | //用空格分割行中的各个组成部分 228 | String[] tempsa = temps.split("[ ]+"); 229 | if (tempsa[0].trim().equals("v")) {//此行为顶点坐标 230 | //若为顶点坐标行则提取出此顶点的XYZ坐标添加到原始顶点坐标列表中 231 | alv.add(Float.parseFloat(tempsa[1])); 232 | alv.add(Float.parseFloat(tempsa[2])); 233 | alv.add(Float.parseFloat(tempsa[3])); 234 | }else if(tempsa[0].trim().equals("vn")){ 235 | // 若为法向量坐标 236 | aln.add(Float.parseFloat(tempsa[1])); 237 | aln.add(Float.parseFloat(tempsa[2])); 238 | aln.add(Float.parseFloat(tempsa[3])); 239 | } 240 | else if (tempsa[0].trim().equals("vt")) {//此行为纹理坐标行 241 | //若为纹理坐标行则提取ST坐标并添加进原始纹理坐标列表中 242 | alt.add(Float.parseFloat(tempsa[1])); 243 | alt.add(Float.parseFloat(tempsa[2])); 244 | } else if (tempsa[0].trim().equals("f")) {//此行为三角形面 245 | /* 246 | *若为三角形面行则根据 组成面的顶点的索引从原始顶点坐标列表中 247 | *提取相应的顶点坐标值添加到结果顶点坐标列表中,同时根据三个 248 | *顶点的坐标计算出此面的法向量并添加到平均前各个索引对应的点 249 | *的法向量集合组成的Map中 250 | */ 251 | 252 | short[] index = new short[3];//三个顶点索引值的数组 253 | 254 | //计算第0个顶点的索引,并获取此顶点的XYZ三个坐标 255 | index[0] = (short) (Integer.parseInt(tempsa[1].split("/")[0]) - 1); 256 | float x0 = alv.get(3 * index[0]); 257 | float y0 = alv.get(3 * index[0] + 1); 258 | float z0 = alv.get(3 * index[0] + 2); 259 | alvResult.add(x0); 260 | alvResult.add(y0); 261 | alvResult.add(z0); 262 | 263 | //计算第1个顶点的索引,并获取此顶点的XYZ三个坐标 264 | index[1] = (short) (Integer.parseInt(tempsa[2].split("/")[0]) - 1); 265 | float x1 = alv.get(3 * index[1]); 266 | float y1 = alv.get(3 * index[1] + 1); 267 | float z1 = alv.get(3 * index[1] + 2); 268 | alvResult.add(x1); 269 | alvResult.add(y1); 270 | alvResult.add(z1); 271 | 272 | //计算第2个顶点的索引,并获取此顶点的XYZ三个坐标 273 | index[2] = (short) (Integer.parseInt(tempsa[3].split("/")[0]) - 1); 274 | float x2 = alv.get(3 * index[2]); 275 | float y2 = alv.get(3 * index[2] + 1); 276 | float z2 = alv.get(3 * index[2] + 2); 277 | alvResult.add(x2); 278 | alvResult.add(y2); 279 | alvResult.add(z2); 280 | 281 | //记录此面的顶点索引 282 | alFaceIndex.add(index[0]); 283 | alFaceIndex.add(index[1]); 284 | alFaceIndex.add(index[2]); 285 | 286 | 287 | 288 | //将纹理坐标组织到结果纹理坐标列表中 289 | //第1个顶点的纹理坐标 290 | int indexTex = Integer.parseInt(tempsa[1].split("/")[1]) - 1; 291 | altResult.add(alt.get(indexTex * 2)); 292 | altResult.add(alt.get(indexTex * 2 + 1)); 293 | //第2个顶点的纹理坐标 294 | indexTex = Integer.parseInt(tempsa[2].split("/")[1]) - 1; 295 | altResult.add(alt.get(indexTex * 2)); 296 | altResult.add(alt.get(indexTex * 2 + 1)); 297 | //第3个顶点的纹理坐标 298 | indexTex = Integer.parseInt(tempsa[3].split("/")[1]) - 1; 299 | altResult.add(alt.get(indexTex * 2)); 300 | altResult.add(alt.get(indexTex * 2 + 1)); 301 | 302 | 303 | // 获取结果法向量坐标 304 | // 第1个顶点的法向量坐标 305 | int indexNor = Integer.parseInt(tempsa[1].split("/")[2]) - 1; 306 | alnResult.add(aln.get(indexNor * 3)); 307 | alnResult.add(aln.get(indexNor * 3 + 1)); 308 | alnResult.add(aln.get(indexNor * 3 + 2)); 309 | // 第2个顶点的法向量坐标 310 | indexNor = Integer.parseInt(tempsa[2].split("/")[2]) - 1; 311 | alnResult.add(aln.get(indexNor * 3)); 312 | alnResult.add(aln.get(indexNor * 3 + 1)); 313 | alnResult.add(aln.get(indexNor * 3 + 2)); 314 | // 第3个顶点的法向量坐标 315 | indexNor = Integer.parseInt(tempsa[3].split("/")[2]) - 1; 316 | alnResult.add(aln.get(indexNor * 3)); 317 | alnResult.add(aln.get(indexNor * 3 + 1)); 318 | alnResult.add(aln.get(indexNor * 3 + 2)); 319 | } 320 | } 321 | 322 | a=2000; 323 | 324 | //生成顶点数组 325 | int size = alvResult.size(); 326 | float[] vXYZ = new float[size]; 327 | for (int i = 0; i < size; i++) { 328 | vXYZ[i] = alvResult.get(i) * 2.0f; 329 | } 330 | this.vertices = vXYZ; 331 | System.out.println("vertices:"+this.vertices.length); 332 | System.out.println("---------------------------------------------------------------------------"); 333 | 334 | //生成纹理数组 335 | size = altResult.size(); 336 | float[] tST = new float[size]; 337 | for (int i = 0; i < size; i++) { 338 | tST[i] = altResult.get(i); 339 | } 340 | this.texCoords = tST; 341 | System.out.println("texCoords:"+this.texCoords.length); 342 | System.out.println("---------------------------------------------------------------------------"); 343 | 344 | // 生成法向量数组 345 | size = alnResult.size(); 346 | float[] nXYZ = new float[size]; 347 | for(int i=0;i 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /res/drawable/blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/blue.png -------------------------------------------------------------------------------- /res/drawable/btn_default_small.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /res/drawable/btn_default_small_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_default_small_normal.9.png -------------------------------------------------------------------------------- /res/drawable/btn_default_small_normal_disable.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_default_small_normal_disable.9.png -------------------------------------------------------------------------------- /res/drawable/btn_default_small_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_default_small_pressed.9.png -------------------------------------------------------------------------------- /res/drawable/btn_map_poi.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /res/drawable/btn_nav_drag_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/btn_nav_drag_down_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_nav_drag_down_normal.png -------------------------------------------------------------------------------- /res/drawable/btn_nav_drag_down_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_nav_drag_down_pressed.png -------------------------------------------------------------------------------- /res/drawable/btn_poi_search_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/btn_poi_search_normal.png -------------------------------------------------------------------------------- /res/drawable/btn_route_next.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/btn_route_pre.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/green.jpg -------------------------------------------------------------------------------- /res/drawable/groundoverlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/groundoverlay.png -------------------------------------------------------------------------------- /res/drawable/guangao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/guangao.png -------------------------------------------------------------------------------- /res/drawable/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/heart.png -------------------------------------------------------------------------------- /res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /res/drawable/left_back.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/left_back.9.png -------------------------------------------------------------------------------- /res/drawable/marker_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/marker_blue.png -------------------------------------------------------------------------------- /res/drawable/metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/metallic.png -------------------------------------------------------------------------------- /res/drawable/mode_driving.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/mode_driving_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_driving_focused.9.png -------------------------------------------------------------------------------- /res/drawable/mode_driving_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_driving_off.9.png -------------------------------------------------------------------------------- /res/drawable/mode_driving_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_driving_on.9.png -------------------------------------------------------------------------------- /res/drawable/mode_transit.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/mode_transit_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_transit_focused.9.png -------------------------------------------------------------------------------- /res/drawable/mode_transit_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_transit_off.9.png -------------------------------------------------------------------------------- /res/drawable/mode_transit_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_transit_on.9.png -------------------------------------------------------------------------------- /res/drawable/mode_walk.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/drawable/mode_walk_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_walk_focused.9.png -------------------------------------------------------------------------------- /res/drawable/mode_walk_off.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_walk_off.9.png -------------------------------------------------------------------------------- /res/drawable/mode_walk_on.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/mode_walk_on.9.png -------------------------------------------------------------------------------- /res/drawable/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/next.png -------------------------------------------------------------------------------- /res/drawable/next_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/next_disable.png -------------------------------------------------------------------------------- /res/drawable/point.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/point.png -------------------------------------------------------------------------------- /res/drawable/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/prev.png -------------------------------------------------------------------------------- /res/drawable/prev_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/prev_disable.png -------------------------------------------------------------------------------- /res/drawable/purple_pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/purple_pin.png -------------------------------------------------------------------------------- /res/drawable/text_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /res/drawable/text_search_default.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/text_search_default.9.png -------------------------------------------------------------------------------- /res/drawable/text_search_pressed.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/text_search_pressed.9.png -------------------------------------------------------------------------------- /res/drawable/text_search_selected.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/text_search_selected.9.png -------------------------------------------------------------------------------- /res/drawable/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProEthan/3DMap/ddaad56ab32d028dbcace65f5cf3587e9c7fa59d/res/drawable/white.png -------------------------------------------------------------------------------- /res/drawable/whiteborder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /res/layout/basicmap_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 20 | 21 |