Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 3d51344

Browse files
committed
Improved cameras
1 parent c576606 commit 3d51344

File tree

6 files changed

+264
-9
lines changed

6 files changed

+264
-9
lines changed

PyOpenGLtoolbox/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
__author__ = 'Pablo Pizarro @ppizarror.com'
3030
__description__ = 'PyOpenGL toolbox'
3131
__email__ = 'pablo.pizarro@ing.uchile.cl'
32-
__version__ = '2.2.2'
32+
__version__ = '2.3.0'
3333
__url__ = 'https://github.com/ppizarror/pyopengl-toolbox'

PyOpenGLtoolbox/camera.py

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,100 @@ def place(self):
6464
"""
6565
pass
6666

67+
def get_view(self):
68+
"""
69+
Get view matrix.
70+
71+
:return:
72+
:rtype: array
73+
"""
74+
return self._look_at(
75+
_np.array([self.get_pos_x(), self.get_pos_y(), self.get_pos_z()]),
76+
_np.array([self.get_center_x(), self.get_center_y(), self.get_center_z()]),
77+
_np.array([self.get_up_x(), self.get_up_y(), self.get_up_z()])
78+
)
79+
80+
def get_pos_x(self):
81+
"""
82+
Return x position.
83+
84+
:return:
85+
:rtype: float, int
86+
"""
87+
pass
88+
89+
def get_pos_y(self):
90+
"""
91+
Return y position.
92+
93+
:return:
94+
:rtype: float, int
95+
"""
96+
pass
97+
98+
def get_pos_z(self):
99+
"""
100+
Return z position.
101+
102+
:return:
103+
:rtype: float, int
104+
"""
105+
pass
106+
107+
def get_center_x(self):
108+
"""
109+
Return center x position.
110+
111+
:return:
112+
:rtype: float, int
113+
"""
114+
pass
115+
116+
def get_center_y(self):
117+
"""
118+
Return center y position.
119+
120+
:return:
121+
:rtype: float, int
122+
"""
123+
pass
124+
125+
def get_center_z(self):
126+
"""
127+
Return center x position.
128+
129+
:return:
130+
:rtype: float, int
131+
"""
132+
pass
133+
134+
def get_up_x(self):
135+
"""
136+
Return up vector x position.
137+
138+
:return:
139+
:rtype: float, int
140+
"""
141+
pass
142+
143+
def get_up_y(self):
144+
"""
145+
Return up vector y position.
146+
147+
:return:
148+
:rtype: float, int
149+
"""
150+
pass
151+
152+
def get_up_z(self):
153+
"""
154+
Return up vector z position.
155+
156+
:return:
157+
:rtype: float, int
158+
"""
159+
pass
160+
67161
def move_x(self, direction=_CAMERA_POSITIVE):
68162
"""
69163
Moves camera to x-position.
@@ -282,6 +376,86 @@ def place(self):
282376
self._center.get_z(), self._up.get_x(), self._up.get_y(),
283377
self._up.get_z())
284378

