#include "ormodel_model_display.h"
ORModelDisplay::ORModelDisplay(
const char* pName,
HIObject pObject )
: FBModel( pName, pObject )
, mPickedSubItem(-1)
{
mSubComponentSelected[0] = false;
mSubComponentSelected[1] = false;
}
bool ORModelDisplay::FBCreate()
{
Scale.SetPropertyValue(20.0);
return true;
}
void ORModelDisplay::FBDestroy()
{
}
void ORModelDisplay::CreateGeometry()
{
}
{
FBViewingOptions* lViewingOptions = FBSystem::TheOne().Renderer->GetViewingOptions();
bool lIsColorBufferPicking = lViewingOptions->IsInColorBufferPicking();
SetAdditionalUniqueColorIDCount( lIsColorBufferPicking ? 2 : 0);
double lScale = Scale;
glLineWidth(15.0);
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 (!lIsColorBufferPicking)
{
bool ASelected = (
bool)Selected && mSubComponentSelected[0];
bool BSelected = (
bool)Selected && mSubComponentSelected[1];
bool allSelected = ASelected && BSelected;
if (allSelected)
glColor3d(0.0, 1.0, 0.0);
else if (ASelected)
{
glColor3d(0.0,1.0,0.0);
glEnable (GL_LINE_STIPPLE);
glLineStipple (1, 0x0101);
}
else
glColor3d(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex3d(lScale,0,0);
glVertex3d(lScale,lScale,lScale);
glEnd();
glDisable (GL_LINE_STIPPLE);
if (allSelected)
glColor3d(0.0, 1.0, 0.0);
else if (BSelected)
{
glColor3d(0.0,1.0,0.0);
glEnable (GL_LINE_STIPPLE);
glLineStipple (1, 0x0101);
}
else
glColor3d(1.0,1.0,1.0);
glBegin(GL_LINES);
glVertex3d(-lScale,0,0);
glVertex3d(-lScale,lScale,lScale);
glEnd();
glDisable (GL_LINE_STIPPLE);
}
else
{
glColor3dv(GetAdditionalUniqueColorID(0));
glBegin(GL_LINES);
glVertex3d(lScale,0,0);
glVertex3d(lScale,lScale,lScale);
glEnd();
glColor3dv(GetAdditionalUniqueColorID(1));
glBegin(GL_LINES);
glVertex3d(-lScale,0,0);
glVertex3d(-lScale,lScale,lScale);
glEnd();
}
}
glPopMatrix();
}
glPopAttrib();
}
bool ORModelDisplay::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);
}
}
}
return true;
}
{
pIntersectPos =
FBTVector(0, 2.0 * Scale / 3.0, 2.0 * Scale / 3.0);
return true;
}
{
bool bRetVal = true;
if (FBSystem::TheOne().Renderer->IDBufferPicking)
{
bool preSelectionState = mSubComponentSelected[0] || mSubComponentSelected[1];
switch(pAction)
{
{
{
mSubComponentSelected[0] = false;
mSubComponentSelected[1] = false;
}
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)
{
mSubComponentSelected[lPickInfo.mSubItemIndex] = true;
FBTrace(
" [%d] = true\n",lPickInfo.mSubItemIndex);
}
}
}
break;
}
{
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)
{
{
mSubComponentSelected[lPickInfo.mSubItemIndex] = false;
FBTrace(
" [%d] = true\n",lPickInfo.mSubItemIndex);
} else {
mSubComponentSelected[lPickInfo.mSubItemIndex] = !mSubComponentSelected[lPickInfo.mSubItemIndex];
if (mSubComponentSelected[lPickInfo.mSubItemIndex])
FBTrace(
" [%d] = true = !false\n",lPickInfo.mSubItemIndex);
else
FBTrace(
" [%d] = false = !true\n",lPickInfo.mSubItemIndex);
}
}
}
}
break;
}
{
mSubComponentSelected[0] = true;
mSubComponentSelected[1] = true;
break;
}
{
mSubComponentSelected[0] = false;
mSubComponentSelected[1] = false;
break;
}
default:
break;
}
bool postSelectionState = mSubComponentSelected[0] || mSubComponentSelected[1];
bRetVal = preSelectionState != postSelectionState;
}
if (bRetVal)
else
return bRetVal;
}
bool ORModelDisplay::FbxStore(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}
bool ORModelDisplay::FbxRetrieve(FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat)
{
return true;
}