例子说明
The examples included with Urho3D consist of two larger applications built in AngelScript, and a set of smaller sample applications provided in both C++, AngelScript and Lua, which demonstrate a specific engine feature.
Urho3D的例子中包含两个大的用AngelScript构建的应用程序和一套小的用C++, AngelScript和Lua开发的用以展示引擎的具体特性的示例程序.
NinjaSnowWar
The first of the larger examples is a third-person action game. To start, run NinjaSnowWar.bat or NinjaSnowWar.sh in the Bin directory, or use the command Urho3DPlayer Scripts/NinjaSnowWar.as
NinjaSnowWar
第一个大的例子是一个第三人称动作游戏.运行NinjaSnowWar.bat或者在Bin目录运行NinjaSnowWar.sh, 或者使用命令 Urho3DPlayer Scripts/NinjaSnowWar.as 来启动程序
Key and mouse controls:
- WSAD Move
- Left mouse Attack
- Space Jump
- ESC Exit
- F1 Toggle console
- F2 Toggle profiling display
- F3 Toggle physics debug geometry
- F4 Toggle octree debug geometry
- If a joystick is connected, it can also be used for controlling the player character.
键盘和鼠标控制:
- WSAD 移动
- 鼠标左键 攻击
- 空格 跳起
- ESC 退出
- F1 切换控制台
- F2 切换性能分析显示
- F3 切换几何体物理调试
- F4 切换几何体八叉树调试
- 如果链接了操作杆, 可用来控制玩家角色.
NinjaSnowWar also supports client/server multiplayer. To start the server, run the command NinjaSnowWar.bat -server
(-headless option can optionally given so that the server will not open a graphics window.) To connect to a server, specify the option -address followed by the server address (for example -address 127.0.0.1). Optionally set client username with the option -username, followed by the desired name. Use -nobgm option to switch music off.
NinjaSnowWar还支持客户端/服务器模式的多人游戏.运行命令 NinjaSnowWar.bat –server
来启动服务器(任选参数-headless可让服务器不打开图形窗口). 指定-address参数并在后面跟服务器的地址来连接服务器(比如 -address 127.0.0.1). 用可选参数-username后跟你想要的名字来设置客户端用户名. 用-nobgm选项关闭音乐.
Editor
The second larger example is a scene and UI layout editor application written in script. To start, run Editor.bat or Editor.sh, or use the command Urho3DPlayer Scripts/Editor.as
For details on how to use the editor, see Editor instructions.
Editor
第二个大的例子是用脚本实现的场景和UI布局编辑器程序. 运行Editor.bat或者 Editor.sh, 或者使用命令Urho3DPlayer Scripts/Editor.as来启动程序.
怎样使用编辑器的细节, 参见”编辑器指令”
Sample applications
The sample applications start from the very simple (a “Hello World” program) and progress to demonstrate more complex engine features. The code is heavily commented and should be easy to follow for learning. The applications display on-screen instructions when run.
示例程序
例子程序从非常简单(一个“Hello World”程序)开始逐步到比较复杂的引擎特性. 代码有大量的注释便于学习. 程序运行的时候会在屏幕上显示命令.
The AngelScript and Lua versions reside in the Bin/Data/Scripts and Bin/Data/LuaScripts directories. Batch files to run each of them are not provided due to their large amount: instead run the player application with the script file name as the parameter, for example Urho3DPlayer Scripts/01_HelloWorld.as
AngelScript和Lua版本的示例位于Bin/Data/Scripts和Bin/Data/LuaScripts目录. 由于他们数量很大, 不为他们每个都提供批处理文件来运行: 而是使用脚本文件作为参数来运行Urho3DPlayer程序, 例如Urho3DPlayer Scripts/01_HelloWorld.as
The C++ versions need to be explicitly enabled in the build with the CMake option -DURHO3D_SAMPLES=1. When enabled, the executables will be produced into the Bin directory and can be run from there. Their source code is in the Source/Samples directory.
C++版本的示例需要在使用CMake构建时候明确启用选项-DURHO3D_SAMPLES=1. 当选项被启用, 可执行文件将生成在Bin目录并且可以在那里运行. 源代码在Source/Samples目录.
The samples provide the following common key controls:
- ESC Exit
- F1 Toggle console
- F2 Toggle debug HUD
- 1 Cycle texture quality
- 2 Cycle material quality
- 3 Toggle specular lighting
- 4 Toggle shadow rendering
- 5 Cycle shadow resolution
- 6 Cycle shadow filtering quality
- 7 Toggle occlusion culling
- 8 Toggle dynamic instancing
- 9 Take a screenshot and save to the Data directory
例子提供下面的键盘控制:
- ESC 退出
- F1 切换控制台
- F2 切换Debug显示
- 1 循环切换纹理级别
- 2 循环切换材质级别
- 3 切换镜面反射光照
- 4 切换阴影渲染
- 5 循环切换阴影分辨率
- 6 循环切换阴影过滤级别
- 7 切换遮挡剔除
- 8 切换动态实例
- 9 抓屏并保存到Data目录