sketchucation logo sketchucation
    • Login
    1. Home
    2. tt_su
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1,034
    • Groups 1

    tt_su

    @tt_su

    10
    Reputation
    5
    Profile views
    1.0k
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online
    Age 42

    tt_su Unfollow Follow
    registered-users

    Latest posts made by tt_su

    • RE: [Question / Suggestion] Were plugins should be (in menus) ?

      Yea - this is a good topic. I've been thinking that it's be beneficial to have an official UI/UX guide for extensions. I aired the idea internally recently as something that would be a good project to do. Personally I'd prefer to host it on GitHub such that it's possible to use the issue tracker. Maybe make use of GitHub pages. (but that's details)

      We certainly see a lot of different approaches when we moderate the extensions on Extension Warehouse and some times makes suggestions in order to encourage extension developers to follow the existing SU conventions. But there is a need for a descriptive guide.

      posted in Plugins
      tt_suT
      tt_su
    • RE: Load classification system via ruby code

      @blruuska said:

      Dan, Thanks for verifying. It is surprising that NotImplementedError wasn't raised, if that is the case here.

      Ackh! Yea, something is amiss here. Not sure if we intended to support enumeration type in the initial release of the API - but if that's the cause it should have been NotImplemented. However, I might confuse this with the "choice" type. Maybe something changed in the last moment. I need to investigate.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Associating data structures with save

      Can you describe some more the overall concept of what you are doing?

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      Sorry - I should have clarified - the vertex normals depend on whether the edge between the faces are Smooth. Soft doesn't matter - because only Smooth affect shading. The normal is a representation of the surface shading.

      2015-06-09_12h34_47.png

      @jim said:

      [...] but those normals will be the normal of the Face and not any calculated value. This is why you get multiple normals from a vertex in your code and why they are all aligned with each Face normal.

      They are calculated if and only if the mesh came from face.mesh. When building your own there will be no calculation. This is because PolygonMesh itself doesn't do the calculation, but SketchUp will set the vertex normals as it builds the mesh returned to face.mesh.

      Under the hood there is a set_normal function similar to set_uv. But this has never been exposed - probably because entities.add_faces_from_mesh and entitites.fill_from_mesh would never use it.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      @oajfh said:

      I was getting different results after exploding groups and creating the mesh after making a component out of the exploded ex-groups. So the comparison might not only be coordinate-based.

      When you explode the coordinates of the vertices are transformed to it's parents - so you will see different values then before they they where local to the component definition.
      (Also, entities in model.active_entities) are transformed into global coordinates.)

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      @oajfh said:

      I'm building it from an existing component, so I'd simply be copying existing normals. Why would the vertex normals be incorrect ?

      If you query mesh.normal_at(i) on a mesh you created yourself (Geom::PolygonMesh.new) vs face.mesh the normals won't be computed for you.

      @oajfh said:

      Also, are you sure about the point to point comparison ? If you create different groups within a component, won't it duplicate the points ?

      You can observer this in action by inspecting the indices and point count:

      <span class="syntaxdefault"><br />mesh&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PolygonMesh</span><span class="syntaxkeyword">.new<br /></span><span class="syntaxcomment">#<Geom;;PolygonMesh;0x0000000936e850><br /><br /></span><span class="syntaxdefault">index1&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_point</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">1<br /><br />index2&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_point</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">1<br /><br />index3&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_point</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">3.5</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">2<br /><br />mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">count_points<br />2<br /></span>
      

      Or by adding polygons using 3d points:

      <span class="syntaxdefault"><br />mesh&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PolygonMesh</span><span class="syntaxkeyword">.new<br /></span><span class="syntaxcomment">#<Geom;;PolygonMesh;0x0000000a70ec48><br /><br /></span><span class="syntaxdefault">mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_polygon</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">),&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">),&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">1<br /><br />mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_polygon</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">),&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">),&nbsp;</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Point3d</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,-</span><span class="syntaxdefault">5</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault">2<br /><br />mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">count_polygons<br />2<br /><br />mesh</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">count_points<br />4<br /></span>
      
      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      Btw - if you build your own PolygonMesh from scratch the vertex normals won't be correct I believe...

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      @oajfh said:

      ThomThom, doesn't the add_polygon method simply add any new points at the end of the point array ? That's the behaviour it's exhibited for me so far, so wouldn't applying what Dan said be alright ?

      PolygonMesh.add_point will add a new point only if there isn't an existing point for the same location (within tolerance). This means it looks up the existing points (which unfortunately is a linear look up.)
      PolygonMesh.add_polygon will internally call this same function.

      The linear nature of add_point I assume is because internally this class is for use with individual faces - so you're not going to have that many points nor duplicates.

      To get max performance when building a PolygonMesh you add all the points first - collecting the indices you get in return. Then add polygons using indices instead of points - this reduce the number of linear lookups.

      I usually use a Hash to build a source => polygon_point_index lookup. This can be vertex => index for instance.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      @oajfh said:

      Hmm. How would that fare performance-wise ? If I want to recover vertex normals, I probably end up checking vertexes multiple times and making sure I don't get a normal from the same vertex more than once, but on the other hand calculating face normals is faster than calculating weighted vertex normals.

      Yea - that's a good point. I don't think you can rely on 100% that the order of the points in PolygonMesh to match the face it came from.

      If performance is critical I think you will get best results from calculating in C/C++ via A Ruby extension which then only iterates the vertices (though you need to collect that from edges or faces - but collecting that into an std::set or something shouldn't affect your performance too much.). You then do the calculations with native code.

      posted in Developers' Forum
      tt_suT
      tt_su
    • RE: Vertex Normals... ?

      By the way - what version of SU are you developing in?
      In SU2015 the polygon_mesh should return correct vertex normal - as we make sure to rebuild the cache if it's invalid when the mesh is built.
      http://www.sketchup.com/intl/en/developer/docs/releases

      @unknownuser said:

      Fixed a bug where Geom::PolygonMesh.normal_at would not return correct vertex normal if the model was modified in the same processing loop as the script obtaining the PolygonMesh.

      posted in Developers' Forum
      tt_suT
      tt_su