Browse Source

Merge pull request #279 from Hoikas/max-fixes

Fix Lots of Max Issues
Branan Purvine-Riley 12 years ago
parent
commit
ad1407c75f
  1. 20
      Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp
  2. 26
      Sources/Tools/MaxComponent/Pch.h
  3. 3
      Sources/Tools/MaxComponent/plComponentBase.h
  4. 10
      Sources/Tools/MaxComponent/plComponentMgr.cpp
  5. 41
      Sources/Tools/MaxComponent/plMiscComponents.cpp
  6. 2
      Sources/Tools/MaxComponent/plMiscComponents.h
  7. 11
      Sources/Tools/MaxConvert/Pch.h
  8. 104
      Sources/Tools/MaxConvert/hsControlConverter.cpp
  9. 6
      Sources/Tools/MaxConvert/hsMaterialConverter.cpp
  10. 3
      Sources/Tools/MaxConvert/hsMaterialConverter.h
  11. 2
      Sources/Tools/MaxExport/Pch.h
  12. 28
      Sources/Tools/MaxExport/SimpleExport.cpp
  13. 10
      Sources/Tools/MaxExport/plExportDlg.cpp
  14. 41
      Sources/Tools/MaxMain/MaxCompat.h
  15. 18
      Sources/Tools/MaxMain/Pch.h
  16. 9
      Sources/Tools/MaxMain/plComponentDlg.h
  17. 3
      Sources/Tools/MaxMain/plMaxNodeBase.cpp
  18. 9
      Sources/Tools/MaxPlasmaLights/Pch.h
  19. 1
      Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h
  20. 10
      Sources/Tools/MaxPlasmaMtls/Pch.h
  21. 35
      Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp

20
Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp

@ -217,15 +217,27 @@ void plRegistryKeyList::Write(hsStream* s)
s->WriteLE32(0);
s->WriteByte(0); // Deprecated flags
s->WriteLE32(fKeys.size());
// We only write out keys with data. Fill this value in later...
uint32_t countPos = s->GetPosition();
s->WriteLE32(0);
// Write out all our keys
// Write out all our keys with data
uint32_t keyCount = 0;
for (auto it = fKeys.begin(); it != fKeys.end(); ++it)
(*it)->Write(s);
{
plKeyImp* key = *it;
if (key->ObjectIsLoaded())
{
++keyCount;
key->Write(s);
}
}
// Go back to the start and write the length of our data
// Rewind and write out data size and key count
uint32_t endPos = s->GetPosition();
s->SetPosition(beginPos);
s->WriteLE32(endPos-beginPos-sizeof(uint32_t));
s->SetPosition(countPos);
s->WriteLE32(keyCount);
s->SetPosition(endPos);
}

26
Sources/Tools/MaxComponent/Pch.h

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Standard Library
#include <algorithm>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
@ -78,6 +79,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <shlwapi.h>
#include <windowsx.h>
// 3ds Max SDK
// This stuff should ALWAYS come after hsWindows.h
#include <max.h>
#include <bmmlib.h>
#include <CS/bipexp.h>
#include <decomp.h>
#include <dummy.h>
#include <iparamm2.h>
#include <meshdlib.h>
#include <notetrck.h>
#include <notify.h>
#include <stdmat.h>
// These MaxComponent headers will trigger a rebuild if they are changed
// So it's probably best to precompile them anyway.
// Some of these may include 3dsm headers, so ensure they come after hsWindows.h
@ -102,18 +116,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "MaxMain/plMaxNode.h"
#include "MaxMain/plMaxNodeData.h"
// 3ds Max SDK
// This stuff should ALWAYS come after hsWindows.h
#include <bmmlib.h>
#include <CS/bipexp.h>
#include <decomp.h>
#include <dummy.h>
#include <iparamm2.h>
#include <meshdlib.h>
#include <notetrck.h>
#include <notify.h>
#include <stdmat.h>
#if MAX_VERSION_MAJOR >= 13
# include <INamedSelectionSetManager.h>
#endif

3
Sources/Tools/MaxComponent/plComponentBase.h

@ -45,8 +45,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h"
#include "hsWindows.h"
#include <iparamb2.h>
#include <max.h>
#include <iparamb2.h>
extern TCHAR *GetString(int id);
extern HINSTANCE hInstance;
@ -67,7 +67,6 @@ class INode;
class INodeTab;
class IObjParam;
class ObjectState;
enum IOResult;
class IParamBlock2;
enum RefResult;
class RemapDir;

10
Sources/Tools/MaxComponent/plComponentMgr.cpp

