mirror of
https://github.com/overte-org/overte.git
synced 2025-06-22 10:41:18 +02:00
got basic cloud working
This commit is contained in:
parent
afd553330a
commit
906f3c8c60
2 changed files with 27 additions and 19 deletions
|
@ -21,6 +21,7 @@ Cloud::Cloud() {
|
|||
// Create and initialize particles
|
||||
unsigned int i;
|
||||
glm::vec3 box = glm::vec3(WORLD_SIZE);
|
||||
bounds = box;
|
||||
count = NUM_PARTICLES;
|
||||
wrapBounds = false;
|
||||
particles = new Particle[count];
|
||||
|
@ -34,9 +35,9 @@ Cloud::Cloud() {
|
|||
particles[i].position.y = y;
|
||||
particles[i].position.z = z;
|
||||
|
||||
particles[i].velocity.x = randFloat() - 0.5f;
|
||||
particles[i].velocity.y = randFloat() - 0.5f;
|
||||
particles[i].velocity.z = randFloat() - 0.5f;
|
||||
const float INIT_VEL_SCALE = 0.10;
|
||||
particles[i].velocity = randVector();
|
||||
particles[i].velocity *= WORLD_SIZE * INIT_VEL_SCALE;
|
||||
|
||||
float color_mult = 1 - COLOR_MIN;
|
||||
particles[i].color = glm::vec3(x*color_mult/WORLD_SIZE + COLOR_MIN,
|
||||
|
@ -48,12 +49,13 @@ Cloud::Cloud() {
|
|||
|
||||
void Cloud::render() {
|
||||
|
||||
field->render();
|
||||
/*
|
||||
float particle_attenuation_quadratic[] = { 0.0f, 0.0f, 2.0f };
|
||||
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
|
||||
float maxSize = 0.0f;
|
||||
glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
|
||||
glPointSize( maxSize );
|
||||
|
@ -65,6 +67,12 @@ void Cloud::render() {
|
|||
|
||||
glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
|
||||
glEnable( GL_POINT_SPRITE_ARB );
|
||||
*/
|
||||
glPointSize(3.0f);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
|
||||
glBegin( GL_POINTS );
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -90,7 +98,7 @@ void Cloud::simulate (float deltaTime) {
|
|||
//particles[i].position += particles[i].velocity;
|
||||
|
||||
// Decay Velocity (Drag)
|
||||
const float CONSTANT_DAMPING = 0.5;
|
||||
const float CONSTANT_DAMPING = 0.15;
|
||||
particles[i].velocity *= (1.f - CONSTANT_DAMPING*deltaTime);
|
||||
|
||||
// Interact with Field
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Field.h"
|
||||
|
||||
#define FIELD_SCALE 0.00050
|
||||
#define FIELD_SCALEf 0.00050f
|
||||
#define FIELD_SCALEf 0.1f
|
||||
#define COLOR_DRIFT_RATE 0.001f // per-frame drift of particle color towards field element color
|
||||
#define COLOR_MIN 0.2f // minimum R/G/B value at 0,0,0 - also needs setting in cloud.cpp
|
||||
|
||||
|
@ -43,9 +43,9 @@ Field::Field()
|
|||
float fx, fy, fz;
|
||||
for (i = 0; i < FIELD_ELEMENTS; i++)
|
||||
{
|
||||
field[i].val.x = (randFloat() - 0.5f)*FIELD_SCALEf;
|
||||
field[i].val.y = (randFloat() - 0.5f)*FIELD_SCALEf;
|
||||
field[i].val.z = (randFloat() - 0.5f)*FIELD_SCALEf;
|
||||
field[i].val.x = (randFloat() - 0.5f)*FIELD_SCALEf * WORLD_SIZE;
|
||||
field[i].val.y = (randFloat() - 0.5f)*FIELD_SCALEf * WORLD_SIZE;
|
||||
field[i].val.z = (randFloat() - 0.5f)*FIELD_SCALEf * WORLD_SIZE;
|
||||
field[i].scalar = 0;
|
||||
// Record center point for this field cell
|
||||
fx = static_cast<float>(i % 10);
|
||||
|
@ -182,21 +182,21 @@ void Field::render()
|
|||
{
|
||||
int i;
|
||||
float fx, fy, fz;
|
||||
float scale_view = 0.1f;
|
||||
float scale_view = 0.1f * WORLD_SIZE;
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < FIELD_ELEMENTS; i++)
|
||||
{
|
||||
fx = field[i].center.x;
|
||||
fy = field[i].center.y;
|
||||
fz = field[i].center.z;
|
||||
fx = field[i].center.x * WORLD_SIZE;
|
||||
fy = field[i].center.y * WORLD_SIZE;
|
||||
fz = field[i].center.z * WORLD_SIZE;
|
||||
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3f(fx, fy, fz);
|
||||
glVertex3f(fx + field[i].val.x*scale_view,
|
||||
fy + field[i].val.y*scale_view,
|
||||
fz + field[i].val.z*scale_view);
|
||||
glVertex3f(fx + field[i].val.x * scale_view,
|
||||
fy + field[i].val.y * scale_view,
|
||||
fz + field[i].val.z * scale_view);
|
||||
if (USE_SCALAR) {
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3f(fx, fy, fz);
|
||||
|
@ -222,7 +222,7 @@ void Field::render()
|
|||
fy = static_cast<float>(i%100 / 10);
|
||||
fz = static_cast<float>(i / 100);
|
||||
|
||||
glVertex3f(fx, fy, fz);
|
||||
glVertex3f(fx / 10.f * WORLD_SIZE, fy / 10.f * WORLD_SIZE, fz / 10.f * WORLD_SIZE);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue