[Closed] Corner Dirt
The idea here is to create at tool that allows artists to easily place a selection of objects randomly along the edges of faces to quickly place dirt and garbage.
My process for creation:
- The user would define a collection of objects they wanted duplicated everywhere.
- The user would then define the object in which they would want the collection distributed.
- The script:
A. Find all faces who have an average normal facing Z+
B. Find adjacent faces and test them to see if they are within the angle threshold
C. Starting from the shared edge going outward place the objects
Feel free to shed light or jump in and share snippets anyone.
Start:
Below is a snippet that collects the faces who’s normal faces Z+ but within a given threshold.
What would be a good way to attack the next step. Compare the collected faces against all the remaining faces, collecting all those faces who fall within an angle threshold?
(
struct faceData (index , normal)
ground = $ground
numFaces = ground.numfaces
upMin = .7 -- min value of 0.0
upMax = 1.0 --max value of 1.0
facesArr = #() --the faces that fall within the defined threshold values
clearlistener()
for f = 1 to numFaces do
(
faceNormal = polyop.getFaceNormal ground f
if faceNormal.z >= upMin AND faceNormal.z <= upMax do append facesArr (faceData index:f normal:faceNormal)
)
)
Slight update/change
I decided to collect all the faces and add the struct to keep the information for each face because I’m assuming I’m going to be need this information down the road anyways.
(
struct faceData (index , normal, upZ=false)
ground = $ground
numFaces = ground.numfaces
upMin = .7 -- min value of 0.0
upMax = 1.0 --max value of 1.0
facesArr = #() --the faces that fall within the defined threshold values
clearlistener()
for f = 1 to numFaces do
(
faceNormal = polyop.getFaceNormal ground f
pass = if faceNormal.z >= upMin AND faceNormal.z <= upMax then true else false
append facesArr (faceData index:f normal:faceNormal upZ:pass)
)
print facesArr
)
Whats a good way to find neighboring faces based on a face Integer, rather than doing the selec then > grow selection since that method and process would be insanely slow on dense geo.
wait… it was discussed many times here. i’ve posted a benchmarking…
getfacesusingvert (getvertsusingface) …
see my comment in the thread about ‘wishes’
the ‘faces flatness’ is a secondary condition. you have to find first a way to calculate and define the value of a vertex convexity.
Why do you have to find that first.
I was going to take the faces collected that face z+ then compare those faces to the remaining ones . By compared the angle between face to face and then collect the shared edge between the faces whose angle meets the required threshold. …this process not correct.
How about first getting all concave edges that are somewhat parallel to the XY plane, then test their faces for orientation.
What would you be testing and collecting when calculating convexity
Talking about dirt or ambient occlusion, the narrower the angle between faces is, the more you will have ambiant occlusion/dirt in the corner.
I think that’s what DenisT was talking about because his tool might be design to auto-paint vertex ambient occlusion (I was sure to have seen a post about that in that thread and can’t find it anymore…).
Your tool seems to be more designed to auto position props on a ground. Convexity here will be used to figure out if the neighbour face is a wall or a steep ground (according to a given angle).
Btw, I am surprised that such a placement tool does not exist already…
You can select the convex/concave faces with the build in PolySelect tools, its the code that is behind the ribbon’s ‘select’ tab.
See maxroot\stdscripts\PolyTools.ms for example:
fn OnChanged fValue =
(
PolyToolsSelect.ConvexConcave fValue PolyToolsUI.CovexConcave
PolyToolsUI.SurfaceSelectSpinner = fValue
)
Look up ‘PolyToolsSelect’ in mxs help…
edit: combine ‘PolyToolsSelect.ConvexConcave’ with ‘PolyToolsSelect.Normal’ and you’re almost done
Moving forward with this project, what would it be a good process? Just looping through each edge of the mesh, getting the polygon’s that use that edge? Then compared the angle difference between the faces? Or would that not work that way?
I’m just trying to figure out the next step, which I know is the calculating the convexity, but I’m not sure exactly goes into that or what direction to start
Btw, I am surprised that such a placement tool does not exist already…
it does, rtt an ambient occlusion map (scanline/mentalray/there was a free edge render material plugin) and use it as the distribution material in a particle flow position object.
to round trip an ambient occlusion map every time there is a change would be very taxing and not very user friendly, I do agree it is a method to use, but not one I prefer