<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<vehicle type="winch">
    <annotation>Copyright by Polofreak211</annotation>
	
	<storeData>
        <name>
			<en>winch</en>
			<de>Winde</de>
		</name>
        <functions>
            <function>$l10n_function_winch</function>
        </functions>
        <image>store/store_winch.dds</image>
        <price>1005</price>
        <lifetime>600</lifetime>
        <rotation>0</rotation>
        <brand>LIZARD</brand>
        <category>wood</category>
		<shopTranslationOffset>0 0.016 0</shopTranslationOffset>
    </storeData>
	
	<base>
        <typeDesc>$l10n_typeDesc_winch</typeDesc>
        <filename>winch.i3d</filename>
        <size width="1.5" length="1.0" />
        <components>
            <component centerOfMass="0 0.15 0" solverIterationCount="10" mass="220" />
        </components>
        <schemaOverlay attacherJointPosition="0 0" name="IMPLEMENT" />
    </base>
	
    <powerConsumer maxPtoRpm="540" neededMaxPtoPower="5"/>

    <powerTakeOffs>
        <input inputAttacherJointIndices="1" detachNode="ptoDetachNode" inputNode="ptoInputNode" aboveAttacher="true" />
    </powerTakeOffs>	
	
    <attachable>
        <inputAttacherJoints>
            <inputAttacherJoint node="attacherJoint" rootNode="winch_main_component1" jointType="implement" isControllable="true" isDefaultLowered="true" topReferenceNode="topReferenceNode" upperRotLimitScale="0 0 0" lowerTransLimitScale="0 0 0" upperTransLimitScale="0 0 0" lowerRotLimitScale="0 0 0" rotLimitForceLimit="1 1 1">
            	<distanceToGround lower="0.35" upper="0.95" />
            </inputAttacherJoint>
        </inputAttacherJoints>
        <support animationName="moveSupport" startMoveDirection="-1" />
    </attachable>
	
	<dynamicallyLoadedParts>
		<dynamicallyLoadedPart node="0" linkNode="attacherJoint" filename="lowerLinkBalls/lowerLinkBall.i3d"/>
		<dynamicallyLoadedPart node="2" linkNode="topReferenceNode" filename="lowerLinkBalls/lowerLinkBall.i3d"/>
	</dynamicallyLoadedParts>
	
	<designConfigurations title="Unterlenkerkugeln">
        <designConfiguration name="$l10n_ui_yes" price="50">
            <objectChange node="attacherJoint" visibilityActive="true" />
            <objectChange node="topReferenceNode" visibilityActive="true" />
        </designConfiguration>
        <designConfiguration name="$l10n_ui_no" price="0">
            <objectChange node="attacherJoint" visibilityActive="false" />           
            <objectChange node="topReferenceNode" visibilityActive="false" />           
        </designConfiguration>
    </designConfigurations>

    <attacherJointControl maxTiltAngle="25">
        <control controlFunction="controlAttacherJointHeight" controlAxis="AXIS_HYDRAULICATTACHER1" invertControlAxis="true" mouseSpeedFactor="0.5" iconName="IMPLEMENT_ATTACHER_TRANS" />
        <control controlFunction="controlAttacherJointTilt" controlAxis="AXIS_HYDRAULICATTACHER2" invertControlAxis="true" mouseSpeedFactor="0.5" iconName="IMPLEMENT_ATTACHER_ROTX" />
        <sounds>
            <hydraulic template="defaultHydraulicSound" linkNode="winch_main_component1" />
        </sounds>
    </attacherJointControl>
	
	<animations>
		<animation name="moveSupport">
            <part node="supportArm" startTime="0" endTime="0.01" startTrans="0 0.288 0" endTrans="0 0 0" />
        </animation>
		<animation name="CardanAnimation" looping="true">
            <part node="CardanBack" startTime="0" endTime="1" startRot="0 0 0" endRot="0 0 360" />
            <part node="CardanFront" startTime="0" endTime="1" startRot="0 0 0" endRot="0 0 360" />
        </animation>
    </animations>
	
	<winch>
        <rope node="winchRopeNode" triggerNode="winchTrigger" maxTreeMass="8.0" maxNumTrees="4" minLength="1" maxLength="60" maxSubLength="2">
            <mainRope diameter="0.009" uvScale="4" />
            <setupRope diameter="0.009" uvScale="4" emissiveColor="0 2 0 1" />
            <attach node="winchRopeNode">
                <marker width="0.1" offset="0.005" color="0 2 0"/>
            </attach>
            <treeHook filename="shared/ropes/treeHook03.xml"/>
            <objectChange node="winchRope_detached" visibilityActive="false" visibilityInactive="true" />

            <animationNodes>
                <animationNode node="winchRoll" rotSpeed="75" rotAxis="1" turnOnFadeTime="0.1" turnOffFadeTime="0.1" speedFunc="getWinchRopeSpeedFactor" speedFuncParam="1"/>
                <animationNode node="powertrain" rotSpeed="75" rotAxis="1" turnOnFadeTime="0.1" turnOffFadeTime="0.1" speedFunc="getWinchRopeSpeedFactor" speedFuncParam="1"/>
				<!-- TowRolls -->
                <animationNode node="RolleOben" rotSpeed="-75" rotAxis="1" turnOnFadeTime="0.1" turnOffFadeTime="0.1" speedFunc="getWinchRopeSpeedFactor" speedFuncParam="1"/>
                <animationNode node="RolleUnten" rotSpeed="75" rotAxis="1" turnOnFadeTime="0.1" turnOffFadeTime="0.1" speedFunc="getWinchRopeSpeedFactor" speedFuncParam="1"/>
				<!-- clutch lever -->
                <animationNode node="Kupplungshebel"       startTime="0" endTime="0.01" startRot="0 0 0" endRot="-20 0 0"/>
                <animationNode node="Kupplungshebel_Stick" startTime="0.01" endTime="1" startTrans="0 0.32 0" endTrans="0 0.31 0"/>
            </animationNodes>
			
			<sounds>				
				<pullRope file="$data/sounds/vehicles/transmission/transmissionLoop20.wav"  fadeIn="0.1" fadeOut="0.1" >
                    <volume outdoor="1" indoor="0.4" />
                </pullRope>
                <detachTree file="$data/sounds/animations/latches/latchSmall01.wav" fadeIn="0.1" fadeOut="0.1" >
                    <volume outdoor="1.9" indoor="0.8" />
                </detachTree>
				<attachTree file="$data/sounds/animations/latches/latchSmall01.wav" >
                    <volume outdoor="1.9" indoor="0.8" />
                </attachTree>
				<releaseRope file="$data/sounds/vehicles/hydraulic/moving_parts.wav" fadeIn="0.1" fadeOut="0.1" >
                    <volume outdoor="1" indoor="0.4" />
                </releaseRope>
            </sounds>
        </rope>
    </winch>
	
	<turnOnVehicle turnOffIfNotAllowed="true">
        <turnedOnAnimation name="CardanAnimation" speedScale="-10" turnOnFadeTime="2" turnOffFadeTime="2"/>
		
		<sounds>
            <work file="$data/sounds/vehicles/transmission/transmissionLoop20.wav"  fadeIn="0.1" fadeOut="0.1"/>
        </sounds>
    </turnOnVehicle>
	
	<ai>
        <agentAttachment width="0.5" height="0.5" length="0.8" lengthOffset="0"/>
    </ai>

    <foliageBending>
        <bendingNode minX="-1.1" maxX="1.1" minZ="-0.4" maxZ="0.3" yOffset="0.0" />
    </foliageBending>
	
	<baseMaterial>
        <material name="winch_mat" baseNode="winch_vis">
            <shaderParameter name="colorMat0" value="0 0.14 0.08 0"/>
            <shaderParameter name="colorMat1" value="0.5 0.5 0.5 6"/>
            <shaderParameter name="colorMat2" value="0.1 0.1 0.1 0"/>
        </material>
    </baseMaterial>
	
	<!-- Winch Body -->
	<designMaterialConfigurations title="Winde" useDefaultColors="true">
		<designMaterialConfiguration color="0 0.14 0.08 0"/>
		
        <material name="winch_mat" shaderParameter="colorMat0"/>
    </designMaterialConfigurations>
	
	<!-- Winch pulley -->
	<designMaterial2Configurations title="Seilrolle" useDefaultColors="true">
		<designMaterial2Configuration color="0.5 0.5 0.5 6"/>
		
		<material name="winch_mat" shaderParameter="colorMat1"/>
    </designMaterial2Configurations>
	
	<!-- Winch Cardan -->
	<designMaterial3Configurations title="Kardanwelle" useDefaultColors="true">
        <designMaterial3Configuration color="0.1 0.1 0.1 0"/>
		
		<material name="winch_mat" shaderParameter="colorMat2"/>
    </designMaterial3Configurations>
	
    <wearable wearDuration="480" workMultiplier="10" />	
    <washable dirtDuration="90" washDuration="1" workMultiplier="2" fieldMultiplier="2"/>
	
	<i3dMappings>
		<i3dMapping id="winch_main_component1" node="0>" />
		<i3dMapping id="winch_vis" node="0>0" />
		<i3dMapping id="attacherJoint" node="0>0|0|0" />
		<i3dMapping id="topReferenceNode" node="0>0|0|1" />
		<i3dMapping id="ptoInputNode" node="0>0|0|2" />
		<i3dMapping id="ptoDetachNode" node="0>0|0|3" />
		<i3dMapping id="supportArm" node="0>0|0|4|0" />
		<i3dMapping id="winchTrigger" node="0>0|1|0" />
		<i3dMapping id="winchRopeNode" node="0>0|1|1" />
		<i3dMapping id="winchRope_detached" node="0>0|1|2" />
		<i3dMapping id="winchRoll" node="0>0|1|3" />
		<i3dMapping id="powertrain" node="0>0|1|4" />
		<i3dMapping id="CardanBack" node="0>0|1|5|0" />
		<i3dMapping id="CardanFront" node="0>0|1|6" />
		<i3dMapping id="RolleOben" node="0>0|1|7" />
		<i3dMapping id="RolleUnten" node="0>0|1|8" />
		<i3dMapping id="Kupplungshebel" node="0>0|1|9" />
		<i3dMapping id="Kupplungshebel_Stick" node="0>0|1|9|0" />
	</i3dMappings>
</vehicle>
