本文整理汇总了C#中BoundingBox.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox.Offset方法的具体用法?C# BoundingBox.Offset怎么用?C# BoundingBox.Offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.Offset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertPointBoundingBox
public static CGRect ConvertPointBoundingBox(SymbolStyle symbolStyle, BoundingBox boundingBox, IViewport viewport)
{
var screenMin = viewport.WorldToScreen(boundingBox.Min);
var screenMax = viewport.WorldToScreen(boundingBox.Max);
//boundingBox.Offset = symbolStyle.SymbolOffset;
//var newMin = boundingBox.Min;
//var newMax = boundingBox.Max;
if (symbolStyle.SymbolOffset != null)
{
screenMin = new Geometries.Point(
screenMin.X - symbolStyle.SymbolOffset.X,
screenMin.Y - symbolStyle.SymbolOffset.Y);
screenMax = new Geometries.Point(
screenMax.X - symbolStyle.SymbolOffset.X,
screenMax.Y - symbolStyle.SymbolOffset.Y);
var w = viewport.ScreenToWorld(screenMin);
boundingBox.Offset(new Geometries.Point(w.X - boundingBox.MinX, w.Y - boundingBox.MinY));
screenMin = viewport.WorldToScreen(boundingBox.Min);
screenMax = viewport.WorldToScreen(boundingBox.Max);
}
var min = new Geometries.Point(screenMin.X - (32 / 2), screenMax.Y - (32 / 2)); //!!!
var max = new Geometries.Point((min.X + 32), (min.Y + 32)); //!!!
var frame = RoundToPixel(min, max);
//if(symbolStyle.SymbolOffset != null)
// frame.Offset ((float)symbolStyle.SymbolOffset.X, (float)symbolStyle.SymbolOffset.Y);
return frame;
}
示例2: CollideWithReachableBlocks
void CollideWithReachableBlocks( int count, ref Vector3 size,
ref BoundingBox entityBB, ref BoundingBox entityExtentBB)
{
bool wasOn = entity.onGround;
entity.onGround = false;
if( count > 0 )
QuickSort( stateCache, 0, count - 1 );
hitXMin = false; hitYMin = false; hitZMin = false;
hitXMax = false; hitYMax = false; hitZMax = false;
BoundingBox blockBB = default(BoundingBox);
for( int i = 0; i < count; i++ ) {
State state = stateCache[i];
Vector3 blockPos = new Vector3( state.X >> 3, state.Y >> 3, state.Z >> 3 );
int block = (state.X & 0x7) | (state.Y & 0x7) << 3 | (state.Z & 0x7) << 6;
blockBB.Min = blockPos + info.MinBB[block];
blockBB.Max = blockPos + info.MaxBB[block];
if( !entityExtentBB.Intersects( blockBB ) ) continue;
float tx = 0, ty = 0, tz = 0;
CalcTime( ref entity.Velocity, ref entityBB, ref blockBB, out tx, out ty, out tz );
if( tx > 1 || ty > 1 || tz > 1 )
Utils.LogDebug( "t > 1 in physics calculation.. this shouldn't have happened." );
BoundingBox finalBB = entityBB.Offset( entity.Velocity * new Vector3( tx, ty, tz ) );
// if we have hit the bottom of a block, we need to change the axis we test first.
if( !hitYMin ) {
if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
continue;
}
// if flying or falling, test the horizontal axes first.
if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
}
}