Occlusion function inconsistencies

449
1
08-24-2017 07:06 AM
GeorgiosAnastasiou
New Contributor II

Hi! I am trying to use the Occlusion function to detect if the edges of two procedurally created objects touch.

A simple example I made for a cube worked flawlessly, then I moved to my actual objects.

The query I am using for the cylinder-like object is just an extrusion and for the developing upside-down cone is this:

@StartRule
Lot-->
   extrude(0.2)
   center(xz)
   comp(f) {bottom : Root}
 
Root-->
   case(scope.sx > 0.5):
   s('0.97, '0.97, 0)
   center(xy)
   color(0,0.4,0.7) 
   extrude(0.5)Facades
   X
   comp(f){top : Root}
   else: NIL

Facades-->
   comp(f){side:OcclusionDetection | bottom:OcclusionDetection | top:OcclusionDetection}
 
OcclusionDetection -->
   case overlaps (inter):
   color("#ff0000")
   X
   else: color("#c3ff00")

The result is on the image:

Image assessment:

1. there is a "ghost" touch, 2. this is my aim accomplished and 3. that interaction is not registered this time (although earlier it was registering). I move around the yellow-green object to make it re-render and register the overlaps.

Problem: 

Inconsistent behaviour of the occlusion function. The script worked fine the first time I compiled it and after a minute it stopped working. By not working I mean, registering all the time that there is no overlap or having a problem to display the OcclusionDetection colours on-top of the Root colour. It took a lot of time fiddling around with it, although practically staying the same, to make it work again.All these in addition to the issues 1 and 3 from the picture.

Is there a way to improve my script and make it work consistently? 

(The City Engine version used is 2015.2, on a Win 10 system, with Intel Core i5 M520, 6GB RAM, GT320M, SSD)

Tags (1)
0 Kudos
1 Reply
CherylLau
Esri Regular Contributor

If you move the cylinder, then the cylinder regenerates, but the other objects in your scene are not regenerating.  This might be why the occlusion is not detected in 3.  If there was a something triggering occlusion in region 1 before and then this shape got moved, then this might also explain why region 1 remains red.  If you move the yellow-red vertical object that is performing the occlusion queries, then it gets regenerated and should show the correct colors.

In the Root rule, there is a line that says: X.  This creates a terminal shape (meaning, it creates geometry that is displayed) with the blue color defined 2 lines before.  Then, in the OcclusionDetection rule, the case creates either a red shape or a yellow shape.  The red and yellow shapes are placed in the same spot as the blue shapes, so they fight each other to be rendered.  This is why it is hard to see the red and yellow colors.  If you take out the X in the Root rule, then you will have only red or yellow faces.

Since we have fixed some occlusion bugs since 2015.2 and added new features to occlusion queries (labels), I would recommend upgrading to the latest version (currently 2017.0).

0 Kudos