<?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 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="SimpleClothTemplateBase">	
		<mass>2</mass>
		<inertia x="100" y="100" z="100"/>
		<linearDamping>0.8</linearDamping>
		<angularDamping>0.1</angularDamping>
		<friction>0.75</friction>
	</bone-default>

	<!-- Here, I'm using 'bodyexpand' (name doesn't matter) to literally expand the collision distance for specific body parts.
		This helps prevent clipping in specific areas -->
	<bone-default name="bodyexpand">	
		<mass>0</mass>
		<inertia x="0" y="0" z="0"/>
		<margin-multiplier>2</margin-multiplier>
	</bone-default>
	
<!--Now that we have our templates, let's apply them to our bones.-->
	
	<bone name="evgsmpcape1a" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcape1b" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcape1c" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcape1d" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcape1e" template="SimpleClothTemplateBase"/>

	<bone name="evgsmpcapeL1a" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL1b" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL1c" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL1d" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL1e" template="SimpleClothTemplateBase"/>

	<bone name="evgsmpcapeL2a" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL2b" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL2c" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL2d" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeL2e" template="SimpleClothTemplateBase"/>

	<bone name="evgsmpcapeR1a" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR1b" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR1c" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR1d" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR1e" template="SimpleClothTemplateBase"/>

	<bone name="evgsmpcapeR2a" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR2b" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR2c" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR2d" template="SimpleClothTemplateBase"/>
	<bone name="evgsmpcapeR2e" template="SimpleClothTemplateBase"/>

	<bone name="NPC Pelvis [Pelv]" template="bodyexpand"/>
	<bone name="NPC Spine [Spn0]" template="bodyexpand"/>
	<bone name="NPC Spine1 [Spn1]" template="bodyexpand"/>
	
<!--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="SimpleClothConstraintStart">
		<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.55" y="-0.3" z="-0.03"/>
		<angularUpperLimit x="0.23" y="0.3" z="0.03"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<generic-constraint-default name="SimpleClothConstraintBase">
		<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.35" y="-0.15" z="-0.03"/>
		<angularUpperLimit x="0.25" y="0.15" z="0.03"/>
		<angularStiffness x="1" y="1" z="1"/>
	</generic-constraint-default>
	
	<generic-constraint-default name="SimpleClothConstraintNearby">
		<frameInA>
			<basis x="0" y="0" z="0" w="1"/>
			<origin x="0" y="0" z="0"/>
		</frameInA>
		<useLinearReferenceFrameA>false</useLinearReferenceFrameA>
		<linearLowerLimit x="-1.5" y="-1.5" z="-1.5"/>
		<linearUpperLimit x="1.5" y="1.5" z="1.5"/>
		<angularLowerLimit x="-12" y="-12" z="-12"/>
		<angularUpperLimit x="12" y="12" z="12"/>
		<angularStiffness x="0" y="0" z="0"/>
	</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="evgsmpcape1a" bodyB="NPC Spine2 [Spn2]" template="SimpleClothConstraintStart"/>
	<generic-constraint bodyA="evgsmpcape1b" bodyB="evgsmpcape1a" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcape1c" bodyB="evgsmpcape1b" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcape1d" bodyB="evgsmpcape1c" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcape1e" bodyB="evgsmpcape1d" template="SimpleClothConstraintBase"/>
	
	<generic-constraint bodyA="evgsmpcapeL1a" bodyB="NPC Spine2 [Spn2]" template="SimpleClothConstraintStart"/>
	<generic-constraint bodyA="evgsmpcapeL1b" bodyB="evgsmpcapeL1a" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL1c" bodyB="evgsmpcapeL1b" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL1d" bodyB="evgsmpcapeL1c" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL1e" bodyB="evgsmpcapeL1d" template="SimpleClothConstraintBase"/>

	<generic-constraint bodyA="evgsmpcapeL2a" bodyB="NPC Spine2 [Spn2]" template="SimpleClothConstraintStart"/>
	<generic-constraint bodyA="evgsmpcapeL2b" bodyB="evgsmpcapeL2a" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL2c" bodyB="evgsmpcapeL2b" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL2d" bodyB="evgsmpcapeL2c" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeL2e" bodyB="evgsmpcapeL2d" template="SimpleClothConstraintBase"/>

	<generic-constraint bodyA="evgsmpcapeR1a" bodyB="NPC Spine2 [Spn2]" template="SimpleClothConstraintStart"/>
	<generic-constraint bodyA="evgsmpcapeR1b" bodyB="evgsmpcapeR1a" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR1c" bodyB="evgsmpcapeR1b" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR1d" bodyB="evgsmpcapeR1c" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR1e" bodyB="evgsmpcapeR1d" template="SimpleClothConstraintBase"/>

	<generic-constraint bodyA="evgsmpcapeR2a" bodyB="NPC Spine2 [Spn2]" template="SimpleClothConstraintStart"/>
	<generic-constraint bodyA="evgsmpcapeR2b" bodyB="evgsmpcapeR2a" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR2c" bodyB="evgsmpcapeR2b" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR2d" bodyB="evgsmpcapeR2c" template="SimpleClothConstraintBase"/>
	<generic-constraint bodyA="evgsmpcapeR2e" bodyB="evgsmpcapeR2d" template="SimpleClothConstraintBase"/>
	
	<!-- Because we have several bone chains on a single 'sheet' of cloth, we need to prevent the bone chains from splitting too far apart, as well as getting too close together. -->
	
	<generic-constraint bodyA="evgsmpcape1a" bodyB="evgsmpcapeL1a" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1b" bodyB="evgsmpcapeL1b" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1c" bodyB="evgsmpcapeL1c" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1d" bodyB="evgsmpcapeL1d" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1e" bodyB="evgsmpcapeL1e" template="SimpleClothConstraintNearby"/>

	<generic-constraint bodyA="evgsmpcapeL1a" bodyB="evgsmpcapeL2a" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeL1b" bodyB="evgsmpcapeL2b" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeL1c" bodyB="evgsmpcapeL2c" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeL1d" bodyB="evgsmpcapeL2d" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeL1e" bodyB="evgsmpcapeL2e" template="SimpleClothConstraintNearby"/>
	
	<generic-constraint bodyA="evgsmpcape1a" bodyB="evgsmpcapeR1a" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1b" bodyB="evgsmpcapeR1b" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1c" bodyB="evgsmpcapeR1c" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1d" bodyB="evgsmpcapeR1d" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcape1e" bodyB="evgsmpcapeR1e" template="SimpleClothConstraintNearby"/>

	<generic-constraint bodyA="evgsmpcapeR1a" bodyB="evgsmpcapeR2a" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeR1b" bodyB="evgsmpcapeR2b" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeR1c" bodyB="evgsmpcapeR2c" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeR1d" bodyB="evgsmpcapeR2d" template="SimpleClothConstraintNearby"/>
	<generic-constraint bodyA="evgsmpcapeR1e" bodyB="evgsmpcapeR2e" template="SimpleClothConstraintNearby"/>
	
