Godot 4 源码分析 - 获取属性信息

Godot 4 源码分析 - 增加管道通信 学习研究Godot 4,很爽,虽然很庞杂,但相对于自己的水平来说,很强大,尤其是vulkan这块直接打包可用,省得自己从头琢磨。一点一点地消化、优化与完善,最终才能成为自己的。这段时间就在Godot的基础上,增加管道通信,实现Godot与本机已有程序进行通信,以备后续的无缝集成整合。其实,Godot支持各种网络通信,支持UDP、TCP等。为什么非要实现管道通信,本质上还是想看看改造效果。最终目标是实现Godot软件与自己的DrGraph软件的管道通信。 阅读详情

在管道通信基础上,可进行宿主程序与Godot的双向通信。

先拿属性信息试试手。

DrGraph端

static UnicodeString command = "Book.position";
if (InputQuery("输入窗口", "请输入待获取的属性信息", command)) {
	TDrStream_Get drGet(THelper::String::GetStringAt(command, L".", 0).Trim(),
						THelper::String::GetStringAt(command, L".", 1).Trim());
	TDllStream ds;
	ds << drGet;
	PipeStreamServer->WritePipe(ds, 1000);
}

Godot端(源码完善)

List<PropertyInfo> *p_list = new List<PropertyInfo>;
bool p_reversed = true;
destObject->get_property_list(p_list, p_reversed);
cofs << "OK";
for (List<PropertyInfo>::Iterator it = p_list->begin(); it != p_list->end(); ++it) {
	String content = it->name.ptr();
	if (it->class_name.operator String().is_empty() == false)
		content += str_format(U"[%s]", it->class_name.operator String().utf8().get_data());
	Variant value = destObject->get(it->name);
	content += str_format(U" = %s", value.operator String().utf8().get_data());
	cofs << content;
}
delete p_list;

运行结果

132. 13:20:29:829 > 【主线程】 > [Pipe.发送] > 发送数据中内容[DrGraph.28: Request - wait 1000 ms]: 
	[int]类型 > 值 = 2
	[UnicodeString]类型 > 值 = root
	[UnicodeString]类型 > 值 = propertyNames
