本文整理汇总了C++中Lexer::ReadFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::ReadFloat方法的具体用法?C++ Lexer::ReadFloat怎么用?C++ Lexer::ReadFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer::ReadFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseVector
static void ParseVector( Lexer &lexer, float *vec, int dim ) {
lexer.ExpectToken("(");
for( int i=0; i<dim; i++ )
vec[i] = lexer.ReadFloat();
lexer.ExpectToken(")");
}
示例2: ReadMesh
/*
================
ReadMesh
================
*/
static void ReadMesh( Lexer &lexer, aseMesh *inMesh ) {
int idx;
Vec3 temp;
lexer.ExpectToken("{");
const char *p;
const Token *token;
while ( (token = lexer.ReadToken()) != OG_NULL ) {
p = token->GetString();
if ( !p || !*p )
continue;
if ( String::Icmp( p, "}" ) == 0 )
return;
if ( String::Icmp( p, "*" ) != 0 )
lexer.Error( Format("expected *, got '$*'") << p );
if ( lexer.CheckToken( "MESH_NUMVERTEX" ) ) {
inMesh->numVerts = lexer.ReadInt();
inMesh->vertices = new aseVertex[inMesh->numVerts];
}
else if ( lexer.CheckToken( "MESH_NUMFACES" ) ) {
inMesh->numTris = lexer.ReadInt();
inMesh->triangles = new aseTriangle[inMesh->numTris];
}
else if ( lexer.CheckToken( "MESH_VERTEX_LIST" ) ) {
lexer.ExpectToken("{");
for( int i=0; i<inMesh->numVerts; i++ ) {
lexer.ExpectToken("*");
lexer.ExpectToken("MESH_VERTEX");
idx = lexer.ReadInt();
inMesh->vertices[idx].origin.x = lexer.ReadFloat() * ASE_MODEL_SCALE;
inMesh->vertices[idx].origin.y = lexer.ReadFloat() * ASE_MODEL_SCALE;
inMesh->vertices[idx].origin.z = lexer.ReadFloat() * ASE_MODEL_SCALE;
}
lexer.ExpectToken("}");
}
else if ( lexer.CheckToken( "MESH_NORMALS" ) ) {
lexer.ExpectToken("{");
for( ;; ) {
if ( lexer.CheckToken("}") )
break;
lexer.ExpectToken("*");
// don't need the face normal
if ( lexer.CheckToken("MESH_FACENORMAL") ) {
lexer.GotoNextLine();
continue;
}
lexer.ExpectToken("MESH_VERTEXNORMAL");
idx = lexer.ReadInt();
inMesh->vertices[idx].normal.x = lexer.ReadFloat();
inMesh->vertices[idx].normal.y = lexer.ReadFloat();
inMesh->vertices[idx].normal.z = lexer.ReadFloat();
}
}
else if ( lexer.CheckToken( "MESH_FACE_LIST" ) ) {
lexer.ExpectToken("{");
for( int i=0; i<inMesh->numTris; i++ ) {
lexer.ExpectToken("*");
lexer.ExpectToken("MESH_FACE");
idx = lexer.ReadInt();
lexer.CheckToken(":"); // might or might not be there
lexer.ExpectToken("A");
lexer.ExpectToken(":");
inMesh->triangles[idx].v[0] = lexer.ReadInt();
lexer.ExpectToken("B");
lexer.ExpectToken(":");
inMesh->triangles[idx].v[1] = lexer.ReadInt();
lexer.ExpectToken("C");
lexer.ExpectToken(":");
inMesh->triangles[idx].v[2] = lexer.ReadInt();
lexer.GotoNextLine();
}
lexer.ExpectToken("}");
}
else if ( lexer.CheckToken( "MESH_NUMTVERTEX" ) ) {
inMesh->numTVerts = lexer.ReadInt();
inMesh->texCoords = new Vec2[inMesh->numTVerts];
}
else if ( lexer.CheckToken( "MESH_TVERTLIST" ) ) {
lexer.ExpectToken("{");
for( int i=0; i<inMesh->numTVerts; i++ ) {
lexer.ExpectToken("*");
lexer.ExpectToken("MESH_TVERT");
idx = lexer.ReadInt();
inMesh->texCoords[idx].x = lexer.ReadFloat();
inMesh->texCoords[idx].y = 1.0f-lexer.ReadFloat();
lexer.ReadFloat();// don't need 3rd component
}
lexer.ExpectToken("}");
}
else if ( lexer.CheckToken( "MESH_NUMTVFACES" ) )
lexer.ExpectToken( Format() << inMesh->numTris );
else if ( lexer.CheckToken( "MESH_TFACELIST" ) ) {
lexer.ExpectToken("{");
for( int i=0; i<inMesh->numTris; i++ ) {
lexer.ExpectToken("*");
//.........这里部分代码省略.........