|
楼主 |
发表于 2013-1-10 16:55:16
|
显示全部楼层
代码如下,但是问题是,好像所有的粒子的运行轨迹一致导致,出现一个个很大的亮点,并没有预想的分散开形成预想的效果,问题到底在哪如何修改呢?项目难点,下周四要完成,各位大侠帮忙瞧一瞧,给个建议。
// apply a vortex-like acceleration. This code is not optimized,
// it's here only for demonstration purposes.
void operate(osgParticle:article *P, double dt)
{
static osgParticle::Particle *gP = P;
double existTime = dt;
//平面角
static double circulTheta=360;
//俯仰角
static double circulPitch = 0;
//球半径a
static double circurRadius=30;
//粒子运行1.5秒后进行球体轨迹运动
if (P->getAge()>1.5)
{
circulTheta -=0.0045;
circulPitch -=0.0045;
if (circulTheta>90)
{
circulTheta = 0;
}
if (circulPitch>360)
{
circulPitch = 0;
}
circulPitch = P->getCurrentAlpha();
circulPitch = P->ge;
osg::Vec3 tempPos = P->getPosition();
//计算粒子轨迹
y = circurRadius*cos((360-circulTheta)*osg::PI/180);
z = -(circurRadius*sin((360-circulTheta)*osg::PI/180));
x = circurRadius*sin(circulPitch*osg::PI/180);
osg::Vec3 newpos;// = P->getPosition() + v * dt;
newpos[0] = x;
newpos[1] = y;
newpos[2] = z;
P->setPosition(newpos);
}
static double theta=360;
//俯仰角
static double pitch = 360;
//双钮线最大半径a
static double maxRadius=100;
if (P->getAge()>5)
{
theta -=0.0045;
pitch -=0.0045;
if (theta<270)
{
theta = 360;
}
if (pitch<0)
{
pitch = 360;
}
osg::Vec3 tempPos = P->getPosition();
////双钮线半径
lou = sqrt(maxRadius*maxRadius*cos(2*theta*osg::PI/180));
y = lou*cos((360-theta)*osg::PI/180);
z = -(lou*sin((360-theta)*osg::PI/180));
x = lou*sin(pitch*osg::PI/180);
// compute new position
osg::Vec3 newpos;// = P->getPosition() + v * dt;
newpos[0] = x;
newpos[1] = y;
newpos[2] = z;
P->setPosition(newpos);
}
} |
|