当前位置:网站首页>Cherno_游戏引擎系列教程(5):101~
Cherno_游戏引擎系列教程(5):101~
2022-04-22 06:44:00 【亲亲老婆几】
文章目录
- 引擎开发计划:
- 101. Content Browser/Asset Panel
- 102. Content Browser Panel - ImGui Drag Drop
- 103. Textures for Entities!
- 105. PLAY BUTTON!
- 106. 2D PHYSICS!
- 107. Universally Unique Identifiers (UUID/GUID)
- 108. Playing and Stopping Scenes (and Resetting)
- 109. Rendering Circles in a Game Engine
- 110. Rendering Lines in a Game Engine
- 111. Circle Physics Colliders
- 112. Visualizing Physics Colliders
引擎开发计划:
shader编译系统(cache)
hlsl -> glsl
参考:
https://zhuanlan.zhihu.com/p/462659745
https://zhuanlan.zhihu.com/p/56510874
再借鉴虚幻引擎源码:

可以利用 ShaderConductor,其又可以依赖:SPIRV-Cross、DirectXShaderCompiler(DXC)、cxxopts 等。
当前计划:希望可以以后只写一份 hlsl,每次编译都编好适用各个图形api的情形,存入 cache 中。
关于着色器反射,对于 spir-v,有 SPIRV-Reflect:

dx 不知道是有effect之类的还是dx12的官方的着色器反射。
代码反射系统(可以参考 games104 和 虚幻引擎的实现)。
101. Content Browser/Asset Panel
我们显然要使用标准库的 filesystem

这里 stem 和 filename 的区别是有无文件后缀,比如:

102. Content Browser Panel - ImGui Drag Drop
我们这里必须要唯一 id 标识,否则应该用 ImageButtonEx 之类的。
Content Browser Panel - ImGui Drag Drop
不然会导致拖入场景总是一个的bug。
还有一个注意的是这里:
ImGui::SetDragDropPayload("CONTENT_BROWSER_ITEM", itemPath, (wcslen(itemPath) + 1) * sizeof(wchar_t), ImGuiCond_Once);
我们路径名的大小写作:(wcslen(itemPath) + 1) * sizeof(wchar_t),加1是因为 null terminal 啥的东东(其实就是那个 \0 ?)
103. Textures for Entities!
105. PLAY BUTTON!
106. 2D PHYSICS!
一般我们的更新顺序是 script -> physics -> render
可见于Scene::OnUpdateRuntime
107. Universally Unique Identifiers (UUID/GUID)
这里 uuid 我们每次都是随机搞一个值,而不是简单的 ++,比如 0123456 代表 7 个 entity,原因是比如一个游戏有多个人去构建,那么就可能两个人都创造一个 entity 而标号都变成 5 + 1 = 6 这样的情形。
当然也可以搞一个 server 每次都从 server 那里获取一个特定的 id
我们可以简单地用一个比如 unordered_set 去检测冲突。
想让 unordered_map 能够用我们的 UUID 作为 key, 写如下模板特化:
namespace std
{
template<>
struct hash<HEngine::UUID>
{
std::size_t operator()(const HEngine::UUID& uuid) const
{
return hash<uint64_t>()((uint64_t)uuid);
}
};
}
有的人建议用一个 unordeed_set 之类地去检测,如下:

但是 cherno 不建议这样做,两点原因:
- 冲突的风险其实很低,而这样做降低性能
- 这是 local 的,意味着换一台电脑别人做这个项目就完全没有用了。
108. Playing and Stopping Scenes (and Resetting)
109. Rendering Circles in a Game Engine
110. Rendering Lines in a Game Engine
111. Circle Physics Colliders
这里我发现是有点问题的,就是物理系统的半径等值是在 Scene.cpp 的 OnRuntimeStart 函数中预先设置好的,但是依赖那些 component 的初始值,比如我们这里的 CircleCollider2DComponent,如果半径和实际渲染的物体的半径不相等就出问题了。因此我认为实际上应该在每帧赋值一下。
112. Visualizing Physics Colliders
版权声明
本文为[亲亲老婆几]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_47652005/article/details/124082759
边栏推荐
- MYSQL_从精通到放弃目录
- 2022年全国中职组网络安全国赛赛题思路(仅自己一个做题的思路)——网络安全竞赛试题(9)
- VS Code 设置换行
- Shiping information appeared at the China traditional Chinese medicine information conference to help build the data security system of the pharmaceutical industry
- web自动化:5.1selenium鼠标操作-单击、双击、右击、悬停、拖拽
- 学生成绩管理
- Web problem location practice: 2 Prompt information and field verification
- web自动化:8.3 selenium中如何实现浏览器的窗口滚动
- [Shiping information] solutions for confidentiality inspection and compliance control of recorded content
- Shrio study notes (II)
猜你喜欢

jmeter_ Mysql database connection

通用测试技术【一】测试的分类

The JMeter interface requests a security authentication solution

OpenFeign调用详细日志展示

通用测试技术【二】测试方法

Web automation: 4.2 selenium how to switch iframe windows (3 methods)

Under the window environment, VirtualBox loads the virtual machine created in the mobile hard disk
![Eight elder brothers chronicle [3]](/img/8f/33ac4fe97925bed3c393438f230711.png)
Eight elder brothers chronicle [3]

web自动化:8.1如何在浏览器发送js指令
![[Shiping information] solutions for confidentiality inspection and compliance control of recorded content](/img/45/bb2cc00e6d61c7c18268336d00101f.png)
[Shiping information] solutions for confidentiality inspection and compliance control of recorded content
随机推荐
openFeign 服务调用
迎接稳定币3.0时代 USDD带来金融创新
【Mock数据】fastmock根据传入参数动态返回mock内容
Web problem location practice: 2 Prompt information and field verification
Import 3D model from web page - obj / MTL file
Monkey actual combat
monkey
monkey 实战
jmeter 模拟 get 请求
Shiping information appeared at the China traditional Chinese medicine information conference to help build the data security system of the pharmaceutical industry
VS Code 设置换行
Leprechaun绿精灵魔法来袭
TP5 发送邮件(2020-05-27)
【ncnn】——param中-23300的意思
LDAP用户登录认证校验及查询
动态顺序表+OJ
JMeter performance indicator monitoring: CPU, memory, disk, network
Echars dynamically realizes the scatter diagram and customizes the information prompt box
adb logcat 日志
带有支付功能的产品测试