• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
robococ

particle system - fire

2 posts in this topic

Based on nehe tutorial: [url="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19"]http://nehe.gamedev....n.asp?lesson=19[/url]
I would like to make fire - observer CAN ROTATE fire - If I use nehe coordinates to create square with texture:
[code]
glTexCoord2d(1,1); glVertex3f(x+0.5f,y+0.5f,z);
glTexCoord2d(0,1); glVertex3f(x-0.5f,y+0.5f,z);
glTexCoord2d(1,0); glVertex3f(x+0.5f,y-0.5f,z);
glTexCoord2d(0,0); glVertex3f(x-0.5f,y-0.5f,z);
[/code]

Fire looks horrible when I rotate square about 90 degrees - it looks flat:
[url="http://img573.imageshack.us/i/33884504.jpg/"]http://img573.images...i/33884504.jpg/[/url]

When I change coordinates square with texture to mine:
[code]
glTexCoord2d(1,1); glVertex3f(x+0.5f,y+0.5f,z);
glTexCoord2d(0,1); glVertex3f(x-0.5f,y+0.5f,z);
glTexCoord2d(1,0); glVertex3f(x+0.5f,y-0.5f,z);
glTexCoord2d(0,0); glVertex3f(x-0.5f,y-0.5f,z);
[/code]

Fire looks also bad:
[url="http://img69.imageshack.us/i/62229027.jpg/"]http://img69.imagesh...i/62229027.jpg/[/url]

Do you have an idea what I can do ?

This is mine code:
[code]
#define MAX_PARTICLES 1000 // Number Of Particles To Create

float slowdown=2.0f; // Slow Down Particles
float xspeed; // Base X Speed (To Allow Keyboard Direction Of Tail)
float yspeed; // Base Y Speed (To Allow Keyboard Direction Of Tail)
float zoom=-40.0f; // Used To Zoom Out

typedef struct // Create A Structure For Particle
{
bool active; // Active (Yes/No)
float life; // Particle Life
float fade; // Fade Speed
float r; // Red Value
float g; // Green Value
float b; // Blue Value
float x; // X Position
float y; // Y Position
float z; // Z Position
float xi; // X Direction
float yi; // Y Direction
float zi; // Z Direction
float xg; // X Gravity
float yg; // Y Gravity
float zg; // Z Gravity
}
particles; // Particles Structure

particles particle[MAX_PARTICLES]; // Particle Array (Room For Particle Info)

static GLfloat colors[12][3]= // Rainbow Of Colors
{
{1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f},
{1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f},
{1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f}, {1.0f,0.2f,0.0f},
};


//INICIALIZATION:
Init(void)
{
slowdown = 2; // Slow Down Particles
xspeed = 0; // Base X Speed (To Allow Keyboard Direction Of Tail)
yspeed = 200; // Base Y Speed (To Allow Keyboard Direction Of Tail)
zoom = -40; // Used To Zoom Out

for (int loop=0; loop<MAX_PARTICLES; loop++) // Initials All The Textures
{
particle[loop].active = true; // Make All The Particles Active
particle[loop].life = 1.0f; // Particles Life
particle[loop].fade = float(rand()%100)/1000.0f+0.003f; // Random Fade Speed
particle[loop].x = 0.0f; // Center On X Axis
particle[loop].y = 0.0f; // Center On Y Axis
particle[loop].z = 0.0f; // Center On Z Axis
particle[loop].r = colors[loop*(12/MAX_PARTICLES)][0]; // Select Rainbow Color
particle[loop].g = colors[loop*(12/MAX_PARTICLES)][1]; // Select Rainbow Color
particle[loop].b = colors[loop*(12/MAX_PARTICLES)][2]; // Select Rainbow Color
particle[loop].xi = xspeed+float((rand()%60)-32.0f); // X Axis Speed And Direction
particle[loop].yi = yspeed+float((rand()%60)-30.0f); // Y Axis Speed And Direction
particle[loop].zi = float((rand()%60)-30.0f); // Z Axis Speed And Direction
particle[loop].xg = 0.0f; // Set Horizontal Pull To Zero
particle[loop].yg = -0.8f; // Set Vertical Pull Downward
particle[loop].zg = 0.0f; // Set Pull On Z Axis To Zero
}
}


