Very new to CityEngine, especially the code. I am trying to recreate some archaeological architecture at a site in Peru and want the textures to mirror how the buildings actually looked, with a thatched gable roof. I have been writing code to generate this kind of building, but I am so incredibly inexperienced with writing CGA files. Everything I've got I learned from YouTube or the CGA helper. I am trying to use a jpg of a thatched roof texture to overlay on my gable roof, but I am struggling with the orientation. Right now, I have it in my code as :
Roof--> roofGable (20, 1, 1)
# color, uv set 0
setupProjection(0, world.zx, 8, 😎
texture(roof_tex)
// = set(material.colormap,roof_tex)
projectUV(0).
I saw in the CGA help that there is a tileUV function, but I haven't been able to figure it out with what that link gives me.
What I am trying to accomplish is having the thatched roof jpg oriented the same way on all of the roof faces, but I assume I need to split the roof into different faces to achieve this. I think that is done with the comp function? But what are the different faces of the roof called in CGA?
I will insert my code here and the photos of what it generates. Any feedback on my code is welcome, as I am really just starting from scratch here.
In summary: requesting help with tileUV function and/or comp (?) splitting the roof faces.
Thanks!
Code:
/**
* File: Test_rule2rule.cga
* Created: 9 Jun 2022 18:02:40 GMT
* Author: spp566
*/
version "2021.0"
@Range (min=4,max=250,restricted=false)
#attributes
attr height = 10
#textures
const back_tex = "images/Textures/R.jpg"
const roof_tex = "images/Textures/thatched.jpg"
@File
@StartRule
Footprint -->
extrude (height) Building
Building -->
comp(f) {front: WallOne | left: WallTwo | back: WallThree | right: WallFour | top: Roof}
WallOne-->
# color, uv set 0
setupProjection(0, scope.xy, 5, 5)
texture(back_tex)
// = set(material.colormap,back_tex)
projectUV(0)
WallTwo-->
# color, uv set 0
setupProjection(0, scope.xy, 5, 5)
texture(back_tex)
// = set(material.colormap,back_tex)
projectUV(0)
WallThree-->
# color, uv set 0
setupProjection(0, scope.xy, 5, 5)
texture(back_tex)
// = set(material.colormap,back_tex)
projectUV(0)
WallFour-->
# color, uv set 0
setupProjection(0, scope.xy, 5, 5)
texture(back_tex)
// = set(material.colormap,back_tex)
projectUV(0)
Roof--> roofGable (20, 1, 1)
# color, uv set 0
setupProjection(0, world.zx, 8, 😎
texture(roof_tex)
// = set(material.colormap,roof_tex)
projectUV(0)