requirements…
3ds max
sdk installed for the max version you want to extend for
[and the correct version of microsoft visual studio](http://help.autodesk.com/view/3DSMAX/2015/ENU/?guid=__files_GUID_6E179A56_5552_4D0B_BA61_BBD37B9E52DB_htm)
1. go to \Autodesk\<max version> SDK\maxsdk\samples\maxscript\mxsagni
2. double click on mxsagni.vcproj this should open the mxsagni project in visual studio
3. in the solution configurations drop down in the main toobar select [b]Release [/b]from the menu (should be displaying Debug when you start) if you doing a x64 build you'll need to change Solution Platforms dropdown from Win32 to x64.
4. From the solution explorer/Source Files open the file avg_DLX.cpp
5. Copy the following Code
def_visible_primitive(MtlPreviewToBitmap, "MtlPreviewToBitmap");
Value* MtlPreviewToBitmap_cf(Value** arg_list, int count)
{
check_arg_count(MtlPreviewToBitmap, 2, count);
MtlBase* mb = arg_list[0]->to_mtlbase();
int sz = arg_list[1]->to_int();
PStamp *ps = mb->CreatePStamp(sz,1);
if(ps)
{
int d = PSDIM(sz);
int scanw = ByteWidth(d);
int nb = scanw*d;
UBYTE *buf = new UBYTE[nb + sizeof(BITMAPINFOHEADER)];
if(!buf)
&undefined;
// get the image data
ps->GetImage(&buf[sizeof(BITMAPINFOHEADER)]);
// and create the header info
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)buf;
bih->biSize = sizeof(BITMAPINFOHEADER);
bih->biWidth = d;
bih->biHeight = d;
bih->biPlanes = 1;
bih->biBitCount = 24;
bih->biCompression = BI_RGB;
bih->biSizeImage = 0;
Bitmap *map = TheManager->Create((PBITMAPINFO)buf);
delete [] buf;
if(map)
{
one_typed_value_local(MAXBitMap* mbm);
vl.mbm = new MAXBitMap();
vl.mbm->bi.CopyImageInfo(&map->Storage()->bi);
vl.mbm->bi.SetFirstFrame(0);
vl.mbm->bi.SetLastFrame(0);
vl.mbm->bi.SetName("");
vl.mbm->bi.SetDevice("");
if(vl.mbm->bi.Type() > BMM_TRUE_64)
vl.mbm->bi.SetType(BMM_TRUE_64);
vl.mbm->bm = map;
return_value(vl.mbm);
}
}
return &undefined;
}
or other more useful bits of code just before other stuff can be found here
// =================================================
// Spline methods
// =================================================
6. press F7 to build the solution
7. if the Output window displays the following all is good
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Otherwise there are compiler issues, eg a coding syntax error or linker errors.
8. goto the folder Autodesk<Max Version> SDK\exe\stdplugs and copy the file MXSAgni.dlx to \Autodesk<Max Version>\stdplugs. You can back up the original or rename it to MXSAgni.bak or something.
9. restart max
10. run the following from the MXS listener.
display (MtlPreviewToBitmap (getMeditMaterial 1) 0)
11. remember to add [b]MXSAgni.dlx [/b]to any redistributables.