View Full Version : Maya approach similar to Grasshopper's Component Population On Mesh?
08-20-2012, 03:49 AM
Saw a video recently showcasing the Grasshopper addition to Rhino's ability to do Component Population on a Mesh:
Wondering if an equivalent - either a script, or another approach, exists in Maya? In short, the process:
1. Takes a base mesh.
2. Replaces each face of that base mesh with one of four more complex pieces of geometry.
3. The clever part is: which of the 4 alternate - and more complex - pieces of geo is subbed in for that particular face is determined by the textured color of that face. For, instance - a red face is replaced by complex geo #1, a blue face is replaces by complex geo #2, etc.
4. Each piece of complex geo is scaled and rotated to perfectly align with the base face.
Nothing special about the number 4 - ideally, would be an arbitrary number of substitution options. Any way to do this in Maya?
yes you can do this in maya very easily. I find the easiest way is to write a script that executes once and populates your nubrs surface, but you can also make it node based so any update to your component will immediately be reflected. Most node that you will need already exist but if you need to write acustom node python would be a big help.
for the most basic version have a look at the following:
pointOnSurface (to divide your nubs and get world positionand surface normals)
colorAtPoint (to get the color value from your nubs surface)
blendshape (for morphing your component based on colorvalue)
lattice (for moving the component to your nurbs surface)
instead of using lattice I prefer working in u,v,normal space on the nurbs but lattice will give you quick results.
08-21-2012, 01:44 AM
These are great pointers - thank you for the feedback!
08-21-2012, 02:14 AM
Just one more followup question about colorAtPoint - if you have a vertex position on a mesh - which is what it seems like you would be iterating though in this approach - how would you use colorAtPoint to discover the RGB value of the texture at the UV coordinate that corresponds that at vertex position? To put it another way, how to you go from the XYZ position of a vertex on a mesh to the equivalent UV required to query a texture with colorAtPoint?
Ah sorry you want to populate a polymesh. Then I would use “paintvertex color tool” to create the gradient on the mesh where u want it and to query the color using “polyColorPerVertex” . You can use this command to query the face color as well not just the vtx like so in python:
or you can use this def i wrote in python using api that returns:
vtx ID order per face ,vtx normal, vtx position , face color
import maya.cmds as mc
import maya.OpenMaya as om
selection = om.MSelectionList()
iter = om.MItSelectionList (selection, om.MFn.kMesh)
#iter through polygons
while not iter.isDone():
dagPath = om.MDagPath()
component = om.MObject()
polyIter = om.MItMeshPolygon(dagPath, component)
#iter through faces
while not polyIter.isDone():
i = 0
i = polyIter.index()
#vtx ids in order
vtxIDs = om.MIntArray()
for x in range(vtxIDs.length()):
#vtx normals per face
vtxNormArray = om.MVectorArray()
for x in range(vtxNormArray.length()):
pointsArray = om.MPointArray()
for x in range(pointsArray.length()):
mycolor = om.MColor()
PS : Pasting code to the forum seems broken, what am i doing wrong
08-22-2012, 03:52 AM
08-22-2012, 03:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.