diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/detailobjects.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'hammer/detailobjects.h')
| -rw-r--r-- | hammer/detailobjects.h | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/hammer/detailobjects.h b/hammer/detailobjects.h new file mode 100644 index 0000000..332c775 --- /dev/null +++ b/hammer/detailobjects.h @@ -0,0 +1,164 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef DETAILOBJECTS_H +#define DETAILOBJECTS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "mathlib/mathlib.h" +#include "datamap.h" +#include "bspfile.h" +#include "builddisp.h" +#include "mapface.h" +#include "mapdisp.h" +#include "utlsymbol.h" +#include "sprite.h" +#include "studiomodel.h" + +//============================================================================= +// DetailObjects:: class +//============================================================================= + +class DetailObjects : public CMapPoint +{ +// Comparators Functions for initialized member lists + + // Error checking.. make sure the model is valid + is a static prop + struct StaticPropLookup_t + { + CUtlSymbol m_ModelName; + bool m_IsValid; + }; + + // Comparator for static property sorting + + static bool StaticLess( StaticPropLookup_t const& src1, StaticPropLookup_t const& src2 ) + { + return src1.m_ModelName < src2.m_ModelName; + } + +//----------------------------------------------------------------------------- +// Contructors / Destructors +//----------------------------------------------------------------------------- +public: + DetailObjects() {} + ~DetailObjects(); + +//----------------------------------------------------------------------------- +// Internal Constants & Data Structures +//----------------------------------------------------------------------------- +protected: + enum { DETAIL_NAME_LENGTH = 128 }; + + enum DetailPropOrientation_t + { + DETAIL_PROP_ORIENT_NORMAL = 0, + DETAIL_PROP_ORIENT_SCREEN_ALIGNED, + DETAIL_PROP_ORIENT_SCREEN_ALIGNED_VERTICAL, + }; + + // NOTE: If DetailPropType_t enum changes, change CDetailModel::QuadsToDraw + // in detailobjectsystem.cpp + enum DetailPropType_t + { + DETAIL_PROP_TYPE_MODEL = 0, + DETAIL_PROP_TYPE_SPRITE, + DETAIL_PROP_TYPE_SHAPE_CROSS, + DETAIL_PROP_TYPE_SHAPE_TRI, + }; + + // Information about particular detail object types + enum + { + MODELFLAG_UPRIGHT = 0x1, + }; + + class DetailModel_t + { + public: + DetailModel_t(); + CUtlSymbol m_ModelName; + float m_Amount; + float m_MinCosAngle; + float m_MaxCosAngle; + int m_Flags; + int m_Orientation; + int m_Type; + Vector2D m_Pos[2]; + Vector2D m_Tex[2]; + float m_flRandomScaleStdDev; + unsigned char m_ShapeSize; + unsigned char m_ShapeAngle; + unsigned char m_SwayAmount; + }; + + struct DetailObjectGroup_t + { + float m_Alpha; + CUtlVector< DetailModel_t > m_Models; + }; + + struct DetailObject_t + { + CUtlSymbol m_Name; + float m_Density; + CUtlVector< DetailObjectGroup_t > m_Groups; + + bool operator==(const DetailObject_t& src ) const + { + return src.m_Name == m_Name; + } + }; + + +//----------------------------------------------------------------------------- +// Publically callable interfaces +//----------------------------------------------------------------------------- +public: + static void LoadEmitDetailObjectDictionary( char const* pGameDir ); + static void BuildAnyDetailObjects(CMapFace *); + static void EnableBuildDetailObjects( bool bBuild ); // This is used to delay building detail objects until the + // end of the map load. Prevents it from generating the + // detail objects 3x more often than necessary. + + void Render3D( CRender3D* pRender ); + bool ShouldRenderLast(void); + +//----------------------------------------------------------------------------- +// Internal Helper Functions +//----------------------------------------------------------------------------- +protected: + static const char *FindDetailVBSPName( void ); + static void ParseDetailObjectFile( KeyValues& keyValues ); + static void ParseDetailGroup( int detailId, KeyValues* pGroupKeyValues ); + + bool LoadStudioModel( char const* pFileName, char const* pEntityType, CUtlBuffer& buf ); + float ComputeDisplacementFaceArea( CMapFace *pMapFace ); + int SelectGroup( const DetailObject_t& detail, float alpha ); + int SelectDetail( DetailObjectGroup_t const& group ); + void PlaceDetail( DetailModel_t const& model, const Vector& pt, const Vector& normal ); + void EmitDetailObjectsOnFace( CMapFace *pMapFace, DetailObject_t& detail ); + void EmitDetailObjectsOnDisplacementFace( CMapFace *pMapFace, DetailObject_t& detail ); + + void AddDetailSpriteToFace( const Vector &vecOrigin, const QAngle &vecAngles, DetailModel_t const& model, float flScale ); + void AddDetailModelToFace( const char* pModelName, const Vector& pt, const QAngle& angles, int nOrientation ); + + + +//----------------------------------------------------------------------------- +// Protected Data Members +//----------------------------------------------------------------------------- + + static CUtlVector<DetailObject_t> s_DetailObjectDict; // static members? + static bool s_bBuildDetailObjects; + + CUtlVector<CSpriteModel *> m_DetailSprites; + CUtlVector<StudioModel *> m_DetailModels; +}; + +#endif // DETAILOBJECTS_H |