133. 13:20:30:015 > 【主线程】 > [Pipe.Read] > 发送数据[DrGraph.28: Request - wait 1000 ms]成功返回 1837 字节... > PIPE响应中内容[godot -> DrGraph.28: Response - no return]: 
	[int]类型 > 值 = 3
	[UnicodeString]类型 > 值 = OK
	[UnicodeString]类型 > 值 = book.gd = <null>
	[UnicodeString]类型 > 值 = singlePage = false
	[UnicodeString]类型 > 值 = middleBarWidth = 0
	[UnicodeString]类型 > 值 = shader_rect[ColorRect] = ShaderRect:<ColorRect#26944209673>
	[UnicodeString]类型 > 值 = currentPageMode = false
	[UnicodeString]类型 > 值 = currentAreaType = -2
	[UnicodeString]类型 > 值 = triggleAreaMoment = 484887
	[UnicodeString]类型 > 值 = currentPageIndex = 30
	[UnicodeString]类型 > 值 = pageCount = 100
	[UnicodeString]类型 > 值 = pageImgPath = res://Pages/
	[UnicodeString]类型 > 值 = leftMouseDownMoment = 0
	[UnicodeString]类型 > 值 = underAutoTurnPage = false
	[UnicodeString]类型 > 值 = leftMouseDownPos = (0, 0)
	[UnicodeString]类型 > 值 = dllStream[DllStream] = <DllStream#67024979098>
	[UnicodeString]类型 > 值 = AutoTurnObject = <RefCounted#-9223372009692462322>
	[UnicodeString]类型 > 值 = Node2D = <null>
	[UnicodeString]类型 > 值 = Transform = <null>
	[UnicodeString]类型 > 值 = position = (0, 0)
	[UnicodeString]类型 > 值 = rotation = 0
	[UnicodeString]类型 > 值 = rotation_degrees = 0
	[UnicodeString]类型 > 值 = scale = (1, 1)
	[UnicodeString]类型 > 值 = skew = 0
	[UnicodeString]类型 > 值 = transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
	[UnicodeString]类型 > 值 = global_position = (0, 0)
	[UnicodeString]类型 > 值 = global_rotation = 0
	[UnicodeString]类型 > 值 = global_rotation_degrees = 0
	[UnicodeString]类型 > 值 = global_scale = (1, 1)
	[UnicodeString]类型 > 值 = global_skew = 0
	[UnicodeString]类型 > 值 = global_transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
	[UnicodeString]类型 > 值 = CanvasItem = <null>
	[UnicodeString]类型 > 值 = Visibility = <null>
	[UnicodeString]类型 > 值 = visible = true
	[UnicodeString]类型 > 值 = modulate = (1, 1, 1, 1)
	[UnicodeString]类型 > 值 = self_modulate = (1, 1, 1, 1)
	[UnicodeString]类型 > 值 = show_behind_parent = false
	[UnicodeString]类型 > 值 = top_level = false
	[UnicodeString]类型 > 值 = clip_children = 0
	[UnicodeString]类型 > 值 = light_mask = 1
	[UnicodeString]类型 > 值 = visibility_layer = 1
	[UnicodeString]类型 > 值 = Ordering = <null>
	[UnicodeString]类型 > 值 = z_index = 0
	[UnicodeString]类型 > 值 = z_as_relative = true
	[UnicodeString]类型 > 值 = y_sort_enabled = false
	[UnicodeString]类型 > 值 = Texture = <null>
	[UnicodeString]类型 > 值 = texture_filter = 0
	[UnicodeString]类型 > 值 = texture_repeat = 0
	[UnicodeString]类型 > 值 = Material = <null>
	[UnicodeString]类型 > 值 = material[CanvasItemMaterial,ShaderMaterial] = <Object#null>
	[UnicodeString]类型 > 值 = use_parent_material = false
	[UnicodeString]类型 > 值 = Node = <null>
	[UnicodeString]类型 > 值 = _import_path = 
	[UnicodeString]类型 > 值 = name = Book
	[UnicodeString]类型 > 值 = unique_name_in_owner = false
	[UnicodeString]类型 > 值 = scene_file_path = res://book.tscn
	[UnicodeString]类型 > 值 = owner[Node] = <Object#null>
	[UnicodeString]类型 > 值 = multiplayer[MultiplayerAPI] = <SceneMultiplayer#-9223372011168857310>
	[UnicodeString]类型 > 值 = Process = <null>
	[UnicodeString]类型 > 值 = process_mode = 0
	[UnicodeString]类型 > 值 = process_priority = 0
	[UnicodeString]类型 > 值 = Editor Description = <null>
	[UnicodeString]类型 > 值 = editor_description = 
	[UnicodeString]类型 > 值 = script[Script] = <GDScript#-9223372010984307965>

 这已具备RTTI的雏形。 

godot引擎c++源码深度解析系列一 许久没有使用c++开发过项目了,如果按照此时单位的入职要求,必须拥有项目经验的话,那我就得回到十多年前,大学的时代,哪个时候真好,电脑没有这么普及,手机没有这么智能,网络没有这么发达,信息传播没有此时的快,哪个年代,5毛钱一份的报纸或许真的很好。入职it这个行业以来,想必很多的同行,前辈们,都知道,软件开发唯一的要求,实践能力必须很强,不亲自实操,你永远不知道代码里有多少个坑,同样的一段代码,在A电脑能运行,在B电脑就运行不了,这就是环境对此的影响。 阅读详情

相关推荐

Godot 4 源码分析 - 初探

准备研究GoDot 4源码。

drgraph的博客 3668

Godot 4 源码分析 - 练手 - 和谐共生

今天看到一个微信视频,和谐共生,大概效果如下研究这么长时间的Godot,今天试试能否实现上述效果粗看一下,这个效果实现分几步:1. 画圆,并确定多个圆的位置规律2. 动点,并确定各动点的运动规律3. 综合调试。

drgraph的博客 1432

Godot 4 源码分析 - 碰撞

