<?xml version="1.0" encoding="UTF-8"?>

<!--
SMP setup by Everglaid, feel free to use
 -->
 
 <system xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="description.xsd">
 
 
	<!--Let's declare our bone templates.
	We can use these templates to give multiple bones the same physics values, without needing to retype them over and over for each individual bone.
	This can be very helpful if you're making something with a high bone count.-->
	
	<bone name="NPC L Clavicle [LClv]"/>
	<bone name="NPC R Clavicle [RClv]"/>
	<bone name="NPC L Forearm [LLar]"/>
	<bone name="NPC R Forearm [RLar]"/>
	<bone name="NPC L ForearmTwist1 [LLt1]"/>
	<bone name="NPC R ForearmTwist1 [RLt1]"/>
	<bone name="NPC L ForearmTwist2 [LLt2]"/>
	<bone name="NPC R ForearmTwist2 [RLt2]"/>
	<bone name="NPC L Hand [LHnd]"/>
	<bone name="NPC R Hand [RHnd]"/>
	<bone name="NPC Head [Head]"/>
	<bone name="NPC Pelvis [Pelv]"/>
	<bone name="NPC Spine [Spn0]"/>
	<bone name="NPC Spine1 [Spn1]"/>
	<bone name="NPC Spine2 [Spn2]"/>
	<bone name="NPC L Thigh [LThg]"/>
	<bone name="NPC R Thigh [RThg]"/>
	<bone name="NPC L UpperArm [LUar]"/>
	<bone name="NPC R UpperArm [RUar]"/>
	<bone name="NPC L UpperarmTwist1 [LUt1]"/>
	<bone name="NPC R UpperarmTwist1 [RUt1]"/>
	<bone name="NPC L UpperarmTwist2 [LUt2]"/>
	<bone name="NPC R UpperarmTwist2 [RUt2]"/>
	
	<bone-default name="ClothTemplateBase">	
		<mass>1</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0.1</linearDamping>
		<angularDamping>0.1</angularDamping>
	</bone-default>

	<bone-default name="ClothTemplateRope">	
		<mass>3</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0.3</linearDamping>
		<angularDamping>0.3</angularDamping>
	</bone-default>
	
	<bone-default name="ClothTemplateHeavy">	
		<mass>5</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0.1</linearDamping>
		<angularDamping>0.1</angularDamping>
		<gravity-factor>0.5</gravity-factor>
	</bone-default>
	
	<bone-default name="ClothTemplateLock">	
		<mass>2</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0</linearDamping>
		<angularDamping>0.5</angularDamping>
		<friction>1</friction>
		<restitution>0</restitution>
		<gravity-factor>1</gravity-factor>
	</bone-default>

	<bone-default name="ClothTemplateLockSecond">	
		<mass>4</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0</linearDamping>
		<angularDamping>0.1</angularDamping>
		<restitution>0</restitution>
		<gravity-factor>1</gravity-factor>
	</bone-default>
	
	<bone-default name="ClothTemplateHeavier">	
		<mass>10</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0.1</linearDamping>
		<angularDamping>0.1</angularDamping>
		<gravity-factor>0.5</gravity-factor>
	</bone-default>
	
<!--Now that we have our templates, let's apply them to our bones.-->
		
	<bone name="evgsmpbackpackmain" template="ClothTemplateHeavy"/>
	
	<bone name="evgsmpbackpackbox1" template="ClothTemplateHeavy"/>
	<bone name="evgsmpbackpackbox2" template="ClothTemplateHeavy"/>

	<bone name="evgsmpbackpackcloth" template="ClothTemplateHeavy"/>
	
	<bone name="evgsmpbackpackrope1a" template="ClothTemplateRope"/>
	<bone name="evgsmpbackpackrope1b" template="ClothTemplateRope"/>

	<bone name="evgsmpbackpackleath1a" template="ClothTemplateBase"/>
	<bone name="evgsmpbackpackleath1b" template="ClothTemplateBase"/>

	<bone name="evgsmpbackpacklock1a" template="ClothTemplateLock"/>
	<bone name="evgsmpbackpacklock1b" template="ClothTemplateLockSecond"/>
	
	<!-- Lantern parts -->
	
	<bone name="evgsmplanternpole" template="ClothTemplateBase"/>

	<bone name="evgsmplanternrope1a" template="ClothTemplateRope"/>
	<bone name="evgsmplanternrope1b" template="ClothTemplateRope"/>

	<bone name="evgsmplanternring1a" template="ClothTemplateHeavier"/>
	<bone name="evgsmplanternring1b" template="ClothTemplateHeavier"/>	
	<bone name="evgsmplanternring1c" template="ClothTemplateHeavier"/>	
	
