π导航  


【首页】

Blender游戏引擎教程:物体上播放无声电影


【2024-04-17】 Blender学堂】


浏览图片
Blender
游戏引擎教程


1. 渲染引擎:Blender游戏

Info menu >> Engine box >> Blender Game

注:

只有当选择了Blender Game渲染引擎时,有些菜单才可用。

浏览图片

2. 视区着色:纹理化

3D View menu >> Viewport Shading box >> Textured

注:

纹理视区着色使用添加的纹理渲染游戏对象。

3. 材质着色: GLSL

Properties menu >> Render button >> Shading tab >> GLSL button

注:

视频对多纹理也有效

4. 启用GLSL设置

Enable Shaders

Enable Shadows

Enable Lights

Enable Color Management

Enable Ramps

Enable Nodes

Enable Extra Textures

注:

只有当渲染引擎选择Blender游戏后,GLSL设置才会出现。

5.添加一个对象,当作电影屏幕

3D View menu >> Add >> Mesh >> Plane

注:

这里我们用平面作为电影屏幕。

你也可以不用平面,其它人格网格游戏物体都可以当作屏幕。

6.给屏幕一个唯一的名称

Properties menu >> Object button >> Name box

注:

这里,我们把平面命名为: Movie_Screen.

7.给Movie_Screen添加一个材质

Properties menu >> Material button >> New bar

8.给材质一个唯一的名称

Properties menu >> Material button >> Name box

注:

这里,我们命名为: Screen

9.材质设置为无阴影

Properties menu >> Material button >> Shading tab >> Shadeless checkbox

注:

这不是必须的。

10. 给材质添加一个纹理。

Properties menu >> Texture tab >> New

注:

纹理用来显示电影。

11.给材质一个唯一的名称

Properties menu >> Texture tab >> Name box

注:

这里,我们命名为Movie_Curtain

12.纹理类型: Image or Movie

Properties menu >> Texture tab >> Type >> Image or Movie

13.载入一个图像,作为纹理

Properties menu >> Texture button >> Image tab >> Open

从硬盘载入图像。

注:

这里使用名为Movie_Curtain.jpg的纹理

Download: Movie_Curtain.jpg

14. 这是漫射颜色为1.00

Properties menu >> Texture button >> Influence tab >> Diffuse

Color checkbox: Enable

Color: 1.0

15. 设置Blend为Mix

Properties menu >> Texture button >> Influence tab

Blend: Mix

16.创建一个空的UV贴图

Properties menu >> Object Data button >> UV Maps tab >> Plus (+) button

注:

UV贴图用来在游戏物体上定位电影

17. 给UV贴图一个唯一的名称

Properties menu >> Object Data button >> UV Maps tab >> Name

注:

高亮名称,双击,重新命名。

这里UV贴图命名为: Movie_UV

18.纹理贴图坐标: UV

Properties menu >> Texture button >> Mapping tab >> Coordinates: UV

19.选择UV贴图: Movie_UV

Properties menu >> Texture button >> Mapping tab >> Map >> List >> Movie_UV

注:

Movie_UV是前面创建的空UV贴图

20. 选择名为Movie_Screen的网格.

Edit Mode

3D View >> Select Movie_Screen

Edit Mode:

3D View menu >> Mode box >> Edit Mode

Select All:

3D View menu >> Select >> (De)select All

注:

Movie_Screen是现实电影的平面名称。

下一步对网格进行UV展开。

必须在编辑模式下对物体进行UV展开。

21. UV图像编辑器: 选择Movie_Curtain.jpg

UV/Image Editor menu >> Image List >> Movie_Curtain.jpg

注:

Movie_Curtain.jpg在图像列表中,因为在13步中已经打开了。

如果想用不同的图像,可是使用Open.

22. UV图像编辑器: Make Movie_UV the active UV Map

UV/Image Editor >> UV Map List box >> Movie_UV

