本文整理汇总了C++中idLexer::Error方法的典型用法代码示例。如果您正苦于以下问题:C++ idLexer::Error方法的具体用法?C++ idLexer::Error怎么用?C++ idLexer::Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idLexer
的用法示例。
在下文中一共展示了idLexer::Error方法的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: 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;
}
示例3: 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;
}
示例4:
/*
====================
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();
}
示例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: 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;
}
示例8: 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;
}
示例9: ParseParms
/*
================
idDeclParticle::ParseParms
Parses a variable length list of parms on one line
================
*/
void idDeclParticle::ParseParms( idLexer &src, float *parms, int maxParms ) {
idToken token;
memset( parms, 0, maxParms * sizeof( *parms ) );
int count = 0;
while( 1 ) {
if ( !src.ReadTokenOnLine( &token ) ) {
return;
}
if ( count == maxParms ) {
src.Error( "too many parms on line" );
return;
}
token.StripQuotes();
parms[count] = atof( token );
count++;
}
}
示例10: ParseBody
/*
================
idDeclAF::ParseBody
================
*/
bool idDeclAF::ParseBody( idLexer &src ) {
bool hasJoint = false;
idToken token;
idAFVector angles;
idDeclAF_Body *body = new idDeclAF_Body;
bodies.Alloc() = body;
body->SetDefault( this );
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ||
!src.ExpectTokenString( "{" ) ) {
return false;
}
body->name = token;
if ( !body->name.Icmp( "origin" ) || !body->name.Icmp( "world" ) ) {
src.Error( "a body may not be named \"origin\" or \"world\"" );
return false;
}
while( src.ReadToken( &token ) ) {
if ( !token.Icmp( "model" ) ) {
if ( !src.ExpectTokenType( TT_NAME, 0, &token ) ) {
return false;
}
if ( !token.Icmp( "box" ) ) {
body->modelType = TRM_BOX;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "octahedron" ) ) {
body->modelType = TRM_OCTAHEDRON;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "dodecahedron" ) ) {
body->modelType = TRM_DODECAHEDRON;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "cylinder" ) ) {
body->modelType = TRM_CYLINDER;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( "," ) ) {
return false;
}
body->numSides = src.ParseInt();
if ( !src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "cone" ) ) {
body->modelType = TRM_CONE;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( "," ) ) {
return false;
}
body->numSides = src.ParseInt();
if ( !src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "bone" ) ) {
body->modelType = TRM_BONE;
if ( !src.ExpectTokenString( "(" ) ||
!body->v1.Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!body->v2.Parse( src ) ||
!src.ExpectTokenString( "," ) ) {
return false;
}
body->width = src.ParseFloat();
if ( !src.ExpectTokenString( ")" ) ) {
return false;
}
} else if ( !token.Icmp( "custom" ) ) {
src.Error( "custom models not yet implemented" );
//.........这里部分代码省略.........
示例11: ParseSettings
/*
================
idDeclAF::ParseSettings
================
*/
bool idDeclAF::ParseSettings( idLexer &src ) {
idToken token;
if ( !src.ExpectTokenString( "{" ) ) {
return false;
}
while( src.ReadToken( &token ) ) {
if ( !token.Icmp( "mesh" ) ) {
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
return false;
}
} else if ( !token.Icmp( "anim" ) ) {
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
return false;
}
} else if ( !token.Icmp( "model" ) ) {
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
return false;
}
model = token;
} else if ( !token.Icmp( "skin" ) ) {
if ( !src.ExpectTokenType( TT_STRING, 0, &token ) ) {
return false;
}
skin = token;
} else if ( !token.Icmp( "friction" ) ) {
defaultLinearFriction = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
defaultAngularFriction = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
defaultContactFriction = src.ParseFloat();
if ( src.CheckTokenString( "," ) ) {
defaultConstraintFriction = src.ParseFloat();
}
} else if ( !token.Icmp( "totalMass" ) ) {
totalMass = src.ParseFloat();
} else if ( !token.Icmp( "suspendSpeed" ) ) {
suspendVelocity[0] = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
suspendVelocity[1] = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
suspendAcceleration[0] = src.ParseFloat();
if ( !src.ExpectTokenString( "," ) ) {
return false;
}
suspendAcceleration[1] = src.ParseFloat();
} else if ( !token.Icmp( "noMoveTime" ) ) {
noMoveTime = src.ParseFloat();
} else if ( !token.Icmp( "noMoveTranslation" ) ) {
noMoveTranslation = src.ParseFloat();
} else if ( !token.Icmp( "noMoveRotation" ) ) {
noMoveRotation = src.ParseFloat();
} else if ( !token.Icmp( "minMoveTime" ) ) {
minMoveTime = src.ParseFloat();
} else if ( !token.Icmp( "maxMoveTime" ) ) {
maxMoveTime = src.ParseFloat();
} else if ( !token.Icmp( "contents" ) ) {
ParseContents( src, contents );
} else if ( !token.Icmp( "clipMask" ) ) {
ParseContents( src, clipMask );
} else if ( !token.Icmp( "selfCollision" ) ) {
selfCollision = src.ParseBool();
} else if ( token == "}" ) {
break;
} else {
src.Error( "unknown token %s in settings", token.c_str() );
return false;
}
}
return true;
}
示例12: ParseUniversalJoint
/*
================
idDeclAF::ParseUniversalJoint
================
*/
bool idDeclAF::ParseUniversalJoint( 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_UNIVERSALJOINT;
constraint->limit = idDeclAF_Constraint::LIMIT_NONE;
constraint->name = token;
constraint->friction = 0.5f;
constraint->anchor.ToVec3().Zero();
constraint->shaft[0].ToVec3().Zero();
constraint->shaft[1].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( "shafts" ) ) {
if ( !constraint->shaft[0].Parse( src ) ||
!src.ExpectTokenString( "," ) ||
!constraint->shaft[1].Parse( src ) ) {
return false;
}
} else if ( !token.Icmp( "conelimit" ) ) {
if ( !constraint->limitAxis.Parse( src ) ||
!src.ExpectTokenString( "," ) ) {
return false;
}
constraint->limitAngles[0] = src.ParseFloat();
constraint->limit = idDeclAF_Constraint::LIMIT_CONE;
} else if ( !token.Icmp( "pyramidlimit" ) ) {
if ( !constraint->limitAxis.Parse( src ) ||
!src.ExpectTokenString( "," ) ) {
return false;
}
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_PYRAMID;
} else if ( !token.Icmp( "friction" ) ) {
constraint->friction = src.ParseFloat();
} else if ( token == "}" ) {
break;
} else {
src.Error( "unknown token %s in universal joint", token.c_str() );
return false;
}
}
return true;
}
示例13: model
/*
====================
idMD5Mesh::ParseMesh
====================
*/
void idMD5Mesh::ParseMesh( idLexer& parser, int numJoints, const idJointMat* joints )
{
idToken token;
idToken name;
parser.ExpectTokenString( "{" );
//
// parse name
//
if( parser.CheckTokenString( "name" ) )
{
parser.ReadToken( &name );
}
//
// parse shader
//
parser.ExpectTokenString( "shader" );
parser.ReadToken( &token );
idStr shaderName = token;
shader = declManager->FindMaterial( shaderName );
//
// parse texture coordinates
//
parser.ExpectTokenString( "numverts" );
int count = parser.ParseInt();
if( count < 0 )
{
parser.Error( "Invalid size: %s", token.c_str() );
}
this->numVerts = count;
idList<idVec2> texCoords;
idList<int> firstWeightForVertex;
idList<int> numWeightsForVertex;
texCoords.SetNum( count );
firstWeightForVertex.SetNum( count );
numWeightsForVertex.SetNum( count );
int numWeights = 0;
int maxweight = 0;
for( int 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 );
}
idList<int> tris;
tris.SetNum( count * 3 );
numTris = count;
for( int 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
//
//.........这里部分代码省略.........
示例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: FromParser
//.........这里部分代码省略.........
{
return false;
}
}
else if ( token == "allowFlyReachabilities" )
{
if ( !ParseBool( src, allowFlyReachabilities ) )
{
return false;
}
}
else if ( token == "fileExtension" )
{
src.ExpectTokenString( "=" );
src.ExpectTokenType( TT_STRING, 0, &token );
fileExtension = token;
}
else if ( token == "gravity" )
{
ParseVector( src, gravity );
gravityDir = gravity;
gravityValue = gravityDir.Normalize();
invGravityDir = -gravityDir;
}
else if ( token == "maxStepHeight" )
{
if ( !ParseFloat( src, maxStepHeight ) )
{
return false;
}
}
else if ( token == "maxBarrierHeight" )
{
if ( !ParseFloat( src, maxBarrierHeight ) )
{
return false;
}
}
else if ( token == "maxWaterJumpHeight" )
{
if ( !ParseFloat( src, maxWaterJumpHeight ) )
{
return false;
}
}
else if ( token == "maxFallHeight" )
{
if ( !ParseFloat( src, maxFallHeight ) )
{
return false;
}
}
else if ( token == "minFloorCos" )
{
if ( !ParseFloat( src, minFloorCos ) )
{
return false;
}
}
else if ( token == "tt_barrierJump" )
{
if ( !ParseInt( src, tt_barrierJump ) )
{
return false;
}
}
else if ( token == "tt_startCrouching" )
{
if ( !ParseInt( src, tt_startCrouching ) )
{
return false;
}
}
else if ( token == "tt_waterJump" )
{
if ( !ParseInt( src, tt_waterJump ) )
{
return false;
}
}
else if ( token == "tt_startWalkOffLedge" )
{
if ( !ParseInt( src, tt_startWalkOffLedge ) )
{
return false;
}
}
else
{
src.Error( "invalid token '%s'", token.c_str() );
}
}
if ( numBoundingBoxes <= 0 )
{
src.Error( "no valid bounding box" );
}
return true;
}