@ -102,13 +102,6 @@ int IDescCompare(ClassDesc *desc1, ClassDesc *desc2);
void plComponentMgr::Register(ClassDesc *desc)
{
// No descs? Go ahead and push it to the back...
if (fDescs.size() == 0)
{
fDescs.push_back(desc);
return;
}
// Organize desc's by category and name
std::vector<ClassDesc*>::iterator it;
for (it = fDescs.begin(); it != fDescs.end(); it++)
@ -119,6 +112,9 @@ void plComponentMgr::Register(ClassDesc *desc)
return;
}
}
// Still here? Push it to the back.
fDescs.push_back(desc);
}
int IDescCompare(ClassDesc *desc1, ClassDesc *desc2)

41
Sources/Tools/MaxComponent/plMiscComponents.cpp

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "resource.h"
#include <iparamm2.h>
#include <memory>
#include <notify.h>
#pragma hdrstop
@ -96,6 +97,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Location Related
#include "plAgeDescription/plAgeDescription.h"
#include "plFile/plEncryptedStream.h"
#include "MaxMain/plMaxCFGFile.h"
#include "MaxMain/plAgeDescInterface.h"
#include "plResMgr/plPageInfo.h"
@ -270,7 +272,7 @@ protected:
int idx = ComboBox_AddString( hAgeCombo, ageName.c_str() );
// Store the pathas the item data for later (so don't free it yet!)
ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)ageFiles[i].AsString().c_str() );
ComboBox_SetItemData( hAgeCombo, idx, (LPARAM)hsStrcpy(ageFiles[i].AsString().c_str()) );
if (ageName == curAge)
ComboBox_SetCurSel( hAgeCombo, idx );
@ -649,9 +651,9 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge));
IVerifyLatestAgeAsset( curAge, path, errMsg );
std::unique_ptr<plAgeDescription> aged(plPageInfoUtils::GetAgeDesc(curAge));
hsUNIXStream s;
if (!s.Open(path))
if (!aged)
{
errMsg->Set( true,
"PageInfo Convert Error",
@ -664,13 +666,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
return;
}
// create and read the age desc
plAgeDescription aged;
aged.Read(&s);
s.Close();
// Update based on the age file now
fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged.GetSequencePrefix() );
fCompPB->SetValue( kInfoSeqPrefix, 0, (int)aged->GetSequencePrefix() );
// Find our page
const char *compPBPageName = fCompPB->GetStr( kInfoPage );
@ -688,16 +685,16 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
}
plAgePage *page;
aged.SeekFirstPage();
aged->SeekFirstPage();
while( ( page = aged.GetNextPage() ) != nil )
while( ( page = aged->GetNextPage() ) != nil )
{
if( page->GetName().CompareI( compPBPageName ) == 0 )
{
fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() );
// Also re-copy the page name, just to make sure the case is correct
fCompPB->SetValue( kInfoPage, 0, (const char *)page->GetName().c_str() );
fCompPB->SetValue( kInfoPage, 0, const_cast<char*>(page->GetName().c_str()) );
return;
}
}
@ -790,18 +787,16 @@ plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName )
{
plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid() || ageName.IsNull())
return nil;
hsUNIXStream s;
if (!s.Open(plFileName::Join(ageFolder, ageName + ".age")))
return nil;
// Create and read the age desc
plAgeDescription *aged = new plAgeDescription;
aged->Read( &s );
s.Close();
return nullptr;
return aged;
plAgeDescription* aged = new plAgeDescription;
if (aged->ReadFromFile(plFileName::Join(ageFolder, ageName + ".age")))
return aged;
else
{
delete aged;
return nullptr;
}
}
const char* LocCompGetPage(plComponentBase* comp)

2
Sources/Tools/MaxComponent/plMiscComponents.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plMiscComponents_inc
#include "plComponent.h"
#include <notify.h>
#define ROOM_CID Class_ID(0x70a1570d, 0x472f5647)
#define PAGEINFO_CID Class_ID(0x54ee40f1, 0x4de45acc)
@ -55,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plFileName;
class plAgeDescription;
class plComponentBase;
struct NotifyInfo;
const char* LocCompGetPage(plComponentBase* comp);

11
Sources/Tools/MaxConvert/Pch.h

