a bit of stuff, time to add spirv-link into this project
This commit is contained in:
30
game/client/milmoba/materials.cpp
Normal file
30
game/client/milmoba/materials.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "materials.h"
|
||||
|
||||
class CBasicPBR: public CBaseMaterial
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(CBasicPBR, CBaseMaterial)
|
||||
DECLARE_DATADESC()
|
||||
|
||||
FMat::XMFLOAT4 m_vAlbedo = { 1, 1, 1, 1 };
|
||||
FMat::XMTexture m_tAlbedo = TEXTURE_NO_TEXTURE;
|
||||
};
|
||||
|
||||
BEGIN_DATADESC(CBasicPBR)
|
||||
DEFINE_KEYFIELD(m_vAlbedo, FIELD_SHADER_COLOR_FLOAT4, "AlbedoMultiplier")
|
||||
DEFINE_KEYFIELD(m_tAlbedo, FIELD_SHADER_TEXTURE, "AlbedoTexture")
|
||||
END_DATADESC()
|
||||
DEFINE_MATERIAL(CBasicPBR, "funny_basic_pbr")
|
||||
|
||||
|
||||
|
||||
class CBasicError: public CBaseMaterial
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(CBasicError, CBaseMaterial)
|
||||
DECLARE_DATADESC()
|
||||
};
|
||||
|
||||
BEGIN_DATADESC(CBasicError)
|
||||
END_DATADESC()
|
||||
DEFINE_MATERIAL(CBasicError, "funny_error")
|
||||
@@ -1,58 +1,10 @@
|
||||
#include "../baseentity.h"
|
||||
#include "../worldrender.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "game.h"
|
||||
|
||||
class C_MOBAPlayer: public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(C_MOBAPlayer, C_BaseEntity)
|
||||
virtual void Precache ( void ) override;
|
||||
virtual void Spawn( void ) override;
|
||||
virtual void Think( float fDelta );
|
||||
|
||||
IMesh *m_pMesh;
|
||||
IMeshInstance *m_pMeshInstances[10];
|
||||
};
|
||||
#include "player.h"
|
||||
#include "cglm/cglm.h"
|
||||
#include "assetmgr.h"
|
||||
|
||||
void C_MOBAPlayer::Precache()
|
||||
{
|
||||
IVertexBuffer *pBuffer;
|
||||
IBuffer *pDataBuffer;
|
||||
IShader *pShader;
|
||||
IMaterial *pMaterial;
|
||||
pShader = g_pRenderContext->CreateShader("game/core/shaders/mesh_raster.shader_c");
|
||||
|
||||
IFileHandle *pHandle = filesystem->Open("game/core/meshes/spot.fmesh_c", FILEMODE_READ);
|
||||
float *pData = (float*)V_malloc(filesystem->Size(pHandle));
|
||||
filesystem->Read(pHandle, pData, filesystem->Size(pHandle));
|
||||
pBuffer = g_pRenderContext->CreateVertexBuffer(filesystem->Size(pHandle));
|
||||
pBuffer->Lock();
|
||||
void *pMapped = pBuffer->Map();
|
||||
V_memcpy(pMapped, pData, filesystem->Size(pHandle));
|
||||
pBuffer->Unmap();
|
||||
pBuffer->Unlock();
|
||||
V_free(pData);
|
||||
filesystem->Close(pHandle);
|
||||
|
||||
|
||||
m_pMesh = g_pWorldRenderer->CreateMesh("game/core/meshes/spot.fmesh_c");
|
||||
g_pWorldRenderer->SetCameraPosition((Vector){0,0,-20});
|
||||
g_pWorldRenderer->SetCameraRotation((Quat){1,0,0,0});
|
||||
|
||||
m_pMesh->ConfigureShader(pShader);
|
||||
pShader->Build();
|
||||
pMaterial = g_pRenderContext->CreateMaterial(pShader);
|
||||
|
||||
m_pMesh->SetVertices(pBuffer);
|
||||
m_pMesh->SetMaterial(pMaterial);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
m_pMeshInstances[i] = g_pWorldRenderer->CreateInstance(m_pMesh);
|
||||
m_pMeshInstances[i]->SetScale({1, 1, 1});
|
||||
m_pMeshInstances[i]->SetPosition({(float)i,0,0});
|
||||
m_pMeshInstances[i]->SetRotation({1,0,0,0});
|
||||
}
|
||||
g_pAssetManager->LoadModel("game/core/models/cube.fmdl");
|
||||
}
|
||||
|
||||
|
||||
@@ -64,13 +16,6 @@ void C_MOBAPlayer::Spawn()
|
||||
|
||||
void C_MOBAPlayer::Think( float fDelta )
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
m_pMeshInstances[i]->SetPosition({(float)i, 0 ,-(float)g_pEngineVars->m_fTime});
|
||||
versor v;
|
||||
glm_euler_zxy_quat((vec3){(float)g_pEngineVars->m_fTime,0,0}, v);
|
||||
m_pMeshInstances[i]->SetRotation({v[0], v[1], v[2], v[3]});
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(player, C_MOBAPlayer)
|
||||
|
||||
17
game/client/milmoba/player.h
Normal file
17
game/client/milmoba/player.h
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#include "baseentity.h"
|
||||
#include "worldrender.h"
|
||||
#include "game.h"
|
||||
#include "assetmgr.h"
|
||||
|
||||
|
||||
class C_MOBAPlayer: public C_BaseEntity
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS(C_MOBAPlayer, C_BaseEntity)
|
||||
virtual void Precache ( void ) override;
|
||||
virtual void Spawn( void ) override;
|
||||
virtual void Think( float fDelta );
|
||||
|
||||
FunnyModel_t *pModel;
|
||||
};
|
||||
Reference in New Issue
Block a user