本文整理汇总了C#中HkdBreakableShape.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# HkdBreakableShape.GetChildren方法的具体用法?C# HkdBreakableShape.GetChildren怎么用?C# HkdBreakableShape.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HkdBreakableShape
的用法示例。
在下文中一共展示了HkdBreakableShape.GetChildren方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsFixed
public static bool IsFixed(HkdBreakableShape breakableShape)
{
System.Diagnostics.Debug.Assert(m_tmpInfos.Count == 0, "");
if (!breakableShape.IsValid())
return false;
if ((breakableShape.UserObject & (uint)HkdBreakableShape.Flags.IS_FIXED) != 0)
{
return true;
}
else
{
Debug.Assert(m_tmpInfos.Count == 0);
breakableShape.GetChildren(m_tmpInfos);
foreach (var child in m_tmpInfos)
{
if ((child.Shape.UserObject & (uint)HkdBreakableShape.Flags.IS_FIXED) != 0)
{
m_tmpInfos.Clear();
return true;
}
}
m_tmpInfos.Clear();
}
return false;
}
示例2: DrawBreakableShape
private void DrawBreakableShape(HkdBreakableShape breakableShape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
{
//VRageRender.MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, , Color.White, 1, false);
DrawCollisionShape(breakableShape.GetShape(), worldMatrix, alpha, ref shapeIndex, breakableShape.Name + " Strength: " + breakableShape.GetStrenght() + " Static:" + breakableShape.IsFixed());
if (!string.IsNullOrEmpty(breakableShape.Name) && breakableShape.Name != "PineTree175m_v2_001" && breakableShape.IsFixed())
{
}
DebugShapesPositions[breakableShape.Name] = worldMatrix.Translation;
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
breakableShape.GetChildren(children);
Vector3 parentCom = breakableShape.CoM;
foreach (var shapeInst in children)
{
Matrix transform = shapeInst.GetTransform();
// transform.Translation += (shapeInst.Shape.CoM - parentCom);
Matrix trWorld = transform * worldMatrix * Matrix.CreateTranslation(Vector3.Right * 2);
DrawBreakableShape(shapeInst.Shape, trWorld, alpha, ref shapeIndex);
}
}
示例3: DrawConnections
private void DrawConnections(HkdBreakableShape breakableShape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
{
List<HkdConnection> connections = new List<HkdConnection>();
breakableShape.GetConnectionList(connections);
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
breakableShape.GetChildren(children);
foreach (var conn in connections)
{
var posA = DebugShapesPositions[conn.ShapeAName];
var posB = DebugShapesPositions[conn.ShapeBName];
bool cont = false;
foreach (var child in children)
{
if ((child.ShapeName == conn.ShapeAName) || (child.ShapeName == conn.ShapeBName))
cont = true;
}
if (cont)
VRageRender.MyRenderProxy.DebugDrawLine3D(posA, posB, Color.White, Color.White, false);
}
}
示例4: DisableRefCountRec
private void DisableRefCountRec(HkdBreakableShape bShape)
{
bShape.DisableRefCount();
var lst = new List<HkdShapeInstanceInfo>();
bShape.GetChildren(lst);
foreach (var child in lst)
DisableRefCountRec(child.Shape);
}
示例5: CreatePieceData
private void CreatePieceData(MyModel model, HkdBreakableShape breakableShape)
{
//Root shape for fractured compound blocks
{
var msg = VRageRender.MyRenderProxy.PrepareAddRuntimeModel();
ProfilerShort.Begin("GetDataFromShape");
m_tmpMesh.Data = msg.ModelData;
MyDestructionData.Static.Storage.GetDataFromShape(breakableShape, m_tmpMesh);
System.Diagnostics.Debug.Assert(msg.ModelData.Sections.Count > 0, "Invalid data");
if (msg.ModelData.Sections.Count > 0)
{
if(MyFakes.USE_HAVOK_MODELS)
msg.ReplacedModel = model.AssetName;
VRageRender.MyRenderProxy.AddRuntimeModel(breakableShape.ShapeName, msg);
}
ProfilerShort.End();
}
using (m_tmpChildrenList.GetClearToken())
{
breakableShape.GetChildren(m_tmpChildrenList);
LoadChildrenShapes(m_tmpChildrenList);
}
}
示例6: ConvertAllShapesToFractureComponentShapeBuilder
private static void ConvertAllShapesToFractureComponentShapeBuilder(HkdBreakableShape shape, ref Matrix shapeRotation, MyBlockOrientation blockOrientation, HashSet<string> names, MyObjectBuilder_FractureComponentCubeBlock fractureComponentBuilder)
{
var name = shape.Name;
if (names.Contains(name))
{
MyBlockOrientation shapeOrientation = new MyBlockOrientation(ref shapeRotation);
if (shapeOrientation == blockOrientation)
{
MyObjectBuilder_FractureComponentCubeBlock.FracturedShape builderShape = new MyObjectBuilder_FractureComponentBase.FracturedShape();
builderShape.Name = name;
builderShape.Fixed = MyDestructionHelper.IsFixed(shape);
fractureComponentBuilder.Shapes.Add(builderShape);
}
}
if (shape.GetChildrenCount() > 0)
{
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
shape.GetChildren(children);
foreach (var child in children)
{
var childShapeRotation = child.GetTransform();
ConvertAllShapesToFractureComponentShapeBuilder(child.Shape, ref childShapeRotation, blockOrientation, names, fractureComponentBuilder);
}
}
}
示例7: SetDataFromCompound
public void SetDataFromCompound(HkdBreakableShape compound)
{
var render = this.Render as MyRenderComponentFracturedPiece;
if (render != null)
{
compound.GetChildren(m_shapeInfos);
foreach (var shapeInstanceInfo in m_shapeInfos)
{
System.Diagnostics.Debug.Assert(shapeInstanceInfo.IsValid(), "Invalid shapeInstanceInfo!");
if (shapeInstanceInfo.IsValid())
{
render.AddPiece(shapeInstanceInfo.ShapeName, shapeInstanceInfo.GetTransform());
}
}
m_shapeInfos.Clear();
}
}
示例8: SetShape
public virtual void SetShape(HkdBreakableShape shape, bool compound)
{
Debug.Assert(shape.IsValid());
if (Shape.IsValid())
Shape.RemoveReference();
Shape = shape;
var render = Entity.Render as MyRenderComponentFracturedPiece;
Debug.Assert(render != null);
if (render != null)
{
render.ClearModels();
if (compound)
{
Debug.Assert(m_tmpChildren.Count == 0);
shape.GetChildren(m_tmpChildren);
foreach (var shapeInstanceInfo in m_tmpChildren)
{
System.Diagnostics.Debug.Assert(shapeInstanceInfo.IsValid(), "Invalid shapeInstanceInfo!");
if (shapeInstanceInfo.IsValid())
{
render.AddPiece(shapeInstanceInfo.ShapeName, Matrix.Identity);
}
}
m_tmpChildren.Clear();
}
else
{
render.AddPiece(shape.Name, Matrix.Identity);
}
render.UpdateRenderObject(true);
}
}
示例9: GetAllBlockBreakableShapeNames
private static void GetAllBlockBreakableShapeNames(HkdBreakableShape shape, HashSet<string> outNames)
{
var name = shape.Name;
if (!string.IsNullOrEmpty(name))
outNames.Add(name);
if (shape.GetChildrenCount() > 0)
{
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
shape.GetChildren(children);
foreach (var child in children)
GetAllBlockBreakableShapeNames(child.Shape, outNames);
}
}
示例10: GetCurrentFracturedShapeList
private static bool GetCurrentFracturedShapeList(HkdBreakableShape breakableShape, List<MyObjectBuilder_FractureComponentBase.FracturedShape> shapeList, string[] excludeShapeNames = null)
{
Debug.Assert(breakableShape.IsValid());
if (!breakableShape.IsValid())
return false;
var shapeName = breakableShape.Name;
bool shapeNameEmpty = string.IsNullOrEmpty(shapeName);
if (excludeShapeNames != null && !shapeNameEmpty)
{
foreach (var shapeNameToRemove in excludeShapeNames)
{
if (shapeName == shapeNameToRemove)
return false;
}
}
if (breakableShape.GetChildrenCount() > 0)
{
List<HkdShapeInstanceInfo> shapeInst = new List<HkdShapeInstanceInfo>();
breakableShape.GetChildren(shapeInst);
bool allChildrenAdded = true;
foreach (var inst in shapeInst)
{
allChildrenAdded &= GetCurrentFracturedShapeList(inst.Shape, shapeList, excludeShapeNames: excludeShapeNames);
}
if (!shapeNameEmpty && allChildrenAdded)
{
foreach (var inst in shapeInst)
{
if (inst.Shape.IsValid())
shapeList.RemoveAll(s => s.Name == inst.ShapeName);
}
shapeList.Add(new MyObjectBuilder_FractureComponentBase.FracturedShape() { Name = shapeName, Fixed = breakableShape.IsFixed() });
}
return allChildrenAdded;
}
else
{
if (!shapeNameEmpty)
{
shapeList.Add(new MyObjectBuilder_FractureComponentBase.FracturedShape() { Name = shapeName, Fixed = breakableShape.IsFixed() });
return true;
}
}
return false;
}
示例11: ConvertAllShapesToFractureComponentShapeBuilder
private static void ConvertAllShapesToFractureComponentShapeBuilder(HkdBreakableShape shape, ref Matrix shapeRotation, MyBlockOrientation blockOrientation,
HashSet<Tuple<string, float>> namesAndBuildProgress, MyObjectBuilder_FractureComponentCubeBlock fractureComponentBuilder, out float buildProgress)
{
buildProgress = 1f;
var name = shape.Name;
Tuple<string, float> foundTuple = null;
foreach (var tuple in namesAndBuildProgress)
{
if (tuple.Item1 == name)
{
foundTuple = tuple;
break;
}
}
if (foundTuple != null)
{
MyBlockOrientation shapeOrientation = new MyBlockOrientation(ref shapeRotation);
if (shapeOrientation == blockOrientation)
{
MyObjectBuilder_FractureComponentCubeBlock.FracturedShape builderShape = new MyObjectBuilder_FractureComponentBase.FracturedShape();
builderShape.Name = name;
builderShape.Fixed = MyDestructionHelper.IsFixed(shape);
fractureComponentBuilder.Shapes.Add(builderShape);
buildProgress = foundTuple.Item2;
}
}
if (shape.GetChildrenCount() > 0)
{
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
shape.GetChildren(children);
foreach (var child in children)
{
var childShapeRotation = child.GetTransform();
float localBuildProgress;
ConvertAllShapesToFractureComponentShapeBuilder(child.Shape, ref childShapeRotation, blockOrientation, namesAndBuildProgress,
fractureComponentBuilder, out localBuildProgress);
if (foundTuple == null)
buildProgress = localBuildProgress;
}
}
}
示例12: GetAllBlockBreakableShapeNames
public static void GetAllBlockBreakableShapeNames(HkdBreakableShape shape, HashSet<Tuple<string, float>> outNamesAndBuildProgress, float buildProgress)
{
var name = shape.Name;
if (!string.IsNullOrEmpty(name))
outNamesAndBuildProgress.Add(new Tuple<string, float>(name, buildProgress));
if (shape.GetChildrenCount() > 0)
{
List<HkdShapeInstanceInfo> children = new List<HkdShapeInstanceInfo>();
shape.GetChildren(children);
foreach (var child in children)
GetAllBlockBreakableShapeNames(child.Shape, outNamesAndBuildProgress, buildProgress);
}
}
示例13: SetDataFromHavok
/// <summary>
/// Sets model from havok to render component of this entity.
/// </summary>
public void SetDataFromHavok(HkdBreakableShape shape)
{
ProfilerShort.Begin("FP.SetDataFromHavok");
Shape = shape;
Shape.AddReference();
if (Render != null)
{
if (shape.IsCompound() || string.IsNullOrEmpty(shape.Name))
{
shape.GetChildren(m_shapeInfos);
Debug.Assert(m_shapeInfos.Count > 0);
foreach (var shapeInstanceInfo in m_shapeInfos)
{
//System.Diagnostics.Debug.Assert(shapeInstanceInfo.IsValid(), "Invalid shapeInstanceInfo!");
if (shapeInstanceInfo.IsValid())
{
Render.AddPiece(shapeInstanceInfo.ShapeName, shapeInstanceInfo.GetTransform());
}
}
m_shapeInfos.Clear();
}
else
Render.AddPiece(shape.Name, Matrix.Identity);
}
ProfilerShort.End();
m_hitPoints = Shape.Volume * 100;
}
示例14: ConnectShapesWithChildren
public static void ConnectShapesWithChildren(HkdBreakableShape parent, HkdBreakableShape shapeA, HkdBreakableShape shapeB)
{
var c = CreateConnection(shapeA, shapeB, shapeA.CoM, shapeB.CoM);
//parent.AddConnection(ref c);
c.AddToCommonParent();
c.RemoveReference();
shapeB.GetChildren(m_shapeInfosList3);
foreach (var child in m_shapeInfosList3)
{
var c2 = CreateConnection(shapeA, child.Shape, shapeA.CoM, shapeB.CoM);
//parent.AddConnection(ref c2);
c2.AddToCommonParent();
c2.RemoveReference();
}
m_shapeInfosList3.Clear();
}