# gather coordinates for vertex at highest point on specific geometry leaf?

313
5
11-27-2012 09:10 AM
New Contributor III
I struggling to figure out how to locate the vertex with the highest y coord within a model.
I'm looking for it to place air traffic type warning lights.
I would assume that I would look for a vertex that is at the same height as the current scope?

any ideas?
Tags (3)
5 Replies
New Contributor
It would depend on how your current project is set up.  If you simply want to look for really high points in your DEM, I would classify the DEM based on a high elevation threshold (for example, classify the dem based on 2 classes, one below a certain elevation, one higher).  This would allow you to visualize the highest parts of the terrain.
New Contributor III
thanks for the reply,
I'm actually looking for vertices in city engine building geometry rather than terrain.
Frequent Contributor II
Hi !

That is currently not yet possible 'cleanly' unless you pass down the info down to the shape. E.g. by testing if a roof floor has the highest split.index.

A hack would be to use convert() in a function named like 'heightAboveFloor' (= code example below) to get the relative distance of the current shape's pivot to the start shape's pivot. This value can then be compared to e.g. 'numberFloors'*'floorHeight' or 'buildingHeight' and then place your light asset if it's 'high enough above floor'. Let me know if this is unclear.

E.g. used in the Medieval Town Example :
`case convert(y,scope,object,pos,0,0,0) < 3.5:`

ps. This works well when footprints are not sloped. If sloped, the heightAboveFloor is only approximate since the Start Shape's pivot only is taken into account.

------------------------

Otherwise :
Since Shapes can not query back up in the Model Hierarchy and down other branches, that info must be fed consistently.

What you can do otherwise is use Python to (3 workflows possible):
1] get the highest vertex and draw a little new Shape there as a Start Shape for placing your lights again with a CGA rule.

2] report all high point shapes and use the Script Based Exporter to analyze the reports, then draw a little shape again as in 1] on the highest one.

3] more complex:
- create a helper attr with PythonHelpValue = 0
- report all positions in CGA
- use Python to find the highest shape on which a light may be created and get it's height.
- set the helper attr with that value ( use Python to set the value and the source to 'user value'.)
- important : at the shape which previously reported the shapes, an other test is prepared in CGA, like :

`PossibleLightPositionShape -->case PythonHelpValue == 0 :    report (shapes height in world.)    print ("run Python now")    NILcase (heightInWorld < PythonHelpValue +delta0.01) && (heightInWorld > PythonHelpValue -delta0.01):    PutLightelse :    NIL`

I used the 3] workflow in support cases where CGA had to be prepared to be able to react to 'multistep Model Generation', where first, a Model creates reports, then Python is used to create statistics over multiple shapes and write the results back to all shapes as user-set attributes for the second generation Model Generation.

---------------------------------

Hopefully, my longtime wish comes true soon where leaf nodes can be combined again in a CGA operation to test exactly such things !

---------------------------------

Maybe read all this twice .. 😉
New Contributor III
Thanks for the reply, some very useful approaches to bear in mind!

I spent many cycles thinking about this one over the last couple of days.
I seem to have a result in cga this morning, another alternative.  🙂
I decided that finding the highest vertices was probably not the best approach for the application I was trying to achieve.
Finding the highest logical point for the proxy light to be placed was the goal.

(read bottom up, its a maya mel'ism I struggle to shake )

`attr aabbYMax=0ProxyPointLight -->        /*         Insert a pointlight representation        - using scatter to a only place one asset on the surfaces that are at the top        */        scatter(surface,1,gaussian, top, 0)  {  s(0,0,0)  i("assets/proxies/pointLight.obj")  color("#ff0000")  PointLight. // now this just needs to be reported }ProxyTopDetail -->       /*       ProxyTopDetail is a shape that produces a representation of a roof top detail model        such as a tv/radio mast geometry on the top of a building        */ s(0,scaleValue*assetInfo(bldTopDtl,sy),0)  i(bldTopDtl) TopDetail.                // work out the top value of the bounding box,         // could be used later if needed for culling.. if needed        // i have a random scale value, within a tolerance for these kind of details set(aabbYMax, (scope.elevation + (scaleValue*assetInfo(bldTopDtl, sy)))) print ("aabbYMax: " + aabbYMax)         //split out only object.top facing faces comp(f) {  //use separated faces as one shape  object.top=   color("#ff0000")   alignScopeToAxes(y)    ProxyPointLight }`
Frequent Contributor II
haha, MEL'ism .. 🙂

I used to code a lot of MEL too. Love it. Love Maya ! It's our favourite 3d app in the office, used a lot to test things and of course also get inspirations..

It's always great to share some insight !

Keep the good work up !