本文整理汇总了C++中parser::DefTokeniser::skipTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ DefTokeniser::skipTokens方法的具体用法?C++ DefTokeniser::skipTokens怎么用?C++ DefTokeniser::skipTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser::DefTokeniser
的用法示例。
在下文中一共展示了DefTokeniser::skipTokens方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseParticleDef
// Parse a single particle def
void ParticlesManager::parseParticleDef(parser::DefTokeniser& tok, const std::string& filename)
{
// Standard DEF, starts with "particle <name> {"
std::string declName = tok.nextToken();
// Check for a valid particle declaration, some .prt files contain materials
if (declName != "particle")
{
// No particle, skip name plus whole block
tok.skipTokens(1);
tok.assertNextToken("{");
for (std::size_t level = 1; level > 0;)
{
std::string token = tok.nextToken();
if (token == "}")
{
level--;
}
else if (token == "{")
{
level++;
}
}
return;
}
// Valid particle declaration, go ahead parsing the name
std::string name = tok.nextToken();
tok.assertNextToken("{");
ParticleDefPtr pdef = findOrInsertParticleDef(name);
pdef->setFilename(filename);
// Let the particle construct itself from the token stream
pdef->parseFromTokens(tok);
}
示例2: GlobalPatchCreator
/*
// Example Primitive
{
patchDef2
{
"textures/darkmod/stone/brick/rough_big_blocks03"
( 5 3 0 0 0 )
(
( ( 64 -88 108 0 0 ) ( 64 -88 184 0 -1.484375 ) ( 64 -88 184 0 -1.484375 ) )
( ( 64 -88 184 1.484375 0 ) ( 64 -88 184 1.484375 -1.484375 ) ( 64 -88 184 1.484375 -1.484375 ) )
( ( 112 -88 184 2.421875 0 ) ( 112 -88 184 2.421875 -1.484375 ) ( 112 -88 184 2.421875 -1.484375 ) )
( ( 160 -88 184 3.359375 0 ) ( 160 -88 184 3.359375 -1.484375 ) ( 160 -88 184 3.359375 -1.484375 ) )
( ( 160 -88 108 4.84375 0 ) ( 160 -88 184 4.84375 -1.484375 ) ( 160 -88 184 4.84375 -1.484375 ) )
)
}
}
*/
scene::INodePtr PatchDef2Parser::parse(parser::DefTokeniser& tok) const
{
scene::INodePtr node = GlobalPatchCreator(DEF2).createPatch();
IPatchNodePtr patchNode = boost::dynamic_pointer_cast<IPatchNode>(node);
assert(patchNode != NULL);
IPatch& patch = patchNode->getPatch();
tok.assertNextToken("{");
// Parse shader
patch.setShader(tok.nextToken());
// Parse parameters
tok.assertNextToken("(");
// parse matrix dimensions
std::size_t cols = string::convert<std::size_t>(tok.nextToken());
std::size_t rows = string::convert<std::size_t>(tok.nextToken());
patch.setDims(cols, rows);
// ignore contents/flags values
tok.skipTokens(3);
tok.assertNextToken(")");
// Parse Patch Matrix
parseMatrix(tok, patch);
// Parse Footer
tok.assertNextToken("}");
tok.assertNextToken("}");
patch.controlPointsChanged();
return node;
}
示例3: parseFromTokens
void ParticleParameter::parseFromTokens(parser::DefTokeniser& tok)
{
std::string val = tok.nextToken();
try
{
setFrom(boost::lexical_cast<float>(val));
}
catch (boost::bad_lexical_cast&)
{
rError() << "[particles] Bad lower value, token is '" <<
val << "'" << std::endl;
}
if (tok.peek() == "to")
{
// Upper value is there, parse it
tok.skipTokens(1); // skip the "to"
val = tok.nextToken();
try
{
// cut off the quotes before converting to double
setTo(boost::lexical_cast<float>(val));
}
catch (boost::bad_lexical_cast&)
{
rError() << "[particles] Bad upper value, token is '" <<
val << "'" << std::endl;
}
}
else
{
setTo(getFrom());
}
}
示例4: if
scene::INodePtr BrushDef3Parser::parse(parser::DefTokeniser& tok) const
{
// Create a new brush
scene::INodePtr node = GlobalBrushCreator().createBrush();
// Cast the node, this must succeed
IBrushNodePtr brushNode = boost::dynamic_pointer_cast<IBrushNode>(node);
assert(brushNode != NULL);
IBrush& brush = brushNode->getIBrush();
tok.assertNextToken("{");
// Parse face tokens until a closing brace is encountered
while (1)
{
std::string token = tok.nextToken();
// Token should be either a "(" (start of face) or "}" (end of brush)
if (token == "}")
{
break; // end of brush
}
else if (token == "(") // FACE
{
// Construct a plane and parse its values
Plane3 plane;
plane.normal().x() = string::to_float(tok.nextToken());
plane.normal().y() = string::to_float(tok.nextToken());
plane.normal().z() = string::to_float(tok.nextToken());
plane.dist() = -string::to_float(tok.nextToken()); // negate d
tok.assertNextToken(")");
// Parse TexDef
Matrix4 texdef;
tok.assertNextToken("(");
tok.assertNextToken("(");
texdef.xx() = string::to_float(tok.nextToken());
texdef.yx() = string::to_float(tok.nextToken());
texdef.tx() = string::to_float(tok.nextToken());
tok.assertNextToken(")");
tok.assertNextToken("(");
texdef.xy() = string::to_float(tok.nextToken());
texdef.yy() = string::to_float(tok.nextToken());
texdef.ty() = string::to_float(tok.nextToken());
tok.assertNextToken(")");
tok.assertNextToken(")");
// Parse Shader
std::string shader = tok.nextToken();
// Parse Flags (usually each brush has all faces detail or all faces structural)
IBrush::DetailFlag flag = static_cast<IBrush::DetailFlag>(
string::convert<std::size_t>(tok.nextToken(), IBrush::Structural));
brush.setDetailFlag(flag);
// Ignore the other two flags
tok.skipTokens(2);
// Finally, add the new face to the brush
/*IFace& face = */brush.addFace(plane, texdef, shader);
}
else {
std::string text = (boost::format(_("BrushDef3Parser: invalid token '%s'")) % token).str();
throw parser::ParseException(text);
}
}
// Final outer "}"
tok.assertNextToken("}");
return node;
}
示例5: parse
/*
// Example Primitive
{
brushDef
{
( -1216 -464 232 ) ( -1088 -464 232 ) ( -1088 -80 120 ) ( ( 0.031250 0 14 ) ( -0.000009 0.031250 4.471550 ) ) common/caulk 134217728 4 0
( -1088 -464 248 ) ( -1216 -464 248 ) ( -1216 -80 136 ) ( ( 0 -0.031373 -0.147059 ) ( 0.007812 0 0.049020 ) ) common/caulk 134217728 0 0
( -1088 -560 120 ) ( -1088 -560 136 ) ( -1088 -80 136 ) ( ( 0.031250 0 16.500000 ) ( 0 0.031250 0.250000 ) ) common/caulk 134217728 4 0
( -1088 -80 136 ) ( -1216 -80 136 ) ( -1216 -80 8 ) ( ( 0.031250 0 2 ) ( 0 0.031250 0.250000 ) ) common/caulk 134217728 4 0
( -1216 -400 136 ) ( -1216 -400 120 ) ( -1216 -80 120 ) ( ( 0.031250 0 -16.500000 ) ( 0 0.031250 0.250000 ) ) common/caulk 134217728 4 0
( -1088 -464 232 ) ( -1216 -464 232 ) ( -1216 -464 248 ) ( ( 0.031250 0 -2 ) ( 0 0.031250 0.250000 ) ) common/caulk 134217728 4 0
}
}
*/
scene::INodePtr BrushDefParser::parse(parser::DefTokeniser& tok) const
{
// Create a new brush
scene::INodePtr node = GlobalBrushCreator().createBrush();
// Cast the node, this must succeed
IBrushNodePtr brushNode = boost::dynamic_pointer_cast<IBrushNode>(node);
assert(brushNode != NULL);
IBrush& brush = brushNode->getIBrush();
tok.assertNextToken("{");
// Parse face tokens until a closing brace is encountered
while (1)
{
std::string token = tok.nextToken();
// Token should be either a "(" (start of face) or "}" (end of brush)
if (token == "}")
{
break; // end of brush
}
else if (token == "(") // FACE
{
// Parse three 3D points to construct a plane
Vector3 p1(string::to_float(tok.nextToken()), string::to_float(tok.nextToken()), string::to_float(tok.nextToken()));
tok.assertNextToken(")");
tok.assertNextToken("(");
Vector3 p2(string::to_float(tok.nextToken()), string::to_float(tok.nextToken()), string::to_float(tok.nextToken()));
tok.assertNextToken(")");
tok.assertNextToken("(");
Vector3 p3(string::to_float(tok.nextToken()), string::to_float(tok.nextToken()), string::to_float(tok.nextToken()));
tok.assertNextToken(")");
// Construct the plane from the three points
Plane3 plane(p1, p2, p3);
// Parse TexDef
Matrix4 texdef;
tok.assertNextToken("(");
tok.assertNextToken("(");
texdef.xx() = string::to_float(tok.nextToken());
texdef.yx() = string::to_float(tok.nextToken());
texdef.tx() = string::to_float(tok.nextToken());
tok.assertNextToken(")");
tok.assertNextToken("(");
texdef.xy() = string::to_float(tok.nextToken());
texdef.yy() = string::to_float(tok.nextToken());
texdef.ty() = string::to_float(tok.nextToken());
tok.assertNextToken(")");
tok.assertNextToken(")");
// Parse Shader, brushDef has an implicit "textures/" not written to the map
std::string shader = "textures/" + tok.nextToken();
// Parse Contents Flags (and ignore them)
tok.skipTokens(3);
// Finally, add the new face to the brush
/*IFace& face = */brush.addFace(plane, texdef, shader);
}
else
{
std::string text = (boost::format(_("BrushDefParser: invalid token '%s'")) % token).str();
throw parser::ParseException(text);
}
}
// Final outer "}"
tok.assertNextToken("}");
return node;
}