Original User: decrementHi Zaldan,your suspicion was right - the model generation happens in a local coordinate system and is immune to numerical problems due to large coordinates. In contrast, the "world" selector in the setupProjection() operation forces the usage of absolute "CityEngine CS" coordinates which can give numerical problems if coordinates are large (6 digits or larger).There are two workarounds which should help you achieve your goals:Workaround 1:
- Align the scope to the CityEngine CS coordinate axes
- use scope-relative setupProjection and add an offset based on the global position
[INDENT]attr streettex = "builtin:uvtest.png"
texOffsetX(size) = getGeoCoord(X) % size
texOffsetZ(size) = -getGeoCoord(Y) % size
StreetTexture2(size) -->
alignScopeToAxes()
setupProjection(0,scope.xz,size,size, -texOffsetX(size), -texOffsetZ(size))
projectUV(0)
texture(streettex)
[/INDENT]Workaround 2:
- align the scope to the CityEngine CS coordinate axes
- use scope-relative setupProjection
- translate the uv coordinates (after projection!) by an offset based on the global position
[INDENT]attr streettex = "builtin:uvtest.png"
texOffsetX(size) = getGeoCoord(X) % size
texOffsetZ(size) = -getGeoCoord(Y) % size
StreetTexture3(size) -->
alignScopeToAxes()
setupProjection(0,scope.xz,size,size) projectUV(0)
translateUV(0, texOffsetX(size) / size, texOffsetZ(size) / size)
texture(streettex)
[/INDENT]Workaround 1 is preferable because it encodes the translation into the projection matrix, while in workaround 2 the offset gets added to the texture coordinates of every vertex. Both approaches work if you use a meter-based coordinate system. If your scene coordinate system is feet-based, you need to account for that:[INDENT]
const f2m = 0.3047996
texOffsetX(size) = (getGeoCoord(X)*f2m) % size
texOffsetZ(size) = (-getGeoCoord(Y)*f2m) % size
[/INDENT]The reason is that everything in CGA happens in the meter-based CityEngine CS - but the getGeoCoord() function is bound to the selected coordinate system.I hope that sets you upgreetingsDecrement