@ -51,7 +51,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Standard Library
#include <algorithm>
#include <float.h>
#include <functional>
#include <math.h>
#include <memory>
#include <string.h>
#include <vector>
@ -75,18 +77,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <CommCtrl.h>
#include <commdlg.h>
// MaxComponent
#include "MaxComponent/plComponent.h"
// 3ds Max SDK
// This stuff should ALWAYS come after hsWindows.h
#include <max.h>
#include <bmmlib.h>
#include <dummy.h>
#include <keyreduc.h>
#include <INode.h>
#include <iparamm2.h> // needs to be above ISkin.h for Max 7
#include <ISkin.h>
#include <istdplug.h>
#include <iparamm2.h>
#include <maxversion.h>
#include <meshdlib.h>
#include <modstack.h>
@ -94,6 +94,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <stdmat.h>
#include <texutil.h>
// MaxComponent
#include "MaxComponent/plComponent.h"
#if MAX_VERSION_MAJOR >= 13
# include <INamedSelectionSetManager.h>
#endif

104
Sources/Tools/MaxConvert/hsControlConverter.cpp

@ -40,12 +40,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <functional>
#include <math.h>
#include <memory>
#include "HeadSpin.h"
#include "hsExceptionStack.h"
#include "hsTemplates.h"
#include "hsWindows.h"
#include <commdlg.h>
#include <math.h>
#include <stdmat.h>
#include <bmmlib.h>
#include <istdplug.h>
@ -72,6 +75,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnSceneObject/plSceneObject.h"
#include "pnSceneObject/plCoordinateInterface.h"
typedef std::unique_ptr<IKey, std::function<void(IKey*)>> ikey_ptr;
/** Allocates a managed buffer to store derivatives of IKey */
static ikey_ptr IAllocKey(size_t size)
{
return ikey_ptr(
reinterpret_cast<IKey*>(new uint8_t[size]),
[](IKey* ptr) { delete[] reinterpret_cast<uint8_t*>(ptr); });
}
//////////////////////////////////////////////////////////////////////////
extern UserPropMgr gUserPropMgr;
hsControlConverter& hsControlConverter::Instance()
@ -760,7 +775,7 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con
return NULL;
}
IKey* key=(IKey*)(new uint8_t[ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
plLeafController* pc = new plLeafController;
uint8_t compressLevel = node->GetAnimCompress();
@ -776,7 +791,7 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con
for(int i = startIdx; i <= endIdx; i++)
{
// Get key
ikeys->GetKey(i, key);
ikeys->GetKey(i, key.get());
const float kMaxRads = M_PI* 0.5f;
Tab<TimeValue> kTimes;
kTimes.ZeroCount();
@ -791,12 +806,12 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con
if (keyType == hsKeyFrame::kQuatKeyFrame)
{
hsQuatKey *hsKey = pc->GetQuatKey(i - startIdx);
ICreateHSInterpKey(control, key, kTimes[k], hsKey, node, camRot);
ICreateHSInterpKey(control, key.get(), kTimes[k], hsKey, node, camRot);
}
else if (keyType == hsKeyFrame::kCompressedQuatKeyFrame64)
{
hsQuatKey tempKey;
ICreateHSInterpKey(control, key, kTimes[k], &tempKey, node, camRot);
ICreateHSInterpKey(control, key.get(), kTimes[k], &tempKey, node, camRot);
hsCompressedQuatKey64 *compKey = pc->GetCompressedQuatKey64(i - startIdx);
compKey->fFrame = tempKey.fFrame;
compKey->SetQuat(tempKey.fValue);
@ -804,14 +819,13 @@ plLeafController* hsControlConverter::ICreateQuatController(plMaxNode* node, Con
else
{
hsQuatKey tempKey;
ICreateHSInterpKey(control, key, kTimes[k], &tempKey, node, camRot);
ICreateHSInterpKey(control, key.get(), kTimes[k], &tempKey, node, camRot);
hsCompressedQuatKey32 *compKey = pc->GetCompressedQuatKey32(i - startIdx);
compKey->fFrame = tempKey.fFrame;
compKey->SetQuat(tempKey.fValue);
}
}
}
delete [] key;
return pc;
}
@ -840,22 +854,21 @@ plLeafController* hsControlConverter::ICreateScaleValueController(plMaxNode* nod
return NULL;
}
IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
plLeafController* pc = new plLeafController;
pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control));
for(int i = startIdx; i <= endIdx; i++)
{
// Get key
ikeys->GetKey(i, key);
ikeys->GetKey(i, key.get());
hsScaleKey *hsKey = pc->GetScaleKey(i - startIdx);
if (hsKey)
ICreateHSInterpKey(control, key, key->time, hsKey, node);
ICreateHSInterpKey(control, key.get(), key->time, hsKey, node);
hsBezScaleKey *bezKey = pc->GetBezScaleKey(i - startIdx);
if (bezKey)
ICreateHSInterpKey(control, key, key->time, bezKey, node);
ICreateHSInterpKey(control, key.get(), key->time, bezKey, node);
}
delete [] key;
return pc;
}
@ -881,23 +894,22 @@ plLeafController* hsControlConverter::ICreateScalarController(plMaxNode* node, C
return NULL;
}
IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
plLeafController* pc = new plLeafController;
pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control));
for(int i = startIdx; i <= endIdx; i++)
{
// Get key
ikeys->GetKey(i, key);
ikeys->GetKey(i, key.get());
hsScalarKey *hsKey = pc->GetScalarKey(i - startIdx);
if (hsKey)
ICreateHSInterpKey(control, key, key->time, hsKey);
ICreateHSInterpKey(control, key.get(), key->time, hsKey);
hsBezScalarKey *bezKey = pc->GetBezScalarKey(i - startIdx);
if (bezKey)
ICreateHSInterpKey(control, key, key->time, bezKey);
ICreateHSInterpKey(control, key.get(), key->time, bezKey);
}
delete [] key;
return pc;
}
return nil;
@ -923,22 +935,21 @@ plLeafController* hsControlConverter::ICreateSimplePosController(plMaxNode* node
return NULL;
}
IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
plLeafController* pc = new plLeafController;
pc->AllocKeys(endIdx - startIdx + 1, GetKeyType(control));
for(int i = startIdx; i <= endIdx; i++)
{
// Get key
ikeys->GetKey(i, key);
ikeys->GetKey(i, key.get());
hsPoint3Key *hsKey = pc->GetPoint3Key(i - startIdx);
if (hsKey)
ICreateHSInterpKey(control, key, key->time, hsKey);
ICreateHSInterpKey(control, key.get(), key->time, hsKey);
hsBezPoint3Key *bezKey = pc->GetBezPoint3Key(i - startIdx);
if (bezKey)
ICreateHSInterpKey(control, key, key->time, bezKey);
ICreateHSInterpKey(control, key.get(), key->time, bezKey);
}
delete [] key;
return pc;
}
@ -979,13 +990,13 @@ int hsControlConverter::IAddPartsKeys(Control* control,
//
// Traverse all keys of controller
//
IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
bool mb=false;
plMaxNode* xformParent = GetXformParent(node);
for(i = startIdx; i <= endIdx; i++)
{
// Get key
ikeys->GetKey(i, key);
ikeys->GetKey(i, key.get());
float frameTime = key->time / GetTicksPerSec();
int frameNum = key->time / GetTicksPerFrame();
hsAssert(frameNum <= hsKeyFrame::kMaxFrameNumber, "Anim is too long.");
@ -1023,7 +1034,6 @@ int hsControlConverter::IAddPartsKeys(Control* control,
// Add key to list
kfArray->Append(hKey);
}
delete [] key;
}
else
{
@ -1099,8 +1109,8 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i
IKeyControl* ikeys = GetKeyControlInterface(control);
IKey* key=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
IKey* lastKey=(IKey*)(new uint8_t [ikeys->GetKeySize()]);
ikey_ptr key = IAllocKey(ikeys->GetKeySize());
ikey_ptr lastKey = IAllocKey(ikeys->GetKeySize());
int i;
for( i = iLo; i < iHi; i++ )
@ -1120,17 +1130,17 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i
// key[i] = key[i-1] * key[i]
// or pass in the previous key and do it here.
///////////////////////////////////////
ikeys->GetKey(i-1, lastKey);
ikeys->GetKey(i, key);
ikeys->GetKey(i-1, lastKey.get());
ikeys->GetKey(i, key.get());
if( cID == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0) )
{
ITCBRotKey* tcbRotKey = (ITCBRotKey*)key;
ITCBRotKey* tcbRotKey = (ITCBRotKey*)key.get();
rads = tcbRotKey->val.angle;
}
else
if( cID == Class_ID(LININTERP_ROTATION_CLASS_ID, 0) )
{
ILinRotKey* linRotKey = (ILinRotKey*)key;
ILinRotKey* linRotKey = (ILinRotKey*)key.get();
Point3 axis;
AngAxisFromQ(linRotKey->val, &rads, axis);
@ -1138,7 +1148,7 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i
else
if( cID == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0) )
{
IBezQuatKey* bezRotKey = (IBezQuatKey*)key;
IBezQuatKey* bezRotKey = (IBezQuatKey*)key.get();
Point3 axis;
AngAxisFromQ(bezRotKey->val, &rads, axis);
@ -1146,26 +1156,26 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i
else
if( cID == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0) )
{
ITCBFloatKey* fKey = (ITCBFloatKey*)key;
ITCBFloatKey* fKey = (ITCBFloatKey*)key.get();
rads = fKey->val;
fKey = (ITCBFloatKey*)lastKey;
fKey = (ITCBFloatKey*)lastKey.get();
rads -= fKey->val;
}
else
if( cID == Class_ID(LININTERP_FLOAT_CLASS_ID, 0) )
{
ILinFloatKey* fKey = (ILinFloatKey*)key;
ILinFloatKey* fKey = (ILinFloatKey*)key.get();
rads = fKey->val;
fKey = (ILinFloatKey*)lastKey;
fKey = (ILinFloatKey*)lastKey.get();
rads -= fKey->val;
}
else
if( cID == Class_ID(HYBRIDINTERP_FLOAT_CLASS_ID, 0) )
{
IBezFloatKey* fKey = (IBezFloatKey*)key;
IBezFloatKey* fKey = (IBezFloatKey*)key.get();
rads = fKey->val;
fKey = (IBezFloatKey*)lastKey;
fKey = (IBezFloatKey*)lastKey.get();
rads -= fKey->val;
}
@ -1188,9 +1198,6 @@ void hsControlConverter::IGetControlSampleTimes(Control* control, int iLo, int i
///////////////////////////////////////
}
delete [] key;
delete [] lastKey;
hsGuardEnd;
}
@ -1443,13 +1450,13 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co
if (numKeys == 0)
return 0;
IKey* key=(IKey*)(new uint8_t [keys->GetKeySize()]);
ikey_ptr key = IAllocKey(keys->GetKeySize());
start = numKeys;
for (int i=0; i<numKeys; i++)
{
keys->GetKey(i, key);
if (IIsKeyInRange(key))
keys->GetKey(i, key.get());
if (IIsKeyInRange(key.get()))
{
if (start > i)
start = i;
@ -1464,7 +1471,7 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co
{
for (int i = 0; i < numKeys; i++)
{
keys->GetKey(i, key);
keys->GetKey(i, key.get());
if (key->time < fSegStart)
start = i;
}
@ -1472,7 +1479,6 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co
if ((start == numKeys) || // no keys before the start time
(start == numKeys - 1)) // no keys after end (since the latest key is before start)
{
delete [] key;
return 0;
}
@ -1480,17 +1486,15 @@ int32_t hsControlConverter::IGetRangeCoverKeyIndices(char* nodeName, Control* co
}
else
{
keys->GetKey(start, key);
keys->GetKey(start, key.get());
if (key->time > fSegStart && start > 0)
start -= 1;
keys->GetKey(end, key);
keys->GetKey(end, key.get());
if (key->time < fSegEnd && end < numKeys - 1)
end += 1;
}
delete [] key;
//fErrorMsg->Set(numInRange>1 && numInRange!=numKeys, nodeName ? nodeName : "?",
// "Warning: Object has controller with keyframes outside of animation interval").CheckAndAsk();

6
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -3944,7 +3944,7 @@ bool hsMaterialConverter::IClearDoneMaterial(Mtl* mtl, plMaxNode* node)
static BMM_Color_64 green64 = BMMCOLOR(0, (1<<16)-1, 0, (1<<16)-1)
BMM_Color_64 hsMaterialConverter::ICubeSample(Bitmap *bitmap[6], double phi, double theta)
static BMM_Color_64 ICubeSample(plErrorMsg* const msg, Bitmap *bitmap[6], double phi, double theta)
{
hsGuardBegin("hsMaterialConverter::ICubeSample");
@ -4024,7 +4024,7 @@ BMM_Color_64 hsMaterialConverter::ICubeSample(Bitmap *bitmap[6], double phi, dou
iMap = (int)(xMap * (map->Width()-1));
jMap = (int)(yMap * (map->Height()-1));
fErrorMsg->Set(!map, "CubeSample", "Bad fallthrough in spherefromcube").Check();
msg->Set(!map, "CubeSample", "Bad fallthrough in spherefromcube").Check();
BMM_Color_64 c;
map->GetLinearPixels(iMap,jMap,1,&c);
return c;
@ -4050,7 +4050,7 @@ void hsMaterialConverter::IBuildSphereMap(Bitmap *bitmap[6], Bitmap *bm)
phi = (0.5 + j) * delPhi;
theta = PI - (0.5 + i) * delThe;
pb[i] = ICubeSample(bitmap, phi, theta);
pb[i] = ICubeSample(fErrorMsg, bitmap, phi, theta);
}
bm->PutPixels(0,j, bm->Width(), pb);
}

3
Sources/Tools/MaxConvert/hsMaterialConverter.h

@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define __HSMATERIALCONVERTER_H
#include "HeadSpin.h"
#include <maxtypes.h>
class hsStream;
class hsScene;
@ -62,7 +63,6 @@ class plString;
class plLocation;
class Animatable;
struct BMM_Color_64;
class Bitmap;
class BitmapTex;
class Color;
@ -306,7 +306,6 @@ private:
hsGMaterial *ICheckForProjectedTexture(plMaxNode *node);
hsGMaterial *IWrapTextureInMaterial(Texmap *texMap, plMaxNode *node);
BMM_Color_64 ICubeSample(Bitmap *bitmap[6], double phi, double theta);
void IBuildSphereMap(Bitmap *bitmap[6], Bitmap *bm);
#if 0 // DEFER_ANIM_MAT
void IProcessAnimMaterial(BitmapTex *bitmapTex, hsGAnimLayer* at, uint32_t texFlags, uint32_t procFlags);

2
Sources/Tools/MaxExport/Pch.h

@ -66,10 +66,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// 3ds Max SDK
// This stuff should ALWAYS come after hsWindows.h
#include <max.h>
#include <bmmlib.h>
#include <guplib.h>
#include <iparamb2.h>
#include <max.h>
#include <notify.h>
#endif // _MaxExport_Pch_inc_

28
Sources/Tools/MaxExport/SimpleExport.cpp

@ -192,24 +192,6 @@ void HSExport2::ShowAbout(HWND hWnd)
{
}
void IGetPath(const char* name, char* path)
{
int i;
// find the last backslash in the full path
for ( i=strlen(name)-1; i>=0 ; i-- )
{
if ( name[i] == '\\' )
break;
}
if ( i >= 0 && i < 256) // if either we couldn't the backslash or the path was too big
{
strncpy(path,name,i+1);
path[i+1] = '\0'; //null terminate string (cause strncpy might not)
}
else
path[0] = '\0'; // otherwise just make it a null string
}
// Another little helper class to help write out a list of textures to a log file
class plTextureLoggerCBack : public plRegistryKeyIterator
{
@ -269,10 +251,10 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
BroadcastNotification(NOTIFY_PRE_EXPORT);
// get just the path (not the file) of where we are going to export to
char out_path[256];
IGetPath(name, out_path);
plFileName out_path = plFileName(name).StripFileName();
// Apparently this was implied by the open dialog, but not if you call Max's ExportToFile() func
SetCurrentDirectory(out_path);
SetCurrentDirectoryW(out_path.AsString().ToWchar());
//
// Setup ErrorMsg
@ -286,7 +268,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
if (dot)
*dot = 0;
char ErrorLogName[512];
sprintf(ErrorLogName, "%s%s.err", out_path, fName);
sprintf(ErrorLogName, "%s%s.err", out_path.AsString().c_str(), fName);
plExportLogErrorMsg logonly_errorMessage(ErrorLogName); // This errorMessage just writes it all to a file
// now decide which errorMessage object to use
@ -341,7 +323,7 @@ int HSExport2::DoExport(const TCHAR *name,ExpInterface *ei,Interface *gi, BOOL s
bool convertOK = plConvert::Instance().Convert();
// Free the material cache. This will delete unused materials.
hsMaterialConverter::Instance().FreeMaterialCache(out_path);
hsMaterialConverter::Instance().FreeMaterialCache(out_path.AsString().c_str());
if (convertOK)
{

10
Sources/Tools/MaxExport/plExportDlg.cpp

@ -339,22 +339,22 @@ void plExportDlgImp::IDoExport()
ShowWindow(fDlg, SW_HIDE);
// Do the export
char exportPath[MAX_PATH];
GetDlgItemText(fDlg, IDC_CLIENT_PATH, exportPath, sizeof(exportPath));
strcat(exportPath, "Export.prd");
wchar_t exportPathTEMP[MAX_PATH];
GetDlgItemTextW(fDlg, IDC_CLIENT_PATH, exportPathTEMP, arrsize(exportPathTEMP));
plFileName exportPath = plFileName::Join(plString::FromWchar(exportPathTEMP), "Export.prd");
// For export time stats
DWORD exportTime = timeGetTime();
if (fExportFile)
IExportCurrentFile(exportPath);
IExportCurrentFile(exportPath.AsString().c_str());
else
{
std::vector<plFileName> sources = plFileSystem::ListDir(fExportSourceDir, "*.max");
for (auto iter = sources.begin(); iter != sources.end(); ++iter)
{
if (GetCOREInterface()->LoadFromFile(iter->AsString().c_str()))
IExportCurrentFile(exportPath);
IExportCurrentFile(exportPath.AsString().c_str());
}
}

41
Sources/Tools/MaxMain/MaxCompat.h

@ -51,43 +51,46 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <maxversion.h>
#if MAX_VERSION_MAJOR <= 9
#define BMMCOLOR(x, y, z, w) \
{x, y, x, w};
# define BMMCOLOR(x, y, z, w) \
{x, y, x, w};
#define DEFAULTREMAP NoRemap()
# define DEFAULTREMAP NoRemap()
#define ENUMDEPENDENTS(maxObject, proc) \
maxObject->EnumDependents(proc);
# define ENUMDEPENDENTS(maxObject, proc) \
maxObject->EnumDependents(proc);
typedef TCHAR MCHAR;
typedef TCHAR MCHAR;
#else
#define BMMCOLOR(x, y, z, w) \
BMM_Color_64(x, y, z, w);
# define BMMCOLOR(x, y, z, w) \
BMM_Color_64(x, y, z, w);
#define DEFAULTREMAP DefaultRemapDir()
# define DEFAULTREMAP DefaultRemapDir()
#define ENUMDEPENDENTS(maxObject, proc) \
maxObject->DoEnumDependents(proc);
# define ENUMDEPENDENTS(maxObject, proc) \
maxObject->DoEnumDependents(proc);
#endif //MAX_VERSION_MAJOR
#if MAX_VERSION_MAJOR <= 13
#define GetParamBlock2Controller(pb, id) pb->GetController(id)
#define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetController(id, tab, ctl)
# define GetParamBlock2Controller(pb, id) pb->GetController(id)
# define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetController(id, tab, ctl)
#else
#define GetParamBlock2Controller(pb, id) pb->GetControllerByID(id)
#define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetControllerByID(id, tab, ctl)
# define GetParamBlock2Controller(pb, id) pb->GetControllerByID(id)
# define SetParamBlock2Controller(pb, id, tab, ctl) pb->SetControllerByID(id, tab, ctl)
#endif // MAX_VERSION_MAJOR
#if MAX_VERSION_MAJOR <= 11 // max 2009. Just a guess, really. 2010 doesn't need this function.
#define INIT_CUSTOM_CONTROLS(instance) InitCustomControls(instance)
# define INIT_CUSTOM_CONTROLS(instance) InitCustomControls(instance)
#else
#define INIT_CUSTOM_CONTROLS(instance)
# define INIT_CUSTOM_CONTROLS(instance)
#endif
#if MAX_VERSION_MAJOR <= 10 // Max 2008
#define GETNAME_RETURN_TYPE TCHAR*
# define GETNAME_RETURN_TYPE TCHAR*
#else
#define GETNAME_RETURN_TYPE const TCHAR*
# define GETNAME_RETURN_TYPE const TCHAR*
#endif
// Old versions of Max define this as an integer, not a Class_ID
#define XREFOBJ_COMPAT_CLASS_ID Class_ID(0x92aab38c, 0)
#endif // _PLASMA_MAXCOMPAT_H

18
Sources/Tools/MaxMain/Pch.h

@ -78,14 +78,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <comutil.h>
#include <direct.h>
// PlasmaMax Stuff included everywhere
// Some of these files may pull in Max SDK headers, so put this below hsWindows.h!
#include "plMaxNode.h"
#include "plMaxNodeData.h"
#include "MaxComponent/plComponent.h"
#include "MaxComponent/plComponentReg.h"
// Misc Max SDK
#include <max.h>
#include <bmmlib.h>
#include <CustAttrib.h>
#include <ICustAttribContainer.h>
@ -93,7 +87,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <guplib.h>
#include <iMenuMan.h>
#include <IMtlEdit.h>
#include <iskin.h>
#include <iparamb2.h> // above ISkin.h for Max 7
#include <ISkin.h>
#include <istdplug.h>
#include <maxversion.h>
#include <mnmath.h>
@ -101,6 +96,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <notify.h>
#include <pbbitmap.h>
// PlasmaMax Stuff included everywhere
// Some of these files may pull in Max SDK headers, so put this below hsWindows.h!
#include "plMaxNode.h"
#include "plMaxNodeData.h"
#include "MaxComponent/plComponent.h"
#include "MaxComponent/plComponentReg.h"
// Utility
#include "MaxCompat.h"
#include "resource.h"

9
Sources/Tools/MaxMain/plComponentDlg.h

@ -43,7 +43,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class Class_ID;
class Interface;
class plMaxNode;
struct NotifyInfo;
#include <maxversion.h>
#if MAX_VERSION_MAJOR >= 9
struct NotifyInfo;
#else
// Max headers are more minimalistic in pre-9 maxes
# include <notify.h>
#endif
class plComponentDlg
{

3
Sources/Tools/MaxMain/plMaxNodeBase.cpp

@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMaxNodeBase.h"
#include "plMaxNodeData.h"
#include "MaxComponent/plComponentBase.h"
#include "MaxCompat.h"
#include <guplib.h>
#include <iparamm2.h>
@ -483,7 +484,7 @@ bool plMaxNodeBase::IsXRef()
{
// Is this an XRef'd object?
Object *obj = GetObjectRef();
if (obj->SuperClassID() == SYSTEM_CLASS_ID && obj->ClassID() == XREFOBJ_CLASS_ID)
if (obj->SuperClassID() == SYSTEM_CLASS_ID && obj->ClassID() == XREFOBJ_COMPAT_CLASS_ID)
return true;
//

9
Sources/Tools/MaxPlasmaLights/Pch.h

@ -54,14 +54,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Windows
#include "hsWindows.h"
// Base MaxPlasmaLights stuff...
#include "plRealTimeLightBase.h"
#include "plRealTimeLights.h"
// Max SDK
#include <max.h>
#include <decomp.h>
#include <hsv.h>
// Base MaxPlasmaLights stuff...
#include "plRealTimeLightBase.h"
#include "plRealTimeLights.h"
// Utility
#include "MaxMain/MaxCompat.h"
#include "resource.h"

1
Sources/Tools/MaxPlasmaLights/plRTProjDirLight.h

@ -56,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class Class_ID;
class IParamBlock2;
struct PB2Value;
class ReferenceMaker;

10
Sources/Tools/MaxPlasmaMtls/Pch.h

@ -59,15 +59,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <commdlg.h>
#include <windowsx.h>
// MaxMain
#include "MaxMain/plMaxNode.h"
#include "MaxMain/MaxCompat.h"
// Misc 3dsm SDK
#include <max.h>
#include <bmmlib.h>
#include <iparamm2.h>
#include <istdplug.h>
#include <max.h>
#include <maxicon.h>
#include <notetrck.h>
#include <notify.h>
@ -75,6 +71,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <texutil.h>
#include <triobj.h>
// MaxMain
#include "MaxMain/plMaxNode.h"
#include "MaxMain/MaxCompat.h"
// Local
#include "resource.h"

35
Sources/Tools/MaxPlasmaMtls/plBinkBitmap.cpp

@ -42,18 +42,43 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsWindows.h"
#include <bmmlib.h>
#include <iparamb2.h>
#pragma hdrstop
class BinkClassDesc : public ClassDesc2
/** Stubbed out BitmapIO instance for deprecated bink layers **/
class plBinkBitmapIO : public BitmapIO
{
public:
int IsPublic() { return 1; }
void* Create(BOOL loading=FALSE)
int ExtCount() { return 1; }
const TCHAR* Ext(int n) { return _T("bik"); }
const TCHAR* LongDesc() { return _T("DEAD: Bink File"); }
const TCHAR* ShortDesc() { return _T("Bink"); }
const TCHAR* AuthorName() { return _T("Colin Bonstead"); }
const TCHAR* CopyrightMessage() { return _T("Copyright 2004, Cyan Inc."); }
unsigned int Version() { return 100; }
int Capability() { return 0; }
DWORD EvaluateConfigure() { return 0; }
BOOL LoadConfigure(void* ptr) { return FALSE; }
BOOL SaveConfigure(void* ptr) { return FALSE; }
BMMRES GetImageInfo(BitmapInfo* fbi) { return BMMRES_INTERNALERROR; }
BitmapStorage* Load(BitmapInfo* fbi, Bitmap* map, BMMRES* status) { return nullptr; }
void ShowAbout(HWND hWnd)
{
hsAssert(false, "bink layers removed due to license issues");
return nil;
hsMessageBoxWithOwner(hWnd, "Bink Layers removed due to license issues", "DEAD", hsMessageBoxNormal, MB_ICONEXCLAMATION);
}
};
class BinkClassDesc : public ClassDesc2
{
public:
int IsPublic() { return 1; }
void* Create(BOOL loading=FALSE) { return static_cast<void*>(new plBinkBitmapIO); }
const TCHAR* ClassName() { return "Bink"; }
SClass_ID SuperClassID() { return BMM_IO_CLASS_ID; }

Loading…
Cancel
Save