function newDummy(%obj,%trans,%sc) {
	if(getWordCount(%obj) == 1 && isObject(%obj)) {
		%box = %obj.getObjectBox();
		%transform = %obj.getTransform();
		%scale = %obj.getScale();
		}
	else if (getWordCount(%obj) == 6) 
		%box = %obj;
	else 
		%box = "0 0 0 1 1 1";
	if (%trans !$= "")
		%transform = %trans;
	if (%sc !$= "")
		%scale = %sc;
	%obj = new ScriptObject(BoxDummy) {
        	class = BoxDummy;
		box = %box;
		transform = %transform;
		scale = %scale;
		};
	return %obj;
}

function boxDummy::set(%dummy,%obj) {
	%obj.setRealSize(%dummy.getRealSize());
	%obj.setRotation(%dummy.getRotation());
	%obj.setEdge(%dummy.getEdge("0 0 0"),"0 0 0");
}


function boxDummy::getObjectBox(%obj) {
	return %obj.box;
}

function boxDummy::setObjectBox(%obj,%box) {
	%obj.box = %box;
}

function boxDummy::getTransform(%obj) {
	return %obj.transform;
}

function boxDummy::setTransform(%obj,%trans) {
	%obj.transform = %trans;
}

function boxDummy::getPosition(%obj) {
	return getWords(%obj.getTransform(),0,2);
}

function boxDummy::setPosition(%obj,%pos) {
	%obj.setTransform(%pos SPC %obj.getRotation());
}

function boxDummy::getRotation(%obj) {
	return getWords(%obj.getTransform(),3,6);
}

function boxDummy::setRotation(%obj,%rot) {
	%obj.setTransform(%obj.getPosition() SPC %rot);
}

function boxDummy::getScale(%obj) {
	return %obj.scale;
}

function boxDummy::setScale(%obj,%scale) {
	%obj.scale = %scale;
}

function boxDummy::getShapeSize(%obj) {
	return VectorSub(getWords(%obj.box,3,5),getWords(%obj.box,0,2));
}

function boxDummy::getRealSize(%obj) {
	return vMul(%obj.getShapeSize(),%obj.getScale());
}

function boxDummy::setRealSize(%obj,%scale) {
	%obj.setScale(vDiv(%scale,%obj.getShapeSize()));
}

function boxDummy::getShapeCenter(%obj) {
	return vDiv(VectorAdd(getWords(%obj.box,3,5),getWords(%obj.box,0,2)),VectorScale(%obj.getShapeSize(),2));
}

function boxDummy::getEdge(%obj,%edge) {
	%pos = vMul(VectorAdd(%edge,%obj.getShapeCenter()),%obj.getRealSize());
	//%rot = %obj.getRotation();
	//%pos = MatrixMulVector("0 0 0" SPC %rot,%pos);	
        //%pos = VectorAdd(%obj.getPosition(),%pos);
	%pos = MatrixMulPoint(%obj.getTransform(),%pos);
	return %pos;
}

function boxDummy::findEdge(%obj,%point) {
	%pos = VectorScale(getWords(%obj.getTransform(),0,2),-1);
	%rot = invRot(getWords(%obj.getTransform(),3,6));
	%point = VectorAdd(%point,%pos);
	%pos = MatrixMulVector(%pos SPC %rot,%point);		
	return VectorSub(vDiv(%pos,%obj.getRealSize()),%obj.getShapeCenter());
}

function boxDummy::setEdge(%obj,%pos,%edge) {
	%offset = VectorSub(%pos,VectorSub(%Obj.getEdge(%edge),%obj.getPosition()));
	%obj.setPosition(%offset);
}
