Пример #1
0
INT_PTR EffectsDlgProc::DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) 
	{
		case WM_INITDIALOG:
		{

			HWND hwndeffect = GetDlgItem(hWnd, IDC_EFFECTLIST);
			SendMessage(hwndeffect, CB_RESETCONTENT, 0L, 0L);
			for (int i = 0; i < vl->NumShaders(); i++) {
				ClassDesc* pClassD = vl->GetEffectCD(i);
				int n = SendMessage(hwndeffect, CB_ADDSTRING, 0L, (LPARAM)(pClassD->ClassName()) );
			}
			SendMessage(hwndeffect, CB_INSERTSTRING, 0L, (LPARAM)GetString(IDS_STR_NONE));
			SendMessage(hwndeffect, CB_SETCURSEL, vl->effectIndex,0L);

			if (vl->IsCurrentEffectSupported()) {
				vl->EnableDlgItem(IDC_ENABLED, TRUE);
			}
			else {
				vl->SetCurrentEffectEnabled(false);
				vl->EnableDlgItem(IDC_ENABLED, FALSE);
			}

			vl->EnableDlgItem(IDC_SAVE_FX, vl->IsSaveFxSupported());

			return TRUE;
		}
	}
	return FALSE;
}
Пример #2
0
const TCHAR * ViewportLoader::GetActiveEffectName()
{
	ClassDesc* pCD = GetEffectCD(effectIndex-1);
	if(pCD)
		return (TCHAR*)pCD->ClassName();
	else
		return NULL;

}
Пример #3
0
//-----------------------------------------------------------------------
bool IsDynamicDxMaterial(MtlBase * newMtl)
{
	DllDir * lookup = GetCOREInterface()->GetDllDirectory();
	ClassDirectory & dirLookup = lookup->ClassDir();

	ClassDesc * cd = dirLookup.FindClass(MATERIAL_CLASS_ID, newMtl->ClassID());
	
	if(cd && cd->SubClassID() == DXMATERIAL_DYNAMIC_UI){
		return true;
	}
	return false;
}
Пример #4
0
void ViewportLoader::LoadEffect(ClassDesc * pd)
{

	ReferenceTarget * newEffect;
	ReferenceTarget * oldEffect;

	if (theHold.Holding())
	{
		oldEffect = effect;

//		theHold.Suspend(); 


		if(pd == NULL){
			newEffect = NULL;
		}
		else{
			newEffect = (ReferenceTarget *)pd->Create(FALSE);
			DbgAssert(newEffect && _M("Plug-in instance creation failed. Possible cause: deferred plug-in failed to load."));
			if(!newEffect)
			{
				// maybe deferred
				ClassDesc * def = FindandLoadDeferedEffect(pd);
				if(def)
				{
					newEffect = (ReferenceTarget *)def->Create(FALSE);
				}

			}

		}

//		theHold.Resume(); 

		if (theHold.Holding())
			theHold.Put(new AddEffectRestore(this,oldEffect,newEffect));

		SwapEffect(newEffect);
	}
}
bool NatLightAssemblyClassDesc::IsValidSun( ClassDesc& cd) 
{
	bool bValidSun = ((cd.ClassID() == NatLightAssembly::GetStandardSunClass()) != FALSE);
	if (!bValidSun)
	{
		INaturalLightClass* pNC = GetNaturalLightClassInterface(&cd);
		if (pNC != NULL && (pNC->GetDesc()->flags & FP_STATIC_METHODS)) 
		{
			bValidSun = (pNC->IsSun() != FALSE);
		}
	}
	return bValidSun;
}
Пример #6
0
bool VDMClassDesc::IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) {

	Class_ID classID = rendererClassDesc.ClassID();

	if((classID == MRRENDERER_CLASSID) /* || (classID == SCANLINERENDERER_CLASS_ID) */ ) {
		return true;
	}
	else {
		// Return 'true' only if the renderer doesn't implement the compatibility interface.
		// This ensures that we are compatible with all renderers unless they specify the contrary.
		IMtlRender_Compatibility_Renderer* rendererCompatibility = Get_IMtlRender_Compatibility_Renderer(rendererClassDesc);
		return (rendererCompatibility == NULL);
	}
}
Пример #7
0
bool mrShaderFilter::ValidateReturnType(ClassDesc& classDesc) {


	SClass_ID superClassID = classDesc.SuperClassID();

	if(superClassID == MATERIAL_CLASS_ID) {

		// Validate if we want a TYPE_MTL return type
		//return ValidType(TYPE_MTL);
		
		// Do not validate types for materials. Only use the apply type for validatoin.
		return true;
	}
	else if(superClassID == TEXMAP_CLASS_ID) {

		imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);

		if(shaderClassDesc == NULL) {
			// Assume that the texture returns a color
			return ValidType(static_cast<ParamType2>(TYPE_RGBA));
		}
		else {

			// Go through the results structure
			ParamBlockDesc2* pbDesc = shaderClassDesc->GetResultPBDesc();
			if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
				return true;
			}

			// Go through the sub-structures, is allowed
			if(m_acceptStructs) {
				Tab<ParamBlockDesc2*>& resultDescs = shaderClassDesc->GetResultPBDescs();
				int count = resultDescs.Count();
				for(int i = 0; i < count; ++i) {
					ParamBlockDesc2* pbDesc = resultDescs[i];
					if((pbDesc != NULL) && ValidateReturnType(*pbDesc)) {
						return true;
					}
				}
			}			

			return false;
		}
	}
	else {
		// Shouldn't occur
		DbgAssert(false);
		return false;
	}
}
Пример #8
0
void TapeHelpCreationManager::CreateNewObject()
{
    tapeObject = (TapeHelpObject*)cDesc->Create();
    lastPutCount = theHold.GetGlobalPutCount();

    macroRec->BeginCreate(cDesc);
    // Start the edit params process
    if ( tapeObject ) {

        tapeObject->SetAFlag(A_OBJ_LONG_CREATE);
#ifndef NO_CREATE_TASK  // russom - 12/04/01
        tapeObject->BeginEditParams( (IObjParam*)createInterface, BEGIN_EDIT_CREATE, NULL );
#endif
    }
}
Пример #9
0
void CreateSWrapObjectProc::CreateNewObject()
	{
	SWrapObj = (SWrapObject*)cDesc->Create();
	lastPutCount  = theHold.GetGlobalPutCount();
	
	// Start the edit params process
	if ( SWrapObj ) {
#ifndef NO_CREATE_TASK	// russom - 12/04/01
		SWrapObj->BeginEditParams( (IObjParam*)createInterface, BEGIN_EDIT_CREATE, NULL );
#endif
#ifdef _OSNAP
		SWrapObj->SetAFlag(A_OBJ_LONG_CREATE);
#endif
		}	
	}
