This repository has been archived on 2024-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
2020-08-04 13:13:01 -04:00

77 lines
2.2 KiB
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#ifndef VMTPREVIEWPANEL_H
#define VMTPREVIEWPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "materialsystem/MaterialSystemUtil.h"
#include "mathlib/vector.h"
#include "tier1/utlstring.h"
#include "vgui_controls/Panel.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// VMT Preview panel
//
//-----------------------------------------------------------------------------
class CVMTPreviewPanel : public vgui::Panel {
DECLARE_CLASS_SIMPLE(CVMTPreviewPanel, vgui::Panel);
public:
// constructor
CVMTPreviewPanel(vgui::Panel *pParent, const char *pName);
void SetVMT(const char *pMaterialName);
const char *GetVMT() const;
// Paints the texture
virtual void Paint(void);
// View it in 3D or 2D mode
void DrawIn3DMode(bool b3DMode);
private:
// Two different preview methods
void DrawSphere(void);
void DrawRectangle(void);
// Set up a projection matrix for a 90 degree fov
void SetupProjectionMatrix(int nWidth, int nHeight);
void SetupOrthoMatrix(int nWidth, int nHeight);
// Sets the camera to look at the the thing we're spinning around
void LookAt(const Vector &vecLookAt, float flRadius);
// Sets up lighting state
void SetupLightingState();
// Draw a sphere
void RenderSphere(const Vector &vCenter, float flRadius, int nTheta,
int nPhi);
// Draw sprite-card based materials
void RenderSpriteCard(const Vector &vCenter, float flRadius);
CUtlString m_VMTName;
CMaterialReference m_Material;
CTextureReference m_pLightmapTexture;
CTextureReference m_DefaultEnvCubemap;
Vector m_LightDirection;
Color m_LightColor;
float m_flLightIntensity;
Vector m_vecCameraDirection;
float m_flLastRotationTime;
bool m_bDrawIn3DMode;
};
#endif // VMTPREVIEWPANEL_H