NikolaiVChr / f16

General Dynamics F-16 for Flightgear flight simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom dynamic view amount

NikolaiVChr opened this issue · comments

Modify this:

view_manager.default_plane = func {
	var wow = me.wow.get();

	# calculate steering factor
	var hdg = me.headingN.getValue();
	var hdiff = normdeg(me.last_heading - hdg);
	me.last_heading = hdg;
	var steering = 0; # normatan(me.hdg_change.filter(hdiff)) * me.size_factor;

	var az = me.az.get();
	var vx = me.vx.get();

	# calculate sideslip factor (zeroed when no forward ground speed)
	var wspd = me.wind_speedN.getValue();
	var wdir = me.headingN.getValue() - me.wind_dirN.getValue();
	var u = vx - wspd * cos(wdir);
	var slip = sin(me.slipN.getValue()) * me.ubody.filter(normatan(u / 10));

	me.heading_offset =							# view heading
		-15 * sin(me.roll) * cos(me.pitch)				#     due to roll
		+ 40 * steering * wow						#     due to ground steering
		+ 10 * slip * (1 - wow);					#     due to sideslip (in air)

	me.pitch_offset =							# view pitch
		10 * sin(me.roll) * sin(me.roll)				#     due to roll
		+ 30 * (1 / (1 + math.exp(2 - az))				#     due to G load
			- 0.119202922);						#         [move to origin; 1/(1+exp(2)) ]

	me.roll_offset = 0;
}