Notifications
Clear all
[Closed] C++ Pick Button
Jul 22, 2015 2:23 pm
Hi, I am trying to create a Pick Button. I have used the samples to get a basic verson of the code, although Max seems to crash as soon as I click the button. So I believe there something wrong with my SetPickMode … Anyone know ? All code is below:
//-----------------------------------------------------------------------------------------------------------------------------------
// Spline Pick
//-----------------------------------------------------------------------------------------------------------------------------------
BOOL SplinePickMode::Filter(INode *node){
ExecuteMAXScriptScript(_T("print \"Filter\""), 0, 0);
if(node){
ExecuteMAXScriptScript(_T("print \"Got Node\""), 0, 0);
return TRUE;
}
return FALSE;
}
BOOL SplinePickMode::HitTest(IObjParam *iop, HWND hWnd, ViewExp * /*vpt*/, IPoint2 m,int flags) {
ExecuteMAXScriptScript(_T("print \"HitTest\""), 0, 0);
return iop->PickNode(hWnd,m,this) ? TRUE : FALSE;
}
BOOL SplinePickMode::Pick(IObjParam *iop, ViewExp *vpt){
if ( ! vpt || ! vpt->IsAlive() )
{
// why are we here
DbgAssert(!_T("Invalid viewport!"));
return FALSE;
}
ExecuteMAXScriptScript(_T("print \"PickingNode\""), 0, 0);
INode *node = vpt->GetClosestHit();
if (!Filter(node)) return FALSE;
ExecuteMAXScriptScript(_T("print \"Return\""), 0, 0);
return FALSE;
}
void SplinePickMode::EnterMode(IObjParam *iop) {
ExecuteMAXScriptScript(_T("print \"Enter\""), 0, 0);
}
void SplinePickMode::ExitMode(IObjParam *iop) {
ExecuteMAXScriptScript(_T("print \"End\""), 0, 0);
}
static SplinePickMode PickSpline;
class RenderDlgProc : public ParamMap2UserDlgProc
{
public:
INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
Render_Object *p = (Render_Object*)map->GetParamBlock()->GetOwner();
switch (msg)
{
case WM_INITDIALOG:
{
theRender.ip = GetCOREInterface();
break;
}
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_PICKSPLINE:
ExecuteMAXScriptScript(_T("print \"PickingSpline\""), 0, 0);
theRender.ip->SetPickMode(&PickSpline);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}
void DeleteThis() {};
};
Sorry for all the Prints, I just place them around so where my code is crashing ^^ Thanks
Edit *: Never Mind, I got it to work. I have redone the code above with the new working code incase anyone wants it. Thanks