Exemplo n.º 1
0
def main():
  global mshelm, wmngr_glfw
  mshelm = dfm2.MeshElem("../test_inputs/bunny_2k.ply");
  mshelm.scaleXYZ(0.02)

  wmngr_glfw = dfm2.WindowManagerGLFW(1.0)

  glfw.init()
  win_glfw = glfw.create_window(640, 480, 'Hello World', None, None)
  glfw.make_context_current(win_glfw)

  dfm2.setSomeLighting()
  glEnable(GL_DEPTH_TEST)

  glfw.set_mouse_button_callback(win_glfw, mouseButtonCB)
  glfw.set_cursor_pos_callback(win_glfw,  mouseMoveCB)
  glfw.set_key_callback(win_glfw, keyFunCB)

  while not glfw.window_should_close(win_glfw):
    glClearColor(1, 1, 1, 1)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    wmngr_glfw.camera.set_gl_camera()
    render()
    glfw.swap_buffers(win_glfw)
    glfw.poll_events()
    if wmngr_glfw.isClose:
      break
  glfw.destroy_window(win_glfw)
  glfw.terminate()
  print("closed")
Exemplo n.º 2
0
def main():
    mshelm = dfm2.MeshElem("../test_inputs/bunny_2k.ply")
    mshelm.color_face = [1, 1, 1, 1]

    aabb = dfm2.AABB3(mshelm.minmax_xyz())
    axis = dfm2.AxisXYZ(100.0)
    axis.line_width = 3

    sampler = dfm2.GPUSampler()
    sampler.init(size_res_width=256,
                 size_res_height=256,
                 is_color=True,
                 is_depth=True)
    sampler.set_coordinate(len_grid=0.2,
                           depth_max=100.0,
                           org=[0, -50, 0],
                           dir_prj=[0, -1.0, 0],
                           dir_width=[1, 0, 0])
    sampler.color = [0, 0, 1, 1]
    sampler.len_axis = 10
    sampler.bgcolor = [1, 1, 0, 1]

    buffer = dfm2.DepthColorBuffer(win_size=[512, 512],
                                   is_color=True,
                                   is_depth=True)
    dfm2.take_depth_shot(mshelm.draw, sampler, buffer)
    buffer.close()

    #  np_depth = numpy.array(dfm2.depth_buffer(sampler),copy=True)
    #  print(np_depth.shape)
    #  numpy.savetxt("hoge.txt",np_depth)

    dfm2.winDraw3d([mshelm, aabb, sampler, axis])
Exemplo n.º 3
0
from OpenGL.GL import *

import sys
sys.path.append("../module_py")
import dfm2


def draw_func():
    glEnable(GL_LIGHTING)
    #glutSolidTeapot(0.5)
    mshelm.draw()


mshelm = dfm2.MeshElem("../test_inputs/bunny_2k.ply")
mshelm.scaleXYZ(0.03)

win = dfm2.WindowGLFW(1.0, winsize=(400, 300))
dfm2.setSomeLighting()
win.draw_loop([draw_func])