Example #1
0
        /// <summary>
        /// Creates a PseudoBlock from a block and an orientation.
        /// </summary>
        /// <param name="block">The block to calculate the local matrix from.</param>
        /// <param name="forward">The direction the block should face towards the target.</param>
        /// <param name="up">A direction perpendicular to forward.</param>
        public PseudoBlock(IMyCubeBlock block, Base6Directions.Direction?forward, Base6Directions.Direction?up)
            : this(block)
        {
            Base6Directions.Direction for2 = forward ?? block.FirstFaceDirection();
            Base6Directions.Direction up2  = up ??
                                             (for2 == Base6Directions.Direction.Forward ? Base6Directions.Direction.Up : Base6Directions.GetPerpendicular(for2));

            if (for2 == up2 || for2 == Base6Directions.GetFlippedDirection(up2))
            {
                Log.DebugLog("incompatible directions, for2: " + for2 + ", up2: " + up2);
                up2 = Base6Directions.GetPerpendicular(for2);
            }

            this.LocalMatrix = new Matrix()
            {
                Forward = block.LocalMatrix.GetDirectionVector(for2),
                Up      = block.LocalMatrix.GetDirectionVector(up2),
                Right   = block.LocalMatrix.GetDirectionVector(Base6Directions.GetCross(for2, up2)),
                M41     = block.LocalMatrix.M41,
                M42     = block.LocalMatrix.M42,
                M43     = block.LocalMatrix.M43,
                M44     = block.LocalMatrix.M44
            };
        }