Attr-Texture copy

From Vectorlab
Jump to: navigation, search


Copy textures between two objects. This is not finished yet! See infos below. This procedure needs the routine A_TextureSpaceAlign to be loaded first. By Orso B. Schmid

NOTES

The result depends on the object types:

  • if the objects have equal obj type, the routine copies the textures part by part
  • if the objects have different type, it transfers the chosen part's texture (sourcePart) to all target object's parts


for example
source = wall and target = extrude; sourcePart=1:
  • --> left wall texture (part!D=1) will apply to the extrude.


for example
source = wall and target = wall; sourcePart=1:
  • --> all textures part by part are transferred from one wall to another.
partID is:
  • 0 for generic 3D objects
  • 0, 1 for roofs, where: 0=Top, 1=dormer
  • 0, 1, 2 for walls, where: 0=Right, 1=Left, 2=Center


{ Orso ***************************************** }
{ Copy the texture from one obj to another }
{ This routine doesn't take into consideration mixing roofs with walls.
It also give misleading results on groups, since they cannot be applied a texture by class,
while the objects therecontained inherit the by class }
PROCEDURE A_TextureCopy(source, target: HANDLE; sourcePart: INTEGER);
	VAR
		typ, part, partCnt : INTEGER;
		sourceIsWall, targetIsWall, sourceIsRoof, targetIsRoof : BOOLEAN;
		
	BEGIN
		IF (source <> NIL) & (target <> NIL) THEN 
			IF IsTextureableObject(source) & IsTextureableObject(target) THEN BEGIN
				
				typ := GetTypeN(source);
				sourceIsWall := A_IsWall(source);
				sourceIsRoof := ((typ=83));
				
				typ := GetTypeN(target);
				targetIsWall := A_IsWall(target);
				targetIsRoof := ((typ=83));
				
				partCnt := -1;
				IF ((sourceIsWall = TRUE) & (sourceIsWall = targetIsWall)) THEN
					partCnt := 2
				ELSE IF ((sourceIsRoof = TRUE) & (sourceIsRoof = targetIsRoof)) THEN
					partCnt := 1
				ELSE IF (GetObjExpandTexture(source) = FALSE) & (GetObjExpandTexture(target) = FALSE) THEN
					partCnt := 0;
				
				{ if the objects are alignable, parts are copied one by one }
				IF partCnt > -1 THEN BEGIN
					SetClass(target, GetClass(source));
					
					part := -1;
					WHILE part < partCnt DO BEGIN { partID from 0 to 2 }
						part := part + 1;
						
						{ each part byClass }
						IF GetTextureRef(source, part, FALSE) = -1 THEN
							SetTextureRef(target, -1, part) 
						ELSE
							SetTextureRef(target, GetTextureRef(source, part, TRUE), part);
					END;
				
				{ otherwise if they are mixed the chosen sourcePart will apply }
				END ELSE BEGIN
				
					IF GetTextureRef(source, sourcePart, TRUE) = 0 THEN
						SetTextureRef(target, -2, 0) { remove texture }
					ELSE
						SetTextureRef(target, GetTextureRef(source, sourcePart, TRUE), 0);
				END;
			END;
	END;