detecting terrain intersetion with a shape to achieve more realistic window texturing

2502
7
02-15-2017 08:03 AM
testtest24
New Contributor

Hello,

I have a static model of a building (converted to a shape to be able to texture it using cga)

while texturing buildings on non-flat terrain, I often encounter a problem as on picture that the windows are (partially) burried under ground:

I would like to fix this problem so that it looks more realistic. The possible solutions that I can think of are:

solution A: (better) - to be able to detect the highest point where terrain intersects a face and from that point make a horizontal line so that I subdivide this face into two subfaces and then place a non-window texture at bottom where the windows might get buried under ground and place a window texture at the top of face

solution B: subdivide this face into regular grid and then check if each subface intersects with terrain.

If so, then put non-widnow texture, otherwise place widnow texture. this looks like a worse solution because it produces lots of useless polygons

so can cityEngine detect if a face collides with a terrain and detect an exact position where it collides using cga/python?

so far I only found occlusion query functions but looks like they work only between shapes and not between shapes and terrains

or If there is a better way how to texture static models of buildings (not extruded using footprints) so that their windows don't collide with terrain please let me know

thanks,

Mark

7 Replies
LR
by
Occasional Contributor III

AFAIK you can't query the raster. You could however create a fine triangular mesh and project it onto the terrain. That way you could use the occlusion query with the terrain height - the accuracy of this would depend on your triangle size.

As for the query itself, it doesn't report the touching height. To save polygons, you could do incremental querying. For example, if you have a wall with four floors you'd first check if the whole wall is touching the ground at all (maybe add a little offset from the bottom or else it'll always trigger). If it returns a positive, divide it (floorcount/2) and check again with the separate parts. The parts that don't touch won't need further splitting.

MarekDekys
New Contributor III

Thanks for help, it worked! it produces more useless polygons but I guess that's the downside...

 

Is it possible to "merge" the polygons that have same textures? to save performance and allow better texturing (because of bigger polygons)..

I tried cleanupGeometry(all, 1) or reduceGeometry(1) but none of them seems to work

0 Kudos
LR
by
Occasional Contributor III

CGA is unfortunately one-way. I think you could try a two-pass method using python, looking something like this:

  • extrude the mesh straight downwards, so it at least covers the bottom-most building's floor.

  • give the walls attributes:
    • some height variable (let's call it myHeight)
    • some kind of UID, if not already present

  • write a cga rule that splits the wall every 0.1m (or smaller, depends on how accurate you want to be). Each slice then does an occlusion query and reports its UID if touched. This means every slice below ground will report back.

  • write a python script to export the report and then pull the values back. Using the report you can now write the touch-height into myHeight: the UID value can be used to target the proper walls, the report count of the UID * your split height equals the (building-) height at which the building touches the triangle surface.

  • Now that you have the touch-height permanently written as attribute, you can write a rule that uses myHeight as split value.
HangyuChen
New Contributor II

Hi LR,

Read this discussion that is helpful for me. I wonder if I can query the inserted OBJ model?

Because I saw the fine triangular mesh created could be queried, I tried my case it seems the model to be ignored..

Any suggestion about it? Thank you.

CHEN

0 Kudos
LR
by
Occasional Contributor III

Rightclick on the OBJ and import it through the dialog. Uncheck the "import as static model" option, then apply the rule to it.

0 Kudos
HangyuChen
New Contributor II

Thanks for your reply. 

I mean obj model which is imported by CGA rule using i (insert operation).

i try to detect intersection between the new shape (new building) and existing building. for this building i use the obj model created by sketchup. just give it a scope and i() it. then new shape can't query it.

is there something i should do to obj model before i() it?

CHEN

0 Kudos
LR
by
Occasional Contributor III

Looks like this is not possible, generated models aren't triggered by the OBJ, only the other way around.

0 Kudos