Skip to content
Alessandro Febretti edited this page Sep 9, 2013 · 14 revisions

Last revision: ver. 4.2-alpha6 - 28 August 2013

[[module cyclops | Python-Reference#module-cyclops]] wraps cyclops::SceneManager

Manages a cyclops scene and its associated resources. The scene manager can be accesed using the global getSceneManager() function.

Methods

Method(s) Description
Backgrond
setBackgroundColor(color)
setSkyBox(skybox)
Scene management
loadModel(modelInfo) Loads a model defined by the data in modelInfo
loadModelAsync(modelInfo, command) Queues a model for loading. Call the command in the command string when loading is done (successful or not)
addModel([[ModelGeometry]] model) Adds a model based on the specified ModelGeometry object.
loadScene(path) Loads a cyclops xml scene file
unload() Cleans the scene and releases all associated resources
addLoader(loader) Registers a new model loader. loader must be an object of ModelLoader type
Wand
displayWand(int wandId, int trackableId) Displays a wand (identified by wandId) and attaches it to a trackable object trackableId
hideWand(int wandId) Hides the wand
setWandEffect(wandId, effect) Sets the render effect for wand wandId
setWandSize(width, height)
Shadow support (experimental)
getMainLight(), setMainLight(light) Sets the main scene light. When shadow mapping is enabled, it will be used to cast shadows
getCurrentShadowSettings() Gets the current settings for shadow mapping
resetShadowSettings(settings) Resets the shadow settings. Can be used to turn shadow maps on and off, and to change their quality
Shaders
setShaderMacroToFile(macro, file) Sets the specified shader macro to the contents of a file. Appearances of the macro in any loaded shader will be replaced with the file contents. Example: scene.setShaderMacroToFile('macro1', 'file.frag') will substitute @macro1 in shaders with the text from file.frag
setShaderMacroToString(macro, string) Sets the specified shader macro to the specified string. Appearances of the macro in any loaded shader will be replaced with the string text. Example: scene.setShaderMacroToFile('macro1', 'a = b + c') will substitute @macro1 in shaders with a = b + c
createProgramFromString(name, vertexCode, fragmentCode) Creates a new Gpu Program using the vertex and fragment source code passed as parameters. Registers the program with the specified name, so it can be used in effect definitions. It aso returns the program as a ProgramAsset object.
addProgram(program) Adds a ProgramAsset to the gpu programs library
updateProgram(program) Updates a ProgramAsset, forcing reloading and recompiling of the associated shaders.
reloadAndRecompileShaders() Forces the shaders to be reloaded and recompiled from source
getGlobalUniforms() Returns the global uniforms object. Can be used to set uniforms that will apply to all entities. See the Uniforms class.
Textures
createTexture(name, pixels) Creates a texture with the specified name using the passed PixelData object. The texture can then be referenced in effect definitions.

Examples

Global Uniforms

	scene = getSceneManager()
	
	# Use the customFragmentDefs section to inject a custom uniform into all shaders
	scene.setShaderMacroToString('customFragmentDefs', '''
		uniform float unif_CustomFloat;
	''')

	# set the global float uniform to 0.5
	customFloat = scene.getGlobalUniforms().addUniform("unif_CustomFloat", UniformType.Float)
	customFloat.setFloat(0.5)
Clone this wiki locally