SuperMap iMobile for Android中模型按照指定路径运动

文章目录


一、在iDesktopX中创建kml并添加模型

1、新建球面场景

2、新建kml

3、添加模型

这里添加静态模型和轨迹模型均可

支持:.fbx、.3ds、.obj、.dae、.x、.osgb、.stl、.off、.gltf、.glb、.s3mb、.osg、.s3m、.sgm、.mesh格式模型

二、将kml文件以及模型文件拷贝到手机指定目录中

三、iMobile场景中加载kml图层

java 复制代码
		//初始化场景
		public SceneControl mSceneControl;
		mSceneControl = (SceneControl) findViewById(R.id.sceneControl);
		//kml图层添加到场景中
		Path = "/sdcard/SampleData/CBD_android/files/";
		mSceneControl.getScene().getLayers().addLayerWith(Path + "kml/test_1.kml", Layer3DType.KML, true,
				"NodeAnimation");

四、让模型动起来

1、获取场景中的kml图层并定位

java 复制代码
		Layer3D layer3d = mSceneControl.getScene().getLayers().get("NodeAnimation");
        mSceneControl.getScene().ensureVisible(layer3d);

2、获取模型并让他动起来

java 复制代码
		//获取GeoPlacemark 
		GeoPlacemark placemark = (GeoPlacemark) ((Feature3D)mSceneControl.getScene().getLayers().get(0).getFeatures().get(0)).getGeometry();
		GeoModel3D myGeoModel = (GeoModel3D) placemark.getGeometry();
		//获取三维模型对象的节点动画
		nodeAnimation = myGeoModel.getNodeAnimation();
		//设置节点动画的播放模式
		nodeAnimation.setPlayMode(nodeAnimationPlayMode);
		//这里的geoline3d为模型的运动路线
		if (geoline3d != null) {
			//设置获取节点动画运行周期的时长,单位:秒。
			nodeAnimation.setLength(mTime);
			Log.v("lzw", "startnodeAnimation mTime=" + mTime);
			//开启节点动画
			nodeAnimation.setEnabled(true);
			//设置节点动画的运动轨迹,目前只接受类型为 GeoLine3D的参数,其他类型无效。
			nodeAnimation.setTrack(geoline3d);
		} else {
			nodeAnimation.setEnabled(false);

		}

五、效果

节点动画

相关推荐
hai_android3 小时前
一行 asLiveData,背后是一座生命周期的桥
android·java·kotlin
阿杰m4 小时前
Android源码第二十三章:Telephony、RIL 与 IMS——来电怎么到应用?
android
booboosui4 小时前
没人认领 .md:安卓把报告交给了音乐播放器打开
android
用户60709759149067 小时前
AOSP 14 OTA 升级指导(四):update_engine 内部机制——Action 流水线与写盘
android
恋猫de小郭11 小时前
Jetpack Compose 1.13 发布,憋了这么久终有交代了
android·前端·flutter
JMchen12311 小时前
【Android 性能优化实战 60 讲】12 异步 Inflate 实战与痛击:源码拆解原生瓶颈,手写增强版布局预加载框架
android·性能优化·实战·启动优化·异步inflate·x2c
好的佩奇1 天前
蓝牙之设备角色与连接
android·flutter·蓝牙
雨白1 天前
Android 消息机制剖析:从 Handler 投递到 Looper 循环的全链路
android
GY-931 天前
【Android】数据分层和依赖注入
android
传奇开心果编程1 天前
【Jetpack Compose娓娓道来】第44课:持久化——让数据“关掉App也不丢”
android·kotlin·移动开发·数据持久化·jetpack compose·ui框架·声明式ui