We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Aligning a repeating texture to repeating elements

TomWaltz
Participant
I'm trying to write a tile surround object that would physically model the tiles complete with grout lines.

Part of the goal is to align a photo-real texture to each individual tile (not always the same one, sometimes part of a pattern).

I'm banging my head against it since I am not having much luck aligning the origin inside the object, let alone finding a way to toggle between materials from tile to tile....

Aside from buying ArchiTile, any suggestions?
Tom Waltz
16 REPLIES 16
Anonymous
Not applicable
With normal body creation you cannot have texture scaling as you like.
You can have a global change by defining the texture and stretching it, but it will be applied to all texture instances.

If you need to stretch the texture differently in many object you should create the body from scratch using teve commands. Its really very easy.

You can create a for loop to create complex objects. A sample code
just to create a vertical face

You need parameters mat (material) and x,y,z scale is to tweak the texture as you like. For tiles you will actually need just the upper surface so it is ultra simple. Just define points edges and a simple polygon

MATERIAL mat
BASE

TEVE 0,0,0, 0,0 ! origin
TEVE A,0,0, Xscale,0 ! P+u,v
TEVE A,0,ZZYZX, Xscale,Zscale ! P +u,v
TEVE 0,0,ZZYZX, 0,Zscale! Z+u,v

EDGE 1,2 ,-1,-1 , 0
EDGE 2,3 ,-1,-1 , 0
EDGE 3,4 ,-1,-1 , 0
EDGE 4,1 ,-1,-1 , 0

PGON 4,0,0, 1,2,3,4

BASE

TEVE 0,0,0 ,0,0
TEVE 1,0,0 ,0,0
TEVE 0,1,0 ,0,0
TEVE 0,0,1 ,0,0

COOR 2+1024, 1,2,3,4 !where code

BODY -1
Anonymous
Not applicable
Here is a more sophisticated example of texture alignment.

The gdl code creates a simple face. You can rotate it using the angle parameter.

You also have 3 hospots. The first one positions the origin of the texture
and the other two scale the texture graphically.

You can in fact use it to position textures in facades.

I wonder is it so hard to have such texture alignment in Archicad?

Its SOOOOO easy

Any comments welcomed. In fact i would like to add a few tricks to that simple gdl.
TomWaltz
Participant
OK, here's the code I tried:

	DEFINE TEXTURE "tilePattern" txtName, 
		txScale, tyScale,
		0, 0
	txtNum = IND(TEXTURE, "tilePattern")

	DEFINE MATERIAL "tilePattern" 24,
		1, 1, 	1, ! RBG Color
		0, 61, txtNum
	matlNum = IND(MATERIAL, "tilePattern")

! Draw Tile
	cPRISM_ 0, 0, matlNum,
				 5, ZZYZX,
			0, 0,     15,
			A, 0,     15,
			A, B,     15,
			0, B,     15,
			0, 0,     -1
	
! Set Texture Origin
	VERT 	0,		B,		0		! Origin
	VERT 	1, 		B, 		0		! X Direction
	VERT	 0, 		1,		0		! Y Direction
	VERT 	0, 		B,		1		! Z Direction
	COOR 2, 1, 2, 3, 4
	BODY -1
The material is definitely not starting at 0,0,0 (the lower left corner) like it's supposed to be,

Any other ideas? Or did I code something wrong?
Picture 1.png
Tom Waltz
Frank Beister
Moderator
Hello Tom.

I can not test it in the moment, but I think, your vertices are wrong.
! Set Texture Origin
   VERT    0,      B,      0      ! Origin
If it should be at 0/0/0, why is there a B inside? The direction of he axis ...

   VERT    1,       B,       0      ! X Direction
   VERT    0,       1,      0      ! Y Direction
   VERT    0,       B,      1      ! Z Direction
is independent of the origin. They show the direction from local, not from texture origin, pointed by the 1st VERT. Your "direction" should be 1/0/0, 0/1/0 and 0/0/1.

I think your VERT-block should work with
   VERT    0,      0,      0      ! Origin
   VERT    1,       0,       0      ! X Direction
   VERT    0,       1,      0      ! Y Direction
   VERT    0,       0,      1      ! Z Direction
You can do some transformations before the VERT commands to bring origin and orientation of your coordinate system in the position you want.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
TomWaltz
Participant
The intention of the "B" value was to move the origin a distance (B) in the Y-direction.

I thought that if my origin was 0,B,0 and the vector was 0,0,0, the material would be tilted.
Tom Waltz
Frank Beister
Moderator
Tom, if it was not clearifying, you can send me the object and the pict. Would be much easier for me to help.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
TomWaltz wrote:
OK, here's the code I tried:

	DEFINE TEXTURE "tilePattern" txtName, 
		txScale, tyScale,
		0, 0
	txtNum = IND(TEXTURE, "tilePattern")

	DEFINE MATERIAL "tilePattern" 24,
		1, 1, 	1, ! RBG Color
		0, 61, txtNum
	matlNum = IND(MATERIAL, "tilePattern")

! Draw Tile
	cPRISM_ 0, 0, matlNum,
				 5, ZZYZX,
			0, 0,     15,
			A, 0,     15,
			A, B,     15,
			0, B,     15,
			0, 0,     -1
	
! Set Texture Origin
	VERT 	0,		B,		0		! Origin
	VERT 	1, 		B, 		0		! X Direction
	VERT	 0, 		1,		0		! Y Direction
	VERT 	0, 		B,		1		! Z Direction
	COOR 2, 1, 2, 3, 4
	BODY -1
The material is definitely not starting at 0,0,0 (the lower left corner) like it's supposed to be,

Any other ideas? Or did I code something wrong?
! Set Texture Origin New
	VERT 	0,		B,		0		! Origin
	VERT 	1, 		B, 		0		! X Direction
	VERT	 0, 		1,		0		! Y Direction
	VERT 	0, 		B,		1		! Z Direction
	COOR 2+256, 1, 2, 3, 4  ! 256 is local coordinate system 
	BODY -1