def _lookat(pos=vec3(0), target=vec3(0), up=vec3(0, 0, 1), roll=0.0): try: M = mat4().lookAt(pos, target, up) except: M = mat4(1) return M.getMat3() * mat3().rotation(radians(roll), vec3(0, 0, 1))
def _lookat(pos=vec3(0), target=vec3(0), up=vec3(0,0,1), roll=0.0): try: M = mat4().lookAt(pos, target, up) except: M = mat4(1) return M.getMat3()*mat3().rotation(radians(roll), vec3(0,0,1))
def __init__(self, name="Material3DS", ambient = (0,0,0,0), diffuse = (1.0, 1.0, 1.0, 1.0), specular = (1.0, 1.0, 1.0, 1.0), shininess = 1, shin_strength = 0, use_blur = 0, transparency = 0.0, falloff = 0, additive = 0, use_falloff = 0, self_illum = False, self_ilpct = 0.0, shading = 0, soften = 0, face_map = 0, two_sided = 0, map_decal = 0, use_wire = 0, use_wire_abs = 0, wire_size = 0, density = 1.0, texture1_map = None, texture1_mask = None, texture2_map = None, texture2_mask = None, opacity_map = None, opacity_mask = None, bump_map = None, bump_mask = None, specular_map = None, specular_mask = None, shininess_map = None, shininess_mask = None, self_illum_map = None, self_illum_mask = None, reflection_map = None, reflection_mask = None, bump_size = 1.0 # Extra parameter to control the bump map ): Material.__init__(self, name=name, density=density) self.ambient = ambient self.diffuse = diffuse self.specular = specular self.shininess = shininess self.shin_strength = shin_strength self.transparency = transparency self.self_illum = self_illum self.self_ilpct = self_ilpct self.texture1_map = texture1_map self.texture1_mask = texture1_mask self.texture2_map = texture2_map self.texture2_mask = texture2_mask self.opacity_map = opacity_map self.opacity_mask = opacity_mask self.bump_map = bump_map self.bump_mask = bump_mask self.specular_map = specular_map self.specular_mask = specular_mask self.shininess_map = shininess_map self.shininess_mask = shininess_mask self.self_illum_map = self_illum_map self.self_illum_mask = self_illum_mask self.reflection_map = reflection_map self.reflection_mask = reflection_mask self.bump_size = bump_size if texture1_map==None: self._gltexture = None glambient = ambient gldiffuse = diffuse else: map = texture1_map T = mat4(1,0,0,-map.offset[0]-0.5, 0,-1,0,0.5-map.offset[1], 0,0,1,0, 0,0,0,1) a = sl.radians(map.rotation) ca = math.cos(a) sa = math.sin(a) R = mat4(ca,-sa,0,0, sa,ca,0,0, 0,0,1,0, 0,0,0,1) S = mat4(map.scale[0],0,0,0.5, 0,map.scale[1],0,0.5, 0,0,1,0, 0,0,0,1) self._gltexture = GLTexture(imagename = map.name, mode = GL_MODULATE, # transform = mat4().scaling(vec3(1,-1,1)) transform = S*R*T ) glambient = map.percent*vec4(1,1,1,1) + (1-map.percent)*vec4(ambient) gldiffuse = map.percent*vec4(1,1,1,1) + (1-map.percent)*vec4(diffuse) self._glmaterial = GLMaterial(ambient = glambient, diffuse = gldiffuse, specular = shin_strength*specular, shininess = 25*shininess, texture = self._gltexture )
def __init__( self, name="Material3DS", ambient=(0, 0, 0, 0), diffuse=(1.0, 1.0, 1.0, 1.0), specular=(1.0, 1.0, 1.0, 1.0), shininess=1, shin_strength=0, use_blur=0, transparency=0.0, falloff=0, additive=0, use_falloff=0, self_illum=False, self_ilpct=0.0, shading=0, soften=0, face_map=0, two_sided=0, map_decal=0, use_wire=0, use_wire_abs=0, wire_size=0, density=1.0, texture1_map=None, texture1_mask=None, texture2_map=None, texture2_mask=None, opacity_map=None, opacity_mask=None, bump_map=None, bump_mask=None, specular_map=None, specular_mask=None, shininess_map=None, shininess_mask=None, self_illum_map=None, self_illum_mask=None, reflection_map=None, reflection_mask=None, bump_size=1.0 # Extra parameter to control the bump map ): Material.__init__(self, name=name, density=density) self.ambient = ambient self.diffuse = diffuse self.specular = specular self.shininess = shininess self.shin_strength = shin_strength self.transparency = transparency self.self_illum = self_illum self.self_ilpct = self_ilpct self.texture1_map = texture1_map self.texture1_mask = texture1_mask self.texture2_map = texture2_map self.texture2_mask = texture2_mask self.opacity_map = opacity_map self.opacity_mask = opacity_mask self.bump_map = bump_map self.bump_mask = bump_mask self.specular_map = specular_map self.specular_mask = specular_mask self.shininess_map = shininess_map self.shininess_mask = shininess_mask self.self_illum_map = self_illum_map self.self_illum_mask = self_illum_mask self.reflection_map = reflection_map self.reflection_mask = reflection_mask self.bump_size = bump_size if texture1_map == None: self._gltexture = None glambient = ambient gldiffuse = diffuse else: map = texture1_map T = mat4(1, 0, 0, -map.offset[0] - 0.5, 0, -1, 0, 0.5 - map.offset[1], 0, 0, 1, 0, 0, 0, 0, 1) a = sl.radians(map.rotation) ca = math.cos(a) sa = math.sin(a) R = mat4(ca, -sa, 0, 0, sa, ca, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) S = mat4(map.scale[0], 0, 0, 0.5, 0, map.scale[1], 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1) self._gltexture = GLTexture( imagename=map.name, mode=GL_MODULATE, # transform = mat4().scaling(vec3(1,-1,1)) transform=S * R * T) glambient = map.percent * vec4( 1, 1, 1, 1) + (1 - map.percent) * vec4(ambient) gldiffuse = map.percent * vec4( 1, 1, 1, 1) + (1 - map.percent) * vec4(diffuse) self._glmaterial = GLMaterial(ambient=glambient, diffuse=gldiffuse, specular=shin_strength * specular, shininess=25 * shininess, texture=self._gltexture)