package com.guru.project.papervision3D.element 
{
	import com.guru.call.FunctionCall;
	import com.guru.project.papervision3D.element.base.MaterialPlane;
	import com.guru.project.papervision3D.element.base.ModelBase;
	import flash.display.MovieClip;
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.objects.DisplayObject3D;
	/**
	 * ...
	 * @author Eddy Lee
	 */
	public class Chair3D extends ModelBase
	{
		private var mBack_mc:MovieClip;
		private var mSeat_mc:MovieClip;
		private var mLeftFoot_mc:MovieClip;
		private var mRightFoot_mc:MovieClip;
		
		private var mBackPlane:MovieClipPlane;
		private var mSeatPlane:MovieClipPlane;
		private var mLeftPlane:MovieClipPlane;
		private var mRightPlane:MovieClipPlane;
		
		private var mSegmentW_num:Number;
		private var mSegmentH_num:Number;
		
		public function Chair3D(pBack_mc:MovieClip, pSeat_mc:MovieClip, pLeftFoot_mc:MovieClip, pRightFoot_mc:MovieClip, pDraggable_bol:Boolean = false)
		{
			super(pDraggable_bol);
			
			mBack_mc = pBack_mc;
			mSeat_mc = pSeat_mc;
			mLeftFoot_mc = pLeftFoot_mc;
			mRightFoot_mc = pRightFoot_mc;
			
			mSegmentW_num = 2;
			mSegmentH_num = 2;
			
			this.initChair();
		}
		
		private function initChair():void
		{
			mBackPlane = new MovieClipPlane(mBack_mc, mBack_mc.width, mBack_mc.height, mSegmentW_num, mSegmentH_num, true);
			mSeatPlane = new MovieClipPlane(mSeat_mc, mSeat_mc.width, mSeat_mc.height, mSegmentW_num, mSegmentH_num, true);
			mLeftPlane = new MovieClipPlane(mLeftFoot_mc, mLeftFoot_mc.width, mLeftFoot_mc.height, mSegmentW_num, mSegmentH_num, true);
			mRightPlane = new MovieClipPlane(mRightFoot_mc, mRightFoot_mc.width, mRightFoot_mc.height, mSegmentW_num, mSegmentH_num, true);
			
			mLeftPlane.x = -mSeat_mc.width/2;
			mLeftPlane.y = mLeftFoot_mc.height/2;
			mLeftPlane.localRotationY = 90;
			
			mRightPlane.x = mSeat_mc.width/2;
			mRightPlane.y = mRightFoot_mc.height/2;
			mRightPlane.localRotationY = -90;
			
			mSeatPlane.y = Math.max(mLeftFoot_mc.height, mRightFoot_mc.height);
			mSeatPlane.localRotationX = 90;
			
			mBackPlane.z = -mSeat_mc.height / 2;
			mBackPlane.y = mSeatPlane.y + mBack_mc.height / 2;
			
			mBackPlane.doubleSided(true);
			mSeatPlane.doubleSided(true);
			mLeftPlane.doubleSided(true);
			mRightPlane.doubleSided(true);
			
			mBackPlane.interactive(true);
			mSeatPlane.interactive(true);
			mLeftPlane.interactive(true);
			mRightPlane.interactive(true);
			
			this.addPlane(mBackPlane);
			this.addPlane(mSeatPlane);
			this.addPlane(mLeftPlane);
			this.addPlane(mRightPlane);
		}
		
		private function onChairPress():void
		{
			
		}
	}

}