//FIRE:
void Scene::DrawFire()
{
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);


for (int loop=0; loop<MAX_PARTICLES; loop++) // Loop Through All The Particles
{
if (particle[loop].active) // If The Particle Is Active
{
float x = particle[loop].x; // Grab Our Particle X Position
float y = particle[loop].y; // Grab Our Particle Y Position
float z = particle[loop].z + zoom; // Particle Z Pos + Zoom

// Draw The Particle Using Our RGB Values, Fade The Particle Based On It's Life
glColor4f(particle[loop].r, particle[loop].g, particle[loop].b, particle[loop].life);

glPushMatrix();
glBegin(GL_TRIANGLE_STRIP);
//MINE COORDINATES:
glTexCoord2d(1,1); glVertex3f(x+5, y, z+5);
glTexCoord2d(0,1); glVertex3f(x-5, y, z+5);
glTexCoord2d(0,0); glVertex3f(x+5, y, z-5);
glTexCoord2d(1,0); glVertex3f(x-5, y, z-5);
/*
//nehe COORDINATES:
glTexCoord2d(1,1); glVertex3f(x+0.5f,y+0.5f,z);
glTexCoord2d(0,1); glVertex3f(x-0.5f,y+0.5f,z);
glTexCoord2d(1,0); glVertex3f(x+0.5f,y-0.5f,z);
glTexCoord2d(0,0); glVertex3f(x-0.5f,y-0.5f,z);
*/
glEnd();
glPopMatrix();

particle[loop].x += particle[loop].xi/(slowdown*1000); // Move On The X Axis By X Speed
particle[loop].y += particle[loop].yi/(slowdown*1000); // Move On The Y Axis By Y Speed
particle[loop].z += particle[loop].zi/(slowdown*1000); // Move On The Z Axis By Z Speed

particle[loop].xi += particle[loop].xg; // Take Pull On X Axis Into Account
particle[loop].yi += particle[loop].yg; // Take Pull On Y Axis Into Account
particle[loop].zi += particle[loop].zg; // Take Pull On Z Axis Into Account
particle[loop].life -= particle[loop].fade; // Reduce Particles Life By 'Fade'

if (particle[loop].life<0.0f) // If Particle Is Burned Out
{
int column = rand()%12;

particle[loop].life = 1.0f; // Give It New Life
particle[loop].fade = float(rand()%100)/1000.0f+0.003f; // Random Fade Value
particle[loop].x = 0.0f; // Center On X Axis
particle[loop].y = 0.0f; // Center On Y Axis
particle[loop].z = 0.0f; // Center On Z Axis
particle[loop].xi = xspeed+float((rand()%60)-32.0f); // X Axis Speed And Direction
particle[loop].yi = yspeed+float((rand()%60)-30.0f); // Y Axis Speed And Direction
particle[loop].zi = float((rand()%60)-30.0f); // Z Axis Speed And Direction
particle[loop].r = colors[column][0]; // Select Red From Color Table
particle[loop].g = colors[column][1]; // Select Green From Color Table
particle[loop].b = colors[column][2]; // Select Blue From Color Table
}
}
}

glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
[/code]

This is texture: [url="http://img13.imageshack.us/i/particle.png/"]http://img13.imagesh...i/particle.png/[/url]
0

Share this post


Link to post
Share on other sites
You need to direct the quads to have their normal pointing towards the eye, so that the surface is always orthogonal to the view vector.
These are billboards; they should act like classic sprites.

You can rotate them in a vertex shader, or rotate a local model matrix of one, repeated quad.
Also, pick a different texture, and apply rotation to it over time, -that should help!
0

Share this post


Link to post
Share on other sites
So I should do something like that:

[code]
glPushMatrix();

// HERE ROTATION ??????

glBegin(GL_TRIANGLE_STRIP);
glTexCoord2d(1,1); glVertex3f(x+0.5f,y+0.5f,z);
glTexCoord2d(0,1); glVertex3f(x-0.5f,y+0.5f,z);
glTexCoord2d(1,0); glVertex3f(x+0.5f,y-0.5f,z);
glTexCoord2d(0,0); glVertex3f(x-0.5f,y-0.5f,z);
glEnd();
glPopMatrix();
[/code]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0