#include "ortexture_template_texture.h"
ORLayeredTextureCustom::ORLayeredTextureCustom(
const char* pName,
HIObject pObject ) : FBLayeredTexture( pName, pObject )
{
}
static void ORLayeredTextureCustom_CustomCompositionSet(
HIObject pMbObject,
bool pValue)
{
ORLayeredTextureCustom* pFbObject = FBCast<ORLayeredTextureCustom>( pMbObject );
pFbObject->CustomComposition.SetPropertyValue(pValue);
pFbObject->SetLayerConfigDirty();
}
bool ORLayeredTextureCustom::FBCreate()
{
FBPropertyPublish(
this, CustomComposition,
"CustomComposition",
NULL, ORLayeredTextureCustom_CustomCompositionSet);
AuxLayer = FBColorAndAlpha(1.0, 0.0, 0.0, 1.0);
CustomComposition = true;
return true;
}
void ORLayeredTextureCustom::FBDestroy()
{
ParentClass::FBDestroy();
}
bool ORLayeredTextureCustom::FbxStore(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
ParentClass::FbxStore(pFbxObject, pStoreWhat);
return true;
}
bool ORLayeredTextureCustom::FbxRetrieve(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
ParentClass::FbxRetrieve(pFbxObject, pStoreWhat);
return true;
}
bool ORLayeredTextureCustom::PlugDataNotify(
FBConnectionAction pAction,FBPlug* pThis,
void* pData,
void* pDataOld,
int pDataSize)
{
if (pThis == &AuxLayer)
{
switch (pAction)
{
{
SetLayerConfigDirty();
}
break;
default:
break;
}
}
return ParentClass::PlugDataNotify(pAction, pThis, pData, pDataOld, pDataSize);
}
bool ORLayeredTextureCustom::EvaluateAnimationNodes( FBEvaluateInfo* pEvaluateInfo )
{
ParentClass::EvaluateAnimationNodes(pEvaluateInfo);
if (CustomComposition && AuxLayer.IsAnimated())
{
FBPropertyAnimatableColorAndAlpha::ValueType lTmpValue;
AuxLayer.GetData(lTmpValue.mValue, sizeof(lTmpValue.mValue), pEvaluateInfo);
SetLayerConfigDirty();
}
return true;
}
void ORLayeredTextureCustom::TextureLayerComposition(FBTime pTime,FBTime pTimeInCurrentTimeRef, int pWidth, int pHeight)
{
if (! CustomComposition)
{
ParentClass::TextureLayerComposition(pTime, pTimeInCurrentTimeRef, pWidth, pHeight);
}
else
{
glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT);
FBColorAndAlpha lBgColor = AuxLayer;
glClearColor(lBgColor[0], lBgColor[1], lBgColor[2], lBgColor[3]);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0,0, pWidth, pHeight);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, 1, 1, 0, -1, 1);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
for (int lLayerIndex = 0, lLayerCount = Layers.GetCount(); lLayerIndex < lLayerCount; lLayerIndex++)
{
FBTexture* lTexture = Layers[lLayerIndex];
switch( lTexture->BlendMode )
{
}
glColor4f(1.0, 1.0, 1.0, lTexture->Alpha);
lTexture->OGLInit();
glBegin(GL_POLYGON);
glTexCoord2f(0.0, 1.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex2f(1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex2f(1.0, 0.0);
glEnd();
}
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}
}