cwiid 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +45 -31
- data/Rakefile +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -35,27 +35,43 @@ Here's a small example displaying the state of the accelerometer:
|
|
35
35
|
require 'opengl'
|
36
36
|
require 'cwiid'
|
37
37
|
wiimote = WiiMote.new
|
38
|
+
wiimote.rpt_mode = WiiMote::RPT_BTN | WiiMote::RPT_ACC
|
39
|
+
$list = nil
|
40
|
+
def init
|
41
|
+
GL.ClearColor 0.0, 0.0, 0.0, 1.0
|
42
|
+
GL.Light GL_LIGHT0, GL_POSITION, [ 0.5, 0.5, 1.0, 0.0 ]
|
43
|
+
GL.Enable GL_LIGHTING
|
44
|
+
GL.Enable GL_LIGHT0
|
45
|
+
GL.DepthFunc GL_LESS
|
46
|
+
GL.Enable GL_DEPTH_TEST
|
47
|
+
$list = GL.GenLists 1
|
48
|
+
GL.NewList $list, GL_COMPILE
|
49
|
+
GL.Material GL_FRONT, GL_SPECULAR, [ 1.0, 1.0, 1.0, 0.15 ]
|
50
|
+
GL.Material GL_FRONT, GL_SHININESS, [ 100.0 ]
|
51
|
+
GL.Material GL_FRONT, GL_EMISSION, [ 0.0, 0.2, 0.0, 1.0 ]
|
52
|
+
GL.Material GL_FRONT, GL_DIFFUSE, [ 0.1, 0.8, 0.1, 1.0 ]
|
53
|
+
GLUT.SolidSphere 0.4, 16, 16
|
54
|
+
GL.EndList
|
55
|
+
end
|
38
56
|
display = proc do
|
39
57
|
acc = wiimote.acc
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
glBegin GL_LINES
|
49
|
-
glVertex 120, 120
|
50
|
-
glVertex acc[1], acc[2]
|
51
|
-
glEnd
|
52
|
-
glutSwapBuffers
|
58
|
+
GL.Clear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
|
59
|
+
GL.PushMatrix
|
60
|
+
GL.Translate( ( acc[0] - 120 ) * 0.01,
|
61
|
+
( 120 - acc[2] ) * 0.01,
|
62
|
+
( 120 - acc[1] ) * 0.01 )
|
63
|
+
GL.CallList $list
|
64
|
+
GL.PopMatrix
|
65
|
+
GLUT.SwapBuffers
|
53
66
|
end
|
54
67
|
reshape = proc do |w, h|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
GLU.
|
68
|
+
GL.Viewport 0, 0, w, h
|
69
|
+
GL.MatrixMode GL_PROJECTION
|
70
|
+
GL.LoadIdentity
|
71
|
+
GLU.Perspective 60.0, w.to_f/h, 1.0, 20.0
|
72
|
+
GL.MatrixMode GL_MODELVIEW
|
73
|
+
GL.LoadIdentity
|
74
|
+
GL.Translate 0.0, 0.0, -3.5
|
59
75
|
end
|
60
76
|
keyboard = proc do |key, x, y|
|
61
77
|
case key
|
@@ -66,18 +82,16 @@ Here's a small example displaying the state of the accelerometer:
|
|
66
82
|
animate = proc do
|
67
83
|
wiimote.get_state
|
68
84
|
exit 0 if wiimote.buttons == WiiMote::BTN_1
|
69
|
-
|
85
|
+
GLUT.PostRedisplay
|
70
86
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
glutMainLoop
|
83
|
-
|
87
|
+
GLUT.Init
|
88
|
+
GLUT.InitDisplayMode GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH
|
89
|
+
GLUT.InitWindowSize 640, 480
|
90
|
+
GLUT.CreateWindow 'Wii Remote'
|
91
|
+
init
|
92
|
+
GLUT.DisplayFunc display
|
93
|
+
GLUT.ReshapeFunc reshape
|
94
|
+
GLUT.KeyboardFunc keyboard
|
95
|
+
GLUT.IdleFunc animate
|
96
|
+
GLUT.MainLoop
|
97
|
+
|
data/Rakefile
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jan Wedekind
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-27 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|