本文整理汇总了C#中HkdBreakableShape.SetStrenght方法的典型用法代码示例。如果您正苦于以下问题:C# HkdBreakableShape.SetStrenght方法的具体用法?C# HkdBreakableShape.SetStrenght怎么用?C# HkdBreakableShape.SetStrenght使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HkdBreakableShape
的用法示例。
在下文中一共展示了HkdBreakableShape.SetStrenght方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
{
base.Init(builder, cubeGrid);
ProfilerShort.Begin("FP.Init");
CheckConnectionAllowed = true;
var ob = builder as MyObjectBuilder_FracturedBlock;
if (ob.Shapes.Count == 0)
{
ProfilerShort.End();
return;
}
OriginalBlocks = new List<MyDefinitionId>();
Orientations = new List<MyBlockOrientation>();
var lst = new List<HkdShapeInstanceInfo>();
foreach (var def in ob.BlockDefinitions)
{
var blockDef = MyDefinitionManager.Static.GetCubeBlockDefinition(def);
if (MyModels.GetModelOnlyData(blockDef.Model).HavokBreakableShapes == null)
{
MyDestructionData.Static.LoadModelDestruction(blockDef, false, Vector3.One);
}
var shape = MyModels.GetModelOnlyData(blockDef.Model).HavokBreakableShapes[0];
var si = new HkdShapeInstanceInfo(shape, null, null);
lst.Add(si);
m_children.Add(si);
shape.GetChildren(m_children);
OriginalBlocks.Add(def);
}
foreach (var or in ob.BlockOrientations)
{
Orientations.Add(or);
}
m_shapes.AddRange(ob.Shapes);
for (int i = 0; i < m_children.Count; i++)
{
var child = m_children[i];
Func<MyObjectBuilder_FracturedBlock.ShapeB, bool> x = s => s.Name == child.ShapeName;
var result = m_shapes.Where(x);
if (result.Count() > 0)
{
var found = result.First();
var m = Matrix.CreateFromQuaternion(found.Orientation);
m.Translation = child.GetTransform().Translation;
var si = new HkdShapeInstanceInfo(child.Shape.Clone(), m);
if(found.Fixed)
si.Shape.SetFlagRecursively(HkdBreakableShape.Flags.IS_FIXED);
lst.Add(si);
m_shapeInfos.Add(si);
m_shapes.Remove(found);
}
else
{
child.GetChildren(m_children);
}
}
if (m_shapeInfos.Count == 0)
{
m_children.Clear();
ProfilerShort.End();
Debug.Fail("No relevant shape was found for fractured block. It was probably reexported and names changed.");
throw new Exception("No relevant shape was found for fractured block. It was probably reexported and names changed.");
}
foreach (var shape in m_shapeInfos)
{
if(! string.IsNullOrEmpty(shape.Shape.Name))
Render.AddPiece(shape.Shape.Name, Matrix.CreateFromQuaternion(Quaternion.CreateFromRotationMatrix(shape.GetTransform().GetOrientation())));
}
if (CubeGrid.CreatePhysics)
{
HkdBreakableShape compound = new HkdCompoundBreakableShape(null, m_shapeInfos);
((HkdCompoundBreakableShape)compound).RecalcMassPropsFromChildren();
Shape = compound;
var mp = new HkMassProperties();
compound.BuildMassProperties(ref mp);
Shape = new HkdBreakableShape(compound.GetShape(), ref mp);
compound.RemoveReference();
foreach (var si in m_shapeInfos)
{
var siRef = si;
Shape.AddShape(ref siRef);
}
Shape.SetStrenght(MyDestructionConstants.STRENGTH);
CreateMountPoints();
}
m_children.Clear();
foreach (var si in m_shapeInfos)
si.Shape.RemoveReference();
foreach (var si in lst)
si.RemoveReference();
m_shapeInfos.Clear();
ProfilerShort.End();
}
示例2: RecreateShape
//.........这里部分代码省略.........
if (blockDef.BuildProgressModels != null)
{
foreach (var progress in blockDef.BuildProgressModels)
{
model = progress.File;
if (VRage.Game.Models.MyModels.GetModelOnlyData(model).HavokBreakableShapes == null)
MyDestructionData.Static.LoadModelDestruction(model, blockDef, Vector3.One);
shape = VRage.Game.Models.MyModels.GetModelOnlyData(model).HavokBreakableShapes[0];
si = new HkdShapeInstanceInfo(shape, null, null);
removeRefsList.Add(si);
m_tmpChildren.Add(si);
shape.GetChildren(m_tmpChildren);
}
}
}
Debug.Assert(m_tmpShapeListInit.Count == 0);
m_tmpShapeListInit.Clear();
m_tmpShapeListInit.AddList(shapeList);
for (int i = 0; i < m_tmpChildren.Count; i++)
{
var child = m_tmpChildren[i];
var result = m_tmpShapeListInit.Where(s => s.Name == child.ShapeName);
if (result.Count() > 0)
{
var found = result.First();
var si = new HkdShapeInstanceInfo(child.Shape.Clone(), Matrix.Identity);
if (found.Fixed)
si.Shape.SetFlagRecursively(HkdBreakableShape.Flags.IS_FIXED);
removeRefsList.Add(si);
m_tmpShapeInfos.Add(si);
m_tmpShapeListInit.Remove(found);
}
else
{
child.GetChildren(m_tmpChildren);
}
}
m_tmpShapeListInit.Clear();
if (shapeList.Count > 0 && m_tmpShapeInfos.Count == 0)
{
ProfilerShort.End();
m_tmpChildren.Clear();
Debug.Fail("No relevant shape was found for fractured block. It was probably reexported and names changed. Block definition: " + Block.BlockDefinition.Id.ToString());
throw new Exception("No relevant shape was found for fractured block. It was probably reexported and names changed. Block definition: " + Block.BlockDefinition.Id.ToString());
}
if (render != null)
{
foreach (var shape in m_tmpShapeInfos)
{
if (!string.IsNullOrEmpty(shape.Shape.Name))
render.AddPiece(shape.Shape.Name, Matrix.Identity);
}
render.UpdateRenderObject(true);
}
m_tmpChildren.Clear();
if (Block.CubeGrid.CreatePhysics)
{
HkdBreakableShape compound = new HkdCompoundBreakableShape(null, m_tmpShapeInfos);
((HkdCompoundBreakableShape)compound).RecalcMassPropsFromChildren();
var mp = new HkMassProperties();
compound.BuildMassProperties(ref mp);
Shape = new HkdBreakableShape(compound.GetShape(), ref mp);
compound.RemoveReference();
foreach (var si in m_tmpShapeInfos)
{
var siRef = si;
Shape.AddShape(ref siRef);
}
Shape.SetStrenght(MyDestructionConstants.STRENGTH);
CreateMountPoints();
// Update neighbours for parent block
var blockOnPosition = Block.CubeGrid.GetCubeBlock(Block.Position);
if (blockOnPosition != null)
blockOnPosition.CubeGrid.UpdateBlockNeighbours(blockOnPosition);
if (Block.CubeGrid.Physics != null)
Block.CubeGrid.Physics.AddDirtyBlock(Block);
}
foreach (var si in m_tmpShapeInfos)
si.Shape.RemoveReference();
m_tmpShapeInfos.Clear();
foreach (var si in removeRefsList)
si.RemoveReference();
ProfilerShort.End();
}