#include "ormarker_template_custom.h"
ORMarkerCustom::ORMarkerCustom(
const char* pName,
HIObject pObject )
: FBModelMarker( pName, pObject )
{
}
bool ORMarkerCustom::FBCreate()
{
Size = 50.0;
Length = 1.0;
Show = true;
mPickedSubItem = -1;
return true;
}
void ORMarkerCustom::FBDestroy()
{
ParentClass::FBDestroy();
}
{
FBMatrix MatrixView;
FBMatrix MatrixProjection;
FBViewingOptions* lViewingOptions = FBSystem::TheOne().Renderer->GetViewingOptions();
bool lIsSelectBufferPicking = lViewingOptions->IsInSelectionBufferPicking();
bool lIsColorBufferPicking = lViewingOptions->IsInColorBufferPicking();
SetAdditionalUniqueColorIDCount( lIsColorBufferPicking ? 2 : 0);
double lScale = 100;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT | GL_TRANSFORM_BIT | GL_LINE_BIT);
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
{
glTranslated(T[0],T[1],T[2]);
if (!lIsSelectBufferPicking && !lIsColorBufferPicking)
{
if ((bool)Selected)
{
if (mPickedSubItem == 0)
glColor3d(1.0,0.0,0.0);
else if (mPickedSubItem == 1)
glColor3d(0.0, 1.0, 0.0);
else
glColor3d(0.0, 0.0, 1.0);
}
else
{
glColor3d(1.0,1.0,1.0);
}
}
glLineWidth(3.0);
glBegin(GL_LINES);
glVertex3d(lScale,lScale,lScale);
glVertex3d(-lScale,lScale,lScale);
glEnd();
if (lIsColorBufferPicking)
glColor3dv(GetAdditionalUniqueColorID(0));
else if (lIsSelectBufferPicking)
glLoadName(1);
glBegin(GL_LINES);
glVertex3d(0,0,0);
glVertex3d(lScale,lScale,lScale);
glEnd();
if (lIsColorBufferPicking)
glColor3dv(GetAdditionalUniqueColorID(1));
else if (lIsSelectBufferPicking)
glLoadName(2);
glBegin(GL_LINES);
glVertex3d(0,0,0);
glVertex3d(-lScale,lScale,lScale);
glEnd();
}
glPopMatrix();
}
glPopAttrib();
}
bool ORMarkerCustom::CustomModelPicking( int pNbHits, unsigned int *pSelectBuffer, FBCamera* pCamera,
int pMouseX,int pMouseY,
FBMatrix* pGlobalInverseMatrix,
{
if( pNbHits <= 0)
return false;
mPickedSubItem = -1;
for (int Count=0; Count<pNbHits; Count++)
{
unsigned int NameCount = *pSelectBuffer++;
assert(NameCount == 1);
pSelectBuffer+=2;
unsigned int NameIndex = *pSelectBuffer++;
if(NameIndex==1)
{
mPickedSubItem = 0;
if(pOutPickedPoint)
{
}
}
else if(NameIndex==2)
{
mPickedSubItem = 1;
if(pOutPickedPoint)
{
*pOutPickedPoint =
FBTVector(-100,100,100,0);
}
}
}
FBTrace(
"Select %s SubItem[%d]", GetFullName(), mPickedSubItem);
return true;
}
bool ORMarkerCustom::PlugStateNotify(
FBConnectionAction pAction,FBPlug* pThis,
void* pData,
void* pDataOld,
int pDataSize)
{
if (FBSystem::TheOne().Renderer->IDBufferPicking)
{
switch(pAction)
{
{
FBPickInfosList* lPickInfoList = FBCreatePickInfosList();
if (FBSystem::TheOne().Renderer->GetLastPickInfoList(*lPickInfoList))
{
for (int lIndex = 0; lIndex < lPickInfoList->GetCount(); lIndex++)
{
FBPickInfos lPickInfo = lPickInfoList->GetAt(lIndex);
if (lPickInfo.mModel == this)
{
FBTrace(
"Select %s SubItem[%d]", GetFullName(), lPickInfo.mSubItemIndex);
mPickedSubItem = lPickInfo.mSubItemIndex;
}
}
}
}
break;
{
FBTrace(
"Unselect %s", GetFullName());
mPickedSubItem = -1;
}
break;
default:
break;
}
}
return ParentClass::PlugStateNotify(pAction, pThis, pData, pDataOld, pDataSize);
}
bool ORMarkerCustom::FbxStore(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}
bool ORMarkerCustom::FbxRetrieve(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}