<!-- Now we introduce our collision meshes & values to prevent clipping with the body as much as possible.-->	
	
	<per-vertex-shape name="bodycollision">
		<margin>1</margin>
		<prenetration>5</prenetration>
		<shared>private</shared>
		<tag>bodycollision</tag>
		<can-collide-with-tag>clothcollision</can-collide-with-tag>
	
	</per-vertex-shape>
	
	<per-triangle-shape name="clothproxy">
		<margin>0.75</margin>
		<prenetration>0.1</prenetration>
		<shared>private</shared>
		<tag>clothcollision</tag>
		
	<weight-threshold bone="evgsmpcape1a">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcape1b">0.5</weight-threshold>	
	<weight-threshold bone="evgsmpcape1c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcape1d">0.2</weight-threshold>	
	<weight-threshold bone="evgsmpcape1e">0.1</weight-threshold>

	<weight-threshold bone="evgsmpcapeR1a">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR1b">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR1c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR1c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR1d">0.2</weight-threshold>	
	<weight-threshold bone="evgsmpcapeR1e">0.1</weight-threshold>

	<weight-threshold bone="evgsmpcapeR2a">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR2b">0.5</weight-threshold>	
	<weight-threshold bone="evgsmpcapeR2c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeR2d">0.2</weight-threshold>	
	<weight-threshold bone="evgsmpcapeR2e">0.1</weight-threshold>

	<weight-threshold bone="evgsmpcapeL1a">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeL1b">0.5</weight-threshold>		
	<weight-threshold bone="evgsmpcapeL1c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeL1d">0.2</weight-threshold>	
	<weight-threshold bone="evgsmpcapeL1e">0.1</weight-threshold>

	<weight-threshold bone="evgsmpcapeL2a">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeL2b">0.5</weight-threshold>		
	<weight-threshold bone="evgsmpcapeL2c">0.5</weight-threshold>
	<weight-threshold bone="evgsmpcapeL2d">0.2</weight-threshold>	
	<weight-threshold bone="evgsmpcapeL2e">0.1</weight-threshold>
	
	</per-triangle-shape>
	
</system>