本文整理汇总了C#中VRageMath.MatrixI.GetDirection方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixI.GetDirection方法的具体用法?C# MatrixI.GetDirection怎么用?C# MatrixI.GetDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRageMath.MatrixI
的用法示例。
在下文中一共展示了MatrixI.GetDirection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
internal void Transform(ref MatrixI transform)
{
Vector3I tMin;
Vector3I tMax;
Vector3I tPos;
Vector3I.Transform(ref this.Min, ref transform, out tMin);
Vector3I.Transform(ref this.Max, ref transform, out tMax);
Vector3I.Transform(ref this.Position, ref transform, out tPos);
Vector3I forward = Base6Directions.GetIntVector(transform.GetDirection(this.Orientation.Forward));
Vector3I up = Base6Directions.GetIntVector(transform.GetDirection(this.Orientation.Up));
Debug.Assert(Vector3I.Dot(ref forward, ref up) == 0);
this.InitOrientation(ref forward, ref up);
this.Min = Vector3I.Min(tMin, tMax);
this.Max = Vector3I.Max(tMin, tMax);
this.Position = tPos;
if (FatBlock != null)
FatBlock.OnTransformed(ref transform);
}
示例2: TestBlockPlacementOnGrid
protected static bool TestBlockPlacementOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I positionMin;
Vector3I.Transform(ref block.Min, ref transform, out positionMin);
Vector3I positionMax;
Vector3I.Transform(ref block.Max, ref transform, out positionMax);
Vector3I min = Vector3I.Min(positionMin, positionMax);
Vector3I max = Vector3I.Max(positionMin, positionMax);
Vector3I forward = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Forward));
Vector3I up = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Up));
MyBlockOrientation blockOrientation = new MyBlockOrientation(Base6Directions.GetDirection(forward), Base6Directions.GetDirection(up));
if (!hitGrid.CanAddCubes(min, max, blockOrientation, block.BlockDefinition))
return false;
return MyCubeGrid.TestPlacementAreaCube(hitGrid, ref settings, min, max, blockOrientation, block.BlockDefinition, ignoredEntity: hitGrid);
}
示例3: CheckConnectivityOnGrid
protected static bool CheckConnectivityOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I position;
Vector3I.Transform(ref block.Position, ref transform, out position);
Vector3I forward = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Forward));
Vector3I up = Base6Directions.GetIntVector(transform.GetDirection(block.Orientation.Up));
MyBlockOrientation blockOrientation = new MyBlockOrientation(Base6Directions.GetDirection(forward), Base6Directions.GetDirection(up));
Quaternion rotation;
blockOrientation.GetQuaternion(out rotation);
var blockDefinition = block.BlockDefinition;
return MyCubeGrid.CheckConnectivity(hitGrid, blockDefinition, blockDefinition.GetBuildProgressModelMountPoints(block.BuildLevelRatio), ref rotation, ref position);
}
示例4: ConvertRotatedGridBlockToStatic
/// <summary>
/// Converts the given block with the given matrix for static grid.
/// </summary>
private static void ConvertRotatedGridBlockToStatic(ref MatrixI transform, MyObjectBuilder_CubeBlock origBlock)
{
MyDefinitionId defId = new MyDefinitionId(origBlock.TypeId, origBlock.SubtypeName);
MyCubeBlockDefinition blockDefinition;
MyDefinitionManager.Static.TryGetCubeBlockDefinition(defId, out blockDefinition);
if (blockDefinition == null)
return;
// Orientation quaternion is not setup in origblock
MyBlockOrientation origOrientation = origBlock.BlockOrientation;
Vector3I origMin = origBlock.Min;
Vector3I origMax;
MySlimBlock.ComputeMax(blockDefinition, origOrientation, ref origMin, out origMax);
Vector3I tMin;
Vector3I tMax;
Vector3I.Transform(ref origMin, ref transform, out tMin);
Vector3I.Transform(ref origMax, ref transform, out tMax);
Base6Directions.Direction forward = transform.GetDirection(origOrientation.Forward);
Base6Directions.Direction up = transform.GetDirection(origOrientation.Up);
// Write data
MyBlockOrientation newBlockOrientation = new MyBlockOrientation(forward, up);
Quaternion rotationQuat;
newBlockOrientation.GetQuaternion(out rotationQuat);
origBlock.Orientation = rotationQuat;
origBlock.Min = Vector3I.Min(tMin, tMax);
}
示例5: TestBlockPlacementOnGrid
protected static bool TestBlockPlacementOnGrid(MySlimBlock block, ref MatrixI transform, ref MyGridPlacementSettings settings, MyCubeGrid hitGrid)
{
Vector3I positionMin;
Vector3I.Transform(ref block.Min, ref transform, out positionMin);
Vector3I positionMax;
Vector3I.Transform(ref block.Max, ref transform, out positionMax);
Vector3I min = Vector3I.Min(positionMin, positionMax);
Vector3I max = Vector3I.Max(positionMin, positionMax);
var forward = transform.GetDirection(block.Orientation.Forward);
var up = transform.GetDirection(block.Orientation.Up);
MyBlockOrientation blockOrientation = new MyBlockOrientation(forward, up);
return hitGrid.CanPlaceBlock(min, max, blockOrientation, block.BlockDefinition, ref settings);
}
示例6: MergeFromAnotherMesh
private void MergeFromAnotherMesh(MyGridNavigationMesh otherMesh, ref MatrixI transform)
{
ProfilerShort.Begin("MergeFromAnotherMesh");
m_mergeHelper.Clear();
// Save the cubes from the other mesh that are touching cubes of this mesh into a helper set.
// Also put the touched cubes from this mesh into the set.
foreach (var position in otherMesh.m_smallTriangleRegistry.Keys)
{
bool add = false;
foreach (var direction in Base6Directions.IntDirections)
{
// CH: TODO: We query the grid so far, but in the future, we should make sure that the access is thread-safe
Vector3I pos = Vector3I.Transform(position + direction, transform);
if (m_cubeSet.Contains(ref pos)) // Test the transformed position...
{
m_mergeHelper.Add(position + direction); // ... but add the original one
add = true;
}
}
if (add) m_mergeHelper.Add(position);
}
foreach (var entry in otherMesh.m_smallTriangleRegistry)
{
Vector3I originalCube = entry.Key;
Vector3I tformedCube; Vector3I.Transform(ref originalCube, ref transform, out tformedCube);
// If the cube is one of the touching cubes, we have to intersect the touching triangles
if (m_mergeHelper.Contains(originalCube))
{
// Take the touching pairs one by one and calculate triangulation of the disjoint union of the opposing faces
// Remove the opposing faces from the old block
// Add the triangulation to the mesh
// Add the rest of the navmesh from this block to the mesh
m_tmpTriangleList.Clear();
// CH: TODO. Just remove the triangles now
foreach (var direction in Base6Directions.EnumDirections)
{
Vector3I directionVec = Base6Directions.GetIntVector((int)direction);
Base6Directions.Direction tformedDirection = transform.GetDirection(direction);
Vector3I tformedFlippedVec = Base6Directions.GetIntVector((int)Base6Directions.GetFlippedDirection(tformedDirection));
// Remove face triangles from this mesh
if (m_mergeHelper.Contains(originalCube + directionVec))
{
List<int> triList = null;
if (m_smallTriangleRegistry.TryGetValue(tformedCube - tformedFlippedVec, out triList))
{
foreach (var index in triList)
{
var triangle = GetTriangle(index);
// CH: TODO: This will probably be expensive. Could we precalculate it?
if (IsFaceTriangle(triangle, tformedCube - tformedFlippedVec, tformedFlippedVec))
m_tmpTriangleList.Add(new KeyValuePair<MyNavigationTriangle, Vector3I>(triangle, tformedCube - tformedFlippedVec));
}
}
}
}
foreach (var triangle in m_tmpTriangleList)
{
RemoveTriangle(triangle.Key, triangle.Value);
}
m_tmpTriangleList.Clear();
int debugCounter = 0;
// CH: TODO: optimize this (actually whole this method)
foreach (var triangleIndex in entry.Value)
{
var triangle = otherMesh.GetTriangle(triangleIndex);
Vector3I pos = entry.Key;
bool addTriangle = true;
foreach (var direction in Base6Directions.EnumDirections)
{
Vector3I dirvec = Base6Directions.GetIntVector((int)direction);
if (m_mergeHelper.Contains(pos + dirvec) && IsFaceTriangle(triangle, pos, dirvec))
{
addTriangle = false;
break;
}
}
if (addTriangle)
{
if (debugCounter == 5) { }
CopyTriangle(triangle, pos, ref transform);
debugCounter++;
}
}
}
// Otherwise, we just transform the triangles from the other mesh and add them to this mesh
else
{
foreach (var triangleIndex in entry.Value)
{
var triangle = otherMesh.GetTriangle(triangleIndex);
//.........这里部分代码省略.........