Exemplo n.º 1
0
 public static RelativeDirection3F FromBlock(IMyCubeBlock block, Vector3 blockDirection)
 {
     RelativeDirection3F result = new RelativeDirection3F(block.CubeGrid);
     result.direction_block = blockDirection;
     result.CubeBlock = block;
     return result;
 }
Exemplo n.º 2
0
        public static RelativeDirection3F FromLocal(IMyCubeGrid grid, Vector3 localDirection)
        {
            RelativeDirection3F result = new RelativeDirection3F(grid);

            result.direction_local = localDirection;
            return(result);
        }
Exemplo n.º 3
0
        public static RelativeDirection3F FromWorld(IMyCubeGrid grid, Vector3 worldDirection)
        {
            RelativeDirection3F result = new RelativeDirection3F(grid);

            result.direction_world = worldDirection;
            return(result);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Rotate to face FaceBlock towards a particular direction.
		/// </summary>
		public void FaceTowards(RelativeDirection3F direction)
		{
			//myLogger.debugLog("entered FaceTowards()", "FaceTowards()");

			if (!SetupStators())
				return;

			// get the direction FaceBlock is currently facing
			Base6Directions.Direction closestDirection = FaceBlock.GetFaceDirection(direction.ToWorld());
			//myLogger.debugLog("closest direction: " + closestDirection, "FaceTowards()");
			RelativeDirection3F currentDir = RelativeDirection3F.FromWorld(FaceBlock.CubeGrid, FaceBlock.WorldMatrix.GetDirectionVector(closestDirection));
			// get the elevation and azimuth from currentDir
			float currentFaceEl, currentFaceAz;
			Vector3.GetAzimuthAndElevation(currentDir.ToBlockNormalized(StatorAz as IMyCubeBlock), out currentFaceAz, out currentFaceEl);

			Vector3 targetDir_block = direction.ToBlockNormalized(StatorAz as IMyCubeBlock);
			float targetEl, targetAz;
			Vector3.GetAzimuthAndElevation(targetDir_block, out targetAz, out targetEl);
			// target elevation and azimuth will change as weapon moves

			// elevation and azimuth are between -Pi and +Pi, stator angles are all over the place
			float elevationChange = MathHelper.WrapAngle(currentFaceEl - targetEl);
			float azimuthChange = MathHelper.WrapAngle(currentFaceAz - targetAz);

			SetVelocity(StatorEl, elevationChange);
			SetVelocity(StatorAz, azimuthChange);
		}
Exemplo n.º 5
0
        public static RelativeDirection3F FromBlock(IMyCubeBlock block, Vector3 blockDirection)
        {
            RelativeDirection3F result = new RelativeDirection3F(block.CubeGrid);

            result.direction_block = blockDirection;
            result.CubeBlock       = block;
            return(result);
        }
Exemplo n.º 6
0
 public static RelativeDirection3F FromWorld(IMyCubeGrid grid, Vector3 worldDirection)
 {
     RelativeDirection3F result = new RelativeDirection3F(grid);
     result.direction_world = worldDirection;
     return result;
 }
Exemplo n.º 7
0
 public static RelativeDirection3F FromLocal(IMyCubeGrid grid, Vector3 localDirection)
 {
     RelativeDirection3F result = new RelativeDirection3F(grid);
     result.direction_local = localDirection;
     return result;
 }