# lecture18 - CSE472 Computer Graphics Particle Systems Why...

This preview shows pages 1–12. Sign up to view the full content.

1 CSE472 Computer Graphics Particle Systems Why we need them What they can do How to do it

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 CSE472 Computer Graphics Particle Systems A very large number of very tiny particles May or may not have any geometry Useful for: Fire, explosions, gas, clouds, fireworks Anything where something breaks into a zillion pieces
3 CSE472 Computer Graphics A Particle struct Particle { CGrPoint p; // Where is it? }; std::list<Particle> m_particles; // All of our particles

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 CSE472 Computer Graphics How to render We have two choices: Particles with geometry Means larger than a pixel Not very common, mostly early work Particles with no geometry Just a tiny point in space We’ll concentrate on these
5 CSE472 Computer Graphics Rendering a particle in OpenGL The gist of it: Don’t Yes, OpenGL can render a “point”, but it’s an entire pixel. It’s in general a bad idea How to render Create a image Render into the image

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 CSE472 Computer Graphics Creating an Image We need an RGB image Just like in the ray tracer But, we’re going to make it float value instead of byte We’re going to do math on the pixel multiple times
7 CSE472 Computer Graphics Creating the Image m_partimage = new float *[m_partimageheight]; m_partimage[0] = new float[m_partimageheight * m_partimagewidth * 3]; for(int i=1; i<m_partimageheight; i++) { m_partimage[i] = m_partimage[0] + i * m_partimagewidth * 3; } for(int i=0; i<m_partimageheight; i++) { // Fill the image with black for(int j=0; j<m_partimagewidth; j++) { m_partimage[i][j * 3] = 0; // red m_partimage[i][j * 3 + 1] = 0; // green m_partimage[i][j * 3 + 2] = 0; // blue } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 CSE472 Computer Graphics Rendering a Particle We need to convert the X,Y,Z coordinate to a screen location This is projection, just as we did before Remember how to do this? We want to mix this with OpenGL, so we’ll use their matrices and values
9 CSE472 Computer Graphics Projection Multiply point by model view matrix Then by projection matrix Homogenize Convert to viewport

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
10 CSE472 Computer Graphics Stealing from OpenGL GLdouble m[16]; GLdouble *pm; // Obtain the ModelView matrix and convert it to CGrTransform glGetDoublev(GL_MODELVIEW_MATRIX, m); CGrTransform modelViewMatrix; pm = m; for(int c=0; c<4; c++) for(int r=0; r<4; r++) modelViewMatrix[r][c] = *pm++; // Obtain the projection matrix and convert it to CGrTransform glGetDoublev(GL_PROJECTION_MATRIX, m); CGrTransform projectionMatrix; pm = m; for(int c=0; c<4; c++) for(int r=0; r<4; r++) projectionMatrix[r][c] = *pm++; // We can go ahead and multiply these together m_partxform = projectionMatrix * modelViewMatrix; // Obtain the glViewport parameters glGetIntegerv(GL_VIEWPORT, m_vp);
11 CSE472

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/25/2008 for the course CSE 472 taught by Professor Owen during the Spring '08 term at Michigan State University.

### Page1 / 40

lecture18 - CSE472 Computer Graphics Particle Systems Why...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online