Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.95 KB | None | 0 0
  1. class IMaterial
  2. {
  3. public:
  4.     // Get the name of the material.  This is a full path to
  5.     // the vmt file starting from "hl2/materials" (or equivalent) without
  6.     // a file extension.
  7.     virtual const char* GetName() const = 0;
  8.     virtual const char* GetTextureGroupName() const = 0;
  9.  
  10.     // Get the preferred size/bitDepth of a preview image of a material.
  11.     // This is the sort of image that you would use for a thumbnail view
  12.     // of a material, or in WorldCraft until it uses materials to render.
  13.     // separate this for the tools maybe
  14.     virtual PreviewImageRetVal_t GetPreviewImageProperties(int* width, int* height,
  15.         ImageFormat* imageFormat, bool* isTranslucent) const = 0;
  16.  
  17.     // Get a preview image at the specified width/height and bitDepth.
  18.     // Will do resampling if necessary.(not yet!!! :) )
  19.     // Will do color format conversion. (works now.)
  20.     virtual PreviewImageRetVal_t GetPreviewImage(unsigned char* data,
  21.         int width, int height,
  22.         ImageFormat imageFormat) const = 0;
  23.     //
  24.     virtual int             GetMappingWidth() = 0;
  25.     virtual int             GetMappingHeight() = 0;
  26.  
  27.     virtual int             GetNumAnimationFrames() = 0;
  28.  
  29.     // For material subrects (material pages).  Offset(u,v) and scale(u,v) are normalized to texture.
  30.     virtual bool            InMaterialPage(void) = 0;
  31.     virtual void            GetMaterialOffset(float* pOffset) = 0;
  32.     virtual void            GetMaterialScale(float* pScale) = 0;
  33.     virtual IMaterial* GetMaterialPage(void) = 0;
  34.  
  35.     // find a vmt variable.
  36.     // This is how game code affects how a material is rendered.
  37.     // The game code must know about the params that are used by
  38.     // the shader for the material that it is trying to affect.
  39.     virtual IMaterialVar* FindVar(const char* varName, bool* found, bool complain = true) = 0;
  40.  
  41.     // The user never allocates or deallocates materials.  Reference counting is
  42.     // used instead.  Garbage collection is done upon a call to
  43.     // IMaterialSystem::UncacheUnusedMaterials.
  44.     virtual void            IncrementReferenceCount(void) = 0;
  45.     virtual void            DecrementReferenceCount(void) = 0;
  46.  
  47.     inline void AddRef() { IncrementReferenceCount(); }
  48.     inline void Release() { DecrementReferenceCount(); }
  49.  
  50.     // Each material is assigned a number that groups it with like materials
  51.     // for sorting in the application.
  52.     virtual int             GetEnumerationID(void) const = 0;
  53.  
  54.     virtual void            GetLowResColorSample(float s, float t, float* color) const = 0;
  55.  
  56.     // This computes the state snapshots for this material
  57.     virtual void            RecomputeStateSnapshots() = 0;
  58.  
  59.     // Are we translucent?
  60.     virtual bool            IsTranslucent() = 0;
  61.  
  62.     // Are we alphatested?
  63.     virtual bool            IsAlphaTested() = 0;
  64.  
  65.     // Are we vertex lit?
  66.     virtual bool            IsVertexLit() = 0;
  67.  
  68.     // Gets the vertex format
  69.     virtual VertexFormat_t  GetVertexFormat() const = 0;
  70.  
  71.     // returns true if this material uses a material proxy
  72.     virtual bool            HasProxy(void) const = 0;
  73.  
  74.     virtual bool            UsesEnvCubemap(void) = 0;
  75.  
  76.     virtual bool            NeedsTangentSpace(void) = 0;
  77.  
  78.     virtual bool            NeedsPowerOfTwoFrameBufferTexture(bool bCheckSpecificToThisFrame = true) = 0;
  79.     virtual bool            NeedsFullFrameBufferTexture(bool bCheckSpecificToThisFrame = true) = 0;
  80.  
  81.     // returns true if the shader doesn't do skinning itself and requires
  82.     // the data that is sent to it to be preskinned.
  83.     virtual bool            NeedsSoftwareSkinning(void) = 0;
  84.  
  85.     // Apply constant color or alpha modulation
  86.     virtual void            AlphaModulate(float alpha) = 0;
  87.     virtual void            ColorModulate(float r, float g, float b) = 0;
  88.  
  89.     // Material Var flags...
  90.     virtual void            SetMaterialVarFlag(MaterialVarFlags_t flag, bool on) = 0;
  91.     virtual bool            GetMaterialVarFlag(MaterialVarFlags_t flag) const = 0;
  92.  
  93.     // Gets material reflectivity
  94.     virtual void            GetReflectivity(Vector& reflect) = 0;
  95.  
  96.     // Gets material property flags
  97.     virtual bool            GetPropertyFlag(MaterialPropertyTypes_t type) = 0;
  98.  
  99.     // Is the material visible from both sides?
  100.     virtual bool            IsTwoSided() = 0;
  101.  
  102.     // Sets the shader associated with the material
  103.     virtual void            SetShader(const char* pShaderName) = 0;
  104.  
  105.     // Can't be const because the material might have to precache itself.
  106.     virtual int             GetNumPasses(void) = 0;
  107.  
  108.     // Can't be const because the material might have to precache itself.
  109.     virtual int             GetTextureMemoryBytes(void) = 0;
  110.  
  111.     // Meant to be used with materials created using CreateMaterial
  112.     // It updates the materials to reflect the current values stored in the material vars
  113.     virtual void            Refresh() = 0;
  114.  
  115.     // GR - returns true is material uses lightmap alpha for blending
  116.     virtual bool            NeedsLightmapBlendAlpha(void) = 0;
  117.  
  118.     // returns true if the shader doesn't do lighting itself and requires
  119.     // the data that is sent to it to be prelighted
  120.     virtual bool            NeedsSoftwareLighting(void) = 0;
  121.  
  122.     // Gets at the shader parameters
  123.     virtual int             ShaderParamCount() const = 0;
  124.     virtual IMaterialVar** GetShaderParams(void) = 0;
  125.  
  126.     // Returns true if this is the error material you get back from IMaterialSystem::FindMaterial if
  127.     // the material can't be found.
  128.     virtual bool            IsErrorMaterial() const = 0;
  129.  
  130.     virtual void            SetUseFixedFunctionBakedLighting(bool bEnable) = 0;
  131.  
  132.     // Gets the current alpha modulation
  133.     virtual float           GetAlphaModulation() = 0;
  134.     virtual void            GetColorModulation(float* r, float* g, float* b) = 0;
  135.  
  136.     // Gets the morph format
  137.     virtual MorphFormat_t   GetMorphFormat() const = 0;
  138.  
  139.     // fast find that stores the index of the found var in the string table in local cache
  140.     virtual IMaterialVar* FindVarFast(char const* pVarName, unsigned int* pToken) = 0;
  141.  
  142.     // Sets new VMT shader parameters for the material
  143.     virtual void            SetShaderAndParams(void* p
  144.     ) = 0;
  145.     virtual const char* GetShaderName() const = 0;
  146.  
  147.     virtual void            DeleteIfUnreferenced() = 0;
  148.  
  149.     virtual bool            IsSpriteCard() = 0;
  150.  
  151.     virtual void            CallBindProxy(void* proxyData) = 0;
  152.  
  153.     virtual IMaterial* CheckProxyReplacement(void* proxyData) = 0;
  154.  
  155.     virtual void            RefreshPreservingMaterialVars() = 0;
  156.  
  157.     virtual bool            WasReloadedFromWhitelist() = 0;
  158.  
  159.     virtual bool            IsPrecached() const = 0;
  160. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement