My favorites | English | Sign in

o3d.Effect Class Reference

Inherits o3d.ParamObject

List of all members.


Detailed Description

An Effect contains a vertex and pixel shader.

Public Types

enum MatrixLoadOrder o3d.Effect

Public Member Functions

copyParams(sourceParamObject) o3d.ParamObject
o3d.Param  createParam(paramName, paramTypeName) o3d.ParamObject
createSASParameters(paramObject) o3d.Effect
createUniformParameters(paramObject) o3d.Effect
o3d.Param  getParam(paramName) o3d.ParamObject
!Array.<!o3d.EffectParameterInfo getParameterInfo() o3d.Effect
!Array.<!o3d.EffectStreamInfo getStreamInfo() o3d.Effect
boolean  isAClassName(className) o3d.ObjectBase
boolean  loadFromFXString(effect) o3d.Effect
boolean  removeParam(param) o3d.ParamObject

Public Properties

string className o3d.ObjectBase
number clientId o3d.ObjectBase
o3d.Effect.MatrixLoadOrder matrixLoadOrder o3d.Effect
string name o3d.NamedObject
!Array.<!o3d.Param> params o3d.ParamObject
string source o3d.Effect

Public Types Documentation

enum o3d.Effect.MatrixLoadOrder

MatrixLoadOrder,

  • ROW_MAJOR, Matrix parameters are loaded in row-major order (DX-style).
  • COLUMN_MAJOR, Matrix parameters are loaded in column-major order (OpenGL-style).

  • Member Function Documentation

    Effect.copyParams ( !o3d.ParamObject sourceParamObject ) [inherited from o3d.ParamObject]

    Copies all the params from a the given source_param_object to this param object. Does not replace any currently existing params with the same name.

    Parameters:
    sourceParamObject param object to copy params from.
    o3d.Param Effect.createParam ( string paramName
    string paramTypeName ) [inherited from o3d.ParamObject]

    Creates a Param with the given name and type on the ParamObject. Will fail if a param with the same name already exists.

    Parameters:
    paramName The name of the Param to be created.
    paramTypeName The type of Param to create. Valid types are
  • 'o3d.ParamBoolean'
  • 'o3d.ParamBoundingBox'
  • 'o3d.ParamDrawContext'
  • 'o3d.ParamDrawList'
  • 'o3d.ParamEffect'
  • 'o3d.ParamFloat'
  • 'o3d.ParamFloat2'
  • 'o3d.ParamFloat3'
  • 'o3d.ParamFloat4'
  • 'o3d.ParamFunction'
  • 'o3d.ParamInteger'
  • 'o3d.ParamMaterial'
  • 'o3d.ParamMatrix4'
  • 'o3d.ParamParamArray'
  • 'o3d.ParamRenderSurface'
  • 'o3d.ParamRenderDepthStencilSurface'
  • 'o3d.ParamSampler'
  • 'o3d.ParamSkin'
  • 'o3d.ParamSteamBank'
  • 'o3d.ParamState'
  • 'o3d.ParamString'
  • 'o3d.ParamTexture'
  • 'o3d.ParamTransform'
  • 'o3d.ProjectionParamMatrix4'
  • 'o3d.ProjectionInverseParamMatrix4'
  • 'o3d.ProjectionTransposeParamMatrix4'
  • 'o3d.ProjectionInverseTransposeParamMatrix4'
  • 'o3d.ViewParamMatrix4'
  • 'o3d.ViewInverseParamMatrix4'
  • 'o3d.ViewTransposeParamMatrix4'
  • 'o3d.ViewInverseTransposeParamMatrix4'
  • 'o3d.ViewProjectionParamMatrix4'
  • 'o3d.ViewProjectionInverseParamMatrix4'
  • 'o3d.ViewProjectionTransposeParamMatrix4'
  • 'o3d.ViewProjectionInverseTransposeParamMatrix4'
  • 'o3d.WorldParamMatrix4'
  • 'o3d.WorldInverseParamMatrix4'
  • 'o3d.WorldTransposeParamMatrix4'
  • 'o3d.WorldInverseTransposeParamMatrix4'
  • 'o3d.WorldViewParamMatrix4'
  • 'o3d.WorldViewInverseParamMatrix4'
  • 'o3d.WorldViewTransposeParamMatrix4'
  • 'o3d.WorldViewInverseTransposeParamMatrix4'
  • 'o3d.WorldViewProjectionParamMatrix4'
  • 'o3d.WorldViewProjectionInverseParamMatrix4'
  • 'o3d.WorldViewProjectionTransposeParamMatrix4'
  • 'o3d.WorldViewProjectionInverseTransposeParamMatrix4'
  • Returns:
    o3d.Param.The newly created Param or null on failure.
    Effect.createSASParameters ( !o3d.ParamObject paramObject )

    For each of the effect's uniform parameters, if it is a SAS parameter creates corresponding StandardParamMatrix4 parameters on the given ParamObject. Note that SAS parameters are handled automatically by the rendering system. so except in some rare cases there is no reason to call this function. Also be aware that the StandardParamMatrix4 Paramters like WorldViewProjectionParamMatrix4, etc.. are only valid during rendering. At all other times they will not return valid values. If a Param with the same name but the wrong type already exists on the given ParamObject CreateSASParameters will attempt to replace it with one of the correct type.

    Parameters:
    paramObject The param object on which the new paramters will be created.
    See Also:
    Effect.createUniformParameters ( !o3d.ParamObject paramObject )

    For each of the effect's uniform parameters, creates corresponding parameters on the given ParamObject. Skips SAS Parameters. If a Param with the same name but the wrong type already exists on the given ParamObject CreateUniformParameters will attempt to replace it with one of the correct type. Note: The most common thing to pass to this function is a Material but depending on your application it may be more appropriate to pass in a Transform, Effect, Element or DrawElement.

    Parameters:
    paramObject The param object on which the new paramters will be created.
    See Also:
    o3d.Param Effect.getParam ( string paramName ) [inherited from o3d.ParamObject]

    Searches by name for a Param defined in the object.

    Parameters:
    paramName Name to search for.
    Returns:
    o3d.Param.The Param with the given name, or null otherwise.
    Effect.getParameterInfo ( )

    Gets info about the parameters this effect needs.

    Returns:
    !Array.<!o3d.EffectParameterInfo>.an array of EffectParameterInfos.
    Effect.getStreamInfo ( )

    Gets info about the streams this effect needs.

    Returns:
    !Array.<!o3d.EffectStreamInfo>.an array of EffectParameterInfos.
    boolean Effect.isAClassName ( string className ) [inherited from o3d.ObjectBase]

    Takes the name of a class as an argument, and returns true if this object is either an instance of that class or derives from that class.

    var t = pack.createObject('o3d.Transform');
    t.isAClassName('o3d.Transform');    // true
    t.isAClassName('o3d.ParamObject');  // true
    t.isAClassName('o3d.Shape');        // false
    
    Parameters:
    className Name of class to check for.
    Returns:
    boolean.true if this object is a or is derived from the given class name.
    boolean Effect.loadFromFXString ( string effect )

    Loads the vertex and pixel shader programs from an string containing an O3D FX description. The string is subset of CG and HLSL. No techinques are allowed. To define the entry points add 2 lines in the following format.

      "// #o3d VertexShaderEntryPoint myVertexShader\n"
      "// #o3d PixelShaderEntryPoint myPixelShader\n"
    
    where "myVertexShader" and "myPixelShader" are the names of your vertex and pixel shaders. At this time the format of those 2 lines is extremely strict. You must have 1 and exactly 1 space between // and #o3d, between #o3d and VertexShaderEntryPoint/PixelShaderEntryPoint and between those and your entry points. You must also specify a matrix load order like this.
    // #o3d MatrixLoadOrder RowMajor
    
    Valid orders are RowMajor and ColumnMajor Note: Currently it is possible to create effects strings that work on only one platform (GL or D3D). You should test your shaders on both platforms. By version 1.0 this function will enforce shaders that only work on both platforms. That format is mostly CG.
    Parameters:
    effect the code of the effect.
    Returns:
    boolean.True if successful.
    boolean Effect.removeParam ( !o3d.Param param ) [inherited from o3d.ParamObject]

    Removes a Param from a ParamObject. This function will fail if the param does not exist on this ParamObject or if the param is unremovable.

    Parameters:
    param param to remove.
    Returns:
    boolean.True if the param was removed.

    Member Property Documentation

    string Effect.className [inherited from o3d.ObjectBase]

    The concrete class name for an object derived from ObjectBase. If you want to know if an object is of a certain type you should use objectBase.isAClassName

    var t = pack.createObject('o3d.Transform');
    t.className == 'o3d.Transform';  // true
    
    This property is read-only.
    number Effect.clientId [inherited from o3d.ObjectBase]

    Unique id of the object. This id will be unique, even across multiple O3D clients in the same page. This property is read-only.

    o3d.Effect.MatrixLoadOrder Effect.matrixLoadOrder

    The order in which matrix data is loaded to the GPU. This property is read-only.

    string Effect.name [inherited from o3d.NamedObject]

    The object's name. Setting this has no meaning to O3D, but is useful for debugging and for the functions Client.getObjects, Pack.getObject, RenderNode.getRenderNodesByNameInTree and RenderNode.getTransformsByNameInTree which search for objects by name.

    !Array.<!o3d.Param> Effect.params [inherited from o3d.ParamObject]

    Gets all the param on this param object. Each access to this field gets the entire list, so it is best to get it just once. For example:

    var params = paramObject.params;
    for (var i = 0; i < params.length; i++) {
      var param = params[i];
    }
    
    Note that modifications to this array [e.g. push()] will not affect the underlying ParamObject, while modifications to the array's members will affect them. This property is read-only.
    string Effect.source

    The source for the shaders on this Effect. This property is read-only.