I have some code that may help you, the math is in there.
This is for a hierarchy of planes, and all matrices are calculated
"manually".
_tx, _ty, _tz : Translation
_scale: (XY axis)
_rotation: (Z axis)
RADIANS=-0.01745
class Plane(...):
def matrix_update(self):
a = self._scale*math.cos(RADIANS*self._rotation)
b = self._scale*math.sin(RADIANS*self._rotation)
if self.parent is None:
self.matrix=(gl.GLdouble * 16)(
a, -b, 0, 0,
b, a, 0, 0,
0, 0, 1, 0,
self._tx, self._ty, self._tz, 1)
else:
c, d = -b, a
origin=self.parent.matrix
A,C = origin[0], origin[1] #C=-B
B,D = origin[4], origin[5] #D=A
X,Y,Z = origin[12], origin[13], origin[14]
self.matrix=(gl.GLdouble * 16)(
A*a+B*c, C*a+D*c, 0, 0,
A*b+B*d, C*b+D*d, 0, 0,
0, 0, 1, 0,
X + A*self._tx + B*self._ty, Y + C*self._tx +
D*self._ty,
Z + self._tz, 1)
for plane in self.children: plane.matrix_update()
El 22/07/2012 21:12, Derek S. escribió:
I have made a basic straightedge-and-compass geometry program.
Point objects are represented by GL_POINTS
Lines by GL_LINES
Circles by GL_LINE_LOOP
I've searched about how zooming and panning can be accomplished,
and have found talk about glMatrixMode, glScale, glTranslate, glOrtho,
etc...
All of the examples / tutorials I've found deal with C++ and 3D,
and none of them seem to actually setup a matrix,
yet they all talk about how zooming/panning is accomplished by
transforming a matrix..
I have never studied matrices so I'm hoping to speed up the learning curve
by seeing an example of:
initial matrix
[0][0][0][0]
[0][0][0][0]
[0][0][0][0]
[0][0][0][0]
zoom
changed matrix
[0][0][0][0]
[0][0][0][0]
[0][0][0][0]
[0][0][0][0]
I'm also wondering if numpy will be of benefit in this situation.
I'm already using it for vectors.
If you can provide an example that will help me figure this out
I would be most grateful! At the very least I would appreciate
a list of the functions you would recommend using for this.
Thanks!
(I'm using pyglet 1.1.4)
--
You received this message because you are subscribed to the Google
Groups "pyglet-users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pyglet-users/-/2o1_ymX6gqkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.