<_templates Include="trucks">
	<Body>
		<Grappler
			Collisions="Internal"
			ForceBodyParams="true"
			Friction="2.0"
			Mass="100"
			NoClientCollisions="true"
		>
			<Constraint AxisLocal="(1;0;0)" Type="Hinge">
				<Motor
					Damping="1.0"
					Force="60000"
					Tau="0.04"
					Type="Position"
				/>
			</Constraint>
		</Grappler>
	</Body>
</_templates>
<TruckAddon>
	<PoweredConstraints>
		<Group Id="crane_grab" IsGamepadHotkey="true">
			<Constraint Name="RightGrappler" Position="100" SpeedMult="2" />
			<Constraint Name="LeftGrappler" Position="-100" SpeedMult="2" />
		</Group>
	</PoweredConstraints>
	<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<PhysicsModel Mesh="trucks/k9000_forwarder_crane">
		<Body ImpactType="Truck" Mass="500">
			<Constraint Type="Fixed" />
			<Body Collisions="Internal" Mass="500" ModelFrame="BoneRotationBase_cdt">
				<Constraint
					AxisLocal="(0;1;0)"
					MinLimit="-355"
					MaxLimit="355"
					Name="Crane"
					Type="Hinge"
				>
					<Motor Force="300000" Tau="0.2" Type="Position" />
				</Constraint>
				<Body Collisions="Internal" Mass="300" ModelFrame="BoneArm1_cdt">
					<Constraint
						AxisLocal="(1;0;0)"
						MinLimit="-75"
						MaxLimit="40"
						Name="Crane"
						Type="Hinge"
					>
						<Motor Force="250000" Tau="0.2" Type="Position" />
					</Constraint>
					<Body Collisions="Internal" Mass="200" ModelFrame="BoneArm2_cdt">
						<Constraint
							AxisLocal="(1;0;0)"
							MinLimit="-171"
							MaxLimit="0"
							Name="Crane"
							Type="Hinge"
						>
							<Motor Force="220000" Tau="0.2" Type="Position" />
						</Constraint>
						<Body Collisions="Internal" Mass="150" ModelFrame="BoneArm3_cdt">
							<Constraint
								AxisLocal="(0;1;0)"
								MinLimit="-0.75"
								MaxLimit="2.25"
								Name="Crane"
								Type="Prismatic"
							>
								<Motor Force="220000" Tau="0.2" Type="Position" />
							</Constraint>
							<Body Collisions="None" Mass="40" ModelFrame="BoneGrapplerRoot_cdt">
								<Constraint
									AxisLocal="(0;0;1)"
									MinLimit="-20"
									MaxLimit="250"
									Type="Hinge"
								>
									<Motor Damping="200" Spring="0" Type="Spring" />
								</Constraint>
								<Body Collisions="None" Mass="40" ModelFrame="BoneGrapplerBase_cdt">
									<Constraint
										AxisLocal="(1;0;0)"
										MinLimit="-80"
										MaxLimit="80"
										Type="Hinge"
									>
										<Motor Damping="200" Spring="0" Type="Spring" />
									</Constraint>
									<Body Collisions="Internal" Mass="50" ForceBodyParams="true" ModelFrame="BoneGrappler_cdt">
										<Constraint
											AxisLocal="(0;-1;0)"
											MinLimit="-180"
											MaxLimit="180"
											Name="GrapplerBase"
											Type="Hinge"
										>
											<Motor Force="50000" Tau="0.2" Type="Position" />
										</Constraint>
										<Body _template="Grappler" ModelFrame="BoneGrapplerLeft_cdt">
											<Constraint MinLimit="-100" MaxLimit="0" Name="LeftGrappler" />
										</Body>
										<Body _template="Grappler" ModelFrame="BoneGrapplerRight_cdt">
											<Constraint MinLimit="0" MaxLimit="100" Name="RightGrappler" />
										</Body>
									</Body>
								</Body>
							</Body>
						</Body>
					</Body>
				</Body>
			</Body>
			<Body Mass="20" Collisions="None" ModelFrame="BoneFront_cdt">
				<Constraint ExplicitParentFrame="0" Type="Fixed" />
			</Body>
		</Body>
	</PhysicsModel>
	<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<ModelAttachments>
		<Ignition>
			<Flare _template="MarkerBeacon" Pos="(-1.506; 3.703; 0.21)" ParentFrame="BoneArm1_cdt" />
			<Flare _template="MarkerBeacon" Pos="(-1.506; 3.703; -0.21)" ParentFrame="BoneArm1_cdt" />
			<Flare _template="MarkerBeacon" Pos="(-4.87; 3.492; 0.187)" ParentFrame="BoneArm2_cdt" />
			<Flare _template="MarkerBeacon" Pos="(-4.87; 3.492; -0.187)" ParentFrame="BoneArm2_cdt" />
		</Ignition>
	</ModelAttachments>
	<GameData>
	    <WinchSocket Pos="(-1.94; 2.85; 0.0)" ParentFrame="BoneGrappler_cdt" />
		<InstallSocket Type="Cat584ForwarderCrane" />
	</GameData>
	<ControlledIK>
		<Chain
			CenterXZ="(-1.031; 0)"
			EndOffset="(0; 2.2; 0)"
			Id="crane"
			ModelFrames="BoneBack_cdt,BoneRotationBase_cdt,BoneArm1_cdt,BoneArm2_cdt,BoneArm3_cdt"
			VerticalLineFrame="BoneGrappler_cdt"
		/>		
	</ControlledIK>
	<ControlledConstraints>
		<Constraint Id="crane_grappler" LinkToControlledIK="crane" Name="GrapplerBase" />
	</ControlledConstraints>
	<AutomaticIK>
		<IKBone ModelFrame="BoneArm1Rod" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0.3; 0)"
				AttachToFrame="BoneArm2_cdt"
				ModelFrame="BoneArm2Rod"
			>
				<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneArm1PistonBase" ParentFrame="BoneRotationBase_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneArm1_cdt"
				ModelFrame="BoneArm1Piston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneArm2PistonBase" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneArm1Rod"
				ModelFrame="BoneArm2Piston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
	</AutomaticIK>
	<AddonCamera
		FirstPersonDir="(-1.0; -0.32; 0.0)"
		FirstPersonPos="(-1.0; 4.7; -0.8)"
		ParentFrame="BoneRotationBase_cdt"
	/>
</TruckAddon>
