本文整理汇总了C++中idLexer::ReadToken方法的典型用法代码示例。如果您正苦于以下问题:C++ idLexer::ReadToken方法的具体用法?C++ idLexer::ReadToken怎么用?C++ idLexer::ReadToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idLexer
的用法示例。
在下文中一共展示了idLexer::ReadToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseParametric
/*
================
idDeclParticle::ParseParametric
================
*/
void idDeclParticle::ParseParametric( idLexer &src, idParticleParm *parm ) {
idToken token;
parm->table = NULL;
parm->from = parm->to = 0.0f;
if ( !src.ReadToken( &token ) ) {
src.Error( "not enough parameters" );
return;
}
if ( token.IsNumeric() ) {
// can have a to + 2nd parm
parm->from = parm->to = atof( token );
if ( src.ReadToken( &token ) ) {
if ( !token.Icmp( "to" ) ) {
if ( !src.ReadToken( &token ) ) {
src.Error( "missing second parameter" );
return;
}
parm->to = atof( token );
} else {
src.UnreadToken( &token );
}
}
} else {
// table
parm->table = static_cast<const idDeclTable *>( declManager->FindType( DECL_TABLE, token, false ) );
}
}
示例2: ParseInOutStruct
/*
========================
ParseInOutStruct
========================
*/
void ParseInOutStruct( idLexer & src, int attribType, idList< inOutVariable_t > & inOutVars ) {
src.ExpectTokenString( "{" );
while( !src.CheckTokenString( "}" ) ) {
inOutVariable_t var;
idToken token;
src.ReadToken( &token );
var.type = token;
src.ReadToken( &token );
var.nameCg = token;
if ( !src.CheckTokenString( ":" ) ) {
src.SkipUntilString( ";" );
continue;
}
src.ReadToken( &token );
var.nameGLSL = token;
src.ExpectTokenString( ";" );
// convert the type
for ( int i = 0; typeConversion[i].typeCG != NULL; i++ ) {
if ( var.type.Cmp( typeConversion[i].typeCG ) == 0 ) {
var.type = typeConversion[i].typeGLSL;
break;
}
}
// convert the semantic to a GLSL name
for ( int i = 0; attribsPC[i].semantic != NULL; i++ ) {
if ( ( attribsPC[i].flags & attribType ) != 0 ) {
if ( var.nameGLSL.Cmp( attribsPC[i].semantic ) == 0 ) {
var.nameGLSL = attribsPC[i].glsl;
break;
}
}
}
// check if it was defined previously
var.declareInOut = true;
for ( int i = 0; i < inOutVars.Num(); i++ ) {
if ( var.nameGLSL == inOutVars[i].nameGLSL ) {
var.declareInOut = false;
break;
}
}
inOutVars.Append( var );
}
src.ExpectTokenString( ";" );
}
示例3:
/*
====================
idRenderModelMD5::ParseJoint
====================
*/
void idRenderModelMD5::ParseJoint( idLexer& parser, idMD5Joint* joint, idJointQuat* defaultPose )
{
//
// parse name
//
idToken token;
parser.ReadToken( &token );
joint->name = token;
//
// parse parent
//
int num = parser.ParseInt();
if( num < 0 )
{
joint->parent = NULL;
}
else
{
if( num >= joints.Num() - 1 )
{
parser.Error( "Invalid parent for joint '%s'", joint->name.c_str() );
}
joint->parent = &joints[ num ];
}
//
// parse default pose
//
parser.Parse1DMatrix( 3, defaultPose->t.ToFloatPtr() );
parser.Parse1DMatrix( 3, defaultPose->q.ToFloatPtr() );
defaultPose->q.w = defaultPose->q.CalcW();
}
示例4: ParseBBoxes
/*
============
idAASSettings::ParseBBoxes
============
*/
bool idAASSettings::ParseBBoxes( idLexer &src )
{
idToken token;
idBounds bounds;
numBoundingBoxes = 0;
if ( !src.ExpectTokenString( "{" ) )
{
return false;
}
while( src.ReadToken( &token ) )
{
if ( token == "}" )
{
return true;
}
src.UnreadToken( &token );
src.Parse1DMatrix( 3, bounds[0].ToFloatPtr() );
if ( !src.ExpectTokenString( "-" ) )
{
return false;
}
src.Parse1DMatrix( 3, bounds[1].ToFloatPtr() );
boundingBoxes[numBoundingBoxes++] = bounds;
}
return false;
}
示例5: ParseFixed
/*
================
idDeclAF::ParseFixed
================
*/
bool idDeclAF::ParseFixed( idLexer &src ) {
idToken token;
idDeclAF_Constraint *constraint = new idDeclAF_Constraint;
constraint->SetDefault( this );
constraints.Alloc() = constraint;
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
!src.ExpectTokenString( "{" ) ) {
return false;
}
constraint->type = DECLAF_CONSTRAINT_FIXED;
constraint->name = token;
while( src.ReadToken( &token ) ) {
if ( !token.Icmp( "body1" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body1 = token;
} else if ( !token.Icmp( "body2" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body2 = token;
} else if ( token == "}" ) {
break;
} else {
src.Error( "unknown token %s in ball and socket joint", token.c_str() );
return false;
}
}
return true;
}
示例6: ParseHinge
/*
================
idDeclAF::ParseHinge
================
*/
bool idDeclAF::ParseHinge( idLexer &src ) {
idToken token;
idDeclAF_Constraint *constraint = new idDeclAF_Constraint;
constraint->SetDefault( this );
constraints.Alloc() = constraint;
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
!src.ExpectTokenString( "{" ) ) {
return false;
}
constraint->type = DECLAF_CONSTRAINT_HINGE;
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
constraint->name = token;
constraint->friction = 0.5f;
constraint->anchor.ToVec3().Zero();
constraint->axis.ToVec3().Zero();
while( src.ReadToken( &token ) ) {
if ( !token.Icmp( "body1" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body1 = token;
} else if ( !token.Icmp( "body2" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body2 = token;
} else if ( !token.Icmp( "anchor" ) ) {
if ( !constraint->anchor.Parse( src ) ) {
return false;
}
} else if ( !token.Icmp( "axis" ) ) {
if ( !constraint->axis.Parse( src ) ) {
return false;
}
} else if ( !token.Icmp( "limit" ) ) {
constraint->limitAngles[0] = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
constraint->limitAngles[1] = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
constraint->limitAngles[2] = src.ParseFloat();
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
} else if ( !token.Icmp( "friction" ) ) {
constraint->friction = src.ParseFloat();
} else if ( token == "}" ) {
break;
} else {
src.Error( "unknown token %s in hinge", token.c_str() );
return false;
}
}
return true;
}
示例7: Parse
/*
================
idAFVector::Parse
================
*/
bool idAFVector::Parse( idLexer &src ) {
idToken token;
if ( !src.ReadToken( &token ) ) {
return false;
}
if ( token == "-" ) {
negate = true;
if ( !src.ReadToken( &token ) ) {
return false;
}
}
else {
negate = false;
}
if ( token == "(" ) {
type = idAFVector::VEC_COORDS;
vec.x = src.ParseFloat();
src.ExpectTokenString( "," );
vec.y = src.ParseFloat();
src.ExpectTokenString( "," );
vec.z = src.ParseFloat();
src.ExpectTokenString( ")" );
}
else if ( token == "joint" ) {
type = idAFVector::VEC_JOINT;
src.ExpectTokenString( "(" );
src.ReadToken( &token );
joint1 = token;
src.ExpectTokenString( ")" );
}
else if ( token == "bonecenter" ) {
type = idAFVector::VEC_BONECENTER;
src.ExpectTokenString( "(" );
src.ReadToken( &token );
joint1 = token;
src.ExpectTokenString( "," );
src.ReadToken( &token );
joint2 = token;
src.ExpectTokenString( ")" );
}
else if ( token == "bonedir" ) {
type = idAFVector::VEC_BONEDIR;
src.ExpectTokenString( "(" );
src.ReadToken( &token );
joint1 = token;
src.ExpectTokenString( "," );
src.ReadToken( &token );
joint2 = token;
src.ExpectTokenString( ")" );
}
else {
src.Error( "unknown token %s in vector", token.c_str() );
return false;
}
return true;
}
示例8: ParseSpring
/*
================
idDeclAF::ParseSpring
================
*/
bool idDeclAF::ParseSpring( idLexer &src ) {
idToken token;
idDeclAF_Constraint *constraint = new idDeclAF_Constraint;
constraint->SetDefault( this );
constraints.Alloc() = constraint;
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
!src.ExpectTokenString( "{" ) ) {
return false;
}
constraint->type = DECLAF_CONSTRAINT_SPRING;
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
constraint->name = token;
constraint->friction = 0.5f;
while( src.ReadToken( &token ) ) {
if ( !token.Icmp( "body1" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body1 = token;
} else if ( !token.Icmp( "body2" ) ) {
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body2 = token;
} else if ( !token.Icmp( "anchor1" ) ) {
if ( !constraint->anchor.Parse( src ) ) {
return false;
}
} else if ( !token.Icmp( "anchor2" ) ) {
if ( !constraint->anchor2.Parse( src ) ) {
return false;
}
} else if ( !token.Icmp( "friction" ) ) {
constraint->friction = src.ParseFloat();
} else if ( !token.Icmp( "stretch" ) ) {
constraint->stretch = src.ParseFloat();
} else if ( !token.Icmp( "compress" ) ) {
constraint->compress = src.ParseFloat();
} else if ( !token.Icmp( "damping" ) ) {
constraint->damping = src.ParseFloat();
} else if ( !token.Icmp( "restLength" ) ) {
constraint->restLength = src.ParseFloat();
} else if ( !token.Icmp( "minLength" ) ) {
constraint->minLength = src.ParseFloat();
} else if ( !token.Icmp( "maxLength" ) ) {
constraint->maxLength = src.ParseFloat();
} else if ( token == "}" ) {
break;
} else {
src.Error( "unknown token %s in spring", token.c_str() );
return false;
}
}
return true;
}
示例9: ParseSlider
/*
================
idDeclAF::ParseSlider
================
*/
bool idDeclAF::ParseSlider( idLexer& src )
{
idToken token;
idDeclAF_Constraint* constraint = new( TAG_DECL ) idDeclAF_Constraint;
constraint->SetDefault( this );
constraints.Alloc() = constraint;
if( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
!src.ExpectTokenString( "{" ) )
{
return false;
}
constraint->type = DECLAF_CONSTRAINT_SLIDER;
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
constraint->name = token;
constraint->friction = 0.5f;
while( src.ReadToken( &token ) )
{
if( !token.Icmp( "body1" ) )
{
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body1 = token;
}
else if( !token.Icmp( "body2" ) )
{
src.ExpectTokenType( TT_STRING, 0, &token );
constraint->body2 = token;
}
else if( !token.Icmp( "axis" ) )
{
if( !constraint->axis.Parse( src ) )
{
return false;
}
}
else if( !token.Icmp( "friction" ) )
{
constraint->friction = src.ParseFloat();
}
else if( token == "}" )
{
break;
}
else
{
src.Error( "unknown token %s in slider", token.c_str() );
return false;
}
}
return true;
}
示例10: Reachability_Special_Read
/*
================
Reachability_Special_Read
================
*/
bool Reachability_Special_Read( idLexer &src, idReachability_Special *reach ) {
idToken key, value;
src.ExpectTokenString( "{" );
while( src.ReadToken( &key ) ) {
if ( key == "}" ) {
return true;
}
src.ExpectTokenType( TT_STRING, 0, &value );
reach->dict.Set( key, value );
}
return false;
}
示例11: ParseOptions
/*
====================
idModelExport::ParseOptions
====================
*/
bool idModelExport::ParseOptions( idLexer &lex ) {
idToken token;
idStr destdir;
idStr sourcedir;
if ( !lex.ReadToken( &token ) ) {
lex.Error( "Expected filename" );
return false;
}
src = token;
dest = token;
while( lex.ReadToken( &token ) ) {
if ( token == "-" ) {
if ( !lex.ReadToken( &token ) ) {
lex.Error( "Expecting option" );
return false;
}
if ( token == "sourcedir" ) {
if ( !lex.ReadToken( &token ) ) {
lex.Error( "Missing pathname after -sourcedir" );
return false;
}
sourcedir = token;
} else if ( token == "destdir" ) {
if ( !lex.ReadToken( &token ) ) {
lex.Error( "Missing pathname after -destdir" );
return false;
}
destdir = token;
} else if ( token == "dest" ) {
if ( !lex.ReadToken( &token ) ) {
lex.Error( "Missing filename after -dest" );
return false;
}
dest = token;
} else {
commandLine += va( " -%s", token.c_str() );
}
} else {
commandLine += va( " %s", token.c_str() );
}
}
if ( sourcedir.Length() ) {
src.StripPath();
sourcedir.BackSlashesToSlashes();
sprintf( src, "%s/%s", sourcedir.c_str(), src.c_str() );
}
if ( destdir.Length() ) {
dest.StripPath();
destdir.BackSlashesToSlashes();
sprintf( dest, "%s/%s", destdir.c_str(), dest.c_str() );
}
return true;
}
示例12: ParseContents
/*
================
idDeclAF::ParseContents
================
*/
bool idDeclAF::ParseContents( idLexer &src, int &c ) const {
idToken token;
idStr str;
while( src.ReadToken( &token ) ) {
str += token;
if ( !src.CheckTokenString( "," ) ) {
break;
}
str += ",";
}
c = ContentsFromString( str );
return true;
}
示例13: R_ParseImageProgram_r
/*
===================
R_ParseImageProgram_r
If pic is NULL, the timestamps will be filled in, but no image will be generated
If both pic and timestamps are NULL, it will just advance past it, which can be
used to parse an image program from a text stream.
===================
*/
static bool R_ParseImageProgram_r( idLexer& src, byte** pic, int* width, int* height,
ID_TIME_T* timestamps, textureUsage_t* usage )
{
idToken token;
float scale;
ID_TIME_T timestamp;
src.ReadToken( &token );
// Since all interaction shaders now assume YCoCG diffuse textures. We replace all entries for the intrinsic
// _black texture to the black texture on disk. Doing this will cause a YCoCG compliant texture to be generated.
// Without a YCoCG compliant black texture we will get color artifacts for any interaction
// material that specifies the _black texture.
if( token == "_black" )
{
token = "textures/black";
}
// also check for _white
if( token == "_white" )
{
token = "guis/assets/white";
}
AppendToken( token );
if( !token.Icmp( "heightmap" ) )
{
MatchAndAppendToken( src, "(" );
if( !R_ParseImageProgram_r( src, pic, width, height, timestamps, usage ) )
{
return false;
}
MatchAndAppendToken( src, "," );
src.ReadToken( &token );
AppendToken( token );
scale = token.GetFloatValue();
// process it
if( pic )
{
R_HeightmapToNormalMap( *pic, *width, *height, scale );
if( usage )
{
*usage = TD_BUMP;
}
}
MatchAndAppendToken( src, ")" );
return true;
}
if( !token.Icmp( "addnormals" ) )
{
byte* pic2 = NULL;
int width2, height2;
MatchAndAppendToken( src, "(" );
if( !R_ParseImageProgram_r( src, pic, width, height, timestamps, usage ) )
{
return false;
}
MatchAndAppendToken( src, "," );
if( !R_ParseImageProgram_r( src, pic ? &pic2 : NULL, &width2, &height2, timestamps, usage ) )
{
if( pic )
{
R_StaticFree( *pic );
*pic = NULL;
}
return false;
}
// process it
if( pic )
{
R_AddNormalMaps( *pic, *width, *height, pic2, width2, height2 );
R_StaticFree( pic2 );
if( usage )
{
*usage = TD_BUMP;
}
}
MatchAndAppendToken( src, ")" );
//.........这里部分代码省略.........
示例14: model
/*
====================
idMD5Mesh::ParseMesh
====================
*/
void idMD5Mesh::ParseMesh( idLexer &parser, int numJoints, const idJointMat *joints ) {
idToken token;
idToken name;
int num;
int count;
int jointnum;
idStr shaderName;
int i, j;
idList<int> tris;
idList<int> firstWeightForVertex;
idList<int> numWeightsForVertex;
int maxweight;
idList<vertexWeight_t> tempWeights;
parser.ExpectTokenString( "{" );
//
// parse name
//
if ( parser.CheckTokenString( "name" ) ) {
parser.ReadToken( &name );
}
//
// parse shader
//
parser.ExpectTokenString( "shader" );
parser.ReadToken( &token );
shaderName = token;
shader = declManager->FindMaterial( shaderName );
//
// parse texture coordinates
//
parser.ExpectTokenString( "numverts" );
count = parser.ParseInt();
if ( count < 0 ) {
parser.Error( "Invalid size: %s", token.c_str() );
}
texCoords.SetNum( count );
firstWeightForVertex.SetNum( count );
numWeightsForVertex.SetNum( count );
numWeights = 0;
maxweight = 0;
for( i = 0; i < texCoords.Num(); i++ ) {
parser.ExpectTokenString( "vert" );
parser.ParseInt();
parser.Parse1DMatrix( 2, texCoords[ i ].ToFloatPtr() );
firstWeightForVertex[ i ] = parser.ParseInt();
numWeightsForVertex[ i ] = parser.ParseInt();
if ( !numWeightsForVertex[ i ] ) {
parser.Error( "Vertex without any joint weights." );
}
numWeights += numWeightsForVertex[ i ];
if ( numWeightsForVertex[ i ] + firstWeightForVertex[ i ] > maxweight ) {
maxweight = numWeightsForVertex[ i ] + firstWeightForVertex[ i ];
}
}
//
// parse tris
//
parser.ExpectTokenString( "numtris" );
count = parser.ParseInt();
if ( count < 0 ) {
parser.Error( "Invalid size: %d", count );
}
tris.SetNum( count * 3 );
numTris = count;
for( i = 0; i < count; i++ ) {
parser.ExpectTokenString( "tri" );
parser.ParseInt();
tris[ i * 3 + 0 ] = parser.ParseInt();
tris[ i * 3 + 1 ] = parser.ParseInt();
tris[ i * 3 + 2 ] = parser.ParseInt();
}
//
// parse weights
//
parser.ExpectTokenString( "numweights" );
count = parser.ParseInt();
if ( count < 0 ) {
parser.Error( "Invalid size: %d", count );
}
//.........这里部分代码省略.........
示例15: R_ParseImageProgram_r
/*
===================
R_ParseImageProgram_r
If pic is NULL, the timestamps will be filled in, but no image will be generated
If both pic and timestamps are NULL, it will just advance past it, which can be
used to parse an image program from a text stream.
===================
*/
static bool R_ParseImageProgram_r( idLexer &src, byte **pic, int *width, int *height,
ID_TIME_T *timestamps, textureDepth_t *depth ) {
idToken token;
float scale;
ID_TIME_T timestamp;
src.ReadToken( &token );
AppendToken( token );
if ( !token.Icmp( "heightmap" ) ) {
MatchAndAppendToken( src, "(" );
if ( !R_ParseImageProgram_r( src, pic, width, height, timestamps, depth ) ) {
return false;
}
MatchAndAppendToken( src, "," );
src.ReadToken( &token );
AppendToken( token );
scale = token.GetFloatValue();
// process it
if ( pic ) {
R_HeightmapToNormalMap( *pic, *width, *height, scale );
if ( depth ) {
*depth = TD_BUMP;
}
}
MatchAndAppendToken( src, ")" );
return true;
}
if ( !token.Icmp( "addnormals" ) ) {
byte *pic2;
int width2, height2;
MatchAndAppendToken( src, "(" );
if ( !R_ParseImageProgram_r( src, pic, width, height, timestamps, depth ) ) {
return false;
}
MatchAndAppendToken( src, "," );
if ( !R_ParseImageProgram_r( src, pic ? &pic2 : NULL, &width2, &height2, timestamps, depth ) ) {
if ( pic ) {
R_StaticFree( *pic );
*pic = NULL;
}
return false;
}
// process it
if ( pic ) {
R_AddNormalMaps( *pic, *width, *height, pic2, width2, height2 );
R_StaticFree( pic2 );
if ( depth ) {
*depth = TD_BUMP;
}
}
MatchAndAppendToken( src, ")" );
return true;
}
if ( !token.Icmp( "smoothnormals" ) ) {
MatchAndAppendToken( src, "(" );
if ( !R_ParseImageProgram_r( src, pic, width, height, timestamps, depth ) ) {
return false;
}
if ( pic ) {
R_SmoothNormalMap( *pic, *width, *height );
if ( depth ) {
*depth = TD_BUMP;
}
}
MatchAndAppendToken( src, ")" );
return true;
}
if ( !token.Icmp( "add" ) ) {
byte *pic2;
int width2, height2;
MatchAndAppendToken( src, "(" );
//.........这里部分代码省略.........