def _generateMatrix(self): """ Generates a transformation matrix from internal data. @returns A Matrix4x4 representation of the transformation component. """ t = self.__translation.matrix() if self.__translation else Matrix4x4.identity() r = self.__rotation.matrix() if self.__rotation else Matrix4x4.identity() s = self.__scale.matrix() if self.__scale else Matrix4x4.identity() return t * r * s
def _generateMatrix(self): """ Generates a transformation matrix from internal data. @returns A Matrix4x4 representation of the transformation component. """ t = self.__translation.matrix( ) if self.__translation else Matrix4x4.identity() r = self.__rotation.matrix( ) if self.__rotation else Matrix4x4.identity() s = self.__scale.matrix() if self.__scale else Matrix4x4.identity() return t * r * s
def _generateMatrix(self): """ Generates a transformation matrix from internal data. @returns A Matrix4x4 representation of the transformation component. """ return Matrix4x4.identity()
def _generateMatrix(self): """ Generates a transformation matrix from internal data. @returns A Matrix4x4 representation of the transformation component. """ return Matrix4x4.identity()
def __init__(self, matrix=Matrix4x4.identity()): """ Constructor. @param m The initial transformation matrix value. """ super(TransformationComponent, self).__init__() self.__matrix = matrix
def __init__(self, matrix=Matrix4x4.identity()): """ Constructor. @param m The initial transformation matrix value. """ super(TransformationComponent, self).__init__() self.__matrix = matrix
def paint_enter(self): """ Implements the GLNodeAdapter's paint_enter method for an OpenGL Render operation. """ GL.glPushAttrib(GL.GL_ENABLE_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_LINE_BIT | GL.GL_CURRENT_BIT) GL.glPushClientAttrib(GL.GL_CLIENT_VERTEX_ARRAY_BIT) GL.glMatrixMode(GL.GL_MODELVIEW) GL.glPushMatrix() GL.glMultMatrixf(self._node.matrix().data()) GL.glColor(self._node.color.getRgbF()) # The positive Z-axis is the default direction for Cylinder Quadrics in OpenGL. # If our vector is not parallel to the z-axis, e.g. (0, 0, Z), then rotate it. # 1) Get a normal from the z-v plane # 2) Get the angle inbetween z-v on the plane (see vector dot product) # 3) Rotate the normal by that angle. v = self._node.axis m = Matrix4x4.identity() if v.x != 0 or v.y != 0: zaxis = Vector3D(0,0,1) angle = zaxis.angle(v) normal = zaxis.crossproduct(v, True) m *= Matrix4x4.rotation(angle, normal) # The positive Z-axis is the default direction fo Cylinder Quadrics in OpenGL. # If our z is negative, we need to flip the cylinder if v.z < 0: yaxis = Vector3D(1,0,0) m *= Matrix4x4.rotation(math.radians(180), yaxis) GL.glMultMatrixf(m.data()) q = self.__quadric r = self._node.radius h = self._node.length sl = self._node.slices st = self._node.stacks lp = self._node.loops GLU.gluQuadricDrawStyle (q, GLU.GLU_FILL) GLU.gluQuadricNormals (q, GLU.GLU_SMOOTH) GLU.gluQuadricOrientation(q, GLU.GLU_OUTSIDE) self._glcylinder(q, r, h, sl, st, lp)