Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / Plugins - Extensions / update 3ds max plugin without restarting 3ds max 2008
  RSS 2.0 ATOM  

update 3ds max plugin without restarting 3ds max 2008
Rate this thread
 
22928
 
Permlink of this thread  
avatar
  • akira32
  • Posted: 17 February 2009 09:45 PM
  • Location: Taipei
  • Total Posts: 41
  • Joined: 13 February 2009 06:07 AM

I read a chinese book called “全方位3D遊戲設計 遊戲引擎與遊戲開發實例剖析” (http://tlsj.tenlong.com.tw/WebMo...isbn=9861256806&sid=28330). In this book’s section 10-4-7, it support a skill about run the modified plugin (export) without restarting 3ds max 2008. Divide the origin 3ds max plugin into main plugin and the function for exporting(to e anothor DLL). When 3ds max start and load the main plugin, the main plugin will load the another DLL has only exporting function and DllMain. I test the moethod and the flow is correct. But I have a serious problem when the main plugin ends, the 3ds max 2008 will crack and show the exception likes the picture(3ds%20max%20two%20plugin%20error.JPG). And break in assemble code as below:

0049CA49  push        0    
0049CA4B  call        ebp  
0049CA4D  push        eax  
0049CA4E  call        dword ptr ds
:[7DFB68h] 
0049CA54  mov         eax
,dword ptr [edi] 
0049CA56  mov         edx
,dword ptr [eax] <===break here
0049CA58  mov         ebp
,
0049CA5D  push        ebp  
0049CA5E  mov         ecx
,edi 
0049CA60  call        edx

The main plugin partial source code as below:

int    maxProject1::DoExport(const TCHAR *name,ExpInterface *ei,Interface *iBOOL suppressPromptsDWORD options)
{
    typedef int 
(CALLBACKD_MYEXPORT)(const TCHAR*,ExpInterface*,Interface*,BOOL,DWORD);

    
HMODULE l_mod;
    
D_MYEXPORT l_export=NULL;
    
int l_ret=0;

    
l_mod=LoadLibrary("plugins_akira\\2\\maxProject2.dll");

    if (
l_mod!=NULL)
    
{
        l_export
=(D_MYEXPORT)GetProcAddress(l_mod,"fDoExport");
        
l_ret=l_export(name,ei,i,suppressPrompts,options);

        
FreeLibrary(l_mod);
    
}

    
return TRUE;//FALSE
}

The source code of another DLL for exporting data as below:

#include "maxProject2.h"
#include "resource.h"

HINSTANCE g_hInstance;

BOOL APIENTRY DllMainHANDLE hModule
                      
DWORD  ul_reason_for_call
                      
LPVOID lpReserved
                      
)
{
    
// cache the DLL instance handle
    
g_hInstance = (HINSTANCE)hModule;

    return 
TRUE;
}

///////////////////////////////////////////////////////////////////////////////
// Translate 3DS Data
///////////////////////////////////////////////////////////////////////////////


static BOOL CALLBACK SettingDlgProc(HWND hwndUINT msgWPARAM wParamLPARAM lParam)
{
    
//static maxProject2 *imp = NULL;

    
switch(msg{
        
case WM_INITDIALOG:
            
//imp = (maxProject2 *)lParam;
            
CenterWindow(hwnd,GetParent(hwnd));
            return 
TRUE;

        case 
WM_COMMAND:
            if (
LOWORD(wParam)==IDCANCEL || LOWORD(wParam)==IDOK)
            
{
                EndDialog
(hwnd0);
                return 
TRUE;
            
}
            
break;

        case 
WM_CLOSE:
            
EndDialog(hwnd0);
            return 
TRUE;

        default:
            return 
FALSE;
    
}
    
    
return TRUE;
}

/**
Receive Data from 3DS Plugin
*/
extern "C" __declspec(dllexportint fDoExport(const TCHAR *name
                                               
ExpInterface *ei
                                               Interface *
i
                                               
BOOL suppressPrompts
                                               
DWORD options)
{
    
// Show Setting Dialog
    //HWND mother=i->GetMAXHWnd();
    
if(DialogBoxParam(g_hInstanceMAKEINTRESOURCE(IDD_SETTING), GetActiveWindow(), SettingDlgProcNULL) == TRUE{
        
//Do Data Export
    
}
    
else
    
{
        
// No Data Export
    
}

    
return TRUE;
}

Colud somebody meet the same problem or has the solution? Or another better method?

PS:
I put my source code about the two plugin in the website of “http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/3ds%20max%20Plugin%20Two%20Project%20Q1.zip”



akira32 編程之家 Yahoo

Attachment Attachment
Replies: 0