本文整理汇总了C++中BlockInfo::setBiomeGrass方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockInfo::setBiomeGrass方法的具体用法?C++ BlockInfo::setBiomeGrass怎么用?C++ BlockInfo::setBiomeGrass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInfo
的用法示例。
在下文中一共展示了BlockInfo::setBiomeGrass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseDefinition
void BlockIdentifier::parseDefinition(JSONObject *b, BlockInfo *parent,
int pack) {
int id;
if (parent == NULL) {
id = b->at("id")->asNumber();
} else {
id = parent->id;
int data = b->at("data")->asNumber();
id |= data << 12;
}
BlockInfo *block = new BlockInfo();
block->id = id;
if (b->has("name"))
block->setName(b->at("name")->asString());
else if (parent != NULL)
block->setName(parent->getName());
else
block->setName("Unknown");
block->enabled = true;
if (b->has("transparent")) {
block->transparent = b->at("transparent")->asBool();
block->rendernormal = false; // for most cases except the following
if (b->has("rendercube"))
block->rendernormal = b->at("rendercube")->asBool();
block->spawninside = false; // for most cases except the following
if (b->has("spawninside"))
block->spawninside = b->at("spawninside")->asBool();
} else if (parent != NULL) {
block->transparent = parent->transparent;
block->rendernormal = parent->rendernormal;
block->spawninside = parent->spawninside;
} else {
block->transparent = false;
block->rendernormal = true;
block->spawninside = false;
}
if (b->has("liquid"))
block->liquid = b->at("liquid")->asBool();
else if (parent != NULL)
block->liquid = parent->liquid;
else
block->liquid = false;
if (b->has("canProvidePower"))
block->providepower = b->at("canProvidePower")->asBool();
else if (parent != NULL)
block->providepower = parent->providepower;
else
block->providepower = false;
if (b->has("alpha"))
block->alpha = b->at("alpha")->asNumber();
else if (parent != NULL)
block->alpha = parent->alpha;
else
block->alpha = 1.0;
QColor blockcolor;
if (b->has("color")) {
QString colorname = b->at("color")->asString();
if (colorname.length() == 6) {
// check if this is an old color definition with missing '#'
bool ok;
colorname.toInt(&ok,16);
if (ok)
colorname.push_front('#');
}
blockcolor.setNamedColor(colorname);
assert(blockcolor.isValid());
} else if (parent != NULL) {
// copy brightest color from parent
blockcolor = parent->colors[15];
} else {
// use hashed by name instead
quint32 hue = qHash(block->getName());
blockcolor.setHsv(hue % 360, 255, 255);
}
// pre-calculate light spectrum
for (int i = 0; i < 16; i++) {
// calculate light attenuation similar to Minecraft
// except base 90% here, were Minecraft is using 80% per level
double light_factor = pow(0.90,15-i);
block->colors[i].setRgb(light_factor*blockcolor.red(),
light_factor*blockcolor.green(),
light_factor*blockcolor.blue(),
255*block->alpha );
}
// biome dependant color
if (b->has("biomeGrass"))
block->setBiomeGrass( b->at("biomeGrass")->asBool() );
if (b->has("biomeFoliage"))
block->setBiomeFoliage( b->at("biomeFoliage")->asBool() );
// variant reduction mask
if (b->has("mask"))
//.........这里部分代码省略.........