/* * Copyright 2009, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ namespace o3d { %[ A State object sets the RenderStates for a particular material or StateSet. %] [nocpp, include="core/cross/state.h"] class State : ParamObject { %[ \var Comparison \li CMP_NEVER (Never) \li CMP_LESS (Less Than) \li CMP_EQUAL (Equal To) \li CMP_LEQUAL (Less Than or Equal To) \li CMP_GREATER (Greater Than) \li CMP_NOTEQUAL (Not Equal To) \li CMP_GEQUAL (Greater Than or Equal To) \li CMP_ALWAYS (Always) %] enum Comparison { CMP_NEVER, /* Never */ CMP_LESS, /* Less Than */ CMP_EQUAL, /* Equal To */ CMP_LEQUAL, /* Less Than or Equal To */ CMP_GREATER, /* Greater Than */ CMP_NOTEQUAL, /* Not Equal To */ CMP_GEQUAL, /* Greater Than or Equal To */ CMP_ALWAYS /* Always */ }; %[ \var Cull \li CULL_NONE Don't Cull by face \li CULL_CW Cull clock-wise faces \li CULL_CCW Cull counter clock-wise faces %] enum Cull { CULL_NONE, /* Don't Cull by face */ CULL_CW, /* Cull clock-wise faces*/ CULL_CCW /* Cull counter clock-wise faces */ }; %[ \var Fill \li POINT \li WIREFRAME \li SOLID %] enum Fill { POINT, /* Points */ WIREFRAME, /* Wireframe */ SOLID /* Solid */ }; %[ \var BlendingFunction \li BLENDFUNC_ZERO \li BLENDFUNC_ONE \li BLENDFUNC_SOURCE_COLOR \li BLENDFUNC_INVERSE_SOURCE_COLOR \li BLENDFUNC_SOURCE_ALPHA \li BLENDFUNC_INVERSE_SOURCE_ALPHA \li BLENDFUNC_DESTINATION_ALPHA \li BLENDFUNC_INVERSE_DESTINATION_ALPHA \li BLENDFUNC_DESTINATION_COLOR \li BLENDFUNC_INVERSE_DESTINATION_COLOR \li BLENDFUNC_SOURCE_ALPHA_SATUTRATE %] enum BlendingFunction { BLENDFUNC_ZERO, BLENDFUNC_ONE, BLENDFUNC_SOURCE_COLOR, BLENDFUNC_INVERSE_SOURCE_COLOR, BLENDFUNC_SOURCE_ALPHA, BLENDFUNC_INVERSE_SOURCE_ALPHA, BLENDFUNC_DESTINATION_ALPHA, BLENDFUNC_INVERSE_DESTINATION_ALPHA, BLENDFUNC_DESTINATION_COLOR, BLENDFUNC_INVERSE_DESTINATION_COLOR, BLENDFUNC_SOURCE_ALPHA_SATUTRATE }; %[ \var BlendingEquation \li BLEND_ADD \li BLEND_SUBTRACT \li BLEND_REVERSE_SUBTRACT \li BLEND_MIN \li BLEND_MAX %] enum BlendingEquation { BLEND_ADD, BLEND_SUBTRACT, BLEND_REVERSE_SUBTRACT, BLEND_MIN, BLEND_MAX }; %[ \var StencilOperation \li STENCIL_KEEP \li STENCIL_ZERO \li STENCIL_REPLACE \li STENCIL_INCREMENT_SATURATE \li STENCIL_DECREMENT_SATURATE \li STENCIL_INVERT \li STENCIL_INCREMENT \li STENCIL_DECREMENT %] enum StencilOperation { STENCIL_KEEP, STENCIL_ZERO, STENCIL_REPLACE, STENCIL_INCREMENT_SATURATE, STENCIL_DECREMENT_SATURATE, STENCIL_INVERT, STENCIL_INCREMENT, STENCIL_DECREMENT }; %[ Returns a Param for a given state. If the param does not already exist it will be created. If the state_name is invalid it will return null. \param state_name name of the state \return param or null if no matching state. Example: \code // Gets the client. g_o3d = document.o3d.o3d; ... // Creates a state object. var state = my_pack.createState("my_state"); // Sets some states. state.getStateParam('o3d.StencilEnable').value = true; state.getStateParam('o3d.StencilReference').value = 25; state.getStateParam('o3d.StencilPassOperation').value = g_o3d.State.STENCIL_REPLACE; state.getStateParam('o3d.StencilComparisonFunction').value = g_o3d.State.CMP_ALWAYS; state.getStateParam('o3d.ZEnable').value = false; state.getStateParam('o3d.ZWriteEnable').value = false; state.getStateParam('o3d.ColorWriteEnable').value = 0; \endcode Valid states:
State Name | Type | Default Value |
o3d.AlphaBlendEnable | ParamBoolean | default = false |
o3d.AlphaComparisonFunction | ParamInteger, State.Comparison | default = State.CMP_ALWAYS |
o3d.AlphaReference | ParamFloat 0-1 | default = 0 |
o3d.AlphaTestEnable | ParamBoolean | default = false |
o3d.BlendAlphaEquation | ParamInteger, State.BlendingEquation | default = State.BLEND_ADD |
o3d.BlendEquation | ParamInteger, State.BlendingEquation | default = State.BLEND_ADD |
o3d.CCWStencilComparisonFunction | ParamInteger, State.Comparison | default = State.CMP_ALWAYS |
o3d.CCWStencilFailOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.CCWStencilPassOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.CCWStencilZFailOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.ColorWriteEnable | ParamInteger 0-15 bit 0 = red, bit 1 = green, bit 2 = blue, bit 3 = alpha | default = 15 |
o3d.CullMode | ParamInteger, State.Cull | default = State.CULL_CW |
o3d.DestinationBlendAlphaFunction | ParamInteger, State.BlendingFunction | default = State.BLENDFUNC_ZERO |
o3d.DestinationBlendFunction | ParamInteger, State.BlendingFunction | default = State.BLENDFUNC_ZERO |
o3d.DitherEnable | ParamBoolean | default = false |
o3d.FillMode | ParamInteger, State.Fill | default = State.SOLID |
o3d.LineSmoothEnable | ParamBoolean | default = false |
o3d.PointSize | ParamFloat | TBD |
o3d.PointSpriteEnable | ParamBoolean | default = false |
o3d.PolygonOffset1 | ParamFloat, polygon offset slope factor | 0 |
o3d.PolygonOffset2 | ParamFloat, polygon offset bias (in resolvable units) | 0 |
o3d.SeparateAlphaBlendEnable | ParamBoolean | default = false; |
o3d.SourceBlendAlphaFunction | ParamInteger, State.BlendingFunction | default = State.BLENDFUNC_ONE |
o3d.SourceBlendFunction | ParamInteger, State.BlendingFunction | default = State.BLENDFUNC_ONE |
o3d.StencilComparisonFunction | ParamInteger, State.Comparison | default = State.CMP_ALWAYS |
o3d.StencilEnable | ParamBoolean | default = false |
o3d.StencilFailOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.StencilMask | ParamInteger 0-255 | default = 255 |
o3d.StencilPassOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.StencilReference | ParamInteger 0-255 | default = 0 |
o3d.StencilWriteMask | ParamInteger 0-255 | default = 255 |
o3d.StencilZFailOperation | ParamInteger, State.StencilOperation | default = State.STENCIL_KEEP |
o3d.TwoSidedStencilEnable | ParamBoolean | default = false |
o3d.ZComparisonFunction | ParamInteger, State.Comparison | default = State.CMP_LESS |
o3d.ZEnable | ParamBoolean | default = true |
o3d.ZWriteEnable | ParamBoolean | default = true |