Grasshopper

algorithmic modeling for Rhino

How do I use Preview or Material to show a mesh with flat shading?  I saw one other question, but the answer wasn't helpful, or I couldn't figure it out.

 

thanks

Views: 1088

Replies to This Discussion

Is it just a slow day on the forum or is this not possible? 

I don't think that's possible.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I just figured it out.  I Decomposed the mesh, then created a new mesh using the vertices and faces, but graphed the faces input.  It displays as a flat shaded object in Rhino.

Oh dear, that means you get an individual mesh for every face in the original mesh. Unwelding would be a better approach, though there is no unweld function available in the Rhino4 SDK.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Well, fortunately this is for a very course mesh.. a heavily faceted surface that I wanted to be able to visualize as faceted without having to bake each time.

You can try using the following code to sort of "unweld" a mesh. Just paste the code inside a vb.net component and connect the mesh to the x input.

 

    Dim m As New mesh

    Dim c As Integer = 0
    For i As Integer = 0 To x.faces.count - 1
      Dim pts(2) As point3f
      Dim ptd As New point3f
      x.Faces.GetFaceVertices(i, pts(0), pts(1), pts(2), ptd)
      m.Vertices.AddVertices(pts)

      If x.Faces(i).IsTriangle Then
        m.Faces.AddFace(c, c + 1, c + 2)
        c += 3
      Else
        m.Vertices.Add(ptd)
        m.Faces.AddFace(c, c + 1, c + 2, c + 3)
        c += 4
      End If
    Next
    m.Normals.ComputeNormals
    a = m

That works well, thanks for the code.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service