public void drawCamerasBoxes() { // WARNING, do not attempt to draw cameras as markes in their correct rotation. It does not work. // I spent lots of time trying to show cameras in their direction, but shit just doesn't work. // 3D boxes are enough I guess // this shows white boxes where cameras are var curVehicle = Game.Player.Character.CurrentVehicle; var rot = curVehicle.Rotation; var rotX = Matrix3D.RotationAroundXAxis(Angle.FromDegrees(rot.X)); var rotY = Matrix3D.RotationAroundYAxis(Angle.FromDegrees(rot.Y)); var rotZ = Matrix3D.RotationAroundZAxis(Angle.FromDegrees(rot.Z)); var rotMat = rotZ * rotY * rotX; for (var i = 0; i < CamerasList.cameras.Count; i++) { var camPos = CamerasList.camerasPositions[i]; // var camRot = CamerasList.camerasRotations[i]; // var relRotX = Matrix3D.RotationAroundXAxis(Angle.FromDegrees(camRot.X)); // var relRotY = Matrix3D.RotationAroundYAxis(Angle.FromDegrees(camRot.Y)); // var relRotZ = Matrix3D.RotationAroundZAxis(Angle.FromDegrees(camRot.Z)); // var relRotMat = relRotZ * relRotY * relRotX; // var relRotMat = relRotX * relRotY * relRotZ; var camPosToCar = rotMat * new Vector3D(camPos.X, camPos.Y, camPos.Z); // var camDirection = new Vector3D(rotMat * relRotMat * new Vector3D(0f, 0f, -1f)); // var camDirection = new Vector3D(relRotMat * new Vector3D(0f, 0f, -1f)); // var camDirection = new Vector3D(0f, 0f, -1f); // var camDirection = new Vector3D(0, 0, 0); // var camRotation = new Vector3D(0, 0, 0); // var camRotation = CamerasList.rotationMatrixToDegrees(rotMat * relRotMat); // var camRotation = Game.Player.Character.CurrentVehicle.Rotation; // camRotation.X *= -1; // camRotation.Y = - Game.Player.Character.CurrentVehicle.Rotation.X; // camRotation.X = Game.Player.Character.CurrentVehicle.Rotation.Y; // var camRotation = CamerasList.rotationMatrixToDegrees(relRotMat * rotMat); // var camRotation = CamerasList.rotationMatrixToDegrees(Matrix3D.RotationAroundZAxis(Angle.FromDegrees(90)) * rotMat); // var camRotation = new Vector3D(Matrix3D.RotationAroundZAxis(Angle.FromDegrees(90)) * // new Vector3D(rot.X, rot.Y, rot.Z)); // var camRotation = CamerasList.rotationMatrixToDegrees(Matrix3D.RotationAroundXAxis(Angle.FromDegrees(-90))); var absolutePosition = curVehicle.Position + new Vector3((float)camPosToCar[0], (float)camPosToCar[1], (float)camPosToCar[2]); HashFunctions.Draw3DBox(absolutePosition, new Vector3(0.3f, 0.3f, 0.3f)); // Logger.WriteLine($"{i}-th cam vector rotation"); // Logger.WriteLine(camRotation); // Logger.WriteLine($"{i}-th cam rotation matrix"); // Logger.WriteLine(relRotMat * rotMat); // World.DrawMarker(MarkerType.ChevronUpx1, absolutePosition, // new Vector3((float) camDirection.X, (float) camDirection.Y, (float) camDirection.Z), // new Vector3((float) camRotation.X, (float) camRotation.Y, (float) camRotation.Z), // new Vector3(1, 1, 1), Color.White); // // HashFunctions.Draw2DText($"X:{camRotation.X:.##} Y:{camRotation.Y:.##} Z:{camRotation.Z:.##}", absolutePosition, Color.Red); } HashFunctions.Draw2DText($"X:{rot.X:.##} Y:{rot.Y:.##} Z:{rot.Z:.##}", curVehicle.Position, Color.Red); // Logger.WriteLine("car vector rotation"); // Logger.WriteLine(Game.Player.Character.CurrentVehicle.Rotation); }
public void DrawOffroadAreas() { foreach (var area in areas) { foreach (var rect in area) { HashFunctions.Draw3DBox( new Vector3((float)(rect.X + rect.Width / 2), (float)(rect.Y + rect.Height / 2), 0), new Vector3((float)rect.Width, (float)rect.Height, 500), 255, 255, 255, 50); } } }
void drawAxesBoxesAround(Vector3 position) { var dist = 10; var vectors = new[] { new Vector3(dist, 0, 0), new Vector3(-dist, 0, 0), // x, pos and neg new Vector3(0, dist, 0), new Vector3(0, -dist, 0), // y, pos and neg new Vector3(0, 0, dist), new Vector3(0, 0, -dist), // z, pos and neg }; var colors = new[] { new Vector3(255, 0, 0), new Vector3(255, 180, 180), // x, pos and neg new Vector3(0, 255, 0), new Vector3(180, 255, 180), // y, pos and neg new Vector3(0, 0, 255), new Vector3(180, 180, 255), // z, pos and neg }; for (int i = 0; i < vectors.Length; i++) { var relativePos = vectors[i]; var color = colors[i]; var absolutePosition = position + new Vector3((float)relativePos[0], (float)relativePos[1], (float)relativePos[2]); HashFunctions.Draw3DBox(absolutePosition, new Vector3(0.3f, 0.3f, 0.3f), (byte)colors[i][0], (byte)colors[i][1], (byte)colors[i][2]); } }