Zh/Cables and Ropes: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{LanguageBar|title = 线缆与绳索}}
{{LanguageBar|Cables|title=电缆系统}}
{{translate}}
 
{{Abstract Mapping:zh-cn}}
{{Abstract Mapping:zh-cn}}
__NOTOC__
__NOTOC__
'''Cables''' provide a simple method for adding movement and complexity to a scene for a relatively low cost. Cables can be strung between moving objects and used as a visual representation between physical constraints (springs, length constraints, etc). Cables can also dynamically be shaken or broken by level events.
'''电缆'''提供了一种简单的方法,以相对较低的性能成本为场景添加动态和复杂性。电缆可以连接在移动物体之间,作为物理约束(弹簧、长度约束等)的可视化表现。电缆还可以通过关卡事件动态摇晃或断裂。
{{note|Cables are ''not'' solid unless you make them that way. To suspend an object by a cable you must also use a physics constraint. Details below.}}
{{note|电缆默认''不具''碰撞体积,除非特别设置。要用电缆悬挂物体必须同时使用物理约束。详情见下文。}}
 
{{Bug|{{Bms|4}}中<code>cable/cable.vmt</code>材质问题较多,建议使用<code>cable/cable_lit</code>或其他替代材质。}}
== Placement ==
[[File:hammer_cables.jpg|frame|A cable strewn between two points in Hammer.]]
 
Cables are strewn through a level using the {{ent:zh-cn|move_rope}} and {{ent:zh-cn|keyframe_rope}} entities using the described method:
 
# Place a {{ent:zh-cn|move_rope}} entity at one desired anchor point for the rope.
# Place a {{ent:zh-cn|keyframe_rope}} at the second anchor point.
# Point the "Next Keyframe" field on the {{ent:zh-cn|move_rope}} to the {{ent:zh-cn|keyframe_rope}} entity.


You'll now see a line representing an estimation of how the cable will lie between the two points. Cloning the {{ent:zh-cn|keyframe_rope}} entity will automatically rename the new entity and point the entity that was cloned from to that new entity. Using this method you can quickly lay out cables through multiple points (like power lines).
== 放置方法 ==
[[File:hammer_cables.jpg|frame|Hammer中两点间铺设的电缆]]


== Appearance ==
电缆线可以完全由{{Ent|move_rope}}或{{Ent|keyframe_rope}}构成,两者内部使用相同类因此可互换。首先在第一个锚点放置任一实体,然后克隆到第二个锚点位置。新实体会自动重命名,原实体将自动指向新实体。通过此方法可快速布置多点电缆(如电力线)。
Cables have a certain amount of "slack", which is the amount of bend they have while resting between their two anchor points. Slack helps give the cables a greater sense of motion and believability. The value entered into the entity field dictates how much "extra" cable there is between the two anchor points. This is equivalent to stretching the cable directly between the two points, then adding the specified number of units to that length.


As the cable moves, the slack is not recalculated, so a cable that initially droops due to slack will become taut if one of the end points moves away from the other. Likewise, a taut cable will begin to droop if its end points move closer together. (NOTE: The {{ent:zh-cn|keyframe_rope}} entity includes a flag marked 'Auto Resize' which will recalculate the slack on the rope in realtime.  This is extremely useful for things like a crane raising an object or a counterweighted elevator.) The line representing the estimated lie of the cable in Hammer will update itself based on the values entered, and may be used as a guide for how the cable will look when seen in the engine.
== 外观表现 ==
电缆具有"松弛度"(Slack)参数,表示两个锚点间自然下垂的程度。松弛度能增强电缆的动态感和真实感。该数值表示超出两点直线距离的额外长度。当端点移动时,松弛度不会重新计算,因此:
* 端点远离时下垂的电缆会绷紧
* 端点靠近时绷紧的电缆会下垂
(注:{{Ent|keyframe_rope}}实体的'Auto Resize'属性可实时重新计算松弛度,非常适合起重机升降物体或配重电梯等场景)Hammer中的预览线会根据输入值更新,可辅助预估引擎中的最终效果。


