Attr-Texture Space align

From Vectorlab
Jump to: navigation, search

Aligns texture space between two objects. This is not finished yet! By Orso B. Schmid

{ Orso ***************************** }	
{ aligns texture space mapping between two objects }
{ you'll use this between two objects which are separate }
{ but with the same texture, so that they'll be seemless }
PROCEDURE A_TextureSpaceAlign(source, target, texSpSource, texSpTarget: HANDLE);
		c1, c2, p, d : VECTOR;
		IF (texSpSource <> NIL) & (texSpTarget <> NIL) THEN BEGIN
			SetTexSpaceKind(texSpTarget, GetTexSpaceKind(texSpSource)); { Maptype: plane, cilinder, sphere, perimeter }
			SetTexSpace2DRadius(texSpTarget, GetTexSpace2DRadius(texSpSource)); { Radius }
			SetTexSpace2DScale(texSpTarget, GetTexSpace2DScale(texSpSource)); { Space Scale }
			SetTexSpace2DRot(texSpTarget, GetTexSpace2DRot(texSpSource)); { rotation }
			Get3DCntr(source, c1.x, c1.y, c1.z);
			Get3DCntr(target, c2.x, c2.y, c2.z);
			d := c2 - c1;
			GetTexSpaceOrigin(texSpSource, p.x, p.y, p.z);
			SetTexSpaceOrigin(texSpTarget, p.x -d.x, p.y -d.y, p.z -d.z); { origin }
			GetTexSpace2DOffset(texSpSource, p.x, p.y); { offset }
			SetTexSpace2DOffset(texSpTarget, p.x, p.y);
			GetTexSpaceOrientU(texSpSource, p.x, p.y, p.z); { flip }
			SetTexSpaceOrientU(texSpTarget, p.x, p.y, p.z);
			GetTexSpaceOrientV(texSpSource, p.x, p.y, p.z);
			SetTexSpaceOrientV(texSpTarget, p.x, p.y, p.z);
			GetTexSpaceOrientW(texSpSource, p.x, p.y, p.z);
			SetTexSpaceOrientW(texSpTarget, p.x, p.y, p.z);