当前位置:   article > 正文

UE5 中 Python 编程:如何设置 Cesium for Unreal 中 坐标系 和 时区 的默认值

UE5 中 Python 编程:如何设置 Cesium for Unreal 中 坐标系 和 时区 的默认值

如何设置 Cesium for Unreal 中 坐标系 和 时区 的默认值

意义:通过Python设置UE对象的值的示例,可以举一反三的获取或设置任意对象的任意值。

step1:创建一个 Cesium 项目

参照 UE5中使用Cesium for Unreal(一)1 创建项目。

step2:编写 Python 脚本

大致过程:获取场景中的 Actor 对象,然后找到要设置的值,设置值,部分值需要调用更新方法。

# 获取 cesium for unreal 中的 Actor 的默认值

import unreal

class CesiumForUnrealLibrary(object):

    ''' 获取Actor '''
    def getActor(self, name):
        actors = self.getEditor().get_all_level_actors()
        for actor in actors:
            if name in actor.get_name():
                return actor
        return None

    ''' 获取当前编辑器中的世界 '''
    def getEditor(self):
        return unreal.get_editor_subsystem(unreal.EditorActorSubsystem)


    ''' 打印对象有哪些函数 '''
    def Show(self, obj):
        help(obj)
        print('-------- 函数列表 functions -----------')
        [print(func) for func in dir(obj) if callable(getattr(obj, func)) and not func.startswith("__")]
        print('-------- 属性信息 properties -----------')
        [print(prop) for prop in dir(obj) if not callable(getattr(obj, prop)) and not prop.startswith("__")]
        print('-------- 方法和入参和返回值等信息 -----------')

MyLib = CesiumForUnrealLibrary()


# 1.替换坐标系到模型的中心点
myactor = MyLib.getActor('CesiumGeoreference')

vec = myactor.get_georeference_origin_longitude_latitude_height()
vec.x = 106.502765
vec.y = 29.613348
vec.z = 300
myactor.set_georeference_origin_longitude_latitude_height(vec)

print( myactor.get_georeference_origin_longitude_latitude_height() )


# 2.设置太阳的时区
myactor = MyLib.getActor('CesiumSunSky')
myactor.solar_time = 6.0
myactor.update_sun()

# MyLib.Show(myactor)
# print( myactor.solar_time )
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51

step3:执行 python 脚本查看效果

粘贴 Python 文件路径到 Python 控制台中执行,即可实时看到效果。
在这里插入图片描述


  1. UE5中使用Cesium for Unreal(一) ↩︎

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/416044
推荐阅读
相关标签
  

闽ICP备14008679号