Panda3D
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Types | Public Member Functions | Static Public Member Functions
RenderAttrib Class Reference

This is the base class for a number of render attributes (other than transform) that may be set on scene graph nodes to control the appearance of geometry. More...

Inheritance diagram for RenderAttrib:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject AlphaTestAttrib AntialiasAttrib AudioVolumeAttrib AuxBitplaneAttrib ClipPlaneAttrib ColorAttrib ColorBlendAttrib ColorScaleAttrib ColorWriteAttrib CullBinAttrib CullFaceAttrib DepthOffsetAttrib DepthTestAttrib DepthWriteAttrib FogAttrib LightAttrib LightRampAttrib MaterialAttrib RenderModeAttrib RescaleNormalAttrib ScissorAttrib ShadeModelAttrib ShaderAttrib StencilAttrib TexGenAttrib TexMatrixAttrib TextureAttrib TransparencyAttrib

List of all members.

Public Types

enum  PandaCompareFunc {
  MNone = 0, MNever = 1, MLess = 2, MEqual = 3,
  MLessEqual = 4, MGreater = 5, MNotEqual = 6, MGreaterEqual = 7,
  MAlways = 8
}
enum  TexGenMode {
  MOff = 0, MEyeSphereMap = 1, MWorldCubeMap = 2, MEyeCubeMap = 3,
  MWorldNormal = 4, MEyeNormal = 5, MWorldPosition = 6, MUnused = 7,
  MEyePosition = 8, MPointSprite = 9, MLightVector = 10, MConstant = 11
}

Public Member Functions

int compareTo (RenderAttrib const other)
 Provides an arbitrary ordering among all unique RenderAttribs, so we can store the essentially different ones in a big set and throw away the rest.
RenderAttrib const compose (RenderAttrib const other)
 Returns a new RenderAttrib object that represents the composition of this attrib with the other attrib.
RenderAttrib const getAutoShaderAttrib (RenderState const state)
 Returns the variant of this RenderAttrib that's most relevant for associating with an auto-generated shader.
unsigned int getHash ()
 Returns a suitable hash value for phash_map.
int getSlot ()
RenderAttrib const getUnique ()
 Returns the pointer to the unique RenderAttrib in the cache that is equivalent to this one.
RenderAttrib const invertCompose (RenderAttrib const other)
 Returns a new RenderAttrib object that represents the composition of the inverse of this attrib with the other attrib.
bool lowerAttribCanOverride ()
 Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib objects of the same type interact.
 output (ostream out)
 write (ostream out, int indent_level)

Static Public Member Functions

static int garbageCollect ()
 Performs a garbage-collection cycle.
static TypeHandle getClassType ()
static int getNumAttribs ()
 Returns the total number of unique RenderAttrib objects allocated in the world.
static listAttribs (ostream out)
 Lists all of the RenderAttribs in the cache to the output stream, one per line.
static bool validateAttribs ()
 Ensures that the cache is still stored in sorted order.

Detailed Description

This is the base class for a number of render attributes (other than transform) that may be set on scene graph nodes to control the appearance of geometry.

This includes TextureAttrib, ColorAttrib, etc.

RenderAttrib represents render attributes that always propagate down to the leaves without regard to the particular node they are assigned to. A RenderAttrib will have the same effect on a leaf node whether it is assigned to the graph at the leaf or several nodes above. This is different from RenderEffect, which represents a particular render property that is applied immediately to the node on which it is encountered, like billboarding or decaling.

You should not attempt to create or modify a RenderAttrib directly; instead, use the make() method of the appropriate kind of attrib you want. This will allocate and return a new RenderAttrib of the appropriate type, and it may share pointers if possible. Do not modify the new RenderAttrib if you wish to change its properties; instead, create a new one.


Member Enumeration Documentation

Enumerator:
MNone 
MNever 
MLess 
MEqual 
MLessEqual 
MGreater 
MNotEqual 
MGreaterEqual 
MAlways 
enum TexGenMode
Enumerator:
MOff 
MEyeSphereMap 
MWorldCubeMap 
MEyeCubeMap 
MWorldNormal 
MEyeNormal 
MWorldPosition 
MUnused 
MEyePosition 
MPointSprite 
MLightVector 
MConstant 

Member Function Documentation

int compareTo ( RenderAttrib const  other)

Provides an arbitrary ordering among all unique RenderAttribs, so we can store the essentially different ones in a big set and throw away the rest.

This method is not needed outside of the RenderAttrib class because all equivalent RenderAttrib objects are guaranteed to share the same pointer; thus, a pointer comparison is always sufficient.

RenderAttrib const compose ( RenderAttrib const  other)

Returns a new RenderAttrib object that represents the composition of this attrib with the other attrib.

In most cases, this is the same as the other attrib; a compose b produces b. Some kinds of attributes, like a TextureTransform, for instance, might produce a new result: a compose b produces c.

static int garbageCollect ( ) [static]

Performs a garbage-collection cycle.

This is called automatically from RenderState::garbage_collect(); see that method for more information.

Returns the variant of this RenderAttrib that's most relevant for associating with an auto-generated shader.

This should be a new RenderAttrib of the same type as this one, with any superfluous data set to neutral. Only the parts of the attrib that contribute to the shader should be reflected in the returned attrib. The idea is to associate the auto-generated shader with the most neutral form of all states, to allow it to be shared across as many RenderState objects as possible.

If this RenderAttrib is completely irrelevant to the auto-shader, this should return NULL to indicate that the attrib won't be assocaited with the shader at all. In this case the attrib does not contribute to the shader meaningfully.

static TypeHandle getClassType ( ) [static]
unsigned int getHash ( )

Returns a suitable hash value for phash_map.

static int getNumAttribs ( ) [static]

Returns the total number of unique RenderAttrib objects allocated in the world.

This will go up and down during normal operations.

int getSlot ( )

Returns the pointer to the unique RenderAttrib in the cache that is equivalent to this one.

This may be the same pointer as this object, or it may be a different pointer; but it will be an equivalent object, and it will be a shared pointer. This may be called from time to time to improve cache benefits.

RenderAttrib const invertCompose ( RenderAttrib const  other)

Returns a new RenderAttrib object that represents the composition of the inverse of this attrib with the other attrib.

In most cases, this is the same as the other attrib; !a compose b produces b. Some kinds of attributes, like a TextureTransform, for instance, might produce a new result: !a compose b produces c.

This is similar to compose() except that the source attrib is inverted first. This is used to compute the relative attribute for one node as viewed from some other node, which is especially useful for transform-type attributes.

static listAttribs ( ostream  out) [static]

Lists all of the RenderAttribs in the cache to the output stream, one per line.

This can be quite a lot of output if the cache is large, so be prepared.

Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib objects of the same type interact.

This should return false if a RenderAttrib on a higher node will compose into a RenderAttrib on a lower node that has a higher override value, or true if the lower RenderAttrib will completely replace the state.

The default behavior is false: normally, a RenderAttrib in the graph cannot completely override a RenderAttrib above it, regardless of its override value--instead, the two attribs are composed. But for some kinds of RenderAttribs, it is useful to allow this kind of override.

This method only handles the one special case of a lower RenderAttrib with a higher override value. If the higher RenderAttrib has a higher override value, it always completely overrides. And if both RenderAttribs have the same override value, they are always composed.

output ( ostream  out)
static bool validateAttribs ( ) [static]

Ensures that the cache is still stored in sorted order.

Returns true if so, false if there is a problem (which implies someone has modified one of the supposedly-const RenderAttrib objects).

write ( ostream  out,
int  indent_level 
)
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties