当前位置: 首页>>代码示例>>C#>>正文


C# Entity.ModifyLinearDamping方法代码示例

本文整理汇总了C#中BEPUphysics.Entities.Entity.ModifyLinearDamping方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.ModifyLinearDamping方法的具体用法?C# Entity.ModifyLinearDamping怎么用?C# Entity.ModifyLinearDamping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BEPUphysics.Entities.Entity的用法示例。


在下文中一共展示了Entity.ModifyLinearDamping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyLiquidForcesTo

 void ApplyLiquidForcesTo(Entity e, double dt)
 {
     if (e.Mass <= 0)
     {
         return;
     }
     Location min = new Location(e.CollisionInformation.BoundingBox.Min);
     Location max = new Location(e.CollisionInformation.BoundingBox.Max);
     min = min.GetBlockLocation();
     max = max.GetUpperBlockBorder();
     for (int x = (int)min.X; x < max.X; x++)
     {
         for (int y = (int)min.Y; y < max.Y; y++)
         {
             for (int z = (int)min.Z; z < max.Z; z++)
             {
                 Location c = new Location(x, y, z);
                 Material mat = (Material)TheRegion.GetBlockInternal(c).BlockMaterial;
                 if (mat.GetSolidity() != MaterialSolidity.LIQUID)
                 {
                     continue;
                 }
                 // TODO: Account for block shape?
                 double vol = e.CollisionInformation.Shape.Volume;
                 double dens = (e.Mass / vol);
                 double WaterDens = 5; // TODO: Read from material. // TODO: Sanity of values.
                 float modifier = (float)(WaterDens / dens);
                 float submod = 0.125f;
                 // TODO: Tracing accuracy!
                 Vector3 impulse = -(TheRegion.PhysicsWorld.ForceUpdater.Gravity + TheRegion.GravityNormal.ToBVector() * 0.4f) * e.Mass * dt * modifier * submod;
                 // TODO: Don't apply smaller logic this if scale is big!
                 for (float x2 = 0.25f; x2 < 1; x2 += 0.5f)
                 {
                     for (float y2 = 0.25f; y2 < 1; y2 += 0.5f)
                     {
                         for (float z2 = 0.25f; z2 < 1; z2 += 0.5f)
                         {
                             Location lc = c + new Location(x2, y2, z2);
                             RayHit rh;
                             if (e.CollisionInformation.RayCast(new Ray(lc.ToBVector(), new Vector3(0, 0, 1)), 0.01f, out rh)) // TODO: Efficiency!
                             {
                                 Vector3 center = lc.ToBVector();
                                 e.ApplyImpulse(ref center, ref impulse);
                                 e.ModifyLinearDamping(mat.GetSpeedMod());
                                 e.ModifyAngularDamping(mat.GetSpeedMod());
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:53,代码来源:LiquidVolume.cs


注:本文中的BEPUphysics.Entities.Entity.ModifyLinearDamping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。