Exemplo n.º 1
0
        # create texture with 4 colors
        floorTex = textures.createTestColorTexutre(bmh, "TestColorTexture") 

        floorMat = createNewMaterialHandle()
        apiCall( ILBCreateMaterial(scene, floorMatName, floorMat) )
        apiCall( ILBSetMaterialTexture(floorMat, ILB_CC_DIFFUSE, floorTex) )
        apiCall( ILBSetChannelUVLayer(floorMat, ILB_CC_DIFFUSE, "uv3") )
        apiCall( ILBSetMaterialTexture(floorMat, ILB_CC_EMISSIVE, floorTex) )
        apiCall( ILBSetChannelUVLayer(floorMat, ILB_CC_EMISSIVE, "uv4") )

        light = createNewLightHandle()
        pos = Vec3(0.0, 1.0, 0.0)
        lookAt = Vec3(0.0, 0.0, 0.0)

        spotMatrix = vecmath.setSpotlightMatrix(pos, lookAt - pos )

        apiCall( ILBCreateSpotLight(scene, "Light", spotMatrix, ColorRGB(1.0, 1.0, 1.0), light) )
        apiCall( ILBSetSpotlightCone(light, M_PI/3.0, 0.1, 2.0) )


        camera = createNewCameraHandle()
        apiCall( ILBCreatePerspectiveCamera(scene, 
                                            'Camera',
                                            vecmath.setCameraMatrix(Vec3(0.3, 3.0, 20.0),  
                                            Vec3(0.1, -0.3, -1.0), 
                                            Vec3(0.0,  1.0,  0.0)), 
                                            camera) )

        apiCall( ILBSetFov(camera, M_PI/4.0, 1.0) )
Exemplo n.º 2
0
def generateLight(_lsType, _scene, _goboTex):
    """docstring for generateLight"""
    lh = createNewLightHandle()
    lookAt = Vec3(0.0, -2.0, 0.0)
    if _lsType == 0:
        apiCall( ILBCreateDirectionalLight(_scene, 
                                           "Light", 
                                           vecmath.directionalLightOrientation(Vec3(1.0, -1.0, -1.0)),
                                           ColorRGB(1.0, 1.0, 0.8),
                                           lh))
        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowAngle(lh, 0.1) )

    elif _lsType == 1:
        # point light
        apiCall( ILBCreatePointLight(_scene,
                                     "Light",
                                     vecmath.translation(Vec3(-1.0, 1.0, 1.0)),
                                     ColorRGB(3.0, 3.0, 2.0),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowRadius(lh, 1.0) )

        # set a quadratic falloff
        apiCall( ILBSetFalloff(lh, ILB_FO_EXPONENT, 2.0, 20.0, True))
    elif _lsType == 2:
        # spot light
        pos = Vec3(-1.0, 1.0, 1.0)
        spotMatrix = vecmath.setSpotlightMatrix(pos, lookAt-pos)
        apiCall( ILBCreateSpotLight(_scene,
                                     "Light",
                                     spotMatrix,
                                     ColorRGB(3.0, 3.0, 2.0),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowRadius(lh, 1.0) )

        coneAngle = M_PI/3.0
        apiCall(ILBSetSpotlightCone(lh, coneAngle, 0.1, 2.0))

    elif _lsType == 3:
        # window light
        pos = Vec3(-1.0, 1.0, 1.0)
        matrix = vecmath.setAreaLightMatrix(pos, 
                                            lookAt-pos,
                                            Vec3(0.0, 1.0, 0.0),
                                            Vec2(2.0, 5.0))
        apiCall( ILBCreateWindowLight(_scene,
                                     "Light",
                                     matrix,
                                     ColorRGB(3.0, 3.0, 2.0),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowAngle(lh, 0.1) )

    elif _lsType == 4:
        #area light
        pos = Vec3(-1.0, 1.0, 1.0)
        matrix = vecmath.setAreaLightMatrix(pos, 
                                            lookAt-pos,
                                            Vec3(0.0, 1.0, 0.0),
                                            Vec2(3.0, 1.0))
        apiCall( ILBCreateAreaLight(_scene,
                                     "Light",
                                     matrix,
                                     ColorRGB(0.4, 0.4, 0.3),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )

    elif _lsType == 5:
        # Point light wit ramp
        transform = vecmath.scaleTranslation(Vec3(17.0, 17.0, 17.0), Vec3(-1.0, 1.0, 1.0))
        apiCall( ILBCreatePointLight(_scene,
                                     "Light",
                                     transform,
                                     ColorRGB(1.0, 1.0, 1.0),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowRadius(lh, 1.0) )
        apiCall( ILBSetFalloff(lh, ILB_FO_EXPONENT, 0.0, 20.0, True) )

        # set some random colors in a ramp
        rampColors = 10
        for i in range(rampColors):
            randCol = vecmath.randomRGBA(3.0)
            apiCall( ILBSetLightRampEntry(lh, i/(rampColors-1.0), randCol.toColorRGB()))

    elif _lsType == 6:
        # spot light
        pos = Vec3(-1.0, 1.0, 1.0)
        spotMatrix = vecmath.setSpotlightMatrix(pos, lookAt - pos)
        apiCall( ILBCreateSpotLight(_scene,
                                     "Light",
                                     spotMatrix,
                                     ColorRGB(3.0, 3.0, 2.0),
                                     lh))

        apiCall( ILBSetCastShadows(lh, True) )
        apiCall( ILBSetShadowSamples(lh, 32) )
        apiCall( ILBSetShadowRadius(lh, 1.0) )
        apiCall( ILBSetLightProjectedTexture(lh, goboTex) )

        coneAngle = M_PI/3.0
        apiCall( ILBSetSpotlightCone(lh, coneAngle, 0.1, 2.0) )

    return lh