在真实场景中,A、B都占据相应的空间位置(3D)或平面位置(2D),在运行过程中,A、B至少有一个能动,它们的相对位置可能会变化,在某个时刻会有交叠。具体而言,一个节点的Layer值必须包含在另一个节点的Mask值中,同时另一个节点的Layer值必须包含在该节点的Mask值中。Layer与Mask应该都是32位整数,对象A有Layer与Mask属性,对象B也有Layer与Mask属性。对于敌人对象之间,可将它们分配到相同的碰撞图层并设置相应的碰撞掩码,以确保它们不会互相碰撞。果然,与猜测的一致。

drgraph的博客 3858

Godot 4 源码分析 - Project Manager

我之前一直用RAD开发Windows程序,哪里还见过这种自己从头搭起来的,比如create_project_item_control处理各工程项。_open_selected_projects_ask,其实最终调用_open_selected_projects。除去界面各控件外,就是加载工程项_load_recent_projects(),直接处理。至于其中的循环,因为在ProjectManager构造函数中,已设置。当然,还有ENTER键会直接调用_open_selected_projects_ask。

drgraph的博客 2940

Godot 4 源码分析 - 获取脚本

继续测试自定义结构发送Book.script.TAutoTurn,结果返回为对象: <GDScript#-9223372010833313372>279. 16:18:07:517 > 【主线程】 > [Pipe.发送] > 发送数据中内容[DrGraph.87: Request - wait 1000 ms]:[int]类型 > 值 = 2[UnicodeString]类型 > 值 = Book.script[UnicodeString]类型 > 值 = TAutoTurn。

drgraph的博客 1525

Godot 4 源码分析 - 动态导入图片文件

用Godot 4尝试编一个电子书软件,初步效果已经出来,并且通过管道通信接口可以获取、设置属性、调用函数,貌似能处理各种事宜了。其实不然,外因通过内因起作用,如果没把里面搞明白,功能没有开放出来,则有些需求就不能实现。比如,现在想动态加载新的图书,这就是一个实际需求。如果每一本电子书,都需要导出一次,那这个软件就太不通用了。直接加载另一图片,结果不成功这就得研究一下了。

drgraph的博客 2761

Godot 4 源码分析 - 命令行参数

粗看Godot 4的源码,稍微调试一下,发现一大堆的命令行参数。在widechar_main中Main::setup中,各命令行参数加入到List<Stirng> args中,并通过OS::get_singleton()->get_cmdline_platform_args()取得平台相关命令行参数,然后args逐项处理。

drgraph的博客 2107

Godot 4 源码分析 - 代码自动补全流程

对于Script编辑器而言,code_complete_func指向ScriptTextEditor::_code_complete_scripts,本质上是调用GDScriptLanguage::complete_code函数。1) CodeTextEditor中创建时钟code_complete_timer,其timeout超时信号绑定_code_complete_timer_timeout函数。而_line_col_changed函数(绑定caret_changed事件)会停止时钟。

drgraph的博客 1633

Godot Little Camera Preview与Godot 4.2+兼容性:升级指南与最佳实践

Godot Little Camera Preview是一款为Godot引擎设计的画中画风格预览插件,支持2D和3D相机实时预览。本指南将帮助开发者快速解决与Godot 4.2+版本的兼容性问题,掌握升级的关键步骤和最佳实践,确保插件功能稳定运行。 ## 插件核心功能与兼容性现状 Godot Little Camera Preview作为轻量级相机预览工具,主要提供以下核心功能: - 实时画中

gitblog_01129的博客 752

Godot 4 源码分析 - 日志输出

使用软件,日志可以提供比较多的运行信息,研究日志也是一种学习。Godot有两种运行模式:带控制台与不带控制台。带控制台的情况下,运行时会打开一个DOS窗口,具体的日志信息就显示在DOS窗口中。但不带控制台,就我目前的了解,这些日志就不知道在哪里显示了。

drgraph的博客 2029

Godot 4 源码分析 - 增加格式化字符串功能

这个过程中发现一个小问题:std::string没法直接转成String,String类提供了一堆构造函数,但就是没有std::string。Godot 4的主要字符串类型为String,已经设计得比较完善了,但有一个问题,格式化这块没怎么考虑。比如,要将Variant 转为 std::string,直接一路火花带闪电。不过fmt的使用方式是{},有点新鲜,貌似与C++ 20兼容,那就先用上。String中有一个format函数,但这个函数只有两个参数,这咋用?顺便再在网上转下,发现fmt库的评价不错。

