Jump to content

Search the Community

Showing results for tags 'align to vertex'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • CGARCHITECT.COM
    • Forum Rules
  • MAIN FORUMS
    • General Discussions
    • Hardware and Technical Discussions
    • Off Topic
    • Pro Plan Members
  • VISUALIZATION GALLERIES
    • Architectural Visualization Gallery
    • Work in Progress (WIP)
  • SOFTWARE
    • 3ds Max
    • V-Ray
    • Other Renderers
    • Other Visualization Software
    • CAD Software
    • Post Production Software
    • VR/AR/MR/Real-Time
    • Vegetation
    • Color Management
  • MISCELLANEOUS
    • New Member Introductions
  • SITE FEEDBACK AND SUGGESTIONS
    • Comments and Feedback

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Display Name


Country

Found 1 result

  1. This script aligns and orients objects to vertices By: 1)Taking a selection of vertexes and storing them as an array 2)asking the user to pick a piece of geometry 3)calculating the "orientation" of a vertex by --getting the faces which use that vertex --calculating and combining their local orientation 4)using that info to create a resultant matrix3 transform 5)copying the target object and applying the matrix3 transform to the object I made it to do things like add studs to fabric, or place oriented objects onto a mesh surface. It could easily be adapted to distribute randomly sized objects over a mesh There is a problem with it - the simple code I wrote, correctly solves the orientation, but it scales up the target object. I used a workaround to solve this by resetting the scale of the object to -1 -1 -1 for x,y,z respectively, on line 27: targetMesh.scale = point3 -1 -1 -1 I'm not an expert coder and would like some help making this more elegant. I think I understand the arithmetic I need to do to adjust the matrix at lines 19-21, but I don't know what the relationship is between the original scale of the object and the scale of the transform matrix I'm creating. If I could get some help with this, I'd really appreciate it. --- fn orientObjectToVertex targetVertVal targetMesh= ( --work out what bits of the target object have the info we need targetVert = targetVertVal --getVertSelection $ as array targetFaces = meshop.getFacesUsingVert $ targetVert as array --variable points faceNormal = point3 0 0 0 rightVector = point3 0 0 0 upVector = point3 0 0 0 --constants faceNum = targetFaces.count worldUpVector = [0,0,1] centerPos = getVert $ targetVertVal for i = 1 to faceNum do ( faceNormal += in coordsys $ (getFaceNormal $ targetFaces[i]) rightVector += normalize (cross worldUpVector faceNormal) upVector += normalize ( cross rightVector faceNormal) ) theMatrix = matrix3 rightVector upVector faceNormal centerpos targetMesh.transform = theMatrix targetMesh.scale = point3 -1 -1 -1 ) fn g_filter o = superclassof o == Geometryclass targetMesh = pickObject message:"Pick Target Surface:" filter:g_filter targetVertArray = getVertSelection $ as array targetObjectArray = #() for q = 1 to targetVertArray.count do ( targetObjectArray[q] = instance targetMesh orientObjectToVertex targetVertArray[q] targetObjectArray[q] )
×
×
  • Create New...