PDA

View Full Version : cloud modeling - partical system



apit
08-11-2003, 08:53 AM
i have model a cloud..
the problem is, how to animate it..
i don't really understand about the partical system...
which formula should i used to animate the cloud?
below is my cloud model source code ::


#include <glut.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define TITIK 2000
typedef GLfloat point3D[3];
typedef point3D gas[TITIK];

gas dot;

void Populate(gas anal)
{
int i=0;
GLfloat randx, randy;
{
while(i<TITIK)
{
randx = 2 * ((GLfloat)rand()/RAND_MAX) -1;
randy = 2 * ((GLfloat)rand()/RAND_MAX) -1;

// if not true, then (x,y) lies outside of the unit circle, so do not keep
if( 1.0 > (randx * randx + randy * randy) )
{
anal[i][0] = randx;
anal[i][1] = randy;
anal[i][2] = 0;
i++;
}
}
}
}

void MyInit()
{
Populate(dot);

}


int Update()
{

}

void Display(void)
{
int i;


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(100.0, 200.0, 100.0, // eye point
1.0, 0.0, 0.0, // center of view
5.0, 0.0, 1.3); // up
glPushMatrix();

glScalef(10.0,10.0,10.0);

glColor3f(1.0, 1.0, 1.0);

glBegin(GL_QUADS);
for (i=0; i<TITIK; i++)
glVertex3fv(dot[i]);
glEnd();

glutSwapBuffers();
}


void Reshape(int w,int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(25.0, 0.3, 1.0, 300.0);
}


void Animate()
{

}

int main(int argc, char** argv)
{

glutInit(&argc,argv);
glutInitDisplayMode (GLUT_DOUBLE |GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(600,400);
glutInitWindowPosition(50,50);
glutCreateWindow("Awan");
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
MyInit();
glutMainLoop();
return 0;
}

JanHH
08-11-2003, 11:01 AM
maybe you should explain what exactly you want to do, instead of pasting code no one understands (and why do you call your variables "anal"???).. which effect you want to achieve.

Jan

JanHH
08-11-2003, 11:03 AM
"anal" really suggests that you want to program a farting simulation, to visualize "gas" clouds.. is this true? http://www.opengl.org/discussion_boards/ubb/wink.gif

Jan

JanHH
08-11-2003, 11:09 AM
I remember that there was a small programm on the c64 which did this acustically.. it asked parameters for time, "dry" or "wet" and number of "bubbles", and then produced a really realistic fart. really, that's no joke..

apit
08-11-2003, 10:43 PM
yes jahn..i study the gas code and try to convert it to cloud...

Kilam Malik
08-11-2003, 10:52 PM
Originally posted by JanHH:
I remember that there was a small programm on the c64 which did this acustically.. it asked parameters for time, "dry" or "wet" and number of "bubbles", and then produced a really realistic fart. really, that's no joke..

I remember that one too... that was a cool application. Why not port it and add some visualization with the code from apit?

Ok, getting serious. In your anal-array you will also need direction an velocity of each particle. Then you need a function you call each frame to calculate the new position of each particle depending on direction an velocity and also change both. You could begin with simple sinus / cosinus patterns.

Kilam.

apit
08-12-2003, 09:02 PM
so..what should i do now? which formula should i use to generate cloud animation? can you give me some idea and guide?

JanHH
08-13-2003, 07:21 AM
a reason why this question might be hard to answer is that clouds (the ones up in the sky) are in fact not very animated.. they are rather static objects. Another point might be how to arrange particles that they make up the shape of a cloud, I had to solve this recently, but I guess that's not what you mean. So you should first find out what kind of thing you want to visualize, maybe smoke thrown up by the wheels of a car or something like that, particles that are actually MOVING, what ordinary clouds don't do. And I guess there are a lot of formulas how to do this then.

torisutan
08-13-2003, 05:12 PM
maybe look into volume rendering and perlin noise?

i've used perlin noise to generate animated 2d cloud textures, and the same technique can be used for 3d textures. however i havn't played with animated clouds since i've learnt about volume rendering.

the only problem u may find, is generating the textures is quite cpu intensive, but this would be the first thing i try.

apit
08-15-2003, 08:27 PM
maybe a simple formula to move the cloud...
do you have any suggestion which formula to use(in partical system case)?

JanHH
08-16-2003, 05:04 AM
can you please say why and in which style you want to move your cloud, as, as I repeatedly said, clouds simply don't move (at least, not the particles in it)? It's hard to give a formula to animate something which just is not animated.

SirKnight
08-17-2003, 04:45 PM
http://expert.ics.purdue.edu/~schpokj/research/purpl/clouds/index.html


-SirKnight

SirKnight
08-17-2003, 04:47 PM
Originally posted by JanHH:
can you please say why and in which style you want to move your cloud, as, as I repeatedly said, clouds simply don't move (at least, not the particles in it)? It's hard to give a formula to animate something which just is not animated.




And what planet does this occur? Not Earth I know that.


-SirKnight

JanHH
08-17-2003, 07:41 PM
the clouds I see in the sky are not very animated, they might move, but do not really change their shape, are rather static objects.. is this different on your planet?

jamac
08-18-2003, 04:32 AM
Originally posted by JanHH:
the clouds I see in the sky are not very animated, they might move, but do not really change their shape, are rather static objects.. is this different on your planet?

Surely not...stop frame animation of a rain cloud shows that they move and radically alter their shape over time. Even within an hour or two a cloud can look completely different. Its just a question of scale (physical and timeline).

This is the case on earth amd on other planets too just the physical constant alter (gravity, density, max wind speed etc.

The poster needs to provide much more information though and not just copy/paste code that he/she does not understand.

JAMAC

Robert Osfield
08-18-2003, 05:08 AM
Originally posted by JanHH:
the clouds I see in the sky are not very animated, they might move, but do not really change their shape, are rather static objects.. is this different on your planet?

Clouds in the real world earth are very dynamic, their boundaries can change as fast, and often faster the prevailing wind speed. I *know* as I have often thermalled up underneath cumulus and soared the leading edges of lenticular clouds whilst hang gliding. Even when not airborne much of hang glider pilots life is spent gazing skywards at clouds. Clouds are *dynamic* changing from second to second.

In realtime graphics you can't model the full complexity of the atmosphere so you have to decide how accurate your want to model and visualise them. Static billboards that float off down wind might be good enough for some apps. A simply skydome might be good enough for others. A series of infiinite planes might be good for yet more...

For those interested in more realistic clouds Mark Harris's work should be of interest:
http://www.cs.unc.edu/~harrism/


Robert.

apit
08-18-2003, 09:19 AM
in my case, i just want to make a simple cloud.. it just a class assignment..i just need to model a simple cloud and animate it.. so for beginner, what is your suggestion to me? it just to make i understand the partical system technic..( just a basic one..no need advance rendering like mark j. harris).. i hope all expert in this forum can help and guide me.. thanks for your concern..

JanHH
08-18-2003, 01:32 PM
of course clouds are dynamic, but not so fast that they really change their shape in realtime, so the particals that make up a cloud are rather static. I think what the poster needs is not animation, but simply creation, how to put up particles so that they look like a cloud (mark harris clouds are not animated as well http://www.opengl.org/discussion_boards/ubb/wink.gif ).

I would recommend to bother with perlin noise (try google, or search the advanced forum here), I have created my particle clouds with it.

These are my clouds, just in fact that it is something like that you are looking for:
http://de.geocities.com/westphj2003/clouds.html

Jan