本文整理汇总了C++中Stream::GetStreamOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::GetStreamOptions方法的具体用法?C++ Stream::GetStreamOptions怎么用?C++ Stream::GetStreamOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::GetStreamOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
MD5MeshParser::MD5MeshParser(Stream& stream) :
m_stream(stream),
m_keepLastLine(false),
m_lineCount(0),
m_meshIndex(0),
m_streamFlags(stream.GetStreamOptions()) //< Saves stream flags
{
m_stream.EnableTextMode(true);
}
示例2: Save
bool MTLParser::Save(Stream& stream) const
{
m_currentStream = &stream;
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
{
stream.EnableTextMode(true);
resetTextMode.Reset([&stream] ()
{
stream.EnableTextMode(false);
});
}
m_outputStream.Clear();
EmitLine("# Exported by Nazara Engine");
EmitLine();
Emit("# material count: ");
Emit(m_materials.size());
EmitLine();
for (auto& pair : m_materials)
{
const String& matName = pair.first;
const Material& mat = pair.second;
Emit("newmtl ");
EmitLine(matName);
EmitLine();
Emit("Ka ");
Emit(mat.ambient.r / 255.f);
Emit(' ');
Emit(mat.ambient.g / 255.f);
Emit(' ');
Emit(mat.ambient.b / 255.f);
EmitLine();
Emit("Kd ");
Emit(mat.diffuse.r / 255.f);
Emit(' ');
Emit(mat.diffuse.g / 255.f);
Emit(' ');
Emit(mat.diffuse.b / 255.f);
EmitLine();
Emit("Ks ");
Emit(mat.specular.r / 255.f);
Emit(' ');
Emit(mat.specular.g / 255.f);
Emit(' ');
Emit(mat.specular.b / 255.f);
EmitLine();
if (!NumberEquals(mat.alpha, 1.f))
{
Emit("d ");
EmitLine(mat.alpha);
}
if (!NumberEquals(mat.refractionIndex, 1.f))
{
Emit("ni ");
EmitLine(mat.refractionIndex);
}
if (!NumberEquals(mat.shininess, 1.f))
{
Emit("ns ");
EmitLine(mat.shininess);
}
if (mat.illumModel != 0)
{
Emit("illum ");
EmitLine(mat.illumModel);
}
if (!mat.ambientMap.IsEmpty())
{
Emit("map_Ka ");
EmitLine(mat.ambientMap);
}
if (!mat.diffuseMap.IsEmpty())
{
Emit("map_Kd ");
EmitLine(mat.diffuseMap);
}
if (!mat.specularMap.IsEmpty())
{
Emit("map_Ks ");
EmitLine(mat.specularMap);
}
//.........这里部分代码省略.........
示例3: Parse
bool MTLParser::Parse(Stream& stream)
{
m_currentStream = &stream;
// Force stream in text mode, reset it at the end
Nz::CallOnExit resetTextMode;
if ((stream.GetStreamOptions() & StreamOption_Text) == 0)
{
stream.EnableTextMode(true);
resetTextMode.Reset([&stream] ()
{
stream.EnableTextMode(false);
});
}
m_keepLastLine = false;
m_lineCount = 0;
m_materials.clear();
Material* currentMaterial = nullptr;
while (Advance(false))
{
String keyword = m_currentLine.GetWord(0).ToLower();
if (keyword == "ka")
{
float r, g, b;
if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3)
{
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->ambient = Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "kd")
{
float r, g, b;
if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3)
{
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->diffuse = Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "ks")
{
float r, g, b;
if (std::sscanf(&m_currentLine[3], "%f %f %f", &r, &g, &b) == 3)
{
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->specular = Color(static_cast<UInt8>(r*255.f), static_cast<UInt8>(g*255.f), static_cast<UInt8>(b*255.f));
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "ni")
{
float density;
if (std::sscanf(&m_currentLine[3], "%f", &density) == 1)
{
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->refractionIndex = density;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
else if (keyword == "ns")
{
float coef;
if (std::sscanf(&m_currentLine[3], "%f", &coef) == 1)
{
if (!currentMaterial)
currentMaterial = AddMaterial("default");
currentMaterial->shininess = coef;
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else
UnrecognizedLine();
#endif
}
//.........这里部分代码省略.........