379+
def get_pos_x(self):
380+
"""
381+
Return x position.
382+
383+
:return:
384+
:rtype: float, int
385+
"""
386+
return self._pos.get_x()
387+
388+
def get_pos_y(self):
389+
"""
390+
Return y position.
391+
392+
:return:
393+
:rtype: float, int
394+
"""
395+
return self._pos.get_y()
396+
397+
def get_pos_z(self):
398+
"""
399+
Return z position.
400+
401+
:return:
402+
"""
403+
return self._pos.get_z()
404+
405+
def get_center_x(self):
406+
"""
407+
Return center x position.
408+
409+
:return:
410+
:rtype: float, int
411+
"""
412+
return self._center.get_x()
413+
414+
def get_center_y(self):
415+
"""
416+
Return center y position.
417+
418+
:return:
419+
:rtype: float, int
420+
"""
421+
return self._center.get_y()
422+
423+
def get_center_z(self):
424+
"""
425+
Return center x position.
426+
427+
:return:
428+
:rtype: float, int
429+
"""
430+
return self._center.get_z()
431+
432+
def get_up_x(self):
433+
"""
434+
Return up vector x position.
435+
436+
:return:
437+
:rtype: float, int
438+
"""
439+
return self._up.get_x()
440+
441+
def get_up_y(self):
442+
"""
443+
Return up vector y position.
444+
445+
:return:
446+
:rtype: float, int
447+
"""
448+
return self._up.get_y()
449+
450+
def get_up_z(self):
451+
"""
452+
Return up vector z position.
453+
454+
:return:
455+
:rtype: float, int
456+
"""
457+
return self._up.get_z()
458+
285459
def move_x(self, direction=_CAMERA_POSITIVE):
286460
"""
287461
Moves camera to x-position.
@@ -551,6 +725,87 @@ def place(self):
551725
self._up.get_x(), self._up.get_y(),
552726
self._up.get_z())
553727

728+
def get_pos_x(self):
729+
"""
730+
Return x position.
731+
732+
:return:
733+
:rtype: float, int
734+
"""
735+
return self._r * _sin(self._theta) * _cos(self._phi)
736+
737+
def get_pos_y(self):
738+
"""
739+
Return y position.
740+
741+
:return:
742+
:rtype: float, int
743+
"""
744+
return self._r * _sin(self._theta) * _sin(self._phi)
745+
746+
def get_pos_z(self):
747+
"""
748+
Return z position.
749+
750+
:return:
751+
:rtype: float, int
752+
"""
753+
return self._r * _cos(self._theta)
754+
755+
def get_center_x(self):
756+
"""
757+
Return center x position.
758+
759+
:return:
760+
:rtype: float, int
761+
"""
762+
return self._center.get_x()
763+
764+
def get_center_y(self):
765+
"""
766+
Return center y position.
767+
768+
:return:
769+
:rtype: float, int
770+
"""
771+
return self._center.get_y()
772+
773+
def get_center_z(self):
774+
"""
775+
Return center x position.
776+
777+
:return:
778+
:rtype: float, int
779+
"""
780+
return self._center.get_z()
781+
782+
def get_up_x(self):
783+
"""
784+
Return up vector x position.
785+
786+
:return:
787+
:rtype: float, int
788+
"""
789+
return self._up.get_x()
790+
791+
def get_up_y(self):
792+
"""
793+
Return up vector y position.
794+
795+
:return:
796+
:rtype: float, int
797+
"""
798+
return self._up.get_y()
799+
800+
def get_up_z(self):
801+
"""
802+
Return up vector z position.
803+
804+
:return:
805+
:rtype: float, int
806+
"""
807+
return self._up.get_z()
808+
554809
def __str__(self):
555810
"""
556811
Returns camera status.

PyOpenGLtoolbox/figures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
_FIGURES_ERRS.append(False)
4949

5050

51-
class VBObject:
51+
class VBObject(object):
5252
"""
5353
VBO object that can load and draw elements using shaders.
5454
"""
@@ -405,9 +405,9 @@ def create_sphere(lats=10, longs=10, color=None):
405405
_gl.glBegin(_gl.GL_QUAD_STRIP)
406406

407407
for _j in range(0, longs + 1):
408-
long = 2 * _pi * float(float(_j - 1) / float(longs))
409-
x = _cos(long)
410-
y = _sin(long)
408+
_long = 2 * _pi * float(float(_j - 1) / float(longs))
409+
x = _cos(_long)
410+
y = _sin(_long)
411411
_gl.glNormal3f(x * zr0, y * zr0, z0)
412412
_gl.glVertex3f(x * zr0, y * zr0, z0)
413413
_gl.glNormal3f(x * zr1, y * zr1, z1)

PyOpenGLtoolbox/mathlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
_UTILS_MATH_POINT_3 = 'util-point-3'
3636

3737

38-
class Point3:
38+
class Point3(object):
3939
"""
4040
Point with 3 components.
4141
"""

PyOpenGLtoolbox/particles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
_PARTICLES_ROUND = 3
4444

4545

46-
class Particle:
46+
class Particle(object):
4747
"""
4848
Particle.
4949
"""

PyOpenGLtoolbox/shader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
_SHADER_VERTEX = 0x02
3939

4040

41-
class Shader:
41+
class Shader(object):
4242
"""
4343
Shader class, can load an compile GLSL shaders.
4444
"""
@@ -179,7 +179,7 @@ def print_shader(self):
179179
print(self._file)
180180

181181

182-
class ShaderProgram:
182+
class ShaderProgram(object):
183183
"""
184184
ShaderProgram class, contains fragment and shader code that runs in background.
185185
"""

0 commit comments

Comments
 (0)