def __init__(self, indices, vertices, normal_indices, normals, texcoord_indices, texcoords, material): """A triangle should not be created manually.""" self.vertices = vertices """A (3, 3) float array for points in the triangle""" self.normals = normals """A (3, 3) float array with the normals for points in the triangle. If the triangle didn't have normals, they will be computed.""" self.texcoords = texcoords """A tuple with (3, 2) float arrays with the texture coordinates for the points in the triangle""" self.material = material """If coming from an unbound :class:`collada.triangleset.TriangleSet`, contains a string with the material symbol. If coming from a bound :class:`collada.triangleset.BoundTriangleSet`, contains the actual :class:`collada.material.Effect` the triangle is bound to.""" self.indices = indices """A (3,) int array with vertex indexes of the 3 vertices in the vertex array""" self.normal_indices = normal_indices """A (3,) int array with normal indexes of the 3 vertices in the normal array""" self.texcoord_indices = texcoord_indices """A (3,2) int array with texture coordinate indexes of the 3 vertices in the texcoord array.""" if self.normals is None: #generate normals vec1 = numpy.subtract(vertices[0], vertices[1]) vec2 = numpy.subtract(vertices[2], vertices[0]) vec3 = toUnitVec(numpy.cross(toUnitVec(vec2), toUnitVec(vec1))) self.normals = numpy.array([vec3, vec3, vec3])
def __init__(self, indices, vertices, normals, texcoords, material): """A triangle should not be created manually.""" self.vertices = vertices """A (3, 3) float array for points in the triangle""" self.normals = normals """A (3, 3) float array with the normals for points in the triangle. If the triangle didn't have normals, they will be computed.""" self.texcoords = texcoords """A tuple with (3, 2) float arrays with the texture coordinates for the points in the triangle""" self.material = material """If coming from an unbound :class:`collada.triangleset.TriangleSet`, contains a string with the material symbol. If coming from a bound :class:`collada.triangleset.BoundTriangleSet`, contains the actual :class:`collada.material.Effect` the triangle is bound to.""" self.indices = indices """A (3, 3) int array with vertex indexes in the vertex array""" if self.normals is None: # generate normals vec1 = numpy.subtract(vertices[0], vertices[1]) vec2 = numpy.subtract(vertices[2], vertices[0]) vec3 = toUnitVec(numpy.cross(toUnitVec(vec2), toUnitVec(vec1))) self.normals = numpy.array([vec3, vec3, vec3])
def __init__(self, eye, interest, upvector, xmlnode=None): """Creates a lookat transformation :param numpy.array eye: An unshaped numpy array of floats of length 3 containing the position of the eye :param numpy.array interest: An unshaped numpy array of floats of length 3 containing the point of interest :param numpy.array upvector: An unshaped numpy array of floats of length 3 containing the up-axis direction :param xmlnode: When loaded, the xmlnode it comes from """ self.eye = eye """A numpy array of length 3 containing the position of the eye""" self.interest = interest """A numpy array of length 3 containing the point of interest""" self.upvector = upvector """A numpy array of length 3 containing the up-axis direction""" if len(eye) != 3 or len(interest) != 3 or len(upvector) != 3: raise DaeMalformedError('Corrupted lookat transformation node') self.matrix = numpy.identity(4, dtype=numpy.float32) """The resulting transformation matrix. This will be a numpy.array of size 4x4.""" front = toUnitVec(numpy.subtract(eye, interest)) side = numpy.multiply(-1, toUnitVec(numpy.cross(front, upvector))) self.matrix[0, 0:3] = side self.matrix[1, 0:3] = upvector self.matrix[2, 0:3] = front self.matrix[3, 0:3] = eye self.xmlnode = xmlnode """ElementTree representation of the transform.""" if xmlnode is None: self.xmlnode = E.lookat(' '.join( map( str, numpy.concatenate( (self.eye, self.interest, self.upvector)))))
def __init__(self, eye, interest, upvector, xmlnode=None): """Creates a lookat transformation :param numpy.array eye: An unshaped numpy array of floats of length 3 containing the position of the eye :param numpy.array interest: An unshaped numpy array of floats of length 3 containing the point of interest :param numpy.array upvector: An unshaped numpy array of floats of length 3 containing the up-axis direction :param xmlnode: When loaded, the xmlnode it comes from """ self.eye = eye """A numpy array of length 3 containing the position of the eye""" self.interest = interest """A numpy array of length 3 containing the point of interest""" self.upvector = upvector """A numpy array of length 3 containing the up-axis direction""" if len(eye) != 3 or len(interest) != 3 or len(upvector) != 3: raise DaeMalformedError('Corrupted lookat transformation node') self.matrix = numpy.identity(4, dtype=numpy.float32) """The resulting transformation matrix. This will be a numpy.array of size 4x4.""" front = toUnitVec(numpy.subtract(eye,interest)) side = numpy.multiply(-1, toUnitVec(numpy.cross(front, upvector))) self.matrix[0,0:3] = side self.matrix[1,0:3] = upvector self.matrix[2,0:3] = front self.matrix[3,0:3] = eye self.xmlnode = xmlnode """ElementTree representation of the transform.""" if xmlnode is None: self.xmlnode = E.lookat(' '.join(map(str, numpy.concatenate((self.eye, self.interest, self.upvector)) )))