<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Tiling roof using CGA for better texture overlay in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/tiling-roof-using-cga-for-better-texture-overlay/m-p/1182806#M10540</link>
    <description>&lt;P&gt;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 :&lt;/P&gt;&lt;P&gt;Roof--&amp;gt; roofGable (20, 1, 1)&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, world.zx, 8, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;BR /&gt;texture(roof_tex)&lt;BR /&gt;// = set(material.colormap,roof_tex)&lt;BR /&gt;projectUV(0).&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary: requesting help with tileUV function and/or comp (?) splitting the roof faces.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt;* File: Test_rule2rule.cga&lt;BR /&gt;* Created: 9 Jun 2022 18:02:40 GMT&lt;BR /&gt;* Author: spp566&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;version "2021.0"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@Range (min=4,max=250,restricted=false)&lt;BR /&gt;#attributes&lt;BR /&gt;attr height = 10&lt;/P&gt;&lt;P&gt;#textures&lt;/P&gt;&lt;P&gt;const back_tex = "images/Textures/R.jpg"&lt;BR /&gt;const roof_tex = "images/Textures/thatched.jpg"&lt;BR /&gt;@File&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@StartRule&lt;BR /&gt;&lt;BR /&gt;Footprint --&amp;gt;&lt;BR /&gt;extrude (height) Building&lt;BR /&gt;&lt;BR /&gt;Building --&amp;gt;&lt;BR /&gt;comp(f) {front: WallOne | left: WallTwo | back: WallThree | right: WallFour | top: Roof}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;WallOne--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallTwo--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallThree--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallFour--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;/P&gt;&lt;P&gt;Roof--&amp;gt; roofGable (20, 1, 1)&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, world.zx, 8, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;BR /&gt;texture(roof_tex)&lt;BR /&gt;// = set(material.colormap,roof_tex)&lt;BR /&gt;projectUV(0)&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2022 17:11:52 GMT</pubDate>
    <dc:creator>KaleiOliver_utsa</dc:creator>
    <dc:date>2022-06-14T17:11:52Z</dc:date>
    <item>
      <title>Tiling roof using CGA for better texture overlay</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/tiling-roof-using-cga-for-better-texture-overlay/m-p/1182806#M10540</link>
      <description>&lt;P&gt;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 :&lt;/P&gt;&lt;P&gt;Roof--&amp;gt; roofGable (20, 1, 1)&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, world.zx, 8, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;BR /&gt;texture(roof_tex)&lt;BR /&gt;// = set(material.colormap,roof_tex)&lt;BR /&gt;projectUV(0).&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary: requesting help with tileUV function and/or comp (?) splitting the roof faces.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt;* File: Test_rule2rule.cga&lt;BR /&gt;* Created: 9 Jun 2022 18:02:40 GMT&lt;BR /&gt;* Author: spp566&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;version "2021.0"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;@Range (min=4,max=250,restricted=false)&lt;BR /&gt;#attributes&lt;BR /&gt;attr height = 10&lt;/P&gt;&lt;P&gt;#textures&lt;/P&gt;&lt;P&gt;const back_tex = "images/Textures/R.jpg"&lt;BR /&gt;const roof_tex = "images/Textures/thatched.jpg"&lt;BR /&gt;@File&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@StartRule&lt;BR /&gt;&lt;BR /&gt;Footprint --&amp;gt;&lt;BR /&gt;extrude (height) Building&lt;BR /&gt;&lt;BR /&gt;Building --&amp;gt;&lt;BR /&gt;comp(f) {front: WallOne | left: WallTwo | back: WallThree | right: WallFour | top: Roof}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;WallOne--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallTwo--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallThree--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;BR /&gt;&lt;BR /&gt;WallFour--&amp;gt;&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, scope.xy, 5, 5)&lt;BR /&gt;texture(back_tex)&lt;BR /&gt;// = set(material.colormap,back_tex)&lt;BR /&gt;projectUV(0)&lt;/P&gt;&lt;P&gt;Roof--&amp;gt; roofGable (20, 1, 1)&lt;BR /&gt;# color, uv set 0&lt;BR /&gt;setupProjection(0, world.zx, 8, &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;BR /&gt;texture(roof_tex)&lt;BR /&gt;// = set(material.colormap,roof_tex)&lt;BR /&gt;projectUV(0)&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 17:11:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/tiling-roof-using-cga-for-better-texture-overlay/m-p/1182806#M10540</guid>
      <dc:creator>KaleiOliver_utsa</dc:creator>
      <dc:date>2022-06-14T17:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Tiling roof using CGA for better texture overlay</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/tiling-roof-using-cga-for-better-texture-overlay/m-p/1296728#M11044</link>
      <description>&lt;P&gt;You could use the &lt;FONT face="courier new,courier"&gt;horizontal&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;vertical&lt;/FONT&gt; selectors in a &lt;FONT face="courier new,courier"&gt;comp&lt;/FONT&gt; split to select the bottom face of the roof (which is hidden inside the building, so I &lt;FONT face="courier new,courier"&gt;NIL&lt;/FONT&gt; it) and the vertical roof pediment sides (which I made a &lt;FONT face="courier new,courier"&gt;Wall&lt;/FONT&gt;).&amp;nbsp; The remaining faces (&lt;FONT face="courier new,courier"&gt;all&lt;/FONT&gt;) go to &lt;FONT face="courier new,courier"&gt;RoofFace&lt;/FONT&gt; which sets up the projection for the roof texture so that it aligns with the roof eave edges (by choosing &lt;FONT face="courier new,courier"&gt;scope.xy&lt;/FONT&gt; in this case).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Roof --&amp;gt;
	roofGable(20, 1, 1)
	comp(f) { horizontal: NIL
			| vertical: Wall
			| all: RoofFace }

Wall --&amp;gt;
	setupProjection(0, scope.xy, 5, 5)
	texture(back_tex)
	projectUV(0)
	
RoofFace --&amp;gt;
	setupProjection(0, scope.xy, 8, 8)
	texture(roof_tex)
	projectUV(0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that this solution will not work for all gable roofs.&amp;nbsp; If the roof slope is too steep, the slanted faces will get categorized as vertical.&amp;nbsp; Similarly, if the roof slope is too flat, the slanted faces will get categorized as horizontal.&amp;nbsp; Unfortunately, I don't have a solution that would work all the time.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 15:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/tiling-roof-using-cga-for-better-texture-overlay/m-p/1296728#M11044</guid>
      <dc:creator>CherylLau</dc:creator>
      <dc:date>2023-06-07T15:38:03Z</dc:date>
    </item>
  </channel>
</rss>

