Class Index | File Index

Classes


Class c3dl.Effect

c3dl.Effect specifies exactly how a geometric object should be rendered. An Effect is an instantiation of an EffectTemplate, which is a template for creating effects with similar results.

Effects are composed of a vertex shader, fragment shader and a rendering callback. The shaders perform the transformation, lighting calculations and anything else necessary. The callback typically sets the uniform and vertex attributes.

When the library is told to render an object which has an effect, it will first call the rendering callback. This allows the user to do things such as toggle depth tests, set the uniform variables, or adjust any other rendering state variables required to perform the required rendering. The shader programs are then executed and the object is rendered.

Some effect templates have already been written and using them requires minimal effort.

	// c3dl.effects is a namespace which contains premade effects.
	var effect = new c3dl.Effect();
	effect.init(c3dl.effects.GOOCH);
	var teapot = c3dl.Collada();
	teapot.init('teapot.dae');
	// the effect's parameters were not set, so the default Gooch params
	// will be used.
	teapot.setEffect(effect);
	

In the example above, none of the Gooch parameters were set, therefore the default Gooch parameters are used. However, not all effects have default parameters and therefore some need to be set. Wheather an effect has default parameters is noted in c3dl.effects.


Defined in: effect.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
Get the EffectTemplate which was used to create this Effect.
 
getParameter(paramName)
Get the value of the parameter 'paramName'.
 
init(effectTemplate)
Call this after the Effect has been created.
 
setParameter(paramName, paramValue)
Set the value of the parameter 'paramName' to 'paramvalue'.
Class Detail
c3dl.Effect()
Method Detail
{c3dl.EffectTemplate} getEffectTemplate()
Get the EffectTemplate which was used to create this Effect.
Returns:
{c3dl.EffectTemplate} the effect template which was used to create this effect.

getParameter(paramName)
Get the value of the parameter 'paramName'.
Parameters:
{String} paramName
Returns:
the value of 'paramName' or null if parameter does not exist or has not been set.

init(effectTemplate)
Call this after the Effect has been created. Once the Effect has been created and initialized, its parameters can be set.
Parameters:
{c3dl.EffectTemplate} effectTemplate

setParameter(paramName, paramValue)
Set the value of the parameter 'paramName' to 'paramvalue'.
Parameters:
{String} paramName
Name of the parameter to set.
paramValue
The value to set the parameter. If the value does not match the parameter's type, a warning will be displayed and the parameter will not be set.

Documentation generated by JsDoc Toolkit 2.1.0 on Fri Feb 19 2010 17:58:40 GMT-0500 (EST)