本文整理汇总了C++中ParticleSystem::applyForce方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystem::applyForce方法的具体用法?C++ ParticleSystem::applyForce怎么用?C++ ParticleSystem::applyForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem::applyForce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Demo::update() {
Vec2f gravity = Vec2f(0, 0.01);
particleSystem->applyForce(gravity);
float dx = lmap((float)getMousePos().x, 0.0f, (float)getWindowWidth(), -0.2f, 0.2f);
Vec2f wind = Vec2f(dx, 0);
particleSystem->applyForce(wind);
particleSystem->addParticle();
particleSystem->update();
}
示例2: lmap
void NOC_4_08_ParticleSystemSmokeApp::draw()
{
gl::clear( Color::black() );
// Calculate a "wind" force based on mouse horizontal position
float dx = lmap( mousePos.x, 0.0f, float( getWindowWidth() ), -0.2f, 0.2f );
Vec2f wind = Vec2f( dx, 0 );
ps.applyForce(wind);
for( int i = 0; i < 2; i++ ){
ps.addParticle();
}
ps.run();
// Draw an arrow representing the wind force
drawVector( wind, Vec2f( getWindowWidth() / 2, 50 ), 500 );
}
开发者ID:FreeArtBureau,项目名称:The-Nature-of-Code-Examples,代码行数:17,代码来源:NOC_4_08_ParticleSystemSmokeApp.cpp
示例3: update
void update(int t) {
if (currentCamera == 0) {
cameraAngle += (diffMouseDownX / 100.0);
cameraDistance = (cameraDistance += (diffMouseDownY / 20.0)) < 10 ? 10 : cameraDistance;
camera.set(
cameraDistance * cos(cameraAngle * (M_PI / 180)),
cameraElevation,
cameraDistance * sin(cameraAngle * (M_PI / 180))
);
cameraLookAt = Vector3();
cameraUp = Vector3(0, 1, 0);
}
else if (currentCamera == 1) {
aboveCamera.y = (std::max(50.0, aboveCamera.y + (diffMouseDownY / 100.0)));
aboveCameraLookAt = Vector3(0, aboveCamera.y - 100, aboveCamera.z);
cameraLookAt = aboveCameraLookAt;
camera.set(aboveCamera.x, aboveCamera.y, aboveCamera.z);
cameraUp = aboveCameraUp;
}
else if (currentCamera == 2) {
frontCamera.y = (frontCamera.y + (diffMouseDownY / 100.0));
frontCamera.x = (frontCamera.x - (diffMouseDownX / 100.0));
frontCamera.z = (cameraDistance);
frontCameraLookAt = frontCamera.add(Vector3(0.0, 0.0, -1.0));
cameraLookAt = frontCameraLookAt;
camera.set(frontCamera.x, frontCamera.y, frontCamera.z);
cameraUp = frontCameraUp;
}
else if (currentCamera == 3) {
getFreeCameraLookAt();
cameraLookAt = freeCameraLookAt;
camera.set(freeCamera.x, freeCamera.y, freeCamera.z);
freeCameraUp.x = sin(upAngle * (M_PI / 180));
freeCameraUp.y = cos(upAngle * (M_PI / 180));
cameraUp = freeCameraUp;
}
else if (currentCamera >= 4) {
updateFlyBy();
cameraLookAt = flyBySettings.lookAt;
camera.set(
flyBySettings.position.x,
flyBySettings.position.y,
flyBySettings.position.z
);
cameraUp = flyBySettings.up;
}
gravity.y = gravityIntensity;
particleSystem.applyForce(gravity);
for (int i = 0; i < 9; i++) {
if (gravitationalForce[i].type != GRAVITATIONALFORCETYPE_NONE) {
particleSystem.applyGravitationalForce(gravitationalForce[i]);
}
}
if (cycleColours) {
colourSwitch--;
if (colourSwitch == 0) {
colourSwitch = 10;
Particle::startColour = emitColours[initialColour];
currentColour = Particle::startColour;
initialColour = (++initialColour) == colourCount ? 0 : initialColour;
}
else {
Particle::startColour.r = linearEase(10 - colourSwitch, currentColour.r, emitColours[initialColour].r - currentColour.r, 10);
Particle::startColour.g = linearEase(10 - colourSwitch, currentColour.g, emitColours[initialColour].g - currentColour.g, 10);
Particle::startColour.b = linearEase(10 - colourSwitch, currentColour.b, emitColours[initialColour].b - currentColour.b, 10);
}
}
particleSystem.update();
// FPS monitoring
frame++;
elapsedTime = glutGet(GLUT_ELAPSED_TIME);
if (elapsedTime - timebase > 1000) {
fps = frame * 1000.0 / (elapsedTime - timebase);
timebase = elapsedTime;
//.........这里部分代码省略.........