Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.57 KB | None | 0 0
  1. #pragma once
  2. //========= Copyright Valve Corporation, All rights reserved. ============//
  3. //
  4. // Purpose:
  5. //
  6. // $NoKeywords: $
  7. //
  8. //===========================================================================//
  9.  
  10. //-----------------------------------------------------------------------------
  11. // forward declaraions
  12. //-----------------------------------------------------------------------------
  13.  
  14. class IMaterialVar;
  15. class ITexture;
  16. class IMaterialProxy;
  17. class Vector;
  18.  
  19. #ifndef CONCAT_IMPL
  20. #define CONCAT_IMPL(x, y) x##y
  21. #ifndef MACRO_CONCAT
  22. #define MACRO_CONCAT(x, y) CONCAT_IMPL(x, y)
  23. #ifndef PAD
  24. #define PAD(SIZE) BYTE MACRO_CONCAT(_pad, __COUNTER__)[SIZE];
  25. #endif
  26. #endif
  27. #endif
  28. class KeyValuesv2 {
  29. public:
  30. PAD(32)
  31. };
  32.  
  33. //-----------------------------------------------------------------------------
  34. // Flags for GetVertexFormat
  35. //-----------------------------------------------------------------------------
  36. #define VERTEX_POSITION 0x0001
  37. #define VERTEX_NORMAL 0x0002
  38. #define VERTEX_COLOR 0x0004
  39. #define VERTEX_SPECULAR 0x0008
  40.  
  41. #define VERTEX_TANGENT_S 0x0010
  42. #define VERTEX_TANGENT_T 0x0020
  43. #define VERTEX_TANGENT_SPACE ( VERTEX_TANGENT_S | VERTEX_TANGENT_T )
  44.  
  45. // Indicates we're using wrinkle
  46. #define VERTEX_WRINKLE 0x0040
  47.  
  48. // Indicates we're using bone indices
  49. #define VERTEX_BONE_INDEX 0x0080
  50.  
  51. // Indicates this is a vertex shader
  52. #define VERTEX_FORMAT_VERTEX_SHADER 0x0100
  53.  
  54. // Indicates this format shouldn't be bloated to cache align it
  55. // (only used for VertexUsage)
  56. #define VERTEX_FORMAT_USE_EXACT_FORMAT 0x0200
  57.  
  58. // Indicates that compressed vertex elements are to be used (see also VertexCompressionType_t)
  59. #define VERTEX_FORMAT_COMPRESSED 0x400
  60.  
  61. // Update this if you add or remove bits...
  62. #define VERTEX_LAST_BIT 10
  63.  
  64. #define VERTEX_BONE_WEIGHT_BIT (VERTEX_LAST_BIT + 1)
  65. #define USER_DATA_SIZE_BIT (VERTEX_LAST_BIT + 4)
  66. #define TEX_COORD_SIZE_BIT (VERTEX_LAST_BIT + 7)
  67.  
  68. #define VERTEX_BONE_WEIGHT_MASK ( 0x7 << VERTEX_BONE_WEIGHT_BIT )
  69. #define USER_DATA_SIZE_MASK ( 0x7 << USER_DATA_SIZE_BIT )
  70.  
  71. #define VERTEX_FORMAT_FIELD_MASK 0x0FF
  72.  
  73. // If everything is off, it's an unknown vertex format
  74. #define VERTEX_FORMAT_UNKNOWN 0
  75.  
  76.  
  77.  
  78. //-----------------------------------------------------------------------------
  79. // Macros for construction..
  80. //-----------------------------------------------------------------------------
  81. #define VERTEX_BONEWEIGHT( _n ) ((_n) << VERTEX_BONE_WEIGHT_BIT)
  82. #define VERTEX_USERDATA_SIZE( _n ) ((_n) << USER_DATA_SIZE_BIT)
  83. #define VERTEX_TEXCOORD_MASK( _coord ) (( 0x7ULL ) << ( TEX_COORD_SIZE_BIT + 3 * (_coord) ))
  84. typedef unsigned __int64 uint64;
  85. typedef uint64 VertexFormat_t;
  86.  
  87. inline VertexFormat_t VERTEX_TEXCOORD_SIZE(int nIndex, int nNumCoords)
  88. {
  89. uint64 n64 = nNumCoords;
  90. uint64 nShift = TEX_COORD_SIZE_BIT + (3 * nIndex);
  91. return n64 << nShift;
  92. }
  93.  
  94.  
  95.  
  96. //-----------------------------------------------------------------------------
  97. // Gets at various vertex format info...
  98. //-----------------------------------------------------------------------------
  99. inline int VertexFlags(VertexFormat_t vertexFormat)
  100. {
  101. return static_cast<int> (vertexFormat & ((1 << (VERTEX_LAST_BIT + 1)) - 1));
  102. }
  103.  
  104. inline int NumBoneWeights(VertexFormat_t vertexFormat)
  105. {
  106. return static_cast<int> ((vertexFormat >> VERTEX_BONE_WEIGHT_BIT) & 0x7);
  107. }
  108.  
  109. inline int UserDataSize(VertexFormat_t vertexFormat)
  110. {
  111. return static_cast<int> ((vertexFormat >> USER_DATA_SIZE_BIT) & 0x7);
  112. }
  113.  
  114. inline int TexCoordSize(int nTexCoordIndex, VertexFormat_t vertexFormat)
  115. {
  116. return static_cast<int> ((vertexFormat >> (TEX_COORD_SIZE_BIT + 3 * nTexCoordIndex)) & 0x7);
  117. }
  118.  
  119. inline bool UsesVertexShader(VertexFormat_t vertexFormat)
  120. {
  121. return (vertexFormat & VERTEX_FORMAT_VERTEX_SHADER) != 0;
  122. }
  123.  
  124. // We're testing 2 normal compression methods
  125. // One compressed normals+tangents into a SHORT2 each (8 bytes total)
  126. // The other compresses them together, into a single UBYTE4 (4 bytes total)
  127. // FIXME: pick one or the other, compare lighting quality in important cases
  128. #define COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2 0
  129. #define COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4 1
  130. //#define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_SEPARATETANGENTS_SHORT2
  131. #define COMPRESSED_NORMALS_TYPE COMPRESSED_NORMALS_COMBINEDTANGENTS_UBYTE4
  132.  
  133.  
  134. //-----------------------------------------------------------------------------
  135. // Shader state flags can be read from the FLAGS materialvar
  136. // Also can be read or written to with the Set/GetMaterialVarFlags() call
  137. // Also make sure you add/remove a string associated with each flag below to CShaderSystem::ShaderStateString in ShaderSystem.cpp
  138. //-----------------------------------------------------------------------------
  139. enum MaterialVarFlags_t
  140. {
  141. MATERIAL_VAR_DEBUG = (1 << 0),
  142. MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
  143. MATERIAL_VAR_NO_DRAW = (1 << 2),
  144. MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),
  145.  
  146. MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
  147. MATERIAL_VAR_VERTEXALPHA = (1 << 5),
  148. MATERIAL_VAR_SELFILLUM = (1 << 6),
  149. MATERIAL_VAR_ADDITIVE = (1 << 7),
  150. MATERIAL_VAR_ALPHATEST = (1 << 8),
  151. MATERIAL_VAR_MULTIPASS = (1 << 9),
  152. MATERIAL_VAR_ZNEARER = (1 << 10),
  153. MATERIAL_VAR_MODEL = (1 << 11),
  154. MATERIAL_VAR_FLAT = (1 << 12),
  155. MATERIAL_VAR_NOCULL = (1 << 13),
  156. MATERIAL_VAR_NOFOG = (1 << 14),
  157. MATERIAL_VAR_IGNOREZ = (1 << 15),
  158. MATERIAL_VAR_DECAL = (1 << 16),
  159. MATERIAL_VAR_ENVMAPSPHERE = (1 << 17),
  160. MATERIAL_VAR_NOALPHAMOD = (1 << 18),
  161. MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19),
  162. MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
  163. MATERIAL_VAR_TRANSLUCENT = (1 << 21),
  164. MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
  165. MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23),
  166. MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
  167. MATERIAL_VAR_ENVMAPMODE = (1 << 25),
  168. MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
  169. MATERIAL_VAR_HALFLAMBERT = (1 << 27),
  170. MATERIAL_VAR_WIREFRAME = (1 << 28),
  171. MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29),
  172. MATERIAL_VAR_IGNORE_ALPHA_MODULATION = (1 << 30),
  173.  
  174. // NOTE: Only add flags here that either should be read from
  175. // .vmts or can be set directly from client code. Other, internal
  176. // flags should to into the flag enum in imaterialinternal.h
  177. };
  178.  
  179.  
  180. //-----------------------------------------------------------------------------
  181. // Internal flags not accessible from outside the material system. Stored in Flags2
  182. //-----------------------------------------------------------------------------
  183. enum MaterialVarFlags2_t
  184. {
  185. // NOTE: These are for $flags2!!!!!
  186. // UNUSED = (1 << 0),
  187.  
  188. MATERIAL_VAR2_LIGHTING_UNLIT = 0,
  189. MATERIAL_VAR2_LIGHTING_VERTEX_LIT = (1 << 1),
  190. MATERIAL_VAR2_LIGHTING_LIGHTMAP = (1 << 2),
  191. MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP = (1 << 3),
  192. MATERIAL_VAR2_LIGHTING_MASK =
  193. (MATERIAL_VAR2_LIGHTING_VERTEX_LIT |
  194. MATERIAL_VAR2_LIGHTING_LIGHTMAP |
  195. MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP),
  196.  
  197. // FIXME: Should this be a part of the above lighting enums?
  198. MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL = (1 << 4),
  199. MATERIAL_VAR2_USES_ENV_CUBEMAP = (1 << 5),
  200. MATERIAL_VAR2_NEEDS_TANGENT_SPACES = (1 << 6),
  201. MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING = (1 << 7),
  202. // GR - HDR path puts lightmap alpha in separate texture...
  203. MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA = (1 << 8),
  204. MATERIAL_VAR2_NEEDS_BAKED_LIGHTING_SNAPSHOTS = (1 << 9),
  205. MATERIAL_VAR2_USE_FLASHLIGHT = (1 << 10),
  206. MATERIAL_VAR2_USE_FIXED_FUNCTION_BAKED_LIGHTING = (1 << 11),
  207. MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT = (1 << 12),
  208. MATERIAL_VAR2_USE_EDITOR = (1 << 13),
  209. MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE = (1 << 14),
  210. MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE = (1 << 15),
  211. MATERIAL_VAR2_IS_SPRITECARD = (1 << 16),
  212. MATERIAL_VAR2_USES_VERTEXID = (1 << 17),
  213. MATERIAL_VAR2_SUPPORTS_HW_SKINNING = (1 << 18),
  214. MATERIAL_VAR2_SUPPORTS_FLASHLIGHT = (1 << 19),
  215. };
  216.  
  217.  
  218. //-----------------------------------------------------------------------------
  219. // Preview image return values
  220. //-----------------------------------------------------------------------------
  221. enum PreviewImageRetVal_t
  222. {
  223. MATERIAL_PREVIEW_IMAGE_BAD = 0,
  224. MATERIAL_PREVIEW_IMAGE_OK,
  225. MATERIAL_NO_PREVIEW_IMAGE,
  226. };
  227.  
  228.  
  229. enum ImageFormat
  230. {
  231. IMAGE_FORMAT_UNKNOWN = -1,
  232. IMAGE_FORMAT_RGBA8888 = 0,
  233. IMAGE_FORMAT_ABGR8888,
  234. IMAGE_FORMAT_RGB888,
  235. IMAGE_FORMAT_BGR888,
  236. IMAGE_FORMAT_RGB565,
  237. IMAGE_FORMAT_I8,
  238. IMAGE_FORMAT_IA88,
  239. IMAGE_FORMAT_P8,
  240. IMAGE_FORMAT_A8,
  241. IMAGE_FORMAT_RGB888_BLUESCREEN,
  242. IMAGE_FORMAT_BGR888_BLUESCREEN,
  243. IMAGE_FORMAT_ARGB8888,
  244. IMAGE_FORMAT_BGRA8888,
  245. IMAGE_FORMAT_DXT1,
  246. IMAGE_FORMAT_DXT3,
  247. IMAGE_FORMAT_DXT5,
  248. IMAGE_FORMAT_BGRX8888,
  249. IMAGE_FORMAT_BGR565,
  250. IMAGE_FORMAT_BGRX5551,
  251. IMAGE_FORMAT_BGRA4444,
  252. IMAGE_FORMAT_DXT1_ONEBITALPHA,
  253. IMAGE_FORMAT_BGRA5551,
  254. IMAGE_FORMAT_UV88,
  255. IMAGE_FORMAT_UVWQ8888,
  256. IMAGE_FORMAT_RGBA16161616F,
  257. IMAGE_FORMAT_RGBA16161616,
  258. IMAGE_FORMAT_UVLX8888,
  259. IMAGE_FORMAT_R32F, // Single-channel 32-bit floating point
  260. IMAGE_FORMAT_RGB323232F, // NOTE: D3D9 does not have this format
  261. IMAGE_FORMAT_RGBA32323232F,
  262. IMAGE_FORMAT_RG1616F,
  263. IMAGE_FORMAT_RG3232F,
  264. IMAGE_FORMAT_RGBX8888,
  265.  
  266. IMAGE_FORMAT_NULL, // Dummy format which takes no video memory
  267.  
  268. // Compressed normal map formats
  269. IMAGE_FORMAT_ATI2N, // One-surface ATI2N / DXN format
  270. IMAGE_FORMAT_ATI1N, // Two-surface ATI1N format
  271.  
  272. IMAGE_FORMAT_RGBA1010102, // 10 bit-per component render targets
  273. IMAGE_FORMAT_BGRA1010102,
  274. IMAGE_FORMAT_R16F, // 16 bit FP format
  275.  
  276. // Depth-stencil texture formats
  277. IMAGE_FORMAT_D16,
  278. IMAGE_FORMAT_D15S1,
  279. IMAGE_FORMAT_D32,
  280. IMAGE_FORMAT_D24S8,
  281. IMAGE_FORMAT_LINEAR_D24S8,
  282. IMAGE_FORMAT_D24X8,
  283. IMAGE_FORMAT_D24X4S4,
  284. IMAGE_FORMAT_D24FS8,
  285. IMAGE_FORMAT_D16_SHADOW, // Specific formats for shadow mapping
  286. IMAGE_FORMAT_D24X8_SHADOW, // Specific formats for shadow mapping
  287.  
  288. // supporting these specific formats as non-tiled for procedural cpu access (360-specific)
  289. IMAGE_FORMAT_LINEAR_BGRX8888,
  290. IMAGE_FORMAT_LINEAR_RGBA8888,
  291. IMAGE_FORMAT_LINEAR_ABGR8888,
  292. IMAGE_FORMAT_LINEAR_ARGB8888,
  293. IMAGE_FORMAT_LINEAR_BGRA8888,
  294. IMAGE_FORMAT_LINEAR_RGB888,
  295. IMAGE_FORMAT_LINEAR_BGR888,
  296. IMAGE_FORMAT_LINEAR_BGRX5551,
  297. IMAGE_FORMAT_LINEAR_I8,
  298. IMAGE_FORMAT_LINEAR_RGBA16161616,
  299.  
  300. IMAGE_FORMAT_LE_BGRX8888,
  301. IMAGE_FORMAT_LE_BGRA8888,
  302.  
  303. NUM_IMAGE_FORMATS
  304. };
  305.  
  306. enum MaterialPropertyTypes_t
  307. {
  308. MATERIAL_PROPERTY_NEEDS_LIGHTMAP = 0, // bool
  309. MATERIAL_PROPERTY_OPACITY, // int (enum MaterialPropertyOpacityTypes_t)
  310. MATERIAL_PROPERTY_REFLECTIVITY, // vec3_t
  311. MATERIAL_PROPERTY_NEEDS_BUMPED_LIGHTMAPS // bool
  312. };
  313.  
  314. struct MorphFormat_t;
  315.  
  316. //-----------------------------------------------------------------------------
  317. // material interface
  318. //-----------------------------------------------------------------------------
  319. class IMaterial
  320. {
  321. public:
  322. // Get the name of the material. This is a full path to
  323. // the vmt file starting from "hl2/materials" (or equivalent) without
  324. // a file extension.
  325. virtual const char * GetName() const = 0;
  326. virtual const char * GetTextureGroupName() const = 0;
  327.  
  328. // Get the preferred size/bitDepth of a preview image of a material.
  329. // This is the sort of image that you would use for a thumbnail view
  330. // of a material, or in WorldCraft until it uses materials to render.
  331. // separate this for the tools maybe
  332. virtual PreviewImageRetVal_t GetPreviewImageProperties(int *width, int *height,
  333. ImageFormat *imageFormat, bool* isTranslucent) const = 0;
  334.  
  335. // Get a preview image at the specified width/height and bitDepth.
  336. // Will do resampling if necessary.(not yet!!! :) )
  337. // Will do color format conversion. (works now.)
  338. virtual PreviewImageRetVal_t GetPreviewImage(unsigned char *data,
  339. int width, int height,
  340. ImageFormat imageFormat) const = 0;
  341. //
  342. virtual int GetMappingWidth() = 0;
  343. virtual int GetMappingHeight() = 0;
  344.  
  345. virtual int GetNumAnimationFrames() = 0;
  346.  
  347. // For material subrects (material pages). Offset(u,v) and scale(u,v) are normalized to texture.
  348. virtual bool InMaterialPage(void) = 0;
  349. virtual void GetMaterialOffset(float *pOffset) = 0;
  350. virtual void GetMaterialScale(float *pScale) = 0;
  351. virtual IMaterial *GetMaterialPage(void) = 0;
  352.  
  353. // find a vmt variable.
  354. // This is how game code affects how a material is rendered.
  355. // The game code must know about the params that are used by
  356. // the shader for the material that it is trying to affect.
  357. virtual IMaterialVar * FindVar(const char *varName, bool *found, bool complain = true) = 0;
  358.  
  359. // The user never allocates or deallocates materials. Reference counting is
  360. // used instead. Garbage collection is done upon a call to
  361. // IMaterialSystem::UncacheUnusedMaterials.
  362. virtual void IncrementReferenceCount(void) = 0;
  363. virtual void DecrementReferenceCount(void) = 0;
  364.  
  365. inline void AddRef() { IncrementReferenceCount(); }
  366. inline void Release() { DecrementReferenceCount(); }
  367.  
  368. // Each material is assigned a number that groups it with like materials
  369. // for sorting in the application.
  370. virtual int GetEnumerationID(void) const = 0;
  371.  
  372. virtual void GetLowResColorSample(float s, float t, float *color) const = 0;
  373.  
  374. // This computes the state snapshots for this material
  375. virtual void RecomputeStateSnapshots() = 0;
  376.  
  377. // Are we translucent?
  378. virtual bool IsTranslucent() = 0;
  379.  
  380. // Are we alphatested?
  381. virtual bool IsAlphaTested() = 0;
  382.  
  383. // Are we vertex lit?
  384. virtual bool IsVertexLit() = 0;
  385.  
  386. // Gets the vertex format
  387. virtual VertexFormat_t GetVertexFormat() const = 0;
  388.  
  389. // returns true if this material uses a material proxy
  390. virtual bool HasProxy(void) const = 0;
  391.  
  392. virtual bool UsesEnvCubemap(void) = 0;
  393.  
  394. virtual bool NeedsTangentSpace(void) = 0;
  395.  
  396. virtual bool NeedsPowerOfTwoFrameBufferTexture(bool bCheckSpecificToThisFrame = true) = 0;
  397. virtual bool NeedsFullFrameBufferTexture(bool bCheckSpecificToThisFrame = true) = 0;
  398.  
  399. // returns true if the shader doesn't do skinning itself and requires
  400. // the data that is sent to it to be preskinned.
  401. virtual bool NeedsSoftwareSkinning(void) = 0;
  402.  
  403. // Apply constant color or alpha modulation
  404. virtual void AlphaModulate(float alpha) = 0;
  405. virtual void ColorModulate(float r, float g, float b) = 0;
  406.  
  407. // Material Var flags...
  408. virtual void SetMaterialVarFlag(MaterialVarFlags_t flag, bool on) = 0;
  409. virtual bool GetMaterialVarFlag(MaterialVarFlags_t flag) const = 0;
  410.  
  411. // Gets material reflectivity
  412. virtual void GetReflectivity(Vector& reflect) = 0;
  413.  
  414. // Gets material property flags
  415. virtual bool GetPropertyFlag(MaterialPropertyTypes_t type) = 0;
  416.  
  417. // Is the material visible from both sides?
  418. virtual bool IsTwoSided() = 0;
  419.  
  420. // Sets the shader associated with the material
  421. virtual void SetShader(const char *pShaderName) = 0;
  422.  
  423. // Can't be const because the material might have to precache itself.
  424. virtual int GetNumPasses(void) = 0;
  425.  
  426. // Can't be const because the material might have to precache itself.
  427. virtual int GetTextureMemoryBytes(void) = 0;
  428.  
  429. // Meant to be used with materials created using CreateMaterial
  430. // It updates the materials to reflect the current values stored in the material vars
  431. virtual void Refresh() = 0;
  432.  
  433. // GR - returns true is material uses lightmap alpha for blending
  434. virtual bool NeedsLightmapBlendAlpha(void) = 0;
  435.  
  436. // returns true if the shader doesn't do lighting itself and requires
  437. // the data that is sent to it to be prelighted
  438. virtual bool NeedsSoftwareLighting(void) = 0;
  439.  
  440. // Gets at the shader parameters
  441. virtual int ShaderParamCount() const = 0;
  442. virtual IMaterialVar **GetShaderParams(void) = 0;
  443.  
  444. // Returns true if this is the error material you get back from IMaterialSystem::FindMaterial if
  445. // the material can't be found.
  446. virtual bool IsErrorMaterial() const = 0;
  447.  
  448. virtual void SetUseFixedFunctionBakedLighting(bool bEnable) = 0;
  449.  
  450. // Gets the current alpha modulation
  451. virtual float GetAlphaModulation() = 0;
  452. virtual void GetColorModulation(float *r, float *g, float *b) = 0;
  453.  
  454. // Gets the morph format
  455. virtual MorphFormat_t GetMorphFormat() const = 0;
  456.  
  457. // fast find that stores the index of the found var in the string table in local cache
  458. virtual IMaterialVar * FindVarFast(char const *pVarName, unsigned int *pToken) = 0;
  459.  
  460. // Sets new VMT shader parameters for the material
  461. virtual void SetShaderAndParams(void *pKeyValues) = 0;
  462. virtual const char * GetShaderName() const = 0;
  463.  
  464. virtual void DeleteIfUnreferenced() = 0;
  465.  
  466. virtual bool IsSpriteCard() = 0;
  467.  
  468. virtual void CallBindProxy(void *proxyData) = 0;
  469.  
  470. virtual IMaterial *CheckProxyReplacement(void *proxyData) = 0;
  471.  
  472. virtual void RefreshPreservingMaterialVars() = 0;
  473.  
  474. virtual bool WasReloadedFromWhitelist() = 0;
  475.  
  476. virtual bool IsPrecached() const = 0;
  477. };
  478.  
  479. inline bool IsErrorMaterial(IMaterial *pMat)
  480. {
  481. return !pMat || pMat->IsErrorMaterial();
  482. }
  483.  
  484. typedef unsigned short MaterialHandle_t;
  485.  
  486. class IMaterialSystem
  487. {
  488. public:
  489. IMaterial * FindMaterial(char const* pMaterialName, const char *pTextureGroupName, bool complain = true, const char *pComplainPrefix = NULL)
  490. {
  491. typedef IMaterial*(__thiscall* Fn)(PVOID, char const*, char const*, bool, char const*);
  492. return Utils::GetVFunc< Fn >(this, 84)(this, pMaterialName, pTextureGroupName, complain, pComplainPrefix);
  493. }
  494.  
  495. IMaterial* CreateMaterial(const char *pMaterialName, KeyValuesv2 *pVMTKeyValues)
  496. {
  497. typedef IMaterial* (__thiscall* Fn)(PVOID, const char *, KeyValuesv2*);
  498. return Utils::GetVFunc<Fn>(this, 83)(this, pMaterialName, pVMTKeyValues);
  499. }
  500.  
  501. MaterialHandle_t FirstMaterial()
  502. {
  503. typedef MaterialHandle_t(__thiscall* Fn)(void*);
  504. return Utils::GetVFunc<Fn>(this, 86)(this);
  505. }
  506.  
  507. MaterialHandle_t NextMaterial(MaterialHandle_t h)
  508. {
  509. typedef MaterialHandle_t(__thiscall* Fn)(void*, MaterialHandle_t);
  510. return Utils::GetVFunc<Fn>(this, 87)(this, h);
  511. }
  512.  
  513. MaterialHandle_t InvalidMaterial()
  514. {
  515. typedef MaterialHandle_t(__thiscall* Fn)(void*);
  516. return Utils::GetVFunc<Fn>(this, 88)(this);
  517. }
  518.  
  519. IMaterial* GetMaterial(MaterialHandle_t h)
  520. {
  521. typedef IMaterial*(__thiscall* Fn)(void*, MaterialHandle_t);
  522. return Utils::GetVFunc<Fn>(this, 89)(this, h);
  523. }
  524.  
  525. };
  526.  
  527. extern IMaterialSystem* g_pMaterialSys;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement