Пример #1
0
        objReader.getMeshNames(meshNames)
        for i in range(len(meshNames)):

            vertices = Vec3Array()
            normals = Vec3Array()
            uvs = Vec2Array()
            materialName = None
            materialName = objReader.getMeshData(meshNames[i], vertices, normals, uvs)

            if len(vertices) != 0:
                meshHandles[meshNames[i]] = constructMesh(meshNames[i], vertices, normals, uvs, materialName, bmh)

        lightManager = LightManager()

        sun = DirectionalLightSource( "Sun", 
                                      vecmath.translation(Vec3(0.0, 7.5, -20.0)) * vecmath.directionalLightOrientation(vecmath.normalize(Vec3(-1.0, -1.0, -0.25))), 
            ColorRGB(0.6, 0.6, 0.5))
        sun.setCastShadows(True);
        sun.setShadowSamples(32);
        sun.setShadowAngle(0.025);
        lightManager.addLight(sun);     

        sky = SkyLightSource( "Sky", vecmath.translation(Vec3(0.0, 5.0, -00.0)), ColorRGB(0.25, 0.3, 0.4))
        lightManager.addLight(sky)

        sceneUpVector = ILB_UP_POS_Y
        sceneScale = 1.0
        perspCamera = Camera("Camera", vecmath.translation(Vec3(-5.0, 5.0, -10.0)) * vecmath.cameraOrientation(vecmath.normalize(Vec3(0.25, -0.25, -1.0)), Vec3(0.0, 1.0, 0.0)), math.pi/2.0, 1.0)

        targetManager = TargetManager()
        objTrans = vecmath.scaleTranslation(Vec3(1.0, 1.0, 1.0), Vec3(0.0, 0.0, 0.0))
Пример #2
0

        # create the floor material
        floorMat = createNewMaterialHandle()
        primitives.apiCall( ILBCreateMaterial(scene, floorMatName, floorMat) )
        primitives.apiCall( ILBSetMaterialColor(floorMat, ILB_CC_DIFFUSE, ColorRGBA(0.7, 0.7, 0.7, 1.0)) )

        sphereMat = createNewMaterialHandle()
        apiCall( ILBCreateMaterial(scene, sphereMatName, sphereMat) )
        apiCall( ILBSetMaterialColor(sphereMat, ILB_CC_DIFFUSE, ColorRGBA(0.9, 0.9, 0.9, 1.0)) )


        camera = createNewCameraHandle()
        apiCall( ILBCreatePerspectiveCamera(scene, 
                 "Camera", 
                 vecmath.translation(Vec3(0.0, 0.0, 10.0)),
                 camera) )

        # Finalize the scene
        apiCall(ILBEndScene(scene));


        # create config
        beastConfig = beastCacheFolder + "/data/occlusion.xml"

        dom = minidom.getDOMImplementation()
        xmlDoc = dom.createDocument(None, "ILConfig", None)
        docRoot = xmlDoc.documentElement

        AASettingsElement = xmlDoc.createElement("AASettings")
        xmlCreateElement(AASettingsElement, "minSampleRate", "0")
Пример #3
0
 def createCamera(self):
     """docstring for createCamera"""
     apiCall( ILBCreatePerspectiveCamera(self.m_scene, 
              "Camera", 
              vecmath.translation(Vec3(0.0, 0.0, 10.0)),
              self.m_camera) )
Пример #4
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