本文整理汇总了C++中Sprite3D::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite3D::retain方法的具体用法?C++ Sprite3D::retain怎么用?C++ Sprite3D::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite3D
的用法示例。
在下文中一共展示了Sprite3D::retain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCLOG
void PUParticle3DModelRender::render( Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem )
{
if (!_isVisible)
return;
if (_spriteList.empty()) {
for (unsigned int i = 0; i < particleSystem->getParticleQuota(); ++i) {
Sprite3D *sprite = Sprite3D::create(_modelFile);
if (sprite == nullptr)
{
CCLOG("failed to load file %s", _modelFile.c_str());
continue;
}
sprite->setTexture(_texFile);
sprite->setBlendFunc(particleSystem->getBlendFunc());
sprite->setCullFaceEnabled(false);
sprite->retain();
_spriteList.push_back(sprite);
}
if (!_spriteList.empty()) {
const AABB &aabb = _spriteList[0]->getAABB();
Vec3 corners[8];
aabb.getCorners(corners);
_spriteSize = corners[3] - corners[6];
} else {
_isVisible = false;
return;
}
}
const ParticlePool& particlePool = particleSystem->getParticlePool();
ParticlePool::PoolList activeParticleList = particlePool.getActiveDataList();
Mat4 mat;
Mat4 rotMat;
Mat4 sclMat;
Quaternion q;
transform.decompose(nullptr, &q, nullptr);
unsigned int index = 0;
for (auto iter : activeParticleList)
{
auto particle = static_cast<PUParticle3D *>(iter);
Mat4::createRotation(q * particle->orientation, &rotMat);
sclMat.m[0] = particle->width / _spriteSize.x;
sclMat.m[5] = particle->height / _spriteSize.y;
sclMat.m[10] = particle->depth / _spriteSize.z;
mat = rotMat * sclMat;
mat.m[12] = particle->position.x;
mat.m[13] = particle->position.y;
mat.m[14] = particle->position.z;
if (_spriteList[index]->getCameraMask() != particleSystem->getCameraMask())
_spriteList[index]->setCameraMask(particleSystem->getCameraMask());
_spriteList[index]->setColor(Color3B(particle->color.x * 255, particle->color.y * 255, particle->color.z * 255));
_spriteList[index]->setOpacity(particle->color.w * 255);
_spriteList[index]->visit(renderer, mat, Node::FLAGS_DIRTY_MASK);
++index;
}
}