== Behavior ==
== 行为特性 ==
Cable anchor points may be placed in {{L|Entity Hierarchy (parenting)|hierarchy}} with other objects, and will move along with those entities. In the sample map provided in the SDK, a {{L|func_door|moving door}} (cleverly disguised as a pole) provides a dynamic anchor point for two cables. As the door moves, the cables stretch and move to maintain their span. In addition, a timed {{L|env_shake}} entity periodically moves all the anchor points, causing the cables to "bounce." These techniques can be a very effective visual tool for adding movement and polish to simple moving pieces in the world.
电缆锚点可与其他物体建立{{L|Entity_Hierarchy_(parenting)|层级关系}}并随之移动。SDK示例地图中,伪装成杆子的{{Ent|func_door|移动门}}作为两个电缆的动态锚点,门移动时电缆会相应伸缩。此外定时触发的{{Ent|env_shake}}会使所有锚点震动,导致电缆"弹跳"。这些技巧能有效为场景中的简单运动部件增添动态细节。


It is possible to detach cables from their anchor points, either by a player's direct action or by triggering it to do so. When a cable receives a "Break" input, it will detach itself from the anchor point which received the input. A cable will also detach itself from an anchor point if that point is parented via hierarchy to an entity which is killed. In the sample map provided in the SDK, add a weapon_crowbar entity to the map. The tattered pole (a {{L|func_breakable}}) on the left-most side of the map can be broken with the crowbar. When the pole breaks, it triggers a "Break" output to the anchor point at its top and the cable attached to it will fall to the ground.
可通过玩家操作或触发输入使电缆从锚点脱离。当电缆收到"Break"输入时,会从接收输入的锚点断开。如果锚点的父实体被销毁,电缆也会脱离。SDK示例中,添加weapon_crowbar实体后,可用撬棍破坏左侧的{{Ent|func_breakable|破损杆子}},杆子断裂时会向顶部锚点发送"Break"输出,导致连接的电缆坠落。


By default, cables are not solid and will pass through world geometry. In some cases (especially when cables are broken), this can be visually unacceptable. By using the "Collide With World" setting on the entity, the cable can be made to collide with world geometry. Because this makes the cable more expensive, this setting is only recommended for cables that exhibit the problem of penetrating the world.
默认情况下电缆会穿透世界几何体。某些情况下(特别是电缆断裂时)这可能影响视觉效果。通过实体上的"Collide With World"设置可使电缆与世界几何体碰撞。由于会增加性能消耗,建议仅对存在穿透问题的电缆启用此功能。


== Example maps ==
== 示例地图 ==
* <code>sdk_cables.vmf</code>
* <code>sdk_cables.vmf</code>


