39 return *(
unsigned int *)&f;
47 ID_INLINE
unsigned int StringCRC(
const char *str ) {
49 const unsigned char *ptr;
52 ptr =
reinterpret_cast<const unsigned char*
>(str);
53 for ( i = 0; str[
i]; i++ ) {
54 crc ^= str[
i] << (i & 3);
76 RotY = -atan2( n[2],
idMath::Sqrt( n[1] * n[1] + n[0] * n[0]) );
77 RotZ = atan2( n[1], n[0] );
83 texT[0] = -sin(RotY) * cos(RotZ);
84 texT[1] = -sin(RotY) * sin(RotZ);
98 for ( i = 0; i < 2; i++ ) {
100 v[
i][1] = texX[1] * texMat[
i][0] + texY[1] * texMat[
i][1];
101 v[
i][2] = texX[2] * texMat[
i][0] + texY[2] * texMat[
i][1];
123 src.
Error(
"idMapPatch::Parse: unexpected EOF" );
130 src.
Error(
"idMapPatch::Parse: unable to Parse patchDef3 info" );
135 src.
Error(
"idMapPatch::Parse: unable to parse patchDef2 info" );
141 patch->
SetSize( info[0], info[1] );
142 if ( version < 2.0
f ) {
155 src.
Error(
"idMapPatch::Parse: bad size" );
162 src.
Error(
"idMapPatch::Parse: bad patch vertex data" );
166 for ( j = 0; j < patch->
GetWidth(); j++ ) {
168 src.
Error(
"idMapPatch::Parse: bad vertex row data" );
172 for ( i = 0; i < patch->
GetHeight(); i++ ) {
176 src.
Error(
"idMapPatch::Parse: bad vertex column data" );
181 vert = &((*patch)[i * patch->
GetWidth() +
j]);
182 vert->
xyz[0] = v[0] - origin[0];
183 vert->
xyz[1] = v[1] - origin[1];
184 vert->
xyz[2] = v[2] - origin[2];
190 src.
Error(
"idMapPatch::Parse: unable to parse patch control points" );
195 src.
Error(
"idMapPatch::Parse: unable to parse patch control points, no closure" );
202 if ( token ==
"}" ) {
226 fp->
WriteFloatString(
"// primitive %d\n{\n patchDef3\n {\n", primitiveNum );
229 fp->
WriteFloatString(
"// primitive %d\n{\n patchDef2\n {\n", primitiveNum );
234 for ( i = 0; i <
GetWidth(); i++ ) {
239 v->
xyz[1] + origin[1], v->
xyz[2] + origin[2], v->
st[0], v->
st[1] );
258 for ( i = 0; i <
GetWidth(); i++ ) {
290 src.
Error(
"idMapBrush::Parse: unexpected EOF" );
294 if ( token ==
"}" ) {
301 if ( token ==
"(" ) {
306 src.
Error(
"idMapBrush::Parse: unexpected %s, expected ( or epair key string", token.
c_str() );
314 src.
Error(
"idMapBrush::Parse: expected epair value string not found" );
319 epairs.
Set( key, token );
323 src.
Error(
"idMapBrush::Parse: unexpected EOF" );
336 src.
Error(
"idMapBrush::Parse: unable to read brush side plane definition" );
345 src.
Error(
"idMapBrush::Parse: unable to read brush side plane definition" );
350 planepts[0] -= origin;
351 planepts[1] -= origin;
352 planepts[2] -= origin;
360 src.
Error(
"idMapBrush::Parse: unable to read brush side texture matrix" );
368 src.
Error(
"idMapBrush::Parse: unable to read brush side material" );
374 if ( version < 2.0
f ) {
375 side->
material =
"textures/" + token;
395 for ( i = 0; i < sides.
Num(); i++ ) {
410 int i, shift[2], rotate;
430 src.
Error(
"idMapBrush::ParseQ3: unable to read brush side plane definition" );
435 planepts[0] -= origin;
436 planepts[1] -= origin;
437 planepts[2] -= origin;
443 src.
Error(
"idMapBrush::ParseQ3: unable to read brush side material" );
449 side->
material =
"textures/" + token;
471 for ( i = 0; i < sides.
Num(); i++ ) {
489 fp->
WriteFloatString(
"// primitive %d\n{\n brushDef3\n {\n", primitiveNum );
524 for ( j = 0; j < 4; j++ ) {
551 if ( token !=
"{" ) {
552 src.
Error(
"idMapEntity::Parse: { not found, found %s", token.
c_str() );
566 src.
Error(
"idMapEntity::Parse: EOF without closing brace" );
569 if ( token ==
"}" ) {
573 if ( token ==
"{" ) {
576 src.
Error(
"idMapEntity::Parse: unexpected EOF" );
585 if ( token.
Icmpn(
"brush", 5 ) == 0 ) {
593 else if ( token.
Icmpn(
"patch", 5 ) == 0 ) {
627 sscanf( value,
"%lf %lf %lf", &v1, &v2, &v3 );
729 name.StripFileExtension();
733 if ( !ignoreRegion ) {
773 while ( removeEntities ) {
775 removeEntities =
entities[0]->epairs.MatchPrefix(
"removeEntities", removeEntities );
780 if (
entities[0]->epairs.GetString(
"overrideMaterial",
"", material ) ) {
785 switch( mapPrimitive->
GetType() ) {
794 static_cast<idMapPatch *
>(mapPrimitive)->SetMaterial( material );
803 if (
entities[0]->epairs.GetBool(
"forceEntityNames" ) ) {
813 if (
entities[0]->epairs.GetBool(
"moveFuncGroups" ) ) {
843 if ( fromBasePath ) {
960 if (
name.Length() ) {
961 ID_TIME_T time = (ID_TIME_T)-1;
int GetNumSides(void) const
int CheckTokenString(const char *string)
const idPlane & GetPlane(void) const
idList< idMapEntity * > entities
GLsizei const GLfloat * value
idStr & SetFileExtension(const char *extension)
idList< idDrawVert > verts
void AddPrimitive(idMapPrimitive *p)
bool FromPoints(const idVec3 &p1, const idVec3 &p2, const idVec3 &p3, bool fixDegenerate=true)
const idVec3 & Normal(void) const
idMapBrushSide * GetSide(int i) const
int GetVertSubdivisions(void) const
idMapEntity * FindEntity(const char *name)
int AddSide(idMapBrushSide *side)
const idStr & GetKey(void) const
unsigned int GetGeometryCRC(void) const
const float * ToFloatPtr(void) const
void SetExplicitlySubdivided(bool b)
GLenum GLenum GLenum GLenum GLenum scale
int Parse1DMatrix(int x, float *m)
const ID_TIME_T GetFileTime(void)
void StripTrailingWhitespace(void)
static idMapBrush * Parse(idLexer &src, const idVec3 &origin, bool newFormat=true, float version=CURRENT_MAP_VERSION)
void ComputeAxisBase(idVec3 &normal, idVec3D &texS, idVec3D &texT)
unsigned int GetGeometryCRC(void) const
bool Write(idFile *fp, int primitiveNum, const idVec3 &origin) const
int GetHorzSubdivisions(void) const
const float * ToFloatPtr(void) const
float GetFloatValue(void)
static float Sqrt(float x)
bool Write(idFile *fp, int primitiveNum, const idVec3 &origin) const
const char * GetMaterial(void) const
static idMapBrush * ParseQ3(idLexer &src, const idVec3 &origin)
float ParseFloat(bool *errorFlag=NULL)
idList< idMapPrimitive * > primitives
void Set(const char *key, const char *value)
int ReadTokenOnLine(idToken *token)
const int CURRENT_MAP_VERSION
int Icmp(const char *text) const
int GetHeight(void) const
int Icmpn(const char *text, int n) const
void RemovePrimitiveData()
GLfloat GLfloat GLfloat v2
void Error(const char *str,...) id_attribute((format(printf
int ExpectTokenType(int type, int subtype, idToken *token)
void RemoveEntities(const char *classname)
static class idFileSystem * fileSystem
void SetMaterial(const char *p)
const char * GetString(const char *key, const char *defaultString="") const
unsigned int GetGeometryCRC(void) const
static idMapEntity * Parse(idLexer &src, bool worldSpawn=false, float version=CURRENT_MAP_VERSION)
bool Parse(const char *filename, bool ignoreRegion=false, bool osPath=false)
static float Fabs(float f)
bool Write(const char *fileName, const char *ext, bool fromBasePath=true)
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
virtual idFile * OpenFileWrite(const char *relativePath, const char *basePath="fs_savepath")=0
bool GetExplicitlySubdivided(void) const
const idStr & GetValue(void) const
void SetVertSubdivisions(int n)
void DeleteContents(bool clear)
void SetMaterial(const char *p)
ID_INLINE unsigned int FloatCRC(float f)
virtual int WriteFloatString(const char *fmt,...) id_attribute((format(printf
void GetTextureVectors(idVec4 v[2]) const
void UnreadToken(const idToken *token)
const idKeyValue * FindKey(const char *key) const
virtual void Printf(const char *fmt,...) id_attribute((format(printf
ID_INLINE unsigned int StringCRC(const char *str)
void RemoveEntity(idMapEntity *mapEnt)
idList< idMapBrushSide * > sides
int ExpectTokenString(const char *string)
GLfloat GLfloat GLfloat GLfloat v3
int Append(const type &obj)
idMapPrimitive * GetPrimitive(int i) const
virtual idFile * OpenExplicitFileWrite(const char *OSPath)=0
bool RemoveIndex(int index)
const char * GetMaterial(void) const
bool Write(idFile *fp, int entityNum) const
const char * c_str(void) const
void SetHorzSubdivisions(int n)
const idKeyValue * GetKeyVal(int index) const
const idVec3 & ToVec3(void) const
int Parse2DMatrix(int y, int x, float *m)
void RemovePrimitiveData()
char * va(const char *fmt,...)
int AddEntity(idMapEntity *mapentity)
virtual void CloseFile(idFile *f)=0
void SetGeometryCRC(void)
static idMapPatch * Parse(idLexer &src, const idVec3 &origin, bool patchDef3=true, float version=CURRENT_MAP_VERSION)
int GetNumPrimitives(void) const
int GetNumKeyVals(void) const
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void SetSize(int patchWidth, int patchHeight)
const int OLD_MAP_VERSION
int ReadToken(idToken *token)
bool Remove(const type &obj)
int LoadFile(const char *filename, bool OSPath=false)
static class idCommon * common