Notifications
Clear all

[Closed] Fetch SetViewportVisualStyle() C++

Does anyone know how to get or set the viewport style?


int index = ip7->getActiveViewportIndex();
IViewPanel* pPanel = GetViewPanelManager()->GetActiveViewPanel();
ViewExp *vpt = nullptr;
vpt = pPanel->GetViewExpByIndex(index).ToPointer();


NOW THIS DOES NOT SHOW UP
vpt->GetViewportVisualStyle(); 

7 Replies

Looks like I can get there like this…

ViewExp& vpt = ip->GetActiveViewExp();
vpt.ViewExp::GetInterface(IVIEWPORT_SETTINGS_INTERFACE_ID);

but I don’t know how or what I’m looking for to get to

SetViewportVisualStyle();

There are no samples or good information on this stuff.

you should read the sdk help more careful:

IViewportViewSetting

Note:
To access this interface from a ViewExp object, please call ViewExp::GetInterface(IVIEWPORT_SETTINGS_INTERFACE_ID).

that means you have to get IVIEWPORT_SETTINGS_INTERFACE_ID interface of ViewExp as MaxSDK::Graphics::IViewportViewSetting

Sorry, with out and SDK sample I get lost between “ViewExp to GetViewportVisualStyle”


    int index = ip7->getActiveViewportIndex();
  IViewPanel* pPanel = GetViewPanelManager()->GetActiveViewPanel();
  ViewExp *vpt = nullptr;
  GraphicsWindow *gw = vpt->getGW();
  MaxSDK::Graphics::IViewportViewSetting *newClass = static_cast<MaxSDK::Graphics::IViewportViewSetting*>(GetCOREInterface(IVIEWPORT_SETTINGS_INTERFACE_ID));
 newClass->SetViewportVisualStyle(MaxSDK::Graphics::VisualStyle::VisualStyleClay);
    

Ok, we got it


int index = ip7->getActiveViewportIndex();
IViewPanel* pPanel = GetViewPanelManager()->GetActiveViewPanel();
ViewExp *vpt = nullptr;
vpt = pPanel->GetViewExpByIndex(index).ToPointer();
MaxSDK::Graphics::IViewportViewSetting *newClass = static_cast<MaxSDK::Graphics::IViewportViewSetting*>(vpt->GetInterface(IVIEWPORT_SETTINGS_INTERFACE_ID));

// to get
int i = newClass->GetViewportVisualStyle();  

// to set
newClass->SetViewportVisualStyle(MaxSDK::Graphics::VisualStyle::VisualStyleClay);

now it’s correct. but could be a little simpler:

Interface* ip = GetCOREInterface();
ViewExp& vp = ip->GetActiveViewExp();
int style = 0; // VisualStyleRealistic

MaxSDK::Graphics::IViewportViewSetting* si = (MaxSDK::Graphics::IViewportViewSetting*)vp.GetInterface(IVIEWPORT_SETTINGS_INTERFACE_ID); 
if (si)
{
	si->SetViewportVisualStyle((MaxSDK::Graphics::VisualStyle)style);
}

you don’t need to get ViewExp by index. as i know SetViewportVisualStyle always applies to an active viewport anyway

Nice one thanks for your help.