地平线4数据输出
此贴为了那些有开发需求的而设,这些数据并不是我一个人研究的,而是参考了github不少项目以及forzamotorsport论坛大佬的帖子做了一些整理。先说说数据怎么输出吧,steam版未测试,个人猜测是直接输入IP,端口就能用。这里说说win10商店版(以下均以WIN10商店版作为演示)。
WIN10商店版这里有个坑,老开发用户应该都造,UWP应用访问不了“127.0.0.1”这样的代理(如果你的电脑是公网IP,个人猜测这里填外网地址或许是可以的)。解决法子呢也有,我这里演示用fiddler的。
完成后,你就会发现,地平线4访问“127.0.0.1”这样的内网地址了。
地平线4是通过UDP把游戏内的数据传出来的,传出来的数据最好用存储一字节元素的数组存储(Java & C#: byte[] ,C++:byte[] 或者 byte*),本人是主Java开发的,对其他语言有错误请谅解。
废渣4的数据每次固定传出324个一字节数据,目前我能确定的就只有这些,还有些实在是没找到官方文档
下面为Java代码
参考:https://github.com/zackdevine/FH4RP(C#)private Boolean IsRaceOn;
/// Timestamp in MS, can overflow to 0 eventually
private Long time;
private Float EngineMaxRPM;
private Float EngineIdleRPM;
private Float EngineCurrentRPM;
/// Right (x) position axis in local space
private Float AccelerationX;
/// Up (y) position axis in local space
private Float AccelerationY;
/// Forward (z) position axis in local space
private Float AccelerationZ;
/// Right (x) velocity axis in local space
private Float VelocityX;
/// Up (y) velocity axis in local space
private Float VelocityY;
/// Forward (z) velocity axis in local space
private Float VelocityZ;
/// Pitch (x) velocity in local space
private Float AngularVelocityX;
/// Yaw (y) velocity in local space
private Float AngularVelocityY;
/// Roll (z) velocity in local space
private Float AngularVelocityZ;
private Float Yaw;
private Float Pitch;
private Float Roll;
/// Normalized suspension travel (Front Left Tire) - 0.0 = max stretch | 1.0 = max compression
private Float NormalizedSuspensionTravelFrontLeft;
/// Normalized suspension travel (Front Right Tire) - 0.0 = max stretch | 1.0 = max compression
private Float NormalizedSuspensionTravelFrontRight;
/// Normalized suspension travel (Rear Left Tire) - 0.0 = max stretch | 1.0 = max compression
private Float NormalizedSuspensionTravelRearLeft;
/// Normalized suspension travel (Rear Right Tire) - 0.0 = max stretch | 1.0 = max compression
private Float NormalizedSuspensionTravelRearRight;
/// Normalized tire slip ratio (Front Left Tire) - 0.0 = 100% grip and |ratio| > 1.0 means loss of grip
private Float TireSlipRatioFrontLeft;
/// Normalized tire slip ratio (Front Right Tire) - 0.0 = 100% grip and |ratio| > 1.0 means loss of grip
private Float TireSlipRatioFrontRight;
/// Normalized tire slip ratio (Rear Left Tire) - 0.0 = 100% grip and |ratio| > 1.0 means loss of grip
private Float TireSlipRatioRearLeft;
/// Normalized tire slip ratio (Rear Right Tire) - 0.0 = 100% grip and |ratio| > 1.0 means loss of grip
private Float TireSlipRatioRearRight;
/// Wheel rotation speed in radians/sec - Front Left Tire
private Float WheelRotationSpeedFrontLeft;
/// Wheel rotation speed in radians/sec - Front Right Tire
private Float WheelRotationSpeedFrontRight;
/// Wheel rotation speed in radians/sec - Rear Left Tire
private Float WheelRotationSpeedRearLeft;
/// Wheel rotation speed in radians/sec - Rear Right Tire
private Float WheelRotationSpeedRearRight;
/// Returns 1 when the front left wheel is on a rumble strip, 0 when not
private Boolean WheelOnRumbleStripFrontLeft;
/// Returns 1 when the front right wheel is on a rumble strip, 0 when not
private Boolean WheelOnRumbleStripFrontRight;
/// Returns 1 when the rear left wheel is on a rumble strip, 0 when not
private Boolean WheelOnRumbleStripRearLeft;
/// Returns 1 when the rear right wheel is on a rumble strip, 0 when not
private Boolean WheelOnRumbleStripRearRight;
// From 0 to 1, where 1 is the deepest puddle
private Float WheelInPuddleDepthFrontLeft;
private Float WheelInPuddleDepthFrontRight;
private Float WheelInPuddleDepthRearLeft;
private Float WheelInPuddleDepthRearRight;
// Non-dimensional surface rumble values passed to controller force feedback
private Float SurfaceRumbleFrontLeft;
private Float SurfaceRumbleFrontRight;
private Float SurfaceRumbleRearLeft;
private Float SurfaceRumbleRearRight;
// Tire normalized slip angle, = 0 means 100% grip and |angle| > 1.0 means loss of grip.
private Float TireSlipAngleFrontLeft;
private Float TireSlipAngleFrontRight;
private Float TireSlipAngleRearLeft;
private Float TireSlipAngleRearRight;
// Tire normalized combined slip, = 0 means 100% grip and |slip| > 1.0 means loss of grip.
private Float TireCombinedSlipFrontLeft;
private Float TireCombinedSlipFrontRight;
private Float TireCombinedSlipRearLeft;
private Float TireCombinedSlipRearRight;
// Actual suspension travel in meters
private Float SuspensionTravelFrontLeft;
private Float SuspensionTravelFrontRight;
private Float SuspensionTravelRearLeft;
private Float SuspensionTravelRearRight;
/// The Car ID
private Integer CarOrdinal;
/// The car class
private CarClass CarClass;
/// The performance index value
private Integer CarPI;
/// The current drivetrain type
private DrivetrainType DrivetrainType;
/// The number of cylinders
private Integer NumCylinders;
/// X position in meters
private Float PositionX;
/// Y position in meters
private Float PositionY;
/// Z position in meters
private Float PositionZ;
/// Current speed in meters per second
private Float Speed;
/// The amount of power in watts
private Float Power;
/// The amount of torque in newton-meters
private Float Torque;
// Tire temperature (celcius)
private Float TireTempFrontLeft;
private Float TireTempFrontRight;
private Float TireTempRearLeft;
private Float TireTempRearRight;
/// Boost amount
private Float Boost;
/// Fuel amount
private Float Fuel;
/// Distance traveled (meters)
private Float DistanceTraveled;
/// Best lap time
private Float BestLap;
/// Last lap time
private Float LastLap;
/// Current lap time
private Float CurrentLap;
/// Current race (total) time
private Float CurrentRaceTime;
/// Current lap number
private Short LapNumber;
/// Current race position
private Integer RacePosition;
/// Acceleration amount
private Integer Accel;
/// Brake amount
private Integer Brake;
/// Clutch amount
private Integer Clutch;
/// Handbrake amount
private Integer Handbrake;
/// Current gear
private Integer Gear;
/// Current steering amount
private Byte Steer;
private Byte NormalizedDrivingLine;
private Byte NormalizedAIBrakeDifference;车辆的类型(上图中的CarClass):
D级:0
C级:1
B级:2
A级:3
S1级:4
S2级:5
X级:6
车辆的驱动方式(上图中的DrivetrainType):
前驱:0
后驱:1
四驱:2
希望对那些苦苦寻找数据输出的程序猿们有所帮助
页:
[1]