camPos = Vec3(10.0, 20.0, 10.0) lookAt = Vec3(0.0, -3.0, 0.0) camera = createNewCameraHandle() primitives.apiCall( ILBCreatePerspectiveCamera(scene, 'Camera', vecmath.setCameraMatrix(camPos, vecmath.normalize(lookAt - camPos), Vec3(0.0, 0.0, -1.0)), camera) ) apiCall( ILBSetFov(camera, M_PI/4.0, 1.0) ) # Create a textured diffuse material for sphere 0 sm0 = createNewMaterialHandle() tex = textures.createXorTexture( bmh, "Tex1", ColorRGB(0.6, 0.6, 0.3) ) apiCall( ILBCreateMaterial(scene, "Textured", sm0) ) apiCall( ILBSetMaterialTexture(sm0, ILB_CC_DIFFUSE, tex) ) apiCall( ILBSetMaterialOverrides(sphereInstances[0], sm0, 1) ) # Create a textured specular material for sphere 1 sm1 = createNewMaterialHandle() apiCall( ILBCreateMaterial(scene, "TexturedSpec", sm1) ) apiCall( ILBSetMaterialTexture(sm1, ILB_CC_DIFFUSE, tex) ) apiCall( ILBSetMaterialColor(sm1, ILB_CC_SPECULAR, ColorRGBA(1.0, 1.0, 0.7, 1.0)) ) apiCall( ILBSetMaterialScale(sm1, ILB_CC_SHININESS, 25.0) ) apiCall( ILBSetMaterialOverrides(sphereInstances[1], sm1, 1) )
apiCall( ILBCreateManager( beastCacheFolder + r'/temp/lightsources', ILB_CS_LOCAL, bmh) ) # Set the path to the Beast binaries apiCall( ILBSetBeastPath(bmh, beastBinFolder) ) # Waste the cache from previous runs if present apiCall( ILBClearCache(bmh) ) # Create ball and a plane meshes sphereMatName = 'SphereMaterial' floorMatName = 'FloorMaterial' floorMesh = primitives.createPlaneSimple(bmh, 'Floor', floorMatName) sphereMesh = primitives.createSphere(bmh, 'Sphere', sphereMatName, 30, 15) goboTex = textures.createXorTexture(bmh, "xorTex", ColorRGB(1.0, 1.0, 1.0)) lsTypes = 7 scenes = [] cameras = [] for lightType in range(lsTypes): scene = createNewSceneHandle() sceneName = "SceneInstance_" + str(lightType) apiCall( ILBBeginScene(bmh, sceneName, scene) ) skylight = createNewLightHandle() primitives.apiCall( ILBCreateSkyLight( scene, 'SkyLight', vecmath.identity(), ColorRGB(0.21, 0.21, 0.3), skylight) ) # Create an instance of the plane that will be a floor floorInstance = createNewInstanceHandle()
sphereRad = 2.0 spherePosRadius = 5.0 M_PI = 3.14159265358979323846 for i in range(spheres): angle = (M_PI * 2.0 * i) / spheres x = math.cos(angle) * spherePosRadius z = math.sin(angle) * spherePosRadius trans = vecmath.scaleTranslation(Vec3(sphereRad, sphereRad, sphereRad), Vec3(x, -3.0, z)) tempInstance = createNewInstanceHandle() sphereName = 'SphereInstance_' + str(i) apiCall( ILBCreateInstance(scene, sphereMesh, sphereName, trans, tempInstance) ) # Create a texture for the floor floorTex = textures.createXorTexture(bmh, 'xorTexture', ColorRGB(0.9, 0.7, 0.7)) floorMat = createNewMaterialHandle() apiCall( ILBCreateMaterial(scene, floorMatName, floorMat) ) apiCall( ILBSetMaterialTexture(floorMat, ILB_CC_DIFFUSE, floorTex) ) sphereMat = createNewMaterialHandle() apiCall( ILBCreateMaterial(scene, sphereMatName, sphereMat) ) apiCall( ILBSetMaterialColor(sphereMat, ILB_CC_DIFFUSE, ColorRGBA(0.3, 0.3, 0.3, 1.0)) ) apiCall( ILBSetMaterialColor(sphereMat, ILB_CC_SPECULAR, ColorRGBA(1.0, 1.0, 1.0, 1.0)) ) apiCall( ILBSetMaterialScale(sphereMat, ILB_CC_REFLECTION, 0.1) ) apiCall( ILBSetMaterialScale(sphereMat, ILB_CC_SHININESS, 15.0) ) light = createNewLightHandle() apiCall( ILBCreateDirectionalLight( scene, 'Sun', vecmath.directionalLightOrientation(Vec3(1.0, -1.0, -1.0)), ColorRGB(1.0, 1.0, 0.8), light) )