<_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="90000"
					Tau="0.04"
					Type="Position"
				/>
			</Constraint>
		</Grappler>
		<Anchor NoFoliageCollisions="true" Mass="150">
			<Constraint 
				AxisLocal="(1;0;0)"
				Type="Hinge"
				Name="Anchor"
			>
				<Motor Force="45000" Tau="0.4" Type="Position" />
			</Constraint>
			<Body
				Mass="50"
				ForceBodyParams="true" 
				NoFoliageCollisions="true"
			>
				<Constraint
					AxisLocal="(1;0;0)"
					MinLimit="-90"
					MaxLimit="5"
					Type="Hinge"
				>
					<Motor Damping="10" Spring="1" Type="Spring" />
				</Constraint>
			</Body>
		</Anchor>
	</Body>
</_templates>
<TruckAddon>
	<PoweredConstraints>
		<Group Id="crane_grab" IsGamepadHotkey="true">
			<Constraint Name="RightGrappler" Position="50" SpeedMult="2" />
			<Constraint Name="LeftGrappler" Position="-50" SpeedMult="2" />
		</Group>
		<Group Id="anchors_position">
			<Constraint Name="RightAnchor" Position="155" TerminalFix="true" />
			<Constraint Name="LeftAnchor" Position="155" TerminalFix="true" />
		</Group>
	</PoweredConstraints>
	<PhysicsModel Mesh="trucks/kenworth_loader">
		<Body ImpactType="Truck" Mass="600">
			<Constraint Type="Fixed" />
			<Body Mass="400" ModelFrame="BoneRotationBase_cdt">
				<Constraint
					AxisLocal="(0;1;0)"
					MinLimit="-355"
					MaxLimit="355"
					Name="Crane"
					Type="Hinge"
				>
					<Motor Force="240000" Tau="0.2" Type="Position" />
				</Constraint>
				<Body Mass="300" ModelFrame="BoneArm1_cdt">
					<Constraint
						AxisLocal="(0;0;1)"
						MinLimit="-50"
						MaxLimit="80"
						Name="Crane"
						Type="Hinge"
					>
						<Motor Force="200000" Tau="0.2" Type="Position" />
					</Constraint>					
					<Body Mass="200" ModelFrame="BoneArm1_1_cdt">
						<Constraint
							AxisLocal="(0;1;0)"
							MinLimit="0"
							MaxLimit="0.01"
							Name="Crane"
							Type="Prismatic"
						>
							<Motor Force="170000" Tau="0.2" Type="Position" />
						</Constraint>
						<Body Mass="200" ModelFrame="BoneArm2_cdt">
						<Constraint
							AxisLocal="(0;0;1)"
							MinLimit="0"
							MaxLimit="160"
							Name="Crane"
							Type="Hinge"
						>
							<Motor Force="140000" Tau="0.2" Type="Position" />
						</Constraint>
							<Body Collisions="None" Mass="40" ModelFrame="BoneGrapplerRoot_cdt">
							<Constraint
								AxisLocal="(0;0;1)"
								MinLimit="-240"
								MaxLimit="10"
								Type="Hinge"
							>
								<Motor Damping="200" Spring="0" Type="Spring" />
							</Constraint>
								<Body Collisions="None" Mass="40" ModelFrame="BoneGrapplerBase_cdt">
								<Constraint
									AxisLocal="(1;0;0)"
									MinLimit="-70"
									MaxLimit="70"
									Type="Hinge"
								>
									<Motor Damping="200" Spring="0" Type="Spring" />
								</Constraint>
									<Body
										Collisions="None"
										ForceBodyParams="true"
										Mass="40"
										ModelFrame="BoneGrappler_cdt"
									>
									<Constraint
										AxisLocal="(0;-1;0)"
										MinLimit="-180"
										MaxLimit="180"
										Name="GrapplerBase"
										Type="Hinge"
									>
										<Motor Force="15000" Tau="0.1" Type="Position" />
									</Constraint>
										<Body _template="Grappler" ModelFrame="BoneGrapplerLeft_cdt">
											<Constraint MinLimit="-50" MaxLimit="0" Name="LeftGrappler" />
										</Body>
										<Body _template="Grappler" ModelFrame="BoneGrapplerRight_cdt">
											<Constraint MinLimit="0" MaxLimit="50" Name="RightGrappler" />
										</Body>
									</Body>
								</Body>
							</Body>
						</Body>
					</Body>
				</Body>
			</Body>
			<Body _template="Anchor" ModelFrame="BoneLeftAnchor_cdt">
				<Constraint MinLimit="0" MaxLimit="180" Name="LeftAnchor" />
				<Body ModelFrame="BoneLeftAnchorFoot_cdt" />
			</Body>
			<Body _template="Anchor" ModelFrame="BoneRightAnchor_cdt">
				<Constraint MinLimit="0" MaxLimit="180" Name="RightAnchor" />
				<Body ModelFrame="BoneRightAnchorFoot_cdt" />
			</Body>			
		</Body>
	</PhysicsModel>
	<GameData>
       	<WinchSocket Pos="(-1.9; 2.8; 0.0)" ParentFrame="BoneGrappler_cdt" />
		<InstallSocket Type="KenworthLoader" />
	</GameData>
	<ControlledIK>
		<Chain
			CenterXZ="(-2.8; 0)"
			EndOffset="(2.7; 0.1; 0)"
			Id="crane"
			MinRadius="1.0"
			ModelFrames="BoneCart_cdt,BoneRotationBase_cdt,BoneArm1_cdt,BoneArm1_1_cdt,BoneArm2_cdt"
			VerticalLineFrame="BoneGrappler_cdt"
		/>
	</ControlledIK>		
	<ControlledConstraints>
		<Constraint Id="crane_grappler" LinkToControlledIK="crane" Name="GrapplerBase" />
	</ControlledConstraints>
	<AutomaticIK>
		<IKBone ModelFrame="BoneBasePistonBase" ParentFrame="BoneRotationBase_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneArm1_cdt"
				ModelFrame="BoneBasePiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneArmPistonBase" ParentFrame="BoneArm1_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneArm2_cdt"
				ModelFrame="BoneArmPiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>

		<IKBone ModelFrame="BoneRightAnchorPistonBase" ParentFrame="BoneCart_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneRightAnchor_cdt"
				ModelFrame="BoneRightAnchorPiston"
			>
				<IKJoint AxisLocal="(0;0;1)" Type="Slider" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneLeftAnchorPistonBase" ParentFrame="BoneCart_cdt">
			<IKJoint AxisLocal="(1;0;0)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneLeftAnchor_cdt"
				ModelFrame="BoneLeftAnchorPiston"
			>
				<IKJoint AxisLocal="(0;0;1)" Type="Slider" />
			</IKBone>
		</IKBone>
		
		<IKBone ModelFrame="BoneGrapplerLeftPistonBase" ParentFrame="BoneGrappler_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneGrapplerLeft_cdt"
				ModelFrame="BoneGrapplerLeftPiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
		<IKBone ModelFrame="BoneGrapplerRightPistonBase" ParentFrame="BoneGrappler_cdt">
			<IKJoint AxisLocal="(0;0;1)" Type="Hinge" />
			<IKBone
				AttachOffset="(0; 0; 0)"
				AttachToFrame="BoneGrapplerRight_cdt"
				ModelFrame="BoneGrapplerRightPiston"
			>
				<IKJoint AxisLocal="(0;1;0)" Type="Slider" />
			</IKBone>
		</IKBone>
	</AutomaticIK>
	<AddonCamera
		FirstPersonDir="(0.653; -0.757; 0)"
		FirstPersonPos="(-2.025; 4.856; 0.585)"
		ParentFrame="BoneRotationBase_cdt"
	/>
</TruckAddon>