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);

		}

五、效果

节点动画

相关推荐
石山岭14 小时前
自己动手写了一个 Android 虚拟定位 App:GPSSimulate 技术实
android·前端
杉氧16 小时前
副作用 (Side Effects) 全攻略:如何像大师一样掌控 Composable 的生命周期?
android·架构·android jetpack
Kapaseker20 小时前
Kotlin Toolchain 0.11 发布:主要是把 Amper 干没了
android·kotlin
三少爷的鞋21 小时前
Android 现代架构不需要事件总线进阶篇
android
杉氧2 天前
深入理解 Compose 重组机制:快照系统如何驱动 UI 精准刷新?
android·架构·android jetpack
召钱熏2 天前
状态枚举正确≠渲染正确:一个语音按钮的状态机边界修复实录
android·前端
杉氧2 天前
深度解析:Jetpack Compose 核心架构与底层原理 —— 十年安卓老兵的“破茧重生”
android·架构·android jetpack
通玄2 天前
Jetpack Compose 入门系列(七):ViewModel 与界面状态管理
android
落魄Android在线炒饭2 天前
Android Framework 开发技巧:android.jar 生成与系统快速编译验证
android
如此风景2 天前
Kotlin Flow操作符学习
android·kotlin