Skip to content
Alessandro Febretti edited this page Dec 21, 2014 · 14 revisions

Last revision: ver. 6.0 - 21 December 2014

module cyclops wraps cyclops::SceneManager

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

NOTE The physics engine methods are only supported in version 5.x and up.

Methods

Method(s) Description
Backgrond
(deprecated, will be removed in v6.1) setBackgroundColor(Color color)
setSkyBox(SkyBox skybox) See SkyBox.
Scene management
loadModel(ModelInfo modelInfo) Loads a model defined by the data in modelInfo. See ModelInfo.
loadModelAsync(ModelInfo 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(string path) Loads a cyclops xml scene file
unload() Cleans the scene and releases all associated resources
addLoader(ModelLoade loader) Registers a new model loader. loader must be an object of ModelLoader type
LightingLayer getLightingLayer() Gets the root lighting layer. See LightingLayer.
CompositingLayer getCompositingLayer() Gets the root compositing layer. See CompositingLayer.
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(int wandId, string effect) Sets the render effect for wand wandId
setWandSize(float width, float height)
Shaders
setShaderMacroToFile(string macro, string 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(string macro, string 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
ProgramAsset createProgramFromString(string name, string vertexCode, string 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(ProgramAsset program) Adds a ProgramAsset to the gpu programs library
updateProgram(ProgramAsset program) Updates a ProgramAsset, forcing reloading and recompiling of the associated shaders.
reloadAndRecompileShaders() Forces the shaders to be reloaded and recompiled from source
Uniforms getGlobalUniforms() Returns the global uniforms object. Can be used to set uniforms that will apply to all entities. See the Uniforms class.
Textures
createTexture(string name, PixelData pixels) Creates a texture with the specified name using the passed PixelData object. The texture can then be referenced in effect definitions.
Physics
setPhysicsEnabled(bool enabled), bool isPhysicsEnabled() Use to enable the physics engine or check its state. The physics engine is disabled by default.
setGravity(Vector3 gravity), Vector3 getGravity() Gets or sets the gravity force vector as a Vector3.

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