View Full Version : render a simple smoke

Hi to everyone and happy new year. I need to render some smoke coming from the back of an aeroplane. The aeroplane is circling a planet. The smoke will only be 2-3 spheres who's alpha will gradually go to 0. When the oldest sphere has an alpha of zero, then a new one should be created right behind the aeroplane. The problem is I don't have exact coordinates for the plane. It is created in the center and then transformed to the desired position. Is there any way to get its coordinates at a given time? Thanks for your time.

GreatRedShark

01-06-2005, 06:14 PM

This could probably be done with some simple physics.

Let's see, do you know the initial position of the plane? and how about the speed around the planet? and the distance from the centre?

If you express your speed in terms of angles (or rads) per second, then you just use d=v*t (d==distance, v==velocity(or speed), t==time), and since you know t and v, you can just calculate how far the plane has rotated after time t (assuming v is constant). If you know the radius of the plane from the planet's centre, you can use x=r*cos(theta) and y=r*sin(theta), where theta==d(because the plane is just going around and around in circles). I'm assuming that the plane is just rotating in a flat x-y plane (which could be transformed if you don't want to really be in the x-y plane). If the plane's orbit is changing and not always in the same plane, then it might get more complicated.

There might be a better solution, more accurate or whatever, but this is what I can think of now. hope it helps.

Thanks a lot. I might keep this solution for the future. My problem was solved when I realized (it was like an enlightment) that what changes the plane's position is actually only an angle (I use the same angle in a couple of glRotates) so from that point on it was trivial. But I really appreciate the answer. At one point I was really desperate :)

Aeluned

01-07-2005, 05:21 AM

There's a much, much simpler way:

Transform your plane, then glGet* the modelview matrix.

The transformed point of the plane will reside in the modelview matrix at indices [12],[13] and [14].

What you *do* need to know is the distance from the point that defines the position of the plane to the thruster at the back. This defines a vector.

you should place your new sphere at the position specified by [12],[13],[14] (x,y,z) + the offset vector.

dorbie

01-07-2005, 08:35 PM

moucard - your solution is not a robust one, it relies on the fact thet the path of the aircraft coincides with a rotation about the sphere, but you haven't really solved the problem. You should try to implement the proposed solution of smoke emitter point through model matrix transform to arrive correct world space position to release the particle under any aircraft position and orientation.

It will teach you more about graphics principals in the process.

In the end I reverse transformed the transformations that rotate the aeroplane around, stored the angle at that exact moment and then redid the transformations with the old angle. But yes guys I agree with you. Although at one point I tried to find the transformed position of the aeroplane I failed. I thought, "well, I'm building my aeroplane around 0,0,0" so this is my initial starting point.

I thought I'd multiply that point by the current modelview matrix but it gave values very near to 0 (2.343984e-211 for example, or something similar) to all x,y,z components. I've tested the function that multiplied the matrices with a known case and it works. Was I missing a transformation at that point?

dorbie

01-07-2005, 10:08 PM

That didn't work because the modelview includes the viewing matrix although it should have produced eyespave particles unless you have something crazy lile your projection matrix on the wrong stack.

You need to isolate the model matrix alone for your smoke emitter transformation calculations.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.