Skip to content

Commit 2676338

Browse files
author
Cheng Xie
committedDec 14, 2013
small adjustments
1 parent 843593f commit 2676338

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed
 

‎src/rain.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Rain::Rain(float radius)
1212
Texture* texture = TextureCache::getInstance()->acquire("rain", TextureType::Texture2D);
1313
setParticleTexture(texture);
1414

15-
setEmissionRate(1000);
15+
setEmissionRate(4000);
1616

17-
setMaxParticleCount(10000);
17+
setMaxParticleCount(20000);
1818

1919
ParticleMaterial* material = static_cast<ParticleMaterial *>(material_);
2020
material->setLengthScale(12);
@@ -42,7 +42,7 @@ void Rain::spawnParticle(Particle *particle)
4242
particle->size = 0.08;
4343

4444
float scale = randf(0.6f, 0.8f);
45-
particle->color = {scale, scale, scale};
45+
particle->color = {scale, scale * 0.9, scale * 0.85};
4646

4747
particle->opacity = randf(0.4, 0.7);
4848
}
@@ -58,7 +58,7 @@ void Rain::renderGeometry(DrawContext &context)
5858
ParticleSystem::renderGeometry(context);
5959
transform().setToIdentity();
6060
vec3 camPos = context.camera->position();
61-
transform().translate(camPos.x(), camPos.y() + 30, camPos.z());
61+
transform().translate(camPos.x(), camPos.y() + 50, camPos.z());
6262
}
6363

6464

‎src/rainsplash.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "texturecache.h"
44
#include "particlematerial.h"
55
#include "terrain.h"
6+
#include "drawcontext.h"
7+
#include "camera.h"
68

79
RainSplash::RainSplash(float radius, bool mist, Terrain* terrain)
810
{
@@ -23,18 +25,18 @@ RainSplash::RainSplash(float radius, bool mist, Terrain* terrain)
2325

2426
setParticleTexture(texture);
2527

26-
setEmissionRate(1000);
28+
setEmissionRate(8000);
2729

28-
setMaxParticleCount(10000);
30+
setMaxParticleCount(40000);
2931
}
3032

3133
void RainSplash::spawnParticle(Particle *particle)
3234
{
3335
float phi = randf(0, M_PI * 2);
34-
float r = radius_ * randf(0.3, 1.0);
36+
float r = radius_ * randf(0, 1.0);
3537

36-
float x = cosf(phi) * r;
37-
float z = sinf(phi) * r;
38+
float x = cosf(phi) * r + cameraPosition_.x();
39+
float z = sinf(phi) * r + cameraPosition_.z();
3840
float y = terrain_->height(x, z) + 0.1;
3941

4042
particle->position = {x, y, z};
@@ -58,3 +60,10 @@ void RainSplash::updateParticle(Particle &particle, float dt)
5860
particle.opacity = startOpacity_ * (1 - x);
5961

6062
}
63+
64+
void RainSplash::renderGeometry(DrawContext &context)
65+
{
66+
ParticleSystem::renderGeometry(context);
67+
transform().setToIdentity();
68+
cameraPosition_ = context.camera->position();
69+
}

‎src/rainsplash.h

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class RainSplash : public ParticleSystem
1414

1515
virtual void updateParticle(Particle &particle, float dt) override;
1616

17+
virtual void renderGeometry(DrawContext &context) override;
18+
1719
private:
1820
float radius_ = 0;
1921

@@ -22,6 +24,8 @@ class RainSplash : public ParticleSystem
2224

2325
float startSize_ = 0;
2426
float startOpacity_ = 0;
27+
28+
vec3 cameraPosition_;
2529
};
2630

2731
#endif // RAINSPLASH_H

‎src/scene.cpp

+3-16
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ void Scene::initialize()
8282
sceneObjects_.push_back(rain);
8383

8484
// RainSplash
85-
RainSplash* splash = new RainSplash(50, true, terrain);
85+
RainSplash* splash = new RainSplash(100, true, terrain);
8686
sceneObjects_.push_back(splash);
8787

88-
splash = new RainSplash(50, false, terrain);
88+
splash = new RainSplash(100, false, terrain);
8989
sceneObjects_.push_back(splash);
9090

9191
// Follower cloud
@@ -164,20 +164,7 @@ void Scene::pick(const vec3 &point)
164164
vec3 p = point;
165165
p.setY(terrain_->height(p.x(), p.z()));
166166

167-
PhongMaterial* material1 = new PhongMaterial;
168-
material1->setAmbient({0.2, 0.2, 0.2});
169-
material1->setDiffuse({0.7, 0.7, 0.7});
170-
material1->setSpecular({0.7, 0.7, 0.7});
171-
material1->setShiness(100);
172-
173-
SceneObject* obj1 = new SceneObject;
174-
Mesh* mesh1 = MeshCache::getInstance()->acquire("bunny");
175-
obj1->setMesh(mesh1);
176-
obj1->setMaterial(material1);
177-
178-
obj1->transform().translate(p);
179-
180-
sceneObjects_.push_back(obj1);
167+
tornado_->setDestination(p);
181168
}
182169

183170

0 commit comments

Comments
 (0)
Please sign in to comment.