当前位置: 首页>>代码示例>>C#>>正文


C# MyBlockOrientation.GetQuaternion方法代码示例

本文整理汇总了C#中VRageMath.MyBlockOrientation.GetQuaternion方法的典型用法代码示例。如果您正苦于以下问题:C# MyBlockOrientation.GetQuaternion方法的具体用法?C# MyBlockOrientation.GetQuaternion怎么用?C# MyBlockOrientation.GetQuaternion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VRageMath.MyBlockOrientation的用法示例。


在下文中一共展示了MyBlockOrientation.GetQuaternion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:13,代码来源:MyGridClipboard2.cs

示例2: DetectTouchingGrid

        private MyCubeGrid DetectTouchingGrid(MySlimBlock block)
        {
            if (MyCubeBuilder.Static.DynamicMode)
                return null;

            if (block == null)
                return null;

            if (block.FatBlock is MyCompoundCubeBlock)
            {
                foreach (var blockInCompound in (block.FatBlock as MyCompoundCubeBlock).GetBlocks())
                {
                    MyCubeGrid touchingGrid = DetectTouchingGrid(blockInCompound);
                    if (touchingGrid != null)
                        return touchingGrid;
                }

                return null;
            }

            ProfilerShort.Begin("MultiBlockClipboard: DetectMerge");

            float gridSize = block.CubeGrid.GridSize;
            BoundingBoxD aabb;
            block.GetWorldBoundingBox(out aabb);
            // Inflate by half cube, so it will intersect for sure when there's anything
            aabb.Inflate(gridSize / 2);

            m_tmpNearEntities.Clear();
            MyEntities.GetElementsInBox(ref aabb, m_tmpNearEntities);

            var mountPoints = block.BlockDefinition.GetBuildProgressModelMountPoints(block.BuildLevelRatio);

            try
            {
                for (int i = 0; i < m_tmpNearEntities.Count; i++)
                {
                    var grid = m_tmpNearEntities[i] as MyCubeGrid;
                    if (grid != null && grid != block.CubeGrid && grid.Physics != null && grid.Physics.Enabled && grid.IsStatic && grid.GridSizeEnum == block.CubeGrid.GridSizeEnum)
                    {
                        Vector3I gridOffset = grid.WorldToGridInteger(m_pastePosition);
                        if (!grid.CanMergeCubes(block.CubeGrid, gridOffset))
                            continue;

                        MatrixI transform = grid.CalculateMergeTransform(block.CubeGrid, gridOffset);
                        Base6Directions.Direction forward = transform.GetDirection(block.Orientation.Forward);
                        Base6Directions.Direction up = transform.GetDirection(block.Orientation.Up);
                        MyBlockOrientation newOrientation = new MyBlockOrientation(forward, up);
                        Quaternion newRotation;
                        newOrientation.GetQuaternion(out newRotation);
                        Vector3I newPosition = Vector3I.Transform(block.Position, transform);

                        if (!MyCubeGrid.CheckConnectivity(grid, block.BlockDefinition, mountPoints, ref newRotation, ref newPosition))
                            continue;

                        return grid;
                    }
                }
            }
            finally
            {
                m_tmpNearEntities.Clear();
                ProfilerShort.End();
            }

            return null;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:67,代码来源:MyMultiBlockClipboard.cs

示例3: 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);
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:31,代码来源:MyGridClipboard2.cs

示例4: GetBlockDefinitionAndOrientationInMultiblock

        /// <summary>
        /// Returns block definition and orientation (relative to intersectedBlock's grid) of the given "blockInMultiblock".
        /// </summary>
        private static bool GetBlockDefinitionAndOrientationInMultiblock(MySlimBlock intersectedBlock, ref Quaternion quatOrientation, ref MyCubeBlockDefinition blockDefinition, MySlimBlock blockInMultiBlock)
        {
            blockDefinition = blockInMultiBlock.BlockDefinition;

            Matrix blockOrientationMatrix;
            blockInMultiBlock.Orientation.GetMatrix(out blockOrientationMatrix);

            Matrix rotationDelta = m_multiBlockCreationClipboard.GetRotationDeltaMatrixToHitGrid(intersectedBlock.CubeGrid);
            Matrix multiBlockWorldOrientation = m_multiBlockCreationClipboard.PreviewGrids[0].WorldMatrix.GetOrientation() * rotationDelta;

            Matrix blockWorldOrientationMatrix = blockOrientationMatrix * multiBlockWorldOrientation;
            Matrix blockLocalGridOrientation = blockWorldOrientationMatrix * Matrix.Invert(intersectedBlock.CubeGrid.WorldMatrix.GetOrientation());
            MyBlockOrientation orientation = new MyBlockOrientation(ref blockLocalGridOrientation);
            if (orientation.IsValid)
            {
                orientation.GetQuaternion(out quatOrientation);
                return true;
            }

            Debug.Fail("Wrong orientation");
            return false;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:25,代码来源:MyCubeBuilder.cs


注:本文中的VRageMath.MyBlockOrientation.GetQuaternion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。