forked from uoip/pangolin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleScene.py
44 lines (29 loc) · 1.05 KB
/
SimpleScene.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
38
39
40
41
42
43
44
# https://github.com/stevenlovegrove/Pangolin/tree/master/examples/SimpleScene
import OpenGL.GL as gl
import pangolin
def main():
pangolin.CreateWindowAndBind('Main', 640, 480)
gl.glEnable(gl.GL_DEPTH_TEST)
# Define Projection and initial ModelView matrix
scam = pangolin.OpenGlRenderState(
pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100),
pangolin.ModelViewLookAt(-2, 2, -2, 0, 0, 0, pangolin.AxisY))
tree = pangolin.Renderable()
tree.Add(pangolin.Axis())
# Create Interactive View in window
handler = pangolin.SceneHandler(tree, scam)
dcam = pangolin.CreateDisplay()
dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 /480.0)
dcam.SetHandler(handler)
def draw(view):
view.Activate(scam)
tree.Render()
dcam.SetDrawFunction(draw)
while not pangolin.ShouldQuit():
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# or
# dcam.Activate(scam)
# tree.Render()
pangolin.FinishFrame()
if __name__ == '__main__':
main()