Пример #10
0
bool mrShaderFilter::ValidateApplyType(ClassDesc& classDesc) {

	SClass_ID superClassID = classDesc.SuperClassID();

	if(superClassID == MATERIAL_CLASS_ID) {

		// Validate if materials are accepted
		return ((m_applyTypes & imrShaderClassDesc::kApplyFlag_MtlPhen) != 0);
	}
	else if(superClassID == TEXMAP_CLASS_ID) {

		// First, query for a possible custom apply type
		imrShaderTranslation_ClassInfo* customClassInfo = Get_imrShaderTranslation_ClassInfo(classDesc);
		if(customClassInfo != NULL) {

			unsigned int customApplyType = customClassInfo->GetApplyTypes();
			return ((customApplyType & m_applyTypes) != 0);
		}
		else {
			imrShaderClassDesc* shaderClassDesc = Get_mrShaderClassDesc(&classDesc);

			if(shaderClassDesc == NULL) {
				// Not a mr shader. Validate if texture shaders are accepted.
				return ((m_applyTypes & imrShaderClassDesc::kApplyFlag_Texture) != 0);
			}
			else {

				// Depends on the apply type of the shader
				unsigned int shaderApplyTypes = shaderClassDesc->GetApplyTypes();
				return ((shaderApplyTypes & m_applyTypes) != 0);
			}
		}
	}
	else {
		// Shouldn't occur
		DbgAssert(false);
		return false;
	}
}
Пример #11
0
void plComponentDlg::IOpenRightClickMenu()
{
    HWND hTree = GetDlgItem(fhDlg, IDC_TREE);

    // Get the position of the cursor in screen and tree client coords
    POINT point, localPoint;
    GetCursorPos(&point);
    localPoint = point;
    ScreenToClient(hTree, &localPoint);

    // Check if there is a tree item at that point
    TVHITTESTINFO hitTest;
    hitTest.pt = localPoint;
    TreeView_HitTest(hTree, &hitTest);
    if (!(hitTest.flags & TVHT_ONITEMLABEL))
        return;

    // Check if the tree item has an lParam (is a component)
    TVITEM item;
    item.mask = TVIF_PARAM;
    item.hItem = hitTest.hItem;
    TreeView_GetItem(hTree, &item);

    HMENU menu = nil;
    if (IIsComponent(item.lParam))
        menu = fCompMenu;
    else if (IIsType(item.lParam))
        menu = fTypeMenu;
    else
        return;

    // Select the item we're working with, so the user isn't confused
    TreeView_SelectItem(hTree, item.hItem);

    // Create the popup menu and get the option the user selects
    SetForegroundWindow(fhDlg);
    int sel = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, 0, fhDlg, NULL);
    switch(sel)
    {
    case kMenuDelete:
        IDeleteComponent((plMaxNode*)item.lParam);
        break;

    case kMenuRename:
        TreeView_EditLabel(hTree, hitTest.hItem);
        break;

    case kMenuCopy:
        {
            // Component to copy
            INode *node = (INode*)item.lParam;
            INodeTab tab;
            tab.Append(1, &node);

            // Copy
            INodeTab copy;

            // Make the copy
            fInterface->CloneNodes(tab, Point3(0,0,0), true, NODE_COPY, NULL, &copy);

            // Delete the targets for the copy and add it to the tree
            plMaxNode *newNode = (plMaxNode*)copy[0];
            newNode->ConvertToComponent()->DeleteAllTargets();
            HTREEITEM hItem = IAddComponent(GetDlgItem(fhDlg, IDC_TREE), newNode);
            TreeView_SelectItem(GetDlgItem(fhDlg, IDC_TREE), hItem);
        }
        break;

    case kMenuHide:
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(item.lParam-1);

            std::vector<Class_ID>::iterator it;
            it = std::find(fHiddenComps.begin(), fHiddenComps.end(), desc->ClassID());

            TSTR name = desc->ClassName();
            if (it == fHiddenComps.end())
            {
                fHiddenComps.push_back(desc->ClassID());
                name.Append(" (Hidden)");
            }
            else
                fHiddenComps.erase(it);

            item.mask = TVIF_TEXT;
            item.pszText = name;
            TreeView_SetItem(GetDlgItem(fhDlg, IDC_TREE), &item);

            plComponentUtil::Instance().IUpdateRollups();
        }
        break;
    }

    PostMessage(fhDlg, WM_USER, 0, 0);
}
Пример #12
0
BOOL plComponentDlg::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        fhDlg = hDlg;
        IAddComponentsRecur(GetDlgItem(hDlg, IDC_TREE), (plMaxNode*)GetCOREInterface()->GetRootNode());

        ICreateMenu();
        ICreateRightClickMenu();
        return TRUE;

    case WM_SIZING:
        IPositionControls((RECT*)lParam, wParam);
        return TRUE;

    case WM_ACTIVATE:
        if (LOWORD(wParam) == WA_INACTIVE)
            plMaxAccelerators::Enable();
        else
            plMaxAccelerators::Disable();
        return TRUE;

    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDCANCEL)
        {
            ShowWindow(hDlg, SW_HIDE);
            fInterface->UnRegisterDlgWnd(hDlg);
            return TRUE;
        }
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_ATTACH)
        {
            IAttachTreeSelection();
            return TRUE;
        }
        else if (HIWORD(wParam) == EN_KILLFOCUS && LOWORD(wParam) == IDC_COMMENTS)
        {
            IGetComment();
            return TRUE;
        }
        // "Refresh" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REFRESH)
        {
            IRefreshTree();
            return TRUE;
        }
        // "Remove unused components" menu item
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == ID_REMOVE_UNUSED)
        {
            IRemoveUnusedComps();
            return TRUE;
        }
        // Item selected from 'New' menu
        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) >= MENU_ID_START)
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(LOWORD(wParam)-MENU_ID_START);
            // If this is a component type (not a category)
            if (desc)
            {
                // Create an object of that type and a node to reference it
                Object *obj = (Object*)GetCOREInterface()->CreateInstance(desc->SuperClassID(), desc->ClassID());
                INode *node = GetCOREInterface()->CreateObjectNode(obj);

                plComponentBase *comp = (plComponentBase*)obj;
                node->Hide(!comp->AllowUnhide());
                node->Freeze(TRUE);

                // Add the new component to the tree
                HWND hTree = GetDlgItem(hDlg, IDC_TREE);
                HTREEITEM item = IAddComponent(hTree, (plMaxNode*)node);
                TreeView_SelectItem(hTree, item);
                TreeView_EnsureVisible(hTree, item);
            }
        }
        break;

    case WM_NOTIFY:
        NMHDR *nmhdr = (NMHDR*)lParam;
        if (nmhdr->idFrom == IDC_TREE)
        {
            switch (nmhdr->code)
            {
            case TVN_SELCHANGED:
                {
                    NMTREEVIEW *tv = (NMTREEVIEW*)lParam;

                    IGetComment();

                    bool isComponent = IIsComponent(tv->itemNew.lParam);

                    // If the new selection is a component, enable the attach button and comment field
                    EnableWindow(GetDlgItem(hDlg, IDC_ATTACH), isComponent);
                    SendDlgItemMessage(hDlg, IDC_COMMENTS, EM_SETREADONLY, !isComponent, 0);

                    if (isComponent)
                    {
                        fCommentNode = (plMaxNode*)tv->itemNew.lParam;
                        
                        TSTR buf;
                        fCommentNode->GetUserPropBuffer(buf);
                        SetDlgItemText(hDlg, IDC_COMMENTS, buf);
                    }
                    else
                    {
                        fCommentNode = nil;
                        SetDlgItemText(hDlg, IDC_COMMENTS, "");
                    }

                    return TRUE;
                }
                break;

            case TVN_BEGINLABELEDIT:
                // If this isn't a component, don't allow the edit
                if (!IIsComponent(((NMTVDISPINFO*)lParam)->item.lParam))
                {
                    SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    return TRUE;
                }

                // The edit box this creates kills the focus on our window, causing
                // accelerators to be enabled.  Add an extra disable to counteract that.
                plMaxAccelerators::Disable();

                return TRUE;

            // Finishing changing the name of a component
            case TVN_ENDLABELEDIT:
                {
                    NMTVDISPINFO *di = (NMTVDISPINFO*)lParam;
                    char* text = di->item.pszText;
                    // If the name was changed...
                    if (text && *text != '\0')
                    {
                        // Update the name of the node
                        plMaxNode *node = IGetTreeSelection();
                        node->SetName(text);

                        // Update the name in the panel too
                        if (plComponentUtil::Instance().IsOpen())
                            plComponentUtil::Instance().IUpdateNodeName(node);

                        // Make sure Max knows the file was changed
                        SetSaveRequiredFlag();

                        // Return true to keep the changes
                        SetWindowLong(hDlg, DWL_MSGRESULT, TRUE);
                    }

                    plMaxAccelerators::Enable();
                }
                return TRUE;

            // User double-clicked.  Select the objects the selected component is attached to.
            case NM_DBLCLK:
                ISelectTreeSelection();
                return TRUE;

            case NM_RCLICK:
                IOpenRightClickMenu();
                return TRUE;
                
            case TVN_KEYDOWN:
                // User pressed delete
                if (((NMTVKEYDOWN*)lParam)->wVKey == VK_DELETE)
                {
                    IDeleteComponent(IGetTreeSelection());
                    return TRUE;
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
Пример #13
0
bool mrTwoSidedShader::mrShaderTwoSidedShader_ClassDesc::IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) {

	// Compatible only with the mental ray renderer
	return ((rendererClassDesc.ClassID() == MRRENDERER_CLASSID) != 0);
}
Пример #14
0
	// From IMtlRender_Compatibility_MtlBase
	bool IsCompatibleWithRenderer(ClassDesc& rendererClassDesc) 
	{
		// Only compatible with mental ray and harmony
		return ((rendererClassDesc.ClassID() == MRRENDERER_CLASSID) != 0);
	}
Пример #15
0
void ViewportLoader::LoadEffectsList()
{
	// loads static shader list with name-sorted Shader ClassDesc*'s
	bool bdx9 = false;

	GraphicsWindow *gw = NULL;

	ViewExp& vpt = GetCOREInterface()->GetActiveViewExp();	

	if(vpt.IsAlive())
	{
		gw = vpt.getGW();
		if(gw && gw->GetInterface(D3D9_GRAPHICS_WINDOW_INTERFACE_ID))
	{
		bdx9 = true;
	}
		
	}

	effectsList.ZeroCount();
	SubClassList* scList = GetCOREInterface()->GetDllDir().ClassDir().GetClassList(REF_TARGET_CLASS_ID);
	theHold.Suspend(); // LAM - 3/24/03 - defect 446356 - doing a DeleteThis on created effects, need to make sure hold is off
	for (long i = 0, j = 0; i < scList->Count(ACC_ALL); ++i) {
		if ( (*scList)[ i ].IsPublic() ) {
			ClassDesc* pClassD = (*scList)[ i ].CD();
			const TCHAR *cat = pClassD->Category();
			TCHAR *defcat = GetString(IDS_DX_VIEWPORT_EFFECT);
			if ((cat) && (_tcscmp(cat,defcat) == 0)) 
			{
			
				ReferenceTarget * effect = (ReferenceTarget *)pClassD->Create(TRUE);
				if(effect)
				{

					IDX9DataBridge * vp = (IDX9DataBridge*)effect->GetInterface(VIEWPORT_SHADER9_CLIENT_INTERFACE);
					if( vp)
					{
						if(bdx9)
						{
							
							if(vp->GetDXVersion() >=9.0f || vp->GetDXVersion() == 1.0f)
							{
								effectsList.Append(1, &pClassD);
							}
						}
						else
						{
							if(vp->GetDXVersion() < 9.0f)
							{
								effectsList.Append(1, &pClassD);
							}

						}
					}
					else
					{
						IDXDataBridge * vp = (IDXDataBridge*)effect->GetInterface(VIEWPORT_SHADER_CLIENT_INTERFACE);
						if(vp && !bdx9)
						{
							effectsList.Append(1, &pClassD);
						}
					}

					effect->MaybeAutoDelete();
				}
			}

		}
	}
	theHold.Resume();
	effectsList.Sort(&classDescListCompare);
}
Пример #16
0
StructuralContext::Impl::Impl(const ClassDescriptor* rootClassDesc)
    : m_rootClassDesc(rootClassDesc)
{
    list<ClassDesc> pending;
    set<ClassDesc> processed;
    pending.push_back(rootClassDesc);

    while (!pending.empty())
    {
        ClassDesc current = pending.front();
        pending.pop_front();

        if (processed.count(current))
        {
            continue;
        }

        // Class hierachy
        ClassDesc parent = current->getParentClassDescriptor();
        if (parent)
        {
            if (!processed.count(parent))
            {
                pending.push_back(parent);
            }

            m_classInfoMap[parent].subclasses.insert(current);

            ClassDesc predecessor = current;
            while ((predecessor = predecessor->getParentClassDescriptor()))
            {
                m_classInfoMap[predecessor].allSubclasses.insert(current);
            }
        }

        auto features = current->getFeatureDescriptors();

        for (auto feature : features)
        {
            auto typeDesc = feature->getTypeDescriptor();
            list<IterationItem> path;
            IterationItem item;
            item.desc = typeDesc;
            path.push_back(item);

            while (!path.empty())
            {
                IterationItem currentItem = path.front();
                auto typeDesc = currentItem.desc;
                path.pop_front();

                switch (typeDesc->getKind())
                {
                    case TypeDescriptor::kClass:
                    {
                        auto classDesc = typeDesc->as<ClassDescriptor>();
                        const Reference ref{currentItem.referenceType, current,
                                            feature, classDesc};

                        m_classInfoMap[classDesc].inReferences.push_back(ref);
                        m_classInfoMap[current].outReferences.push_back(ref);

                        m_allReferences.insert(feature);

                        pending.push_back(classDesc);
                    }
                    break;
                    case TypeDescriptor::kPointer:
                    {
                        if (currentItem.referenceType != Reference::kContained)
                        {
                            throw runtime_error("Invalid model");
                        }

                        auto ptrDesc = typeDesc->as<PointerTypeDescriptor>();
                        currentItem.desc = ptrDesc->getPointedTypeDescriptor();
                        currentItem.referenceType =
                            getReferenceType(ptrDesc->getPointerType());

                        path.push_back(currentItem);
                    }
                    break;
                    case TypeDescriptor::kPair:
                    {
                        auto pairDesc = typeDesc->as<PairTypeDescriptor>();

                        currentItem.desc = pairDesc->getFirstTypeDescriptor();
                        path.push_back(currentItem);

                        currentItem.desc = pairDesc->getSecondTypeDescriptor();
                        path.push_back(currentItem);
                    }
                    break;
                    // Containers
                    case TypeDescriptor::kList:
                    case TypeDescriptor::kMap:
                    case TypeDescriptor::kSet:
                    {
                        auto containerDesc =
                            typeDesc->as<ContainerTypeDescriptor>();
                        currentItem.desc =
                            containerDesc->getValueTypeDescriptor();
                        path.push_back(currentItem);
                    }
                    break;
                    default:
                        break;
                }
            }
        }

        processed.insert(current);
    }

    m_allClasses = {processed.begin(), processed.end()};

    // All references
    for (auto& it: m_classInfoMap)
    {
        ClassInfo& classInfo = it.second;
        for (const auto& subclass: classInfo.allSubclasses)
        {
            ClassInfo& subClassInfo = m_classInfoMap[subclass];
            subClassInfo.allOutReferences.insert(
                subClassInfo.allOutReferences.end(),
                classInfo.outReferences.begin(), classInfo.outReferences.end());
            subClassInfo.allInReferences.insert(
                subClassInfo.allInReferences.end(),
                classInfo.inReferences.begin(), classInfo.inReferences.end());
        }
    }

    for (auto& it: m_classInfoMap)
    {
        ClassInfo& classInfo = it.second;
        classInfo.allOutReferences.insert(
            classInfo.allOutReferences.end(),
            classInfo.outReferences.begin(), classInfo.outReferences.end());
        classInfo.allInReferences.insert(
            classInfo.allInReferences.end(),
            classInfo.inReferences.begin(), classInfo.inReferences.end());
    }
}
Пример #17
0
const TCHAR * ViewportLoader::GetEffectName(int i)
{

	ClassDesc* pClassD = GetEffectCD(i-1);
	return (TCHAR*)pClassD->ClassName();
}