Exemple #1
0
BillboardSprite::BillboardSprite(SceneNode* node, BillboardSet* bs, int row, int col, int unitWidth, int unitHeight)
	: mNode(node), mBillboards(bs), mRow(row), mCol(col), mUnitWidth(unitWidth), mUnitHeight(unitHeight),
	mIsFinished(false)
{
	mWidth = row * unitWidth;
	mHeight = col * unitHeight;
	Billboard* b = mBillboards->getBillboard(0);
	if (b)
		b->setTexcoordRect(0, 0, 1 / (float)mRow, 1 / (float)mCol);
}
void BillboardSetComponent::createBillboard(const PonykartParsers::BillboardBlock* const block)
{
	Billboard* bb = billboardSet->createBillboard(block->getVectorProperty("Position")); // make our billboard
	// set its color if it has one, and a rotation
	auto quatIt=block->getQuatTokens().find("colour");
	if (quatIt != block->getQuatTokens().end())
		bb->setColour(toColourValue(quatIt->second));
	bb->setRotation(Degree(block->getFloatProperty("Rotation", 0)));

	auto rectQIt = block->getQuatTokens().find("texturecoords");
	if (rectQIt != block->getQuatTokens().end())
		bb->setTexcoordRect(rectQIt->second.x, rectQIt->second.y, rectQIt->second.z, rectQIt->second.w);

	// It's best to not do this unless we really need to since it makes it less efficient
	auto fTokens = block->getFloatTokens();
	auto heightIt=fTokens.find("height"), widthIt=fTokens.find("width");
	if (heightIt!=fTokens.end() && widthIt!=fTokens.end())
		bb->setDimensions(widthIt->second, heightIt->second);
}