<!--With our bones declared, we need to apply constraints: 'connecting' our bones from child to parent, with some more physics settings.
Again, we'll start with templates: these will define how the physics work on children bones, relative to the parent.-->
		
	<generic-constraint-default name="BackpackBaseMovement">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.001" y="-0.1" z="-0.1"/>
		<linearUpperLimit x="0.001" y="0.1" z="0.1"/>
		<angularLowerLimit x="-0.01" y="-0.01" z="-0.01"/>
		<angularUpperLimit x="0.01" y="0.01" z="0.01"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<generic-constraint-default name="BackpackLeathConstraint">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.0" y="-0.0" z="-0.0"/>
		<linearUpperLimit x="0.0" y="0.0" z="0.0"/>
		<angularLowerLimit x="-0.01" y="-0.01" z="-0.01"/>
		<angularUpperLimit x="0.01" y="0.01" z="0.01"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<generic-constraint-default name="BackpackRopeConstraint">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.001" y="-0.001" z="-0.001"/>
		<linearUpperLimit x="0.001" y="0.001" z="0.001"/>
		<angularLowerLimit x="-0.2" y="-0.2" z="-0.1"/>
		<angularUpperLimit x="0.2" y="0.2" z="0.1"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>	

	<generic-constraint-default name="BackpackLockConstraint">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.0" y="-0.0" z="0.1"/>
		<linearUpperLimit x="0.0" y="0.0" z="0.7"/>
		<angularLowerLimit x="-0.9" y="-0.6" z="-0.3"/>
		<angularUpperLimit x="0.1" y="0.6" z="0.3"/>
		
		<angularStiffness x="1" y="1" z="1"/>
		<angularDamping x="0" y="0" z="0" />
		<angularEquilibrium x="0.07" y="0" z="0" />
		<angularBounce x="1" y="1" z="0" />
	</generic-constraint-default>

	<generic-constraint-default name="BackpackLockConstraintSecond">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.0" y="-0.0" z="-0.0"/>
		<linearUpperLimit x="0.0" y="0.0" z="0.0"/>
		<angularLowerLimit x="-0.01" y="-0.01" z="-0.01"/>
		<angularUpperLimit x="0.01" y="0.01" z="0.01"/>		
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<generic-constraint-default name="BackpackClothConstraint">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.9" y="-0.9" z="-0.9"/>
		<linearUpperLimit x="0.9" y="0.9" z="0.9"/>
		<angularLowerLimit x="-0.2" y="-0.2" z="-0.2"/>
		<angularUpperLimit x="0.2" y="0.2" z="0.2"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>

	<generic-constraint-default name="BackpackBoxConstraint">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.2" y="-0.0" z="-0.2"/>
		<linearUpperLimit x="0.2" y="0.0" z="0.2"/>
		<angularLowerLimit x="-0.0" y="-0.0" z="-0.0"/>
		<angularUpperLimit x="0.0" y="0.0" z="0.0"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<!-- Lantern parts -->

	<generic-constraint-default name="LanternBaseMovement">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.001" y="-0.001" z="-0.001"/>
		<linearUpperLimit x="0.001" y="0.001" z="0.001"/>
		<angularLowerLimit x="-0.001" y="-0.001" z="-0.001"/>
		<angularUpperLimit x="0.001" y="0.001" z="0.001"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>

	<generic-constraint-default name="LanternRingMovement">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-0.001" y="-0.001" z="-0.001"/>
		<linearUpperLimit x="0.001" y="-0.001" z="0.001"/>
		<angularLowerLimit x="-0.2" y="-0.2" z="-0.2"/>
		<angularUpperLimit x="0.2" y="0.2" z="0.2"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	
<!-- Apply the templates to the bones, and set the proper parents.-->

	<!-- The order doesn't matter, but I'll start with attaching the parent chains to the vanilla spine bone.-->
	
	<generic-constraint bodyA="evgsmpbackpackmain" bodyB="NPC Spine2 [Spn2]" template="BackpackBaseMovement"/>	

	<generic-constraint bodyA="evgsmpbackpackbox1" bodyB="NPC Spine2 [Spn2]" template="BackpackBaseMovement"/>
	<generic-constraint bodyA="evgsmpbackpackbox2" bodyB="NPC Spine2 [Spn2]" template="BackpackBaseMovement"/>	
	
	<generic-constraint bodyA="evgsmpbackpackrope1a" bodyB="evgsmpbackpackbox2" template="BackpackRopeConstraint"/>
	<generic-constraint bodyA="evgsmpbackpackrope1b" bodyB="evgsmpbackpackrope1a" template="BackpackRopeConstraint"/>	

	<generic-constraint bodyA="evgsmpbackpackleath1a" bodyB="evgsmpbackpackmain" template="BackpackLeathConstraint"/>
	<generic-constraint bodyA="evgsmpbackpackleath1b" bodyB="evgsmpbackpackmain" template="BackpackLeathConstraint"/>	

	<generic-constraint bodyA="evgsmpbackpacklock1a" bodyB="evgsmpbackpackbox1" template="BackpackLockConstraint"/>
	<generic-constraint bodyA="evgsmpbackpacklock1b" bodyB="evgsmpbackpacklock1a" template="BackpackLockConstraintSecond"/>
	
	<generic-constraint bodyA="evgsmpbackpackcloth" bodyB="evgsmpbackpackbox2" template="BackpackClothConstraint"/>	
	
	<!-- Lantern parts -->
	
	<generic-constraint bodyA="evgsmplanternpole" bodyB="NPC Spine2 [Spn2]" template="LanternBaseMovement"/>

	<generic-constraint bodyA="evgsmplanternrope1a" bodyB="NPC Spine2 [Spn2]" template="BackpackRopeConstraint"/>
	<generic-constraint bodyA="evgsmplanternrope1b" bodyB="evgsmplanternrope1a" template="BackpackRopeConstraint"/>
	
	<generic-constraint bodyA="evgsmplanternring1a" bodyB="NPC Spine2 [Spn2]" template="LanternRingMovement"/>
	<generic-constraint bodyA="evgsmplanternring1b" bodyB="evgsmplanternring1a" template="LanternRingMovement"/>	
	<generic-constraint bodyA="evgsmplanternring1c" bodyB="evgsmplanternring1b" template="LanternRingMovement"/>		
	
</system>