[{"data":1,"prerenderedAt":233},["ShallowReactive",2],{"\u002F2015-01-31-%E7%89%A9%E7%90%86%E6%A8%A1%E6%8B%9F":3},{"id":4,"title":5,"body":6,"date":209,"description":12,"extension":210,"meta":211,"navigation":214,"path":226,"seo":227,"stem":228,"tags":229,"__hash__":232},"blogs\u002F_legacy\u002F2015\u002F2015-01-31-%e7%89%a9%e7%90%86%e6%a8%a1%e6%8b%9f.md","物理模拟",{"type":7,"value":8,"toc":197},"minimark",[9,13,17,20,23,26,33,36,39,44,55,59,62,66,69,73,76,80,83,89,92,97,100,154,158,161,166,170,173,178,187,190,193],[10,11,12],"p",{},"当前UE4使用PhysX3.3作为物理引擎。",[14,15,16],"h2",{"id":16},"碰撞体生成",[10,18,19],{},"碰撞体的生成方式有三种",[10,21,22],{},"第一种是，简单图形碰撞，提供球体、方体和胶囊三种形状的选择。碰撞成本最低，在很多情况下效果也很不错。",[10,24,25],{},"第二种是，基于离散定向多面体的生成方式。K-DOP的方式中，K的值越高的话，理论上碰撞的精度就会提高。但是同时的，碰撞的运算量耗费也会提升。官方的配图非常的形象：",[10,27,28],{},[29,30],"img",{"alt":31,"src":32},"kdop_sizes.jpg","\u002Fwp-content\u002Fuploads\u002F2015\u002F01\u002Fkdop_sizes.jpg",[10,34,35],{},"第三种是凸面碰撞，用的是凸包方法。生成的碰撞图形非常的精确，对于模型不规则又要求精确碰撞的情形比较有效。不过相对的，碰撞成本也非常的高。",[10,37,38],{},"游戏预览中可以使用控制台来打开碰撞调试的开关，打开之后可以看到场景中各个物体的碰撞图形。可以方便进行碰撞的调试。",[40,41,43],"h3",{"id":42},"physics-constraint","Physics Constraint",[10,45,46,47,54],{},"物理约束提供物体之间的连接，根据属性的设置不同会有不同的效果。可以指定连接某个物体的组件，当和人物骨架连接时需要指定连接的骨骼名。连接可以设置选择或者拉伸极限。详细设定可以参照",[48,49,53],"a",{"href":50,"rel":51},"https:\u002F\u002Fdocs.unrealengine.com\u002Flatest\u002FINT\u002FEngine\u002FPhysics\u002FConstraints\u002FConstraintsReference\u002Findex.html",[52],"nofollow","文档","在引擎中测试。",[40,56,58],{"id":57},"physics-damping","Physics Damping",[10,60,61],{},"阻尼分为线性的和旋转的两种。30的线性阻尼足以使物体在初始化时抵挡9.8的重力而不下落。使得有力量作用的运动物体停止的最小线性阻尼是100。在没有旋转阻尼的情况下，旋转会永远进行下去。而100的旋转阻尼几乎会立刻停止旋转。在物理约束上也可以应用阻尼，使得运动超过约束设定的限度之后得以作出相应。应用于约束的阻尼的主要选项分别是刚度和阻尼。",[14,63,65],{"id":64},"vehicles","Vehicles",[10,67,68],{},"UE4文档和范例中提供了专门的汽车演示，游戏中需要要到时可以直接新建一个sample查看官方的实现即可。",[14,70,72],{"id":71},"physical-materials","Physical Materials",[10,74,75],{},"物理材质是面向物理模拟的材质。可以设定材质的摩擦系数、反弹恢复系数、密度等一些列基本的物理属性。",[40,77,79],{"id":78},"surface-type","Surface Type",[10,81,82],{},"表面类型，可以在代码中用来判别的表面类型枚举。",[10,84,85],{},[29,86],{"alt":87,"src":88},"image","\u002Fwp-content\u002Fuploads\u002F2015\u002F01\u002Fimage_thumb1.png",[10,90,91],{},"可以在项目属性中设置",[10,93,94],{},[29,95],{"alt":87,"src":96},"\u002Fwp-content\u002Fuploads\u002F2015\u002F01\u002Fimage_thumb2.png",[10,98,99],{},"或者在项目的Config\\DefaultEngine.ini中添加，如果不觉得麻烦的话：",[101,102,107],"pre",{"className":103,"code":104,"language":105,"meta":106,"style":106},"language-ini shiki shiki-themes github-light-high-contrast github-dark monokai","[PhysicalMaterial.SurfaceTypes]\nSurfaceType1=Glass\nSurfaceType2=Metal\nSurfaceType3=Wood\nSurfaceType4=Concrete\n...\nSurfaceType30=CollapsedStar\n","ini","",[108,109,110,118,124,130,136,142,148],"code",{"__ignoreMap":106},[111,112,115],"span",{"class":113,"line":114},"line",1,[111,116,117],{},"[PhysicalMaterial.SurfaceTypes]\n",[111,119,121],{"class":113,"line":120},2,[111,122,123],{},"SurfaceType1=Glass\n",[111,125,127],{"class":113,"line":126},3,[111,128,129],{},"SurfaceType2=Metal\n",[111,131,133],{"class":113,"line":132},4,[111,134,135],{},"SurfaceType3=Wood\n",[111,137,139],{"class":113,"line":138},5,[111,140,141],{},"SurfaceType4=Concrete\n",[111,143,145],{"class":113,"line":144},6,[111,146,147],{},"...\n",[111,149,151],{"class":113,"line":150},7,[111,152,153],{},"SurfaceType30=CollapsedStar\n",[40,155,157],{"id":156},"physics-sub-stepping","Physics Sub-Stepping",[10,159,160],{},"如果打开这个功能，物理模拟会在一个与游戏逻辑独立的线程中运行。这样在同一帧中就能够就行多次物理演算，其结果是，物理模拟会变得更加的精确和真实。但是对系统资源的消耗也会同步上升。",[10,162,163],{},[29,164],{"alt":87,"src":165},"\u002Fwp-content\u002Fuploads\u002F2015\u002F01\u002Fimage_thumb3.png",[40,167,169],{"id":168},"destructible-mesh","Destructible Mesh",[10,171,172],{},"可破坏的网格，在任意一个网格物体上点击右键即可创建可破坏的网格物体",[10,174,175],{},[29,176],{"alt":87,"src":177},"\u002Fwp-content\u002Fuploads\u002F2015\u002F01\u002Fimage_thumb4.png",[10,179,180,181,186],{},"破坏网格在接受到伤害事件后就会破碎，详细的文档在",[48,182,185],{"href":183,"rel":184},"https:\u002F\u002Fdocs.unrealengine.com\u002Flatest\u002FINT\u002FEngine\u002FPhysics\u002FDestructibles\u002FDestructibleProperties\u002Findex.html",[52],"这里","。想要做出复杂的破坏效果的话，需要用到NVIDIA的Apex。",[188,189],"hr",{},[10,191,192],{},"物理模拟部分大体上就是这些了，如果要做出华丽的效果还需要和粒子系统、音效进行配合。毕竟物理引擎只是对真实环境进行模拟，很多地方还是要依靠代码来进行的。",[194,195,196],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":106,"searchDepth":120,"depth":126,"links":198},[199,203,204],{"id":16,"depth":120,"text":16,"children":200},[201,202],{"id":42,"depth":126,"text":43},{"id":57,"depth":126,"text":58},{"id":64,"depth":120,"text":65},{"id":71,"depth":120,"text":72,"children":205},[206,207,208],{"id":78,"depth":126,"text":79},{"id":156,"depth":126,"text":157},{"id":168,"depth":126,"text":169},"2015-01-31","md",{"layout":212,"status":213,"published":214,"author":215,"author_login":216,"author_email":217,"author_url":218,"wordpress_id":219,"wordpress_url":220,"date_gmt":221,"excerpt":222},"post","publish",true,{"display_name":216,"login":216,"email":217,"url":218},"chaoshikari","chaoshikari@gmail.com","\u002F",1126,"\u002F\u002F?p=1126","2015-01-31 15:17:49 +0000",{"type":7,"value":223},[224],[10,225,12],{},"\u002F2015-01-31-物理模拟",{"title":5,"description":12},"_legacy\u002F2015\u002F2015-01-31-%e7%89%a9%e7%90%86%e6%a8%a1%e6%8b%9f",[230,231],"UE4","物理","e84-jjijwAB6dEac9QTh7MW51RS5Wak5_-CBsED1OXI",1788763180990]