a bit of stuff, time to add spirv-link into this project
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user