Perhaps I'm using it wrong, my 'touches()' rule seems to be unpredictable

2209
2
Jump to solution
05-07-2012 12:44 PM
DavidOConnor
New Contributor
howdy folks, here something that I don't quite understand.  This is a test version of my rules, which is a greatly simplified version of the 5th Element New York city ;)

I'm using the 'touches()' to identify faces where the model penetrates itself.  On these faces, for test purposes, I'd like to have a black texture.

My rule seems to work, but only some of the time, as you can see in the photo.   The black faces are working fine.  I've put an arrow pointing at the faces where it should work, but doesn't (i.e. the faces should be black, but they aren't).

By the way, I'm using 2010.3.  Here is the extract from the rules:

Wall -->    case touches() :   texture("facades/MyFacades/Test_facade_TOUCHES.png")     alignScopeToGeometry(zUp, auto)     setupProjection(0,scope.xy,10*getTileWidth(scope.sx),10*getFloorHeight(scope.sy),0)     projectUV(0)        else:   texture("facades/MyFacades/Test_facade_WINDOW.png")     alignScopeToGeometry(zUp, auto)     setupProjection(0,scope.xy,10*getTileWidth(scope.sx),10*getFloorHeight(scope.sy),0)     projectUV(0)


As usual, your thoughts would be appreciated.  Thank you! :D
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor II
hi.

occlusion checks need '3d scopes' (volumes) to work properly with a certain precision. ( as with every computer thingy, it all only works within certain precision, thus you need to give the computer a little room to work properly. occlusions on floating rotated 2d polys thus usually gives you a headache.

Tackling this can sometimes be a little tricky, but I've had good success with strategies like this :

pseudo code :
comp(f) Face Face --> scale down 10% # to avoid overlaps with neighbor faces extrude (0.05) TestVolume  TestVolume --> case overlaps : comp(f){bottom : reverseNormals ShapeOverlaps | all : NIL} else : ShapeDoesNotOverlap.  ShapeOverlaps  --> scale back up to full size continue.

View solution in original post

0 Kudos
2 Replies
MatthiasBuehler1
Frequent Contributor II
hi.

occlusion checks need '3d scopes' (volumes) to work properly with a certain precision. ( as with every computer thingy, it all only works within certain precision, thus you need to give the computer a little room to work properly. occlusions on floating rotated 2d polys thus usually gives you a headache.

Tackling this can sometimes be a little tricky, but I've had good success with strategies like this :

pseudo code :
comp(f) Face Face --> scale down 10% # to avoid overlaps with neighbor faces extrude (0.05) TestVolume  TestVolume --> case overlaps : comp(f){bottom : reverseNormals ShapeOverlaps | all : NIL} else : ShapeDoesNotOverlap.  ShapeOverlaps  --> scale back up to full size continue.
0 Kudos
DavidOConnor
New Contributor
thank you Matthias!

Yes, I understand... 2D faces aren't picked up by the touches(), but 3D volumes work with touches().  So, looking at your rules, here is how your workaround works:

1. you extrude the flat 2D face to create a very small 3D volume.
2. you invoke the touches() instruction, it should work fine. 
3. just delete the sides and top of the 3D volume, leaving the 2D face behind.

Flipping brilliant, as I use CityEngine, I really do marvel at your brain frequently :D
0 Kudos