drgraph的博客 1680

Godot4.x的整体架构图解析-源码阅读

Godot引擎核心架构解析 本文通过分析Godot 4.4.1源码,重点探讨了引擎的核心架构设计。文章首先指出官方架构图中关系表达不清晰的问题,进而绘制了UML类图来明确类之间的关系。特别分析了Variant与Object的关联实现,揭示了Variant作为通用数据容器如何通过内部ObjData结构持有Object引用。此外,以Sprite2D模块为例,详细说明了Scene模块与RenderingServer的依赖关系,展示了从纹理设置到最终渲染的完整调用链路。这些分析为深入理解Godot引擎的底层机制提供

Pengcode的博客 924

Godot 4 源码分析 - Path2D与PathFollow2D

因为路径是有长度的,本例中为2400,randi()值将按2400取模得到最终的随机值0 - 2399,当然也可以归一化,设置其progress_ratio值为0.0 - 1.0,意思一样。从PathFollow2D代码来看,它派生于Node2D,所以具备transform属性:Position、Rotation、Scale、Skew,对于路径上的点使用而言,这些信息就足够了,能够确定这些点的位置、方向,其实就是一个矢量。查看源码,set_progress的逻辑不只是取模,还有限制范围。

drgraph的博客 2250

GDMaim版本兼容性:支持哪些Godot版本以及如何迁移到新版本

GDMaim是一款专为Godot引擎设计的GDScript代码混淆插件,为游戏开发者提供强大的代码保护方案。本文将详细介绍GDMaim的版本兼容性,包括支持的Godot版本范围、升级迁移指南,以及在不同版本间的平滑过渡策略。无论你是初次接触GDMaim的新手,还是计划升级到最新Godot版本的老用户,这篇文章都将为你提供完整的兼容性指南。 ## 📊 GDMaim支持的Godot版本矩阵 根据

gitblog_00592的博客 782

Godot 4 源码分析 - 文件读入编码处理

今天需要读入xml文件进行处理,结果读入一个带中文的文件时,出错了。当然程序还能运行,但编译器一直报错,而且XML解析也不正确。回头看了一下,原目标文件为GB2312编码。而Godot的FileAccess不支持别的编码。其实已经读入到w里,但String::parse_utf8出错。XML文本内容解析为图形效果。

drgraph的博客 1520

Godot 源码分析(二):Vulkan 渲染后端支持全景

Godot 4.0 起把图形 API 从 OpenGL ES 3.0 升级为,并保留了对三个后端。在深入 Godot 源码之前,先把这四个 API 放在一起做一个系统对比,搞清楚"为什么 Vulkan 是第一选择",而不是其他三个。

大坡3D软件开发 317

Godot游戏案例研究:成功Godot游戏的技术分析

你是否曾经想要开发自己的游戏,却被复杂的引擎和庞大的代码库吓退?Godot引擎以其轻量级、开源免费的特性,正在成为独立游戏开发者的首选。本文将通过一个完整的Godot游戏项目案例,深入分析成功Godot游戏的技术架构和实现细节。 通过本文学到的技术要点: - ✅ Godot场景系统的模块化设计 - ✅ 2D物理引擎的精确控制 - ✅ 动画状态机的优雅实现 - ✅ 游戏状态管理的核心模式 - ✅ ...

gitblog_00287的博客 1363

Godot 源码分析(四):Vulkan 上一层的调用接口(RenderingServer / RenderingDevice / RendererRD)

本文分析了Godot引擎中Vulkan渲染接口的层次架构,从上至下分为四层:1)RenderingServer单例层提供场景、材质等高层API;2)RendererRD层实现具体场景渲染器;3)RenderingDevice层抽象平台无关的GPU操作;4)Vulkan驱动层对接原生API。这种分层设计实现了三大目标:跨平台兼容性(支持Vulkan/Metal/D3D12等)、上层业务稳定性(保持Godot3到4的接口兼容)、统一的资源管线和命令接口。文章通过调用关系图展示了各层职责划分,并详细说明了分层架构

大坡3D软件开发 699
上一篇: Godot 4 源码分析 - 增加管道通信
下一篇: Godot 4 着色器 - Shader调试
DrGraph
博客等级 码龄14年 228粉丝 77原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值