本文整理汇总了C#中VRageMath.MyBlockOrientation类的典型用法代码示例。如果您正苦于以下问题:C# MyBlockOrientation类的具体用法?C# MyBlockOrientation怎么用?C# MyBlockOrientation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyBlockOrientation类属于VRageMath命名空间,在下文中一共展示了MyBlockOrientation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StructureEntry
public StructureEntry( )
{
type = typeof( CubeBlockEntity );
color = new Color( 0, 0, 0 );
useOrientation = false;
orientation = MyBlockOrientation.Identity;
useSubTypeName = false;
subTypeName = "";
}
示例2: Initialize
public void Initialize(ref MyBlockBuildArea area, MyCubeBlockDefinition definition)
{
m_definition = definition;
m_orientation = new MyBlockOrientation(area.OrientationForward, area.OrientationUp);
m_posInGrid = area.PosInGrid;
m_blockMin = area.BlockMin;
m_blockMax = area.BlockMax;
m_stepDelta = area.StepDelta;
m_lookup.Clear();
}
示例3: MyGeneratedBlockLocation
public MyGeneratedBlockLocation(MySlimBlock refBlock, MyCubeBlockDefinition blockDefinition, Vector3I position, MyBlockOrientation orientation, ushort? blockIdInCompound = null, MyGridInfo gridInfo = null)
{
RefBlock = refBlock;
BlockDefinition = blockDefinition;
Position = position;
Orientation = orientation;
BlockIdInCompound = blockIdInCompound;
GridInfo = gridInfo;
GeneratedBlockType = MyStringId.NullOrEmpty;
}
示例4: TestGridPlacement
private static void TestGridPlacement(ref MyGridPlacementSettings settings, ref MatrixD worldMatrix, ref MyCubeGrid touchingGrid, float gridSize, bool isStatic, ref BoundingBoxD localAABB, MyCubeBlockDefinition blockDefinition,
MyBlockOrientation? blockOrientation, ref bool entityOverlap, ref bool touchingStaticGrid, MyCubeGrid grid)
{
var worldAabb = localAABB.Transform(ref worldMatrix);
var invWorldMatrix = grid.PositionComp.WorldMatrixNormalizedInv;
var otherLocalAabb = worldAabb.Transform(ref invWorldMatrix);
Vector3D minToWorld = Vector3D.Transform(localAABB.Min, worldMatrix);
Vector3D maxToWorld = Vector3D.Transform(localAABB.Max, worldMatrix);
Vector3D tempMinLocal = Vector3D.Transform(minToWorld, invWorldMatrix);
Vector3D tempMaxLocal = Vector3D.Transform(maxToWorld, invWorldMatrix);
Vector3D otherMinLocal = Vector3D.Min(tempMinLocal, tempMaxLocal);
Vector3D otherMaxLocal = Vector3D.Max(tempMinLocal, tempMaxLocal);
var scaledMin = (otherMinLocal + gridSize / 2) / grid.GridSize;
var scaledMax = (otherMaxLocal - gridSize / 2) / grid.GridSize;
var tempMin = Vector3I.Round(scaledMin);
var tempMax = Vector3I.Round(scaledMax);
var min = Vector3I.Min(tempMin, tempMax);
var max = Vector3I.Max(tempMin, tempMax);
MyBlockOrientation? gridBlockOrientation = null;
if (MyFakes.ENABLE_COMPOUND_BLOCKS && isStatic && grid.IsStatic && blockOrientation != null)
{
Matrix blockRotation;
blockOrientation.Value.GetMatrix(out blockRotation);
Matrix rotationInGrid = blockRotation * worldMatrix;
rotationInGrid = rotationInGrid * invWorldMatrix;
rotationInGrid.Translation = Vector3.Zero;
Base6Directions.Direction forwardDir = Base6Directions.GetForward(ref rotationInGrid);
Base6Directions.Direction upDir = Base6Directions.GetUp(ref rotationInGrid);
if (Base6Directions.IsValidBlockOrientation(forwardDir, upDir))
gridBlockOrientation = new MyBlockOrientation(forwardDir, upDir);
}
if (!grid.CanAddCubes(min, max, gridBlockOrientation, blockDefinition))
{
entityOverlap = true;
return;
}
if (settings.CanAnchorToStaticGrid && grid.IsTouchingAnyNeighbor(min, max))
{
touchingStaticGrid = true;
if (touchingGrid == null)
touchingGrid = grid;
}
}
示例5: TestPlacementAreaInternal
private static bool TestPlacementAreaInternal(MyCubeGrid targetGrid,
ref MyGridPlacementSettings settings,
MyCubeBlockDefinition blockDefinition,
MyBlockOrientation? blockOrientation,
ref BoundingBoxD localAabb,
MyEntity ignoredEntity,
ref MatrixD worldMatrix,
out MyCubeGrid touchingGrid,
bool dynamicBuildMode = false,
bool ignoreFracturedPieces = false)
{
return TestPlacementAreaInternal(targetGrid, targetGrid != null ? targetGrid.IsStatic : !dynamicBuildMode,
ref settings, blockDefinition, blockOrientation, ref localAabb, ignoredEntity, ref worldMatrix, out touchingGrid, dynamicBuildMode: dynamicBuildMode, ignoreFracturedPieces: ignoreFracturedPieces);
}
示例6: InitOrientation
/// <summary>
/// Initializes the orientation of the slim block according to the given forward and up vectors.
/// Note that the resulting orientation can be different than the supplied orientation due to symmetries.
/// This function chooses one canonical orientation for all orientations from one symetry equivalent group of orientations.
/// </summary>
public void InitOrientation(Base6Directions.Direction Forward, Base6Directions.Direction Up)
{
if (MyCubeGridDefinitions.GetCubeRotationOptions(BlockDefinition) == MyRotationOptionsEnum.None)
{
Orientation = MyBlockOrientation.Identity;
}
else
{
Orientation = new MyBlockOrientation(Forward, Up);
}
if (BlockDefinition.CubeDefinition != null)
{
//Ensure we have always only one distinct orientation use
Orientation = MyCubeGridDefinitions.GetTopologyUniqueOrientation(BlockDefinition.CubeDefinition.CubeTopology, Orientation);
}
}
示例7: GetBlockPlacementMaterials
public override void GetBlockPlacementMaterials(MyCubeBlockDefinition definition, Vector3I position, MyBlockOrientation orientation, MyCubeGrid grid)
{
ClearRequiredMaterials();
GetMaterialsSimple(definition, m_materialList);
}
示例8: ComputeMax
/// <summary>
/// Called when block is destroyed before being removed from grid
/// </summary>
//public void OnDestroy()
//{
// if (FatBlock != null)
// {
// Profiler.Begin("MySlimBlock.OnDestroy");
// FatBlock.OnDestroy();
// Profiler.End();
// }
//}
public static void ComputeMax(MyCubeBlockDefinition definition, MyBlockOrientation orientation, ref Vector3I min, out Vector3I max)
{
Vector3I size = definition.Size - 1;
MatrixI localMatrix = new MatrixI(orientation);
Vector3I.TransformNormal(ref size, ref localMatrix, out size);
Vector3I.Abs(ref size, out size);
max = min + size;
}
示例9: TestBlockPlacementArea
public static bool TestBlockPlacementArea(
MyCubeGrid targetGrid,
ref MyGridPlacementSettings settings,
MyBlockOrientation blockOrientation,
MyCubeBlockDefinition blockDefinition,
ref Vector3D translation,
ref Quaternion rotation,
ref Vector3 halfExtents,
ref BoundingBoxD localAabb,
MyEntity ignoredEntity = null)
{
MyCubeGrid touchingGrid;
return TestBlockPlacementArea(targetGrid, ref settings, blockOrientation, blockDefinition, ref translation, ref rotation, ref halfExtents, ref localAabb, out touchingGrid, ignoredEntity: ignoredEntity);
}
示例10: CreateBlockObjectBuilder
internal static MyObjectBuilder_CubeBlock CreateBlockObjectBuilder(MyCubeBlockDefinition definition, Vector3I min, MyBlockOrientation orientation, long entityID, long owner, bool fullyBuilt)
{
MyObjectBuilder_CubeBlock objectBuilder = (MyObjectBuilder_CubeBlock)MyObjectBuilderSerializer.CreateNewObject(definition.Id);
objectBuilder.BuildPercent = fullyBuilt ? 1 : MyComponentStack.MOUNT_THRESHOLD;
objectBuilder.IntegrityPercent = fullyBuilt ? 1 : MyComponentStack.MOUNT_THRESHOLD;
objectBuilder.EntityId = entityID;
objectBuilder.Min = min;
objectBuilder.BlockOrientation = orientation;
if (definition.ContainsComputer())
{
objectBuilder.Owner = 0;
objectBuilder.ShareMode = MyOwnershipShareModeEnum.All;
}
return objectBuilder;
}
示例11: Build
public void Build(MySlimBlock cubeBlock, long owner, long builder)
{
Quaternion quat = Quaternion.Identity;
var orientation = cubeBlock.Orientation;
Matrix local;
orientation.GetMatrix(out local);
var gridOrientation = m_clipboard.GetFirstGridOrientationMatrix();
if (gridOrientation != Matrix.Identity)
{
var afterRotation = Matrix.Multiply(local, gridOrientation);
orientation = new MyBlockOrientation(ref afterRotation);
}
Quaternion projQuat = Quaternion.Identity;
Orientation.GetQuaternion(out projQuat);
orientation.GetQuaternion(out quat);
quat = Quaternion.Multiply(projQuat, quat);
var projectorGrid = CubeGrid;
var projectedGrid = cubeBlock.CubeGrid;
Vector3I cubeMin = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Min : cubeBlock.Position;
Vector3I cubeMax = cubeBlock.FatBlock != null ? cubeBlock.FatBlock.Max : cubeBlock.Position;
Vector3I min = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMin));
Vector3I max = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeMax));
Vector3I pos = projectorGrid.WorldToGridInteger(projectedGrid.GridIntegerToWorld(cubeBlock.Position));
Vector3I projectedMin = new Vector3I(Math.Min(min.X, max.X), Math.Min(min.Y, max.Y), Math.Min(min.Z, max.Z));
Vector3I projectedMax = new Vector3I(Math.Max(min.X, max.X), Math.Max(min.Y, max.Y), Math.Max(min.Z, max.Z));
MyCubeGrid.MyBlockLocation location = new MyCubeGrid.MyBlockLocation(cubeBlock.BlockDefinition.Id, projectedMin, projectedMax, pos,
quat, 0, owner, builder);
MyObjectBuilder_CubeBlock objectBuilder = null;
//Find original grid builder
foreach (var blockBuilder in m_originalGridBuilder.CubeBlocks)
{
if (blockBuilder.Min == cubeMin && blockBuilder.GetId() == cubeBlock.BlockDefinition.Id)
{
objectBuilder = (MyObjectBuilder_CubeBlock)blockBuilder.Clone();
objectBuilder.SetupForProjector();
}
}
if (objectBuilder == null)
{
System.Diagnostics.Debug.Fail("Original object builder could not be found! (AlexFlorea)");
objectBuilder = cubeBlock.GetObjectBuilder();
location.EntityId = MyEntityIdentifier.AllocateId();
}
objectBuilder.ConstructionInventory = null;
projectorGrid.BuildBlock(cubeBlock.ColorMaskHSV, location, objectBuilder);
HideCube(cubeBlock);
}
示例12: CanBuild
public BuildCheckResult CanBuild(MySlimBlock projectedBlock, bool checkHavokIntersections)
{
MyBlockOrientation blockOrientation = projectedBlock.Orientation;
Matrix local;
blockOrientation.GetMatrix(out local);
var gridOrientation = (m_clipboard as MyGridClipboard).GetFirstGridOrientationMatrix();
if (gridOrientation != Matrix.Identity)
{
var afterRotation = Matrix.Multiply(local, gridOrientation);
blockOrientation = new MyBlockOrientation(ref afterRotation);
}
Quaternion blockOrientationQuat;
blockOrientation.GetQuaternion(out blockOrientationQuat);
Quaternion projQuat = Quaternion.Identity;
Orientation.GetQuaternion(out projQuat);
blockOrientationQuat = Quaternion.Multiply(projQuat, blockOrientationQuat);
Vector3I projectedMin = CubeGrid.WorldToGridInteger(projectedBlock.CubeGrid.GridIntegerToWorld(projectedBlock.Min));
Vector3I projectedMax = CubeGrid.WorldToGridInteger(projectedBlock.CubeGrid.GridIntegerToWorld(projectedBlock.Max));
Vector3I blockPos = CubeGrid.WorldToGridInteger(projectedBlock.CubeGrid.GridIntegerToWorld(projectedBlock.Position));
Vector3I min = new Vector3I(Math.Min(projectedMin.X, projectedMax.X), Math.Min(projectedMin.Y, projectedMax.Y), Math.Min(projectedMin.Z, projectedMax.Z));
Vector3I max = new Vector3I(Math.Max(projectedMin.X, projectedMax.X), Math.Max(projectedMin.Y, projectedMax.Y), Math.Max(projectedMin.Z, projectedMax.Z));
projectedMin = min;
projectedMax = max;
if (!CubeGrid.CanAddCubes(projectedMin, projectedMax))
{
return BuildCheckResult.IntersectedWithGrid;
}
MyGridPlacementSettings settings = new MyGridPlacementSettings();
settings.Mode = MyGridPlacementSettings.SnapMode.OneFreeAxis;
bool canBuild = true;
if (checkHavokIntersections)
{
canBuild = MyCubeGrid.TestPlacementAreaCube(CubeGrid, ref settings, projectedMin, projectedMax, blockOrientation, projectedBlock.BlockDefinition, CubeGrid);
}
bool isConnected = MyCubeGrid.CheckConnectivity(this.CubeGrid, projectedBlock.BlockDefinition, ref blockOrientationQuat, ref blockPos);
if (!canBuild)
{
return BuildCheckResult.IntersectedWithSomethingElse;
}
else
{
if (isConnected)
{
if (CubeGrid.GetCubeBlock(blockPos) == null)
{
return BuildCheckResult.OK;
}
else
{
return BuildCheckResult.AlreadyBuilt;
}
}
}
return BuildCheckResult.NotConnected;
}
示例13: EnableGizmoSpace
private void EnableGizmoSpace(MyGizmoSpaceEnum gizmoSpaceEnum, bool enable, Vector3I? planePos, bool isOdd, MyCubeBlockDefinition cubeBlockDefinition, MyCubeGrid cubeGrid)
{
var gizmoSpace = m_spaces[(int)gizmoSpaceEnum];
gizmoSpace.Enabled = enable;
if (enable)
{
if (planePos.HasValue)
gizmoSpace.SymmetryPlanePos = planePos.Value;
gizmoSpace.SymmetryIsOdd = isOdd;
gizmoSpace.m_buildAllowed = false;
if (cubeBlockDefinition != null)
{
Quaternion orientationQuat = gizmoSpace.LocalOrientation;
MyBlockOrientation blockOrientation = new MyBlockOrientation(ref orientationQuat);
Vector3I rotatedBlockSize;
MyCubeGridDefinitions.GetRotatedBlockSize(cubeBlockDefinition, ref gizmoSpace.m_localMatrixAdd, out rotatedBlockSize);
//integer local center of the cube
Vector3I center = cubeBlockDefinition.Center;
//integer rotated/world center of the cube
Vector3I rotatedCenter;
Vector3I.TransformNormal(ref center, ref gizmoSpace.m_localMatrixAdd, out rotatedCenter);
//offset to the cube to align exactly on intersected cube
Vector3I worldDir = new Vector3I(
Math.Sign(rotatedBlockSize.X) == Math.Sign(gizmoSpace.m_addDir.X) ? rotatedCenter.X : Math.Sign(gizmoSpace.m_addDir.X) * ((Math.Abs(rotatedBlockSize.X) - Math.Abs(rotatedCenter.X) - 1)),
Math.Sign(rotatedBlockSize.Y) == Math.Sign(gizmoSpace.m_addDir.Y) ? rotatedCenter.Y : Math.Sign(gizmoSpace.m_addDir.Y) * ((Math.Abs(rotatedBlockSize.Y) - Math.Abs(rotatedCenter.Y) - 1)),
Math.Sign(rotatedBlockSize.Z) == Math.Sign(gizmoSpace.m_addDir.Z) ? rotatedCenter.Z : Math.Sign(gizmoSpace.m_addDir.Z) * ((Math.Abs(rotatedBlockSize.Z) - Math.Abs(rotatedCenter.Z) - 1)));
gizmoSpace.m_positions.Clear();
gizmoSpace.m_positionsSmallOnLarge.Clear();
if (MyFakes.ENABLE_STATIC_SMALL_GRID_ON_LARGE && gizmoSpace.m_addPosSmallOnLarge != null) {
float smallToLarge = MyDefinitionManager.Static.GetCubeSize(cubeBlockDefinition.CubeSize) / cubeGrid.GridSize;
gizmoSpace.m_minSmallOnLarge = Vector3.MaxValue;
gizmoSpace.m_maxSmallOnLarge = Vector3.MinValue;
gizmoSpace.m_centerPosSmallOnLarge = gizmoSpace.m_addPosSmallOnLarge.Value + smallToLarge * worldDir;
gizmoSpace.m_buildAllowed = true;
Vector3I temp = new Vector3I();
for (temp.X = 0; temp.X < cubeBlockDefinition.Size.X; temp.X++)
for (temp.Y = 0; temp.Y < cubeBlockDefinition.Size.Y; temp.Y++)
for (temp.Z = 0; temp.Z < cubeBlockDefinition.Size.Z; temp.Z++) {
Vector3I rotatedTemp;
Vector3I centeredTemp = temp - center;
Vector3I.TransformNormal(ref centeredTemp, ref gizmoSpace.m_localMatrixAdd, out rotatedTemp);
Vector3 tempIntPos = gizmoSpace.m_addPosSmallOnLarge.Value + smallToLarge * (rotatedTemp + worldDir);
gizmoSpace.m_minSmallOnLarge = Vector3.Min(tempIntPos, gizmoSpace.m_minSmallOnLarge);
gizmoSpace.m_maxSmallOnLarge = Vector3.Max(tempIntPos, gizmoSpace.m_maxSmallOnLarge);
// Commented out - small block can be placed in occupied large block areas
//if (!cubeGrid.CanAddCube(Vector3I.Round(tempIntPos), blockOrientation, null))
// gizmoSpace.m_buildAllowed = false;
gizmoSpace.m_positionsSmallOnLarge.Add(tempIntPos);
}
}
else {
gizmoSpace.m_min = Vector3I.MaxValue;
gizmoSpace.m_max = Vector3I.MinValue;
gizmoSpace.m_centerPos = gizmoSpace.m_addPos + worldDir;
gizmoSpace.m_buildAllowed = true;
Vector3I temp = new Vector3I();
for (temp.X = 0; temp.X < cubeBlockDefinition.Size.X; temp.X++)
for (temp.Y = 0; temp.Y < cubeBlockDefinition.Size.Y; temp.Y++)
for (temp.Z = 0; temp.Z < cubeBlockDefinition.Size.Z; temp.Z++) {
Vector3I rotatedTemp;
Vector3I centeredTemp = temp - center;
Vector3I.TransformNormal(ref centeredTemp, ref gizmoSpace.m_localMatrixAdd, out rotatedTemp);
Vector3I tempIntPos = gizmoSpace.m_addPos + rotatedTemp + worldDir;
gizmoSpace.m_min = Vector3I.Min(tempIntPos, gizmoSpace.m_min);
gizmoSpace.m_max = Vector3I.Max(tempIntPos, gizmoSpace.m_max);
if (cubeGrid != null && !cubeGrid.CanAddCube(tempIntPos, blockOrientation, cubeBlockDefinition))
gizmoSpace.m_buildAllowed = false;
gizmoSpace.m_positions.Add(tempIntPos);
}
}
}
if (gizmoSpace.SymmetryPlane != MySymmetrySettingModeEnum.Disabled)
MirrorGizmoSpace(gizmoSpace, m_spaces[(int)gizmoSpace.SourceSpace], gizmoSpace.SymmetryPlane, planePos.Value, isOdd, cubeBlockDefinition, cubeGrid);
}
}
示例14: UpdateGizmo_Grid
private void UpdateGizmo_Grid(MyCubeBuilderGizmo.MyGizmoSpaceProperties gizmoSpace, bool add, bool remove, bool draw)
{
Color green = new Color(Color.Green * 0.6f, 1f);
Color red = new Color(Color.Red * 0.8f, 1);
Color yellow = Color.Yellow;
Color black = Color.Black;
Color gray = Color.Gray;
Color white = Color.White;
if (add)
{
if (gizmoSpace.m_startBuild != null && gizmoSpace.m_continueBuild != null)
{
gizmoSpace.m_buildAllowed = true;
}
if (PlacingSmallGridOnLargeStatic && gizmoSpace.m_positionsSmallOnLarge.Count == 0)
return;
if (CurrentBlockDefinition != null)
{
Matrix addOrientationMat = gizmoSpace.m_localMatrixAdd.GetOrientation();
MyBlockOrientation gizmoAddOrientation = new MyBlockOrientation(ref addOrientationMat);
if (!PlacingSmallGridOnLargeStatic)
{
gizmoSpace.m_buildAllowed &= CheckValidBlockRotation(gizmoSpace.m_localMatrixAdd, CurrentBlockDefinition.Direction, CurrentBlockDefinition.Rotation)
&& CurrentGrid.CanPlaceBlock(gizmoSpace.m_min, gizmoSpace.m_max, gizmoAddOrientation, gizmoSpace.m_blockDefinition);
}
if (!PlacingSmallGridOnLargeStatic && MySession.Static.SurvivalMode && !DeveloperSpectatorIsBuilding)
{
Vector3 localMin = (m_gizmo.SpaceDefault.m_min - new Vector3(0.5f)) * CurrentGrid.GridSize;
Vector3 localMax = (m_gizmo.SpaceDefault.m_max + new Vector3(0.5f)) * CurrentGrid.GridSize;
BoundingBoxD gizmoBox = new BoundingBoxD(localMin, localMax);
if (!MyCubeBuilderGizmo.DefaultGizmoCloseEnough(ref m_invGridWorldMatrix, gizmoBox, CurrentGrid.GridSize, IntersectionDistance) || MySession.GetCameraControllerEnum() == MyCameraControllerEnum.Spectator)
{
gizmoSpace.m_buildAllowed = false;
gizmoSpace.m_removeBlock = null;
return;
}
if (!MySession.Static.SimpleSurvival && MySession.ControlledEntity is MyCharacter)
{
gizmoSpace.m_buildAllowed &= (MySession.ControlledEntity as MyCharacter).CanStartConstruction(CurrentBlockDefinition);
}
if (MySession.Static.SimpleSurvival)
{
gizmoSpace.m_buildAllowed &= CanBuildBlockSurvivalTime();
}
}
// Check whether mount points match any of its neighbors (only if we can build here though).
if (gizmoSpace.m_buildAllowed)
{
Quaternion.CreateFromRotationMatrix(ref gizmoSpace.m_localMatrixAdd, out gizmoSpace.m_rotation);
if (gizmoSpace.SymmetryPlane == MySymmetrySettingModeEnum.Disabled && !PlacingSmallGridOnLargeStatic)
gizmoSpace.m_buildAllowed = MyCubeGrid.CheckConnectivity(CurrentGrid, CurrentBlockDefinition, ref gizmoSpace.m_rotation, ref gizmoSpace.m_centerPos);
}
Color color = green;
UpdateShowGizmoCube(gizmoSpace, CurrentGrid.GridSize);
// Disable building from cockpit
if (MySession.ControlledEntity != null && MySession.ControlledEntity is MyCockpit && !DeveloperSpectatorIsBuilding)
{
gizmoSpace.m_showGizmoCube = false;
return;
}
gizmoSpace.m_buildAllowed &= gizmoSpace.m_showGizmoCube;
Vector3 temp;
Vector3D worldCenter = Vector3D.Zero;
Vector3D worldPos = gizmoSpace.m_worldMatrixAdd.Translation;
MatrixD drawMatrix = gizmoSpace.m_worldMatrixAdd;
int posIndex = 0;
for (temp.X = 0; temp.X < CurrentBlockDefinition.Size.X; temp.X++)
for (temp.Y = 0; temp.Y < CurrentBlockDefinition.Size.Y; temp.Y++)
for (temp.Z = 0; temp.Z < CurrentBlockDefinition.Size.Z; temp.Z++)
{
color = gizmoSpace.m_buildAllowed ? green : gray;
if (PlacingSmallGridOnLargeStatic)
{
float smallToLarge = MyDefinitionManager.Static.GetCubeSize(CurrentBlockDefinition.CubeSize) / CurrentGrid.GridSize;
Vector3D gridPosition = gizmoSpace.m_positionsSmallOnLarge[posIndex++];
Vector3I gridPositionInt = Vector3I.Round(gridPosition / smallToLarge);
Vector3D tempWorldPos = Vector3D.Transform(gridPosition * CurrentGrid.GridSize, CurrentGrid.WorldMatrix);
worldCenter += tempWorldPos;
drawMatrix.Translation = tempWorldPos;
MyCubeGrid.GetCubeParts(CurrentBlockDefinition, gridPositionInt, gizmoSpace.m_localMatrixAdd.GetOrientation(), CurrentGrid.GridSize, gizmoSpace.m_cubeModelsTemp, gizmoSpace.m_cubeMatricesTemp, gizmoSpace.m_cubeNormals, gizmoSpace.m_patternOffsets);
//.........这里部分代码省略.........
示例15: UpdateGizmo_VoxelMap
private void UpdateGizmo_VoxelMap(MyCubeBuilderGizmo.MyGizmoSpaceProperties gizmoSpace, bool add, bool remove, bool draw)
{
Color green = new Color(Color.Green * 0.6f, 1f);
Color red = new Color(Color.Red * 0.8f, 1);
Color yellow = Color.Yellow;
Color blue = Color.Blue;
//Vector4 black = Color.Black.ToVector4();
Color gray = Color.Gray;
float gridSize = MyDefinitionManager.Static.GetCubeSize(CurrentBlockDefinition.CubeSize);
Vector3 temp;
Vector3D worldCenter = Vector3D.Zero;
Vector3D worldPos = gizmoSpace.m_worldMatrixAdd.Translation;
MatrixD drawMatrix = gizmoSpace.m_worldMatrixAdd;
Color color = green;
UpdateShowGizmoCube(gizmoSpace, gridSize);
int posIndex = 0;
for (temp.X = 0; temp.X < CurrentBlockDefinition.Size.X; temp.X++)
for (temp.Y = 0; temp.Y < CurrentBlockDefinition.Size.Y; temp.Y++)
for (temp.Z = 0; temp.Z < CurrentBlockDefinition.Size.Z; temp.Z++)
{
color = gizmoSpace.m_buildAllowed ? green : gray;
Vector3I gridPosition = gizmoSpace.m_positions[posIndex++];
Vector3D tempWorldPos = gridPosition * gridSize;
if (!MyPerGameSettings.BuildingSettings.StaticGridAlignToCenter)
tempWorldPos -= 0.5 * gridSize;
worldCenter += tempWorldPos;
drawMatrix.Translation = tempWorldPos;
MyCubeGrid.GetCubeParts(CurrentBlockDefinition, gridPosition, gizmoSpace.m_localMatrixAdd.GetOrientation(), gridSize, gizmoSpace.m_cubeModelsTemp, gizmoSpace.m_cubeMatricesTemp, gizmoSpace.m_cubeNormals, gizmoSpace.m_patternOffsets);
if (gizmoSpace.m_showGizmoCube)
{
for (int i = 0; i < gizmoSpace.m_cubeMatricesTemp.Count; i++)
{
MatrixD modelMatrix = gizmoSpace.m_cubeMatricesTemp[i];
modelMatrix.Translation = tempWorldPos;
gizmoSpace.m_cubeMatricesTemp[i] = modelMatrix;
}
m_gizmo.AddFastBuildParts(gizmoSpace, CurrentBlockDefinition, null);
m_gizmo.UpdateGizmoCubeParts(gizmoSpace, m_renderData, ref MatrixD.Identity);
}
}
//calculate world center for block model
worldCenter /= CurrentBlockDefinition.Size.Size;
drawMatrix.Translation = worldCenter;
BoundingBoxD localAABB = new BoundingBoxD(-CurrentBlockDefinition.Size * gridSize * 0.5f, CurrentBlockDefinition.Size * gridSize * 0.5f);
var settings = CurrentBlockDefinition.CubeSize == MyCubeSize.Large ? MyPerGameSettings.BuildingSettings.LargeStaticGrid : MyPerGameSettings.BuildingSettings.SmallStaticGrid;
MyBlockOrientation blockOrientation = new MyBlockOrientation(ref Quaternion.Identity);
bool placementTest = CheckValidBlockRotation(gizmoSpace.m_worldMatrixAdd, CurrentBlockDefinition.Direction, CurrentBlockDefinition.Rotation)
&& MyCubeGrid.TestBlockPlacementArea(CurrentBlockDefinition, blockOrientation, drawMatrix, ref settings, localAABB, false);
gizmoSpace.m_buildAllowed &= placementTest;
gizmoSpace.m_buildAllowed &= gizmoSpace.m_showGizmoCube;
gizmoSpace.m_worldMatrixAdd = drawMatrix;
if (MySession.Static.SurvivalMode && !DeveloperSpectatorIsBuilding)
{
BoundingBoxD gizmoBox = localAABB.Transform(ref drawMatrix);
if (!MyCubeBuilderGizmo.DefaultGizmoCloseEnough(ref MatrixD.Identity, gizmoBox, gridSize, IntersectionDistance) || MySession.GetCameraControllerEnum() == MyCameraControllerEnum.Spectator)
{
gizmoSpace.m_buildAllowed = false;
gizmoSpace.m_showGizmoCube = false;
gizmoSpace.m_removeBlock = null;
return;
}
if (!MySession.Static.SimpleSurvival && MySession.ControlledEntity is MyCharacter)
{
gizmoSpace.m_buildAllowed &= (MySession.ControlledEntity as MyCharacter).CanStartConstruction(CurrentBlockDefinition);
}
if (MySession.Static.SimpleSurvival)
{
gizmoSpace.m_buildAllowed &= CanBuildBlockSurvivalTime();
}
}
//color = gizmoSpace.m_buildAllowed ? green : gray;
color = Color.White;
string lineMaterial = gizmoSpace.m_buildAllowed ? "GizmoDrawLine" : "GizmoDrawLineRed";
if (gizmoSpace.SymmetryPlane == MySymmetrySettingModeEnum.Disabled)
{
MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix,
ref localAABB, ref color, MySimpleObjectRasterizer.Wireframe, 1, 0.04f, lineMaterial: lineMaterial);
//.........这里部分代码省略.........