=== TWHL example maps ===
=== TWHL示例地图 ===
* [https://twhl.info/vault.php?map=3920 A counter-weighted door]
* [https://twhl.info/vault.php?map=3920 配重门系统]
* [https://twhl.info/vault.php?map=3924 Cable shakes on blast]
* [https://twhl.info/vault.php?map=3924 爆炸震动的电缆]


== See also ==
== 相关条目 ==
* {{L|Cables on Models}} - Cable placement on models.
* {{L|Cables on Models|模型电缆布置}}
* {{ent:zh-cn|phys_lengthconstraint}} - entity that suspends an object with a unstretchable cable.
* {{Ent|phys_lengthconstraint}} - 用不可伸缩电缆悬挂物体的实体
* {{ent:zh-cn|phys_pulleyconstraint}} - entity used to make a pulley.
* {{Ent|phys_pulleyconstraint}} - 创建滑轮系统的实体
* {{ent:zh-cn|phys_spring}} - entity used to make a stretchable, springy cable.
* {{Ent|phys_spring}} - 创建弹性伸缩电缆的实体
* {{L|WiseWind}} - Wind-blown power lines
* {{L|WiseWind}} - 受风影响的电力线
* {{L|Hanging lamps}} - tutorial for making a hanging lamp prop.
* {{L|Hanging lamps}} - 制作悬挂灯具道具
* {{L|Suspended Object Trap}} - tutorial for making a trap with an object suspended by a rope.
* {{L|Suspended Object Trap}} - 制作绳索悬吊的陷阱
* {{L|Cable}} - Shader for cable materials.
* {{L|Cable}} - 电缆专用着色器
* {{L|SplineRope}} - Shader for cable materials.
* {{L|SplineRope}} - 电缆材质着色器


{{ACategory|Level Design}}
{{ACategory|Level Design|关卡设计}}

Latest revision as of 19:00, 4 July 2025

English (en)Deutsch (de)Русский (ru)中文 (zh)Translate (Translate)
概括性的地图制作系列 讨论你的想法——帮助我们写你需要的文章和想法

弹药 | 生物 | 蚁狮 | 光束和激光 | 线缆与绳索 | 动态的天空与云雾 | 色彩理论 | 战斗 | 联合军 | 压缩(起源 1) | | 尘土、雾、烟 | 升降机 | 关卡转换 | 环境光效、太阳、天气、室外 | 爆炸 | 火焰 | 植被 | 玻璃和窗户 | 猎头蟹 | 生命值 | 梯子 | 光效 | 优化 | 物理 | 视网膜扫描仪 | 声效和音乐 | 特效 | 地形 | 火车 | 炮塔 | | 武器 | 僵尸

电缆提供了一种简单的方法,以相对较低的性能成本为场景添加动态和复杂性。电缆可以连接在移动物体之间,作为物理约束(弹簧、长度约束等)的可视化表现。电缆还可以通过关卡事件动态摇晃或断裂。

Note.png注意:电缆默认不具碰撞体积,除非特别设置。要用电缆悬挂物体必须同时使用物理约束。详情见下文。
Icon-Bug.png错误:黑山 黑山cable/cable.vmt材质问题较多,建议使用cable/cable_lit或其他替代材质。  [todo tested in ?]

放置方法

Hammer中两点间铺设的电缆

电缆线可以完全由move_ropekeyframe_rope构成,两者内部使用相同类因此可互换。首先在第一个锚点放置任一实体,然后克隆到第二个锚点位置。新实体会自动重命名,原实体将自动指向新实体。通过此方法可快速布置多点电缆(如电力线)。

外观表现

电缆具有"松弛度"(Slack)参数,表示两个锚点间自然下垂的程度。松弛度能增强电缆的动态感和真实感。该数值表示超出两点直线距离的额外长度。当端点移动时,松弛度不会重新计算,因此:

  • 端点远离时下垂的电缆会绷紧
  • 端点靠近时绷紧的电缆会下垂

(注:keyframe_rope实体的'Auto Resize'属性可实时重新计算松弛度,非常适合起重机升降物体或配重电梯等场景)Hammer中的预览线会根据输入值更新,可辅助预估引擎中的最终效果。

行为特性

电缆锚点可与其他物体建立层级关系(en)并随之移动。SDK示例地图中,伪装成杆子的func_door 移动门作为两个电缆的动态锚点,门移动时电缆会相应伸缩。此外定时触发的env_shake会使所有锚点震动,导致电缆"弹跳"。这些技巧能有效为场景中的简单运动部件增添动态细节。

可通过玩家操作或触发输入使电缆从锚点脱离。当电缆收到"Break"输入时,会从接收输入的锚点断开。如果锚点的父实体被销毁,电缆也会脱离。SDK示例中,添加weapon_crowbar实体后,可用撬棍破坏左侧的func_breakable 破损杆子,杆子断裂时会向顶部锚点发送"Break"输出,导致连接的电缆坠落。

默认情况下电缆会穿透世界几何体。某些情况下(特别是电缆断裂时)这可能影响视觉效果。通过实体上的"Collide With World"设置可使电缆与世界几何体碰撞。由于会增加性能消耗,建议仅对存在穿透问题的电缆启用此功能。

示例地图

  • sdk_cables.vmf

TWHL示例地图

相关条目