Movie_UV is in the UV Map List because we created it earlier in Blender 3D (Step 16).

注:

Movie_UV在UV贴图列表中,因为我们之前在Blender 3D中创建了它(步骤16)。

23. 3D View: UV展开平面

3D View menu >> Edit Mode

Mesh >> UV Unwrap >> Unwrap

注:

因为这是一个只有一个面的平面,所以我们可以使用“展开”对其进行UV展开。

24.UV图像编辑器: UV贴图展开图像到平面

UV/Image Editor menu >> Select >> Select/Deselect All

根据需要移动UV顶点。

25. 添加Movie.txt到文本编辑器

Text Editor >> Text >> Open

注:

Movie.txt是一个python脚本。

该脚本可作为文本文件(movie.txt)下载,因为某些Internet提供商不允许将该脚本作为python文件(movie.py)下载。

26.重新命名为Movie.py

Text Editor menu >> Name box

注:

不改名也可以。

27.添加Always传感器到Movie_Screen

选择名为Movie_Screen的平面

Logic Editor >> Sensors >> Add Sensor >> Always

激活TRUE level triggering (pulse mode)

注:

不一定要使用Always传感器。可以使用任何你想要的传感器。

Movie.pypy需要每帧都运行一次。

激活True的触发,每帧都运行Movie.py。

28. 添加Python控制器

Logic Editor >> Controllers >> Add Controller >> Python

执行方式:脚本

注:

需要一个Python控制器,运行python脚本

29. 选择Movie.py

Logic Editor >> Controllers >> Python Controller

Script >> Script List >> Movie.py

注:

先前,在文本编辑器中打开过Movie.txt。

添加Movie.txt (即Movie.py)到游戏引擎的python脚本列表。

30.添加游戏属性到Movie_Screen

Logic Editor menu >> View >> Properties

Properties tab >> Add Game Property button

注:

我们将添加材质名称和电影名称/路径作为python变量(游戏属性)。

这样我们就可以为游戏中的所有电影屏幕使用一个(并且只有一个)python脚本。

31. 属性名: movie -- 属性类型: String

Logic Editor >> Properties tab >> Property Name: movie

Logic Editor >> Properties tab >> Property Type: String

注:

String属性必须命名为movie.

Movie.py代码会查找名为movie的string属性。

32.保存blend文件

Info menu >> File >> Save As

注:

这里,我们可以命名为Movie.blend

33.下载Big Buck Bunny trailer短电影

Logic Editor >> Properties tab >> Path: BBB_Trailer.ogg

Download:

Big Buck Bunny trailer: BBB_Trailer.ogg

34. 输入电影的路径

Logic Editor >> Properties tab >> Path: BBB_Trailer.ogg

注:

这里,我们将电影bbb_trailer.ogg保存到与保存的Blend文件相同的文件夹中。

如果电影位于子文件夹中,请包括子文件夹的路径。

换句话说,如果bbb_trailer.ogg在子文件夹mymovies中,您将使用:mymovies/bb_trailer.ogg

35.添加第二个游戏属性到平面

Logic Editor >> Properties tab >> Add Game Property button

注:

我们将添加材质名称和电影名称作为python变量(游戏属性)。

这样我们就可以为游戏中的所有电影屏幕使用一个(并且只有一个)python脚本。

36.属性名: material -- 属性类型: String

Logic Editor >> Properties tab >> Property Name: material

Logic Editor >> Properties tab >> Property Type: String

注:

该string属性必须命名为material.

Movie.py代码会查找名为material的string属性。

37.输入材质名

Logic Editor >> Properties tab >> Screen

注:

这里材质名为Screen

38. 连接逻辑块

Always Sensor >> Python Controller

注:

从一个逻辑块的输出拉线到另外一个逻辑块的输入。

39.启动游戏引擎

3D View >> Movie_Screen >> Object Mode

Info menu >> Game >> Start Game Engine



                          

copyright©2018-2024 gotopie.com