table of Contents
(B) displaying the feature point
(C) uneven points classification
(A) python read 3D obj files
Reprinted from https://blog.csdn.net/hongmaodaxia/article/details/78956487
Download github in the whole proj, direct running, the data path can be changed to your own! Mouse click can rotate!
(B) displaying the feature point
def draw_feature(data):
glPointSize(20)
glBegin(GL_POINTS)
color = [255, 255, 255]
glColor3f(*color)
po = [data[0], data[1], data[2]]
glVertex3f(*po) # 3个参数xyz f:32位浮点数
# time.sleep(5)
glEnd()
(C) uneven points classification
# 在github下载的proj里面修改
elif e.type == KEYDOWN:
if e.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
# 按下q:显示特征点
elif e.key == K_q:
global look
draw_feature(my_data[look])
pygame.display.flip()
# 按下w:特征点数目+1
elif e.key == K_w:
# global look
look = look + 1
if look >= l:
# jian 与 nojian写入文件
save_file(jianpath + path2, jian)
save_file(nojianpath + path2, nojian)
sys.exit()
# 按下e:归为凸点
elif e.key == K_e:
jian0 = list(my_data[look])
jian.append(jian0)
# print(jian)
# 按下r:归为凹点
elif e.key == K_r:
nojian0 = list(my_data[look])
nojian.append(nojian0)
# 在github下载的proj里面添加一个函数
def save_file(file_path, li):
output = open(file_path, 'w+')
for i in range(len(li)):
for j in range(len(li[i])):
output.write(str(li[i][j]))
output.write(' ')
output.write('\n')
output.close()