This commit is contained in:
2023-11-15 13:44:50 +03:00
parent 8a5aa0ad6c
commit 89d0230c80
13 changed files with 1307 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
$Project
{
$Folder "Source Files"
{
$Folder "Metaballs"
{
$File "metaballs/point_blob_element.cpp"
$File "metaballs/point_blob_element.h"
$File "metaballs/point_blob_container.cpp"
$File "metaballs/point_blob_container.h"
}
}
}

View File

@@ -0,0 +1,34 @@
#include "cbase.h"
#include "point_blob_element.h"
#include "point_blob_container.h"
LINK_ENTITY_TO_CLASS(point_blob_container, CPointBlobContainer);
//i should change the way how i do keyvalue shit later
BEGIN_DATADESC(CPointBlobContainer)
DEFINE_KEYFIELD(GridSize, FIELD_INTEGER, "resolution"),
DEFINE_KEYFIELD(GridBounds, FIELD_VECTOR, "bounds"),
DEFINE_KEYFIELD(color, FIELD_COLOR32, "color"),
DEFINE_KEYFIELD(Ambcolor, FIELD_COLOR32, "ambientcolor"),
DEFINE_KEYFIELD(colorBoost, FIELD_FLOAT, "brightness"),
DEFINE_KEYFIELD(BlobMaterialName, FIELD_STRING, "materialpath"),
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST(CPointBlobContainer, DT_PointBlobContainer)
SendPropInt(SENDINFO(GridSize)),
#if HL2MP //idk how is it different, but it is different
SendPropVector(SENDINFO(GridBounds), -1, SPROP_COORD_MP),
#else
SendPropVector(SENDINFO(GridBounds), -1, SPROP_COORD),
#endif
SendPropInt( SENDINFO(color), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt),
SendPropInt( SENDINFO(Ambcolor), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt),
SendPropFloat(SENDINFO(colorBoost)),
SendPropStringT(SENDINFO(BlobMaterialName)),
END_SEND_TABLE()

View File

@@ -0,0 +1,55 @@
#ifndef C_BLOBCONTAINER_H
#define C_BLOBCONTAINER_H
#include "cbase.h"
#include "props.h"
#include "point_blob_element.h"
//just empty shit to be able to spawn entity using ent_create and use entity for fgd for map
class CPointBlobContainer : public CBreakableProp
{
DECLARE_CLASS(CPointBlobContainer, CBreakableProp);
public:
DECLARE_DATADESC();
DECLARE_SERVERCLASS();
CPointBlobContainer()
{
GridSize = 10;
GridBounds = Vector(50,50,50);
color = {255,255,255};
}
virtual void Spawn()
{
SetTransmitState(FL_EDICT_PVSCHECK);
m_nRenderMode = kRenderNormal;
m_nRenderFX = kRenderFxNone;
SetLightingOrigin(this);
//PrecacheModel("models/error.mdl");
//SetModel("models/error.mdl");
//BaseClass::Spawn();
// to shut up everything
SetMoveType(MOVETYPE_NONE);
m_takedamage = DAMAGE_NO;
SetNextThink(TICK_NEVER_THINK);
m_flAnimTime = gpGlobals->curtime;
m_flPlaybackRate = 0.0;
SetCycle(0);
}
CNetworkVar(int, GridSize);
CNetworkVar(float, colorBoost);
CNetworkVar(Vector, GridBounds);
CNetworkVar(string_t, BlobMaterialName);
CNetworkColor32(color);
CNetworkColor32(Ambcolor);
};
#endif // !C_BLOBCONTAINER_H

View File

@@ -0,0 +1,23 @@
#include "cbase.h"
//#include "c_props.h"
#include "point_blob_element.h"
// memdbgon must be the last include file in a .cpp file!!! :apple_advertisement:
//#include "tier0/memdbgon.h"
LINK_ENTITY_TO_CLASS(point_blob_element, CPointBlobElement);
BEGIN_DATADESC(CPointBlobElement)
//DEFINE_KEYFIELD(radius, FIELD_FLOAT, "radius"),
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST(CPointBlobElement, DT_PointBlobElement)
SendPropFloat(SENDINFO(radius)),
SendPropFloat(SENDINFO(radiusSquared)),
END_SEND_TABLE()

View File

@@ -0,0 +1,49 @@
#ifndef C_BLOBELEMENT_H
#define C_BLOBELEMENT_H
#include "cbase.h"
#include "props.h"
#include "props_shared.h"
/////////////////////////////////////
///
/// This is a blob element, or single blob if you prefer. He needs to initialise METABALL variable.
/// You have to use this with C_PointBlobContainer to see the blob itself.
///
/////////////////////////////////////
class CPointBlobElement : public CBaseEntity
{
DECLARE_CLASS(CPointBlobElement, CBaseEntity);
public:
DECLARE_SERVERCLASS();
DECLARE_DATADESC();
CPointBlobElement(){}
virtual void Spawn()
{
SetTransmitState(FL_EDICT_ALWAYS);
m_nRenderMode = kRenderNormal;
m_nRenderFX = kRenderFxNone;
}
bool KeyValue(const char* szKeyName, const char* szValue)
{
if (FStrEq(szKeyName, "radius"))
{
radius = atof(szValue);
radiusSquared = radius * radius;
}
return BaseClass::KeyValue(szKeyName, szValue);
}
CNetworkVar(float, radius);
CNetworkVar(float, radiusSquared);
};
#endif // C_BLOBELEMENT_H