本文整理汇总了C#中VRageMath.MyBlockOrientation类 的典型用法代码示例。如果您正苦于以下问题:C# MyBlockOrientation类的具体用法?C# MyBlockOrientation怎么用?C# MyBlockOrientation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyBlockOrientation类 属于VRageMath命名空间,在下文中一共展示了MyBlockOrientation类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StructureEntry
public StructureEntry( )
{
type = typeof( CubeBlockEntity );
color = new Color( 0, 0, 0 );
useOrientation = false;
orientation = MyBlockOrientation.Identity;
useSubTypeName = false;
subTypeName = "";
}
开发者ID:rexxar-tc, 项目名称:NewSEServerExtender, 代码行数:9, 代码来源:MultiblockStructure.cs
示例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();
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:10, 代码来源:MyCubeGrid.Static.cs
示例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;
}
开发者ID:fluxit, 项目名称:SpaceEngineers, 代码行数:10, 代码来源:MyAdditionalModelGeneratorBase.cs
示例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;
}
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:50, 代码来源:MyCubeGrid.Static.cs
示例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);
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:14, 代码来源:MyCubeGrid.Static.cs
示例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);
}
}
开发者ID:leandro1129, 项目名称:SpaceEngineers, 代码行数:22, 代码来源:MySlimBlock.cs
示例7: GetBlockPlacementMaterials
public override void GetBlockPlacementMaterials(MyCubeBlockDefinition definition, Vector3I position, MyBlockOrientation orientation, MyCubeGrid grid)
{
ClearRequiredMaterials();
GetMaterialsSimple(definition, m_materialList);
}
开发者ID:stanhebben, 项目名称:SpaceEngineers, 代码行数:5, 代码来源:MySpaceBuildComponent.cs
示例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;
}
开发者ID:leandro1129, 项目名称:SpaceEngineers, 代码行数:21, 代码来源:MySlimBlock.cs
示例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);
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:14, 代码来源:MyCubeGrid.Static.cs
示例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;
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:17, 代码来源:MyCubeGrid.Static.cs
示例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);
}
开发者ID:caomw, 项目名称:SpaceEngineers, 代码行数:59, 代码来源:MyProjector.cs
示例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;
}
开发者ID:caomw, 项目名称:SpaceEngineers, 代码行数:67, 代码来源:MyProjector.cs
示例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);
}
}
开发者ID:Krulac, 项目名称:SpaceEngineers, 代码行数:96, 代码来源:MyCubeBuilderGizmo.cs
示例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);
//.........这里部分代码省略.........
开发者ID:caomw, 项目名称:SpaceEngineers, 代码行数:101, 代码来源:MyCubeBuilder.cs
示例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);
//.........这里部分代码省略.........
开发者ID:caomw, 项目名称:SpaceEngineers, 代码行数:101, 代码来源:MyCubeBuilder.cs
示例16: CheckNeighborMountPointsForCompound
public static bool CheckNeighborMountPointsForCompound(
Vector3 currentMin, Vector3 currentMax, MyCubeBlockDefinition.MountPoint thisMountPoint, ref Vector3I thisMountPointTransformedNormal, MyCubeBlockDefinition thisDefinition,
Vector3I neighborPosition, MyCubeBlockDefinition neighborDefinition, MyCubeBlockDefinition.MountPoint[] neighborMountPoints, MyBlockOrientation neighborOrientation,
List<MyCubeBlockDefinition.MountPoint> otherMountPoints)
{
if (!thisMountPoint.Enabled)
return false;
var currentBox = new BoundingBox(currentMin - neighborPosition, currentMax - neighborPosition);
TransformMountPoints(otherMountPoints, neighborDefinition, neighborMountPoints, ref neighborOrientation);
foreach (var otherMountPoint in otherMountPoints)
{
// Skip mount points which exclude themselves (are not allowed to touch).
if ((((thisMountPoint.ExclusionMask & otherMountPoint.PropertiesMask) != 0 ||
(thisMountPoint.PropertiesMask & otherMountPoint.ExclusionMask) != 0) &&
thisDefinition.Id != neighborDefinition.Id) || !otherMountPoint.Enabled)
continue;
// Check normals on compound side with the same direction (we are in the same block)
if (MyFakes.ENABLE_TEST_BLOCK_CONNECTIVITY_CHECK && (thisMountPointTransformedNormal - otherMountPoint.Normal != Vector3I.Zero))
continue;
var otherBox = new BoundingBox(Vector3.Min(otherMountPoint.Start, otherMountPoint.End), Vector3.Max(otherMountPoint.Start, otherMountPoint.End));
if (currentBox.Intersects(otherBox))
return true;
}
return false;
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:31, 代码来源:MyCubeGrid.Static.cs
示例17: TransformMountPoints
/// <summary>
/// Fills passed lists with mount point data, which is transformed using orientation
/// of the block.
/// </summary>
/// <param name="outMountPoints">Output buffer.</param>
/// <param name="performCorrection">True when you want to have correction performed for when rotation of fractional values would have different result than integers.</param>
public static void TransformMountPoints(List<MyCubeBlockDefinition.MountPoint> outMountPoints, MyCubeBlockDefinition def, MyCubeBlockDefinition.MountPoint[] mountPoints, ref MyBlockOrientation orientation)
{
Debug.Assert(outMountPoints != null);
outMountPoints.Clear();
if (mountPoints == null)
return;
Matrix rotation;
orientation.GetMatrix(out rotation);
var center = def.Center;
for (int i = 0; i < mountPoints.Length; ++i)
{
var mountPoint = mountPoints[i];
var mp = new MyCubeBlockDefinition.MountPoint();
var centeredStart = mountPoint.Start - center;
var centeredEnd = mountPoint.End - center;
Vector3I.Transform(ref mountPoint.Normal, ref rotation, out mp.Normal);
Vector3.Transform(ref centeredStart, ref rotation, out mp.Start);
Vector3.Transform(ref centeredEnd, ref rotation, out mp.End);
mp.ExclusionMask = mountPoint.ExclusionMask;
mp.PropertiesMask = mountPoint.PropertiesMask;
mp.Enabled = mountPoint.Enabled;
// Correction of situations when 0.5 would get transformed to -0.5, resulting in different floor() (integer 0 is transformed to 0).
var startICorrect = Vector3I.Floor(mountPoint.Start) - center;
var endICorrect = Vector3I.Floor(mountPoint.End) - center;
Vector3I.Transform(ref startICorrect, ref rotation, out startICorrect);
Vector3I.Transform(ref endICorrect, ref rotation, out endICorrect);
var startI = Vector3I.Floor(mp.Start);
var endI = Vector3I.Floor(mp.End);
var startCorrection = startICorrect - startI;
var endCorrection = endICorrect - endI;
mp.Start += startCorrection;
mp.End += endCorrection;
outMountPoints.Add(mp);
}
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:49, 代码来源:MyCubeGrid.Static.cs
示例18: CheckMountPointsForSide
/// <summary>
/// Checkes whether blocks A and B have matching mount point on one of their sides. Each block is given by its
/// definition, rotation and position in grid. Position has to be relative to same center. Also, normal relative to block A specifies
/// wall which is used for checking.
/// </summary>
public static bool CheckMountPointsForSide(List<MyCubeBlockDefinition.MountPoint> transormedA, ref MyBlockOrientation orientationA, ref Vector3I positionA, MyDefinitionId idA, ref Vector3I normalA,
List<MyCubeBlockDefinition.MountPoint> transormedB, ref MyBlockOrientation orientationB, ref Vector3I positionB, MyDefinitionId idB)
{
var offsetAB = positionB - positionA;
var normalB = -normalA;
for (int i = 0; i < transormedA.Count; ++i)
{
if(!transormedA[i].Enabled)
continue;
var mountPointA = transormedA[i];
if (mountPointA.Normal != normalA)
continue;
var minA = Vector3.Min(mountPointA.Start, mountPointA.End);
var maxA = Vector3.Max(mountPointA.Start, mountPointA.End);
minA -= offsetAB;
maxA -= offsetAB;
var bboxA = new BoundingBox(minA, maxA);
for (int j = 0; j < transormedB.Count; ++j)
{
if(!transormedB[j].Enabled)
continue;
var mountPointB = transormedB[j];
if (mountPointB.Normal != normalB)
continue;
// Skip mount points which exclude themselves (are not allowed to touch).
if (((mountPointA.ExclusionMask & mountPointB.PropertiesMask) != 0 || (mountPointA.PropertiesMask & mountPointB.ExclusionMask) != 0) &&
idA != idB)
continue;
var bboxB = new BoundingBox(Vector3.Min(mountPointB.Start, mountPointB.End), Vector3.Max(mountPointB.Start, mountPointB.End));
if (bboxA.Intersects(bboxB))
return true;
}
}
return false;
}
开发者ID:ales-vilchytski, 项目名称:SpaceEngineers, 代码行数:48, 代码来源:MyCubeGrid.Static.cs
示例19: ConvertAllShapesToFractureComponentShapeBuilder
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:18305| 2023-10-27
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9690| 2022-11-06
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8186| 2022-11-06
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8555| 2022-11-06
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8465| 2022-11-06
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9405| 2022-11-06
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8437| 2022-11-06
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7871| 2022-11-06
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8422| 2022-11-06
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7400| 2022-11-06
请发表评论