本文整理汇总了C++中Particles::AttachController方法的典型用法代码示例。如果您正苦于以下问题:C++ Particles::AttachController方法的具体用法?C++ Particles::AttachController怎么用?C++ Particles::AttachController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Particles
的用法示例。
在下文中一共展示了Particles::AttachController方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateScene
//----------------------------------------------------------------------------
void ParticleSystems::CreateScene ()
{
mScene = new0 Node();
mWireState = new0 WireState();
mRenderer->SetOverrideWireState(mWireState);
VertexFormat* vformat = VertexFormat::Create(2,
VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
int vstride = vformat->GetStride();
const int numParticles = 32;
VertexBuffer* vbuffer = new0 VertexBuffer(4*numParticles, vstride);
Float4* positionSizes = new1<Float4>(numParticles);
for (int i = 0; i < numParticles; ++i)
{
positionSizes[i][0] = Mathf::SymmetricRandom();
positionSizes[i][1] = Mathf::SymmetricRandom();
positionSizes[i][2] = Mathf::SymmetricRandom();
positionSizes[i][3] = 0.25f*Mathf::UnitRandom();
}
Particles* particles = new0 Particles(vformat, vbuffer, sizeof(int),
positionSizes, 1.0f);
particles->AttachController(new0 BloodCellController());
mScene->AttachChild(particles);
// Create an image with transparency.
const int xsize = 32, ysize = 32;
Texture2D* texture = new0 Texture2D(Texture::TF_A8R8G8B8, xsize,
ysize, 1);
unsigned char* data = (unsigned char*)texture->GetData(0);
float factor = 1.0f/(xsize*xsize + ysize*ysize);
for (int y = 0, i = 0; y < ysize; ++y)
{
for (int x = 0; x < xsize; ++x)
{
// The image is red.
data[i++] = 0;
data[i++] = 0;
data[i++] = 255;
// Semitransparent within a disk, dropping off to zero outside the
// disk.
int dx = 2*x - xsize;
int dy = 2*y - ysize;
float value = factor*(dx*dx + dy*dy);
if (value < 0.125f)
{
value = Mathf::Cos(4.0f*Mathf::PI*value);
}
else
{
value = 0.0f;
}
data[i++] = (unsigned char)(255.0f*value);
}
}
Texture2DEffect* effect = new0 Texture2DEffect(Shader::SF_LINEAR);
effect->GetAlphaState(0, 0)->BlendEnabled = true;
effect->GetDepthState(0, 0)->Enabled = false;
particles->SetEffectInstance(effect->CreateInstance(texture));
}