You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

448 lines
21 KiB

/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plMaxNodeData_inc
#define plMaxNodeData_inc
#include "hsBitVector.h"
#include "plLoadMask.h"
#include "plPhysicalProps.h"
#include "hsTemplates.h"
class hsGMesh;
class plGeometrySpan;
class plLocation;
class plKey;
class plMaxBoneMap;
class plMaxNode;
class plMaxNodeBase;
class plSceneObject;
class plSharedMesh;
class plMaxNodeBaseTab : public Tab<plMaxNodeBase*>
{
};
//
// Created hoping to trim some fat so to speak for all the bools that
// we are tossing around.
//
class DataBF
{
public:
enum DatBit
{
kCanConvert = 0x0,
kForceLocal,
kDrawable, // Absence of this prop forbids making this drawable
kBlendToFB,
kItinerant,
kRunTimeLight,
kMovable,
kIsBarney,
kForceMatCopy,
kNoPreShade,
kIsInstanced,
kParticleRelated,
kNoSpanReSort,
kHasFade,
kNoFaceSort,
kNoSpanSort,
kNoDeferDraw,
kBLevelSet,
kOLevelSet,
kDup2Sided,
kRadiateNorms,
kGeoDice,
kForcePreShade,
kIsGUI,
kSwappableGeomTarget,
kNoShadow,
kForceShadow,
kFilterInherit,
kReverseSort,
kVS,
kConcave,
kCalcEdgeLens,
kEnviron,
kEnvironOnly,
kPhysical, // Absence of this prop forbids making this physical
kSmoothAll,
kForceSortable,
kOverrideHighLevelSDL,
kDisableNormal,
kHasLoadMask,
kWaterDecEnv,
kWaterHeight,
kAlphaTestHigh,
kForceMatShade,
kUnBounded,
kForceVisLOS,
kSortAsOpaque,
};
hsBitVector* fBitVector;
DataBF()
{
fBitVector = new hsBitVector;
fBitVector->SetBit(kDrawable);
fBitVector->SetBit(kPhysical);
}
virtual ~DataBF() { delete fBitVector; }
DataBF& operator=(const DataBF& ot)
{
*fBitVector = *ot.fBitVector;
return *this;
}
DataBF(const DataBF& ot)
{
fBitVector = new hsBitVector;
*fBitVector = *ot.fBitVector;
}
void Init()
{
fBitVector = new hsBitVector;
fBitVector->SetBit(kDrawable);
fBitVector->SetBit(kPhysical);
}
void DeInit() { delete fBitVector; fBitVector = nil; }
12 years ago
bool CanBF(DatBit bitChoice) { return fBitVector->IsBitSet(bitChoice); }
void SetBF(bool b, DatBit bitChoice) { fBitVector->SetBit(bitChoice, b); }
};
class plMaxNodeData
{
public:
plMaxNodeData() :
fpKey(nil),
fpSO(nil) ,
fDecalLevel(0),
fpMesh(nil),
fpRoomKey(nil),
fSoundIdxCounter( 0 ),
fAvatarSO(nil),
fFade(Point3(0,0,0), Point3(0,0,0)),
fNormalChan(0),
fWaterHeight(0),
fGDMaxFaces(0), fGDMaxSize(0), fGDMinFaces(0),
fSwapMesh(nil),
fSwapTargetID((uint32_t)-1),
fCachedAlphaHackLayerCounts(nil),
fBoneMap(nil),
fAnimCompression(1), // Should be plAnimCompressComp::kCompressionLow,
// but I don't want to include the entire header.
fKeyReduceThreshold(0.0002)
{ }
~plMaxNodeData()
{
fpKey = nil;
fpRoomKey = nil;
fpSO = 0;
fAvatarSO = nil;
delete fCachedAlphaHackLayerCounts;
MaxDatBF.DeInit();
}
// Call init on MaxNodeData whose constructor was never called, e.g. if it was malloc'd.
plMaxNodeData& Init()
{
memset( &fpKey, 0, sizeof( plKey ) );
memset( &fpRoomKey, 0, sizeof( plKey ) );
fRenderDependencies.Init();
fBones.Init();
fCachedAlphaHackLayerCounts = nil;
MaxDatBF.Init();
return *this;
}
// Ditto
void DeInit( void )
{
fpKey = nil;
fpRoomKey = nil;
fpSO = 0; fAvatarSO = nil;
delete fCachedAlphaHackLayerCounts;
fCachedAlphaHackLayerCounts = nil;
MaxDatBF.DeInit();
}
plKey GetKey() { return fpKey; }
void SetKey(plKey p ) { fpKey = p; }
plSceneObject * GetSceneObject() { return fpSO; }
void SetSceneObject(plSceneObject *p) { fpSO = p; }
12 years ago
bool CanConvert() { return MaxDatBF.CanBF(MaxDatBF.kCanConvert); }
void SetCanConvert(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kCanConvert); }
12 years ago
bool GetForceLocal() { return MaxDatBF.CanBF(MaxDatBF.kForceLocal); }
void SetForceLocal(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceLocal); }
void * GetMesh() { return fpMesh; } // void pointer for header simplicity
void SetMesh(hsGMesh *p) { fpMesh = p; }
12 years ago
bool GetDrawable() {return MaxDatBF.CanBF(MaxDatBF.kDrawable); }
void SetDrawable(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kDrawable); }
12 years ago
bool GetPhysical() {return MaxDatBF.CanBF(MaxDatBF.kPhysical); }
void SetPhysical(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kPhysical); }
12 years ago
bool GetRunTimeLight() {return MaxDatBF.CanBF(MaxDatBF.kRunTimeLight); }
void SetRunTimeLight(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kRunTimeLight); }
12 years ago
bool GetForceMatShade() {return MaxDatBF.CanBF(MaxDatBF.kForceMatShade); }
void SetForceMatShade(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceMatShade); }
12 years ago
bool GetForceVisLOS() {return MaxDatBF.CanBF(MaxDatBF.kForceVisLOS); }
void SetForceVisLOS(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceVisLOS); }
12 years ago
bool GetEnviron() {return MaxDatBF.CanBF(MaxDatBF.kEnviron); }
void SetEnviron(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kEnviron); }
12 years ago
bool GetEnvironOnly() {return MaxDatBF.CanBF(MaxDatBF.kEnvironOnly); }
void SetEnvironOnly(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kEnvironOnly); }
12 years ago
bool GetWaterDecEnv() { return MaxDatBF.CanBF(MaxDatBF.kWaterDecEnv); }
void SetWaterDecEnv(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kWaterDecEnv); }
12 years ago
bool GetItinerant() {return MaxDatBF.CanBF(MaxDatBF.kItinerant); }
void SetItinerant(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kItinerant); }
12 years ago
bool GetUnBounded() {return MaxDatBF.CanBF(MaxDatBF.kUnBounded); }
void SetUnBounded(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kUnBounded); }
12 years ago
bool GetDisableNormal() {return MaxDatBF.CanBF(MaxDatBF.kDisableNormal); }
void SetDisableNormal(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kDisableNormal); }
12 years ago
bool GetMovable() {return MaxDatBF.CanBF(MaxDatBF.kMovable); }
void SetMovable(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kMovable); }
12 years ago
bool GetNoPreShade() {return MaxDatBF.CanBF(MaxDatBF.kNoPreShade); }
void SetNoPreShade(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoPreShade); }
12 years ago
bool GetForcePreShade() {return MaxDatBF.CanBF(MaxDatBF.kForcePreShade); }
void SetForcePreShade(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForcePreShade); }
12 years ago
bool GetNoShadow() {return MaxDatBF.CanBF(MaxDatBF.kNoShadow); }
void SetNoShadow(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoShadow); }
12 years ago
bool GetForceShadow() {return MaxDatBF.CanBF(MaxDatBF.kForceShadow); }
void SetForceShadow(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceShadow); }
12 years ago
bool GetAlphaTestHigh() {return MaxDatBF.CanBF(MaxDatBF.kAlphaTestHigh); }
void SetAlphaTestHigh(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kAlphaTestHigh); }
12 years ago
bool GetFilterInherit() {return MaxDatBF.CanBF(MaxDatBF.kFilterInherit); }
void SetFilterInherit(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kFilterInherit); }
12 years ago
bool GetIsBarney() {return MaxDatBF.CanBF(MaxDatBF.kIsBarney); }
void SetIsBarney(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kIsBarney); }
12 years ago
bool GetNoSpanSort() {return MaxDatBF.CanBF(MaxDatBF.kNoSpanSort); }
void SetNoSpanSort(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoSpanSort); }
12 years ago
bool GetNoSpanReSort() {return MaxDatBF.CanBF(MaxDatBF.kNoSpanReSort); }
void SetNoSpanReSort(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoSpanReSort); }
12 years ago
bool GetNoFaceSort() {return MaxDatBF.CanBF(MaxDatBF.kNoFaceSort); }
void SetNoFaceSort(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoFaceSort); }
12 years ago
bool GetReverseSort() {return MaxDatBF.CanBF(MaxDatBF.kReverseSort); }
void SetReverseSort(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kReverseSort); }
12 years ago
bool GetSortAsOpaque() {return MaxDatBF.CanBF(MaxDatBF.kSortAsOpaque); }
void SetSortAsOpaque(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kSortAsOpaque); }
12 years ago
bool GetVS() {return MaxDatBF.CanBF(MaxDatBF.kVS); }
void SetVS(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kVS); }
12 years ago
bool GetHasWaterHeight() { return MaxDatBF.CanBF(MaxDatBF.kWaterHeight); }
void SetHasWaterHeight(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kWaterHeight); }
float GetWaterHeight() { return fWaterHeight; }
void SetWaterHeight(float f) { SetHasWaterHeight(true); fWaterHeight = f; }
12 years ago
bool GetSmoothAll() {return MaxDatBF.CanBF(MaxDatBF.kSmoothAll); }
void SetSmoothAll(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kSmoothAll); }
12 years ago
bool GetForceSortable() {return MaxDatBF.CanBF(MaxDatBF.kForceSortable); }
void SetForceSortable(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceSortable); }
12 years ago
bool GetConcave() {return MaxDatBF.CanBF(MaxDatBF.kConcave); }
void SetConcave(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kConcave); }
12 years ago
bool GetCalcEdgeLens() {return MaxDatBF.CanBF(MaxDatBF.kCalcEdgeLens); }
void SetCalcEdgeLens(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kCalcEdgeLens); }
12 years ago
bool GetNoDeferDraw() {return MaxDatBF.CanBF(MaxDatBF.kNoDeferDraw); }
void SetNoDeferDraw(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kNoDeferDraw); }
12 years ago
bool GetBlendToFB() {return MaxDatBF.CanBF(MaxDatBF.kBlendToFB); }
void SetBlendToFB(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kBlendToFB); }
12 years ago
bool GetForceMaterialCopy() {return MaxDatBF.CanBF(MaxDatBF.kForceMatCopy); }
void SetForceMaterialCopy(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kForceMatCopy); }
12 years ago
bool GetInstanced() {return MaxDatBF.CanBF(MaxDatBF.kIsInstanced); }
void SetInstanced(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kIsInstanced); }
12 years ago
bool GetParticleRelated() {return MaxDatBF.CanBF(MaxDatBF.kParticleRelated); }
void SetParticleRelated(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kParticleRelated); }
12 years ago
bool GetDup2Sided() {return MaxDatBF.CanBF(MaxDatBF.kDup2Sided); }
void SetDup2Sided(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kDup2Sided); }
12 years ago
bool GetRadiateNorms() {return MaxDatBF.CanBF(MaxDatBF.kRadiateNorms); }
void SetRadiateNorms(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kRadiateNorms); }
12 years ago
bool GetGeoDice() {return MaxDatBF.CanBF(MaxDatBF.kGeoDice); }
void SetGeoDice(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kGeoDice); }
12 years ago
bool GetIsGUI() {return MaxDatBF.CanBF(MaxDatBF.kIsGUI); }
void SetIsGUI(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kIsGUI); }
plSharedMesh* GetSwappableGeom() { return fSwapMesh;}
void SetSwappableGeom(plSharedMesh *sm) { fSwapMesh = sm; }
uint32_t GetSwappableGeomTarget() { return fSwapTargetID;}
void SetSwappableGeomTarget(uint32_t id) { fSwapTargetID = id;}
plMaxBoneMap* GetBoneMap() { return fBoneMap;}
void SetBoneMap(plMaxBoneMap *bones) { fBoneMap = bones;}
int GetGeoDiceMaxFaces() { return fGDMaxFaces; }
void SetGeoDiceMaxFaces(int f) { fGDMaxFaces = f; }
float GetGeoDiceMaxSize() { return fGDMaxSize; }
void SetGeoDiceMaxSize(float f) { fGDMaxSize = f; }
int GetGeoDiceMinFaces() { return fGDMinFaces; }
void SetGeoDiceMinFaces(int f) { fGDMinFaces = f; }
plKey GetRoomKey() { return fpRoomKey; }
void SetRoomKey(plKey p) { fpRoomKey = p; }
uint32_t GetDecalLevel() { return fDecalLevel; }
void SetDecalLevel(uint32_t i) { fDecalLevel = i; }
uint32_t GetSoundIdxCounter() { return fSoundIdxCounter; }
void SetSoundIdxCounter( uint32_t i ) { fSoundIdxCounter = i; }
plSceneObject * GetAvatarSO() { return fAvatarSO; }
void SetAvatarSO(plSceneObject *so) { fAvatarSO = so; }
int NumRenderDependencies() { return fRenderDependencies.Count(); }
plMaxNodeBase* GetRenderDependency(int i) { return fRenderDependencies[i]; }
void AddRenderDependency(plMaxNodeBase* m) { fRenderDependencies.Append(1, &m); }
void ClearRenderDependencies() { fRenderDependencies.ZeroCount(); }
int NumBones() { return fBones.Count(); }
plMaxNodeBase* GetBone(int i) { return fBones[i]; }
void AddBone(plMaxNodeBase* m) { fBones.Append(1, &m); }
void ClearBones() { fBones.ZeroCount(); }
12 years ago
bool HasFade() { return MaxDatBF.CanBF(MaxDatBF.kHasFade); }
void SetFade(const Box3& b) { MaxDatBF.SetBF((b.Min()[2] != 0)||(b.Max()[2] != 0), MaxDatBF.kHasFade); fFade = b; }
Box3 GetFade() { return fFade; }
12 years ago
bool HasLoadMask() { return MaxDatBF.CanBF(MaxDatBF.kHasLoadMask); }
plLoadMask GetLoadMask() { return HasLoadMask() ? fLoadMask : plLoadMask::kAlways; }
void AddLoadMask(const plLoadMask& m) { if( !HasLoadMask() ) { fLoadMask = m; MaxDatBF.SetBF(true, MaxDatBF.kHasLoadMask); }else{ fLoadMask |= m; } }
12 years ago
bool HasNormalChan() { return fNormalChan > 0; }
void SetNormalChan(int n) { fNormalChan = n; }
int GetNormalChan() { return fNormalChan; }
12 years ago
bool BlendLevelSet() { return MaxDatBF.CanBF(MaxDatBF.kBLevelSet); }
void SetBlendLevel(const plRenderLevel& l) { fBlendLevel = l; MaxDatBF.SetBF(true, MaxDatBF.kBLevelSet); }
const plRenderLevel& GetBlendLevel() { return fBlendLevel; }
12 years ago
bool OpaqueLevelSet() { return MaxDatBF.CanBF(MaxDatBF.kOLevelSet); }
void SetOpaqueLevel(const plRenderLevel& l) { fOpaqueLevel = l; MaxDatBF.SetBF(true, MaxDatBF.kOLevelSet); }
const plRenderLevel& GetOpaqueLevel() { return fOpaqueLevel; }
plPhysicalProps* GetPhysicalProps() { return &fPhysicalProps; }
hsTArray<int> *GetAlphaHackLayersCache( void ) { return fCachedAlphaHackLayerCounts; }
void SetAlphaHackLayersCache( hsTArray<int> *cache ) { fCachedAlphaHackLayerCounts = cache; }
12 years ago
bool GetOverrideHighLevelSDL() { return MaxDatBF.CanBF(MaxDatBF.kOverrideHighLevelSDL); }
void SetOverrideHighLevelSDL(bool b) { MaxDatBF.SetBF(b, MaxDatBF.kOverrideHighLevelSDL); }
uint8_t GetAnimCompress() { return fAnimCompression; }
void SetAnimCompress(uint8_t v) { fAnimCompression = v; }
float GetKeyReduceThreshold() { return fKeyReduceThreshold; }
void SetKeyReduceThreshold(float v) { fKeyReduceThreshold = v; }
protected:
plKey fpKey;
plSceneObject * fpSO;
// hacking this in here temporarily because everything's about to change in the mesh world...
hsGMesh* fpMesh;
plKey fpRoomKey;
uint32_t fDecalLevel;
int32_t fNormalChan;
uint32_t fSoundIdxCounter;
plSceneObject * fAvatarSO;
plMaxNodeBaseTab fRenderDependencies;
plMaxNodeBaseTab fBones;
Box3 fFade;
int fGDMaxFaces;
float fGDMaxSize;
int fGDMinFaces;
plRenderLevel fBlendLevel;
plRenderLevel fOpaqueLevel;
plPhysicalProps fPhysicalProps;
uint32_t fSwapTargetID;
hsTArray<int> *fCachedAlphaHackLayerCounts;
plSharedMesh *fSwapMesh;
plMaxBoneMap *fBoneMap;
plLoadMask fLoadMask;
float fWaterHeight;
uint8_t fAnimCompression;
float fKeyReduceThreshold;
DataBF MaxDatBF;
};
#endif // plSimpleConvert_inc