Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30
  1. #21
    Restraining input meshes to have a euler characteristic of 2, will also block meshes that this algorithm can easily solve. Most simple example: two non intersecting cubes (EC = 4). E.g.
    Code:
      +---------+   +---------+            +---------+ 
      |         |   |         |            |         |
      |         |   |         |            |  +---+  |
      |         |   |         |     or     |  |   |  |
      |         |   |         |            |  +---+  |  
      |         |   |         |            |         |  
      +---------+   +---------+            +---------+
    You have a valid point, but you can't expect an algorithm to take care of everything. Garbage in = Garbage out.



  2. #22
    @ aothms - Geeeeezzz....

    Dunno what is the result after applying the code above cause I havent tested it.

    At these cases, although the mesh consists of 2 non-intersecting parts, each part has Euler result = 2, the correct algorithm based on the fact "counting ALL intersections of a ray at any direction and judging the point is INSIDE the body if they are an ODD number" will ALWAYS work cause for any point in INSIDE either body you will have n = 1 as a result. Thus, you're correctly pointing out that the mesh should be processed first to defining its parts.

    Regards,
    Last edited by Abidos; 28-Aug-10 at 09:08.



  3. #23
    Member Atom's Avatar
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    11,632
    I have put together a test file here to show how I plan on using the aothms code.
    http://blenderartists.org/forum/show...53#post1692253
    I rarely use Blender anymore.
    Houdini Indie is only $200.00 and Apprentice is free!
    Atom's Links Page



  4. #24
    Apparently, there is a nice API function that tells you if a point is inside a mesh or not. Frankly, I didnt pay much attention to it by now. It's use is rather simple and it may be like this:

    Code:
    sce = Scene.GetCurrent()
    ob = Object.GetSelected()[0]
    me = ob.getData(mesh=1)
    mat = ob.mat
    mat_inv = Mathutils.Matrix(mat).invert()
    point = Mathutils.Vector(0,-2,2)
    if me.pointInside(point*mat_inv):
      blah-blah-blah
      .................................
    As per my testings, it works also in case your mesh consists of several parts.

    Regards,



  5. #25
    Member Atom's Avatar
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    11,632
    @abidos: Thanks for the 2.49 tip.

    pointInside is exactly the function that I needed to replace in 2.5. It was not ported over or made available in the API..
    I rarely use Blender anymore.
    Houdini Indie is only $200.00 and Apprentice is free!
    Atom's Links Page



  6. #26
    do you have the 2.5 one
    might be usefull later on!


    and this works only for non manifod mesh !

    but anythng available if you have some manifold mesh ?


    Thanks



  7. #27
    Member oliveirafhm's Avatar
    Join Date
    Aug 2011
    Location
    Uberlândia - MG / Brazil
    Posts
    33
    Hey Guys!
    Someone port the code (pointInsideMesh) to Blender 2.6?



  8. #28
    I need this also!
    I still haven't found a reliable way to do this.
    I have one method, but it doesn't always work.
    Was that 2.49 version reliable?
    If so, why isn't it in the current release?



  9. #29
    Member oliveirafhm's Avatar
    Join Date
    Aug 2011
    Location
    Uberlândia - MG / Brazil
    Posts
    33
    @terrachild

    For me this thread helped to solve my problem (in parts).
    It's working so so, but to me that's enough for the moment.
    For example:
    This solution (by @Atom) doesn't work when i need to detect a point inside a Torus. But when my obj is a Monkey or Cube or any mesh which don't have a hole (like torus obj) it works.



  10. #30
    This thread helped me too. Thx to all for sharing. Here are my updated version (2.74). And a second approach by using closest_point_on_mesh method, but sometimes it seems to be unprecise.

    Code:
    def point_inside(point,obj):
        axes = [ Vector((1,0,0)), Vector((0,1,0)), Vector((0,0,1)) ]
        outside = False
        mat = obj.matrix_world.copy()
        mat.invert()
        for axis in axes:
            orig = mat*point
            count = 0
            while True:
                location,normal,index = obj.ray_cast(orig,orig+axis*1.84467e+19)
                if index == -1: break
                count += 1
                orig = location + axis*0.00001
            if count%2 == 0:
                outside = True
                break
        return not outside
    
    def inside_to_closest_point(p, obj):
        inv = obj.matrix_world.copy()
        inv.invert()
        point, normal, face = obj.closest_point_on_mesh(inv*p, 1.84467e+19)
        return (point-inv*p).dot(normal) >= 0.0



Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •