29 #include "../../idlib/precompiled.h"
33 #include "../../renderer/tr_local.h"
34 #include "../../renderer/model_local.h"
37 #define CURVE_TAG "curve_"
93 float b = atof(value);
96 vAngle[0] = vAngle[1] = 0;
114 if (!key || !key[0]) {
138 if (!key || !key[0]) {
157 if (!key || !key[0]) {
163 sprintf(str,
"%g %g %g %g %g %g %g %g %g",m[0][0],m[0][1],m[0][2],m[1][0],m[1][1],m[1][2],m[2][0],m[2][1],m[2][2]);
177 if (
stricmp(key,
"rotation") == 0) {
215 if (k && strlen(k) > 0) {
216 sscanf(k,
"%f %f %f", &vec[0], &vec[1], &vec[2]);
220 vec[0] = vec[1] = vec[2] = 0;
233 if (k && strlen(k) > 0) {
234 sscanf(k,
"%f %f %f %f", &vec[0], &vec[1], &vec[2], &vec[3]);
238 vec[0] = vec[1] = vec[2] = vec[3] = 0;
251 if (k && strlen(k) > 0) {
267 if (k && strlen(k) > 0) {
271 "%f %f %f %f %f %f %f %f %f ",
307 Error(
"Entity_AddToList: allready linked");
323 Error(
"Entity_RemoveFromList: not linked");
389 {
"light_target", 1 },
391 {
"light_right", 1 },
392 {
"light_start", 1 },
393 {
"light_center", 1 },
395 {
"light_radius", 1 },
396 {
"light_origin", 1 }
408 if (FloatFixups[
j].
type == 1) {
412 }
else if (FloatFixups[
j].
type == 2) {
414 sscanf(kv->
GetValue().
c_str(),
"%f %f %f %f %f %f %f %f %f ",&mat[0][0],&mat[0][1],&mat[0][2],&mat[1][0],&mat[1][1],&mat[1][2],&mat[2][0],&mat[2][1],&mat[2][2]);
415 sprintf(val,
"%g %g %g %g %g %g %g %g %g",mat[0][0],mat[0][1],mat[0][2],mat[1][0],mat[1][1],mat[1][2],mat[2][0],mat[2][1],mat[2][2]);
445 if (model && *model) {
494 if ( g_qeglobals.d_select_mode == sel_editpoint ) {
495 g_qeglobals.d_select_mode = sel_brush;
504 for (
int i = 0;
i <
c;
i++ ) {
520 if ( str.
Icmp(
"CatmullRomSpline" ) == 0 ) {
522 }
else if ( str.
Icmp(
"Nurbs" ) == 0 ) {
533 if ( kv && ent->
curve ) {
537 if ( numPoints > 0 ) {
538 float *fp =
new float[numPoints * 3];
541 for (
int i = 0;
i < numPoints * 3;
i += 3 ) {
585 int len = strlen(buff);
586 while ((isdigit(buff[len-1]) || buff[len-1] ==
'_') && len > 0) {
599 if (e->defArgs.GetString(
"model",
"", str) && e->entityModel ==
NULL) {
608 ent->
eclass->defArgs.GetString(
"model",
"", str);
615 if (e->nShowFlags & ECLASS_WORLDSPAWN) {
619 }
else if (e->nShowFlags & ECLASS_LIGHT) {
623 }
else if (hasModel) {
631 }
else if ( e->nShowFlags & ECLASS_ENV ) {
636 bool hasBody =
false;
649 if (e->fixedsize || hasModel) {
652 b->entityModel =
true;
660 if ( dynamic_cast<idRenderModelPrt*>( modelHandle ) || dynamic_cast<idRenderModelLiquid*>( modelHandle ) ) {
669 for (
int i = 0;
i < 3;
i++) {
670 if (mins[
i] == maxs[
i]) {
678 b->modelHandle = modelHandle;
699 if (!hasModel || (ent->
eclass->nShowFlags & ECLASS_LIGHT && hasModel)) {
705 mins = e->mins + ent->
origin;
706 maxs = e->maxs + ent->
origin;
713 if ( e->texdef.name ==
NULL ) {
714 brushprimit_texdef_t bp;
716 td.SetName( ent->
eclass->defMaterial );
722 printf(
"Warning: Brush entity with no brushes\n");
729 if (cn.
Icmp(
"func_static") == 0) {
730 if (name.
Icmp(model) == 0) {
740 mins[0] = mins[1] = mins[2] = 999999;
741 maxs[0] = maxs[1] = maxs[2] = -999999;
746 for (i = 0; i < 3; i++) {
747 if (b->mins[i] < mins[i]) {
748 mins[
i] = b->mins[
i];
751 if (b->maxs[i] > maxs[i]) {
752 maxs[
i] = b->maxs[
i];
757 for (i = 0; i < 3; i++) {
758 ent->
origin[
i] = (mins[
i] + ((maxs[
i] - mins[
i]) / 2));
765 if (!(e->nShowFlags & ECLASS_WORLDSPAWN)) {
766 if (e->defArgs.FindKey(
"model") ==
NULL && (pModel ==
NULL || (pModel && strlen(pModel) == 0))) {
778 b->next = pList->next;
779 pList->next->prev =
b;
800 if (!GetToken(
true)) {
805 Error(
"ParseEntity: { not found");
814 if (!GetToken(
true)) {
815 Warning(
"ParseEntity: EOF without closing brace");
819 if (!
strcmp(token,
"}")) {
823 if (!
strcmp(token,
"{")) {
856 for (
int i = 0;
i < 3;
i++) {
857 out[
i] = va[
i] + ((vb[
i] - va[
i]) / 2);
877 fprintf(f,
"\"classname\" \"info_player_start\"\n");
881 "\"origin\" \"%i %i %i\"\n",
902 if (e->
eclass->nShowFlags & ECLASS_PLUGINENTITY) {
905 sprintf(text,
"%i %i %i", (
int)origin[0], (
int)origin[1], (
int)origin[2]);
913 sprintf(text,
"%i %i %i", (
int)origin[0], (
int)origin[1], (
int)origin[2]);
928 if (e->
eclass->fixedsize && !b->entityModel) {
932 fprintf(f,
"// brush %i\n", count);
981 sprintf(text,
"%i %i %i", (
int)origin[0], (
int)origin[1], (
int)origin[2]);
996 if (e->
eclass->fixedsize && !b->entityModel) {
1000 fprintf(f,
"// brush %i\n", count);
1035 sprintf(text,
"%i %i %i", (
int)origin[0], (
int)origin[1], (
int)origin[2]);
1050 if (e->
eclass->fixedsize && !b->entityModel) {
1072 if (oldName == oldModel) {
1086 if (!force && name && name[0]) {
1094 bool setModel =
false;
1105 if (eclass && eclass[0]) {
1132 idVec3 mins, maxs, origin;
1135 brushprimit_texdef_t bp;
1140 Sys_Status(
"Entity NOT created, brushes not all from world\n");
1147 if (c->defArgs.GetString(
"model",
"", str) && c->entityModel ==
NULL) {
1167 Select_GetMid(e->
origin);
1178 if (c->defMaterial.Length()) {
1179 td.SetName(c->defMaterial);
1195 Select_GetMid(origin);
1202 if (c->defMaterial.Length()) {
1203 td.SetName(c->defMaterial);
1218 sprintf(text,
"%i %i %i", (
int)origin[0], (
int)origin[1], (
int)origin[2]);
1227 for (face_t *
f = b->brush_faces;
f;
f =
f->next) {
1237 if (b->oprev || b->onext) {
1238 Error(
"Entity_LinkBrush: Allready linked");
1258 if (!b->onext || !b->oprev) {
1259 Error(
"Entity_UnlinkBrush: Not currently linked");
1262 b->onext->oprev = b->oprev;
1263 b->oprev->onext = b->onext;
1264 b->onext = b->oprev =
NULL;
1307 iMin =
Min(i, iMin);
1308 iMax =
Max(i, iMax);
1370 bool playing =
false;
1384 ent->
soundEmitter = g_qeglobals.sw->AllocSoundEmitter();
CMainFrame * g_pParentWnd
bool FilterBrush(brush_t *pb)
bool GetMatrixForKey(entity_t *ent, const char *key, idMat3 &mat)
void WINAPI Sys_UpdateWindows(int nBits)
GLsizei const GLfloat * value
type GetValue(const int index) const
idCurve< idVec3 > * Entity_MakeCurve(entity_t *ent)
assert(prefInfo.fullscreenBtn)
idCVarSystem * cvarSystem
void Delete(const char *key)
idVec3 GetCenter(void) const
const EpairFixup FloatFixups[]
void Entity_FreeEpairs(entity_t *e)
void Entity_Write(entity_t *e, FILE *f, bool use_region)
void Entity_Free(entity_t *e)
bool IsBrushSelected(brush_t *bSel)
const idStr & GetKey(void) const
void Entity_UnlinkBrush(brush_t *b)
ID_INLINE T Max(T x, T y)
bool GetFloatForKey(entity_t *ent, const char *key, float *f)
#define VectorSubtract(a, b, c)
int Parse1DMatrix(int x, float *m)
void Entity_SetCurveData(entity_t *ent)
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
brush_t * Brush_Parse(idVec3 origin)
void Sys_Status(const char *psz, int part)
const char * ValueForKey(entity_t *ent, const char *key)
void Brush_Free(brush_t *b, bool bRemoveNode)
#define VectorAdd(a, b, c)
GLuint GLuint GLsizei GLenum type
void MemFile_fprintf(CMemFile *pMemFile, const char *string,...)
entity_t * Entity_PostParse(entity_t *ent, brush_t *pList)
void Set(const char *key, const char *value)
virtual void Free(bool immediate)=0
int GetNumKeys(entity_t *ent)
entity_t * Entity_Parse(bool onlypairs, brush_t *pList)
void Brush_SetTexture(brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale)
void Brush_Build(brush_t *b, bool bSnap, bool bMarkMap, bool bConvert, bool updateLights)
void Copy(const idDict &other)
int Icmp(const char *text) const
void ParseEpair(idDict *dict)
void SetKeyValue(entity_t *ent, const char *key, const char *value, bool trackAngles)
bool AddPoint(const idVec3 &v)
void Error(const char *pFormat,...)
void Entity_UpdateSoundEmitter(entity_t *ent)
GLuint GLuint GLsizei count
void Entity_UpdateCurveData(entity_t *ent)
const char * GetString(const char *key, const char *defaultString="") const
bool EntityHasModel(entity_t *ent)
void VectorMidpoint(idVec3 va, idVec3 vb, idVec3 &out)
bool GetVector4ForKey(entity_t *ent, const char *key, idVec4 &vec)
virtual const char * GetCVarString(const char *name) const =0
virtual idRenderModel * FindModel(const char *modelName)=0
void Brush_Resize(brush_t *b, idVec3 vMin, idVec3 vMax)
void SetKeyMat3(entity_t *ent, const char *key, idMat3 m)
const idStr & GetValue(void) const
const idSoundShader * shader
const char * Right(int len, idStr &result) const
int Map_GetUniqueEntityID(const char *prefix, const char *eclass)
void FromTransformedBounds(const idBounds &bounds, const idVec3 &origin, const idMat3 &axis)
entity_t * Entity_Clone(entity_t *e)
void TrackMD3Angles(entity_t *e, const char *key, const char *value)
GLubyte GLubyte GLubyte a
void DeleteKey(entity_t *ent, const char *key)
int Brush_MemorySize(brush_t *b)
int LoadMemory(const char *ptr, int length, const char *name, int startLine=1)
void Entity_SetName(entity_t *e, const char *name)
virtual int StartSound(const idSoundShader *shader, const s_channelType channel, float diversity=0, int shaderFlags=0, bool allowSlow=true)=0
virtual idBounds Bounds(const struct renderEntity_s *ent=NULL) const =0
int GetUniqueTargetId(int iHint)
const char * ToString(int precision=2) const
void Brush_Write(brush_t *b, FILE *f, const idVec3 &origin, bool newFormat)
idCurve< idVec3 > * curve
void Entity_RemoveFromList(entity_t *e)
bool Entity_NameIsUnique(const char *name)
idSoundEmitter * soundEmitter
bool GetVectorForKey(entity_t *ent, const char *key, idVec3 &vec)
void Entity_LinkBrush(entity_t *e, brush_t *b)
idRenderModelManager * renderModelManager
void Brush_Rotate(brush_t *b, idMat3 matrix, idVec3 origin, bool bBuild)
entity_t * FindEntity(const char *pszKey, const char *pszValue)
virtual void UpdateEmitter(const idVec3 &origin, int listenerId, const soundShaderParms_t *parms)=0
virtual int AddValue(const float time, const type &value)
int IntForKey(entity_t *ent, const char *key)
brush_t * Brush_Create(idVec3 mins, idVec3 maxs, texdef_t *texdef)
const char * c_str(void) const
const char * GetKeyString(entity_t *ent, int iIndex)
const idKeyValue * GetKeyVal(int index) const
entity_t * Entity_Create(eclass_t *c, bool forceFixed)
void Entity_AddToList(entity_t *e, entity_t *list)
idBounds & ExpandSelf(const float d)
virtual void ParseSpawnArgsToRefSound(const idDict *args, refSound_t *refSound)
char * va(const char *fmt,...)
int GetNumValues(void) const
virtual idRenderModel * ANIM_GetModelFromEntityDef(const char *classname)
void SetKeyVec3(entity_t *ent, const char *key, idVec3 v)
float FloatForKey(entity_t *ent, const char *key)
int Entity_MemorySize(entity_t *e)
void Entity_WriteSelected(entity_t *e, FILE *f)
int GetNumKeyVals(void) const
ID_INLINE T Min(T x, T y)
int sprintf(idStr &string, const char *fmt,...)
void Brush_MakeDirty(brush_t *b)
entity_t * FindEntityInt(const char *pszKey, int iValue)
void FixFloats(idDict *dict)
void Entity_Name(entity_t *e, bool force)
eclass_t * Eclass_ForName(const char *name, bool has_brushes)
bool Map_IsBrushFiltered(brush_t *b)