forked from shreyash002/3D-model-reconstruction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckOccupancy.py
37 lines (27 loc) · 814 Bytes
/
CheckOccupancy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import bpy
import sys
import mathutils
import numpy as np
def is_inside(p, obj, max_dist = 1.84467e+19):
found, point, normal, face = obj.closest_point_on_mesh(p, max_dist)
p2 = point-p
v = p2.dot(normal)
# print(found, v)
return not(v<0.0)
def main():
print("Hello world")
bpy.ops.import_scene.obj(filepath="/home/sk002/Downloads/pix3d/model/bed/IKEA_BEDDINGE/model.obj")
a = False
v1=None
while True:
v1=np.random.uniform(low=-1, high=1, size=(3,))
# point = mathutils.Vector((v1[0], -v1[1] , v1[2]))
point = mathutils.Vector((0,0,0))
obj = bpy.context.selected_objects[0]
a= is_inside(point, obj)
if a==False:
break
print(a, v1)
return a
if __name__=="__main__":
main()