0 registered members (),
1,119
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Particles on the screen [SOLVED]
#261686
04/19/09 13:12
04/19/09 13:12
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
|
Okay, as Jcl said( http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=261620#Post261620 ), i'm trying to You can solve this problem already in world coordinates, in the particle function:
- get the distance vector from the camera to the particle - rotate this vector by the same euler angle you added to the camera angle. - get the distance vector from the rotated vector to the original vector - add this new distance vector to the particle position.
This should keep your particles in front of the camera regardless of the rotation.
i tried
var tVec[3];
var tVec2[3];
vec_diff(tVec,p.x,camera.x);
vec_rotate(tVec,camera.pan);
vec_diff(tVec2,p.x,tVec);
vec_add(p.x,tVec2);
but looking like i missed something (( PS: I based on the particle flame http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=220514#Post220514
|
|
|
Re: Particles on the screen
[Re: VeT]
#261802
04/20/09 10:05
04/20/09 10:05
|
Joined: Aug 2004
Posts: 1,345 Kyiv, Ukraine
VeT
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
|
http://rapidshare.com/files/223527306/TestLevel.rar.htmlOkay, here is the level, where you can rotate camera (controls as usual, you press 0 and then cursor left-right keys) and see that particles problem In Particles.c there is commented(line 40) code:
var tVec[3];
var tVec2[3];
vec_diff(tVec,p.x,camera.x);
vec_rotate(tVec,camera.pan);
vec_diff(tVec2,p.x,tVec);
vec_add(p.x,tVec2);
it seems not to work properly, can anyone help?
|
|
|
Re: Particles on the screen
[Re: VeT]
#261811
04/20/09 10:44
04/20/09 10:44
|
Joined: Apr 2007
Posts: 582 Germany
Poison
User
|
User
Joined: Apr 2007
Posts: 582
Germany
|
Hey vet, this seems to be working: but not that good...-.-
VECTOR tVec;
VECTOR tVec2;
vec_diff(tVec,camera.x,p.x);
vec_rotate(tVec,camera.pan);
vec_diff(tVec2,camera.x,tVec);
vec_set(p.x,tVec2);
Everything is possible, just Do it!
|
|
|
Re: Particles on the screen
[Re: VeT]
#261824
04/20/09 13:16
04/20/09 13:16
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
This is as close as I can get. Not quite the way JCL suggested, but I couldnt get his suggestion to work at all. This is still a bit "twitchy" when camera movement/rotation starts but that MAY be due to an over-abundance of particles, the machine Im testing this on is a dog-box....
//NO changes in any other functions but these two...
function flame_alphafade(PARTICLE *p)
{
start_color[0] = 200;
start_color[1] = 180;
start_color[2] = 100;
end_color[0] = 128;
end_color[1] = 50;
end_color[2] = 50;
vec_lerp(current_color[0], end_color[0], start_color[0], p.lifespan / flame_lifespan);
p.red = current_color[0];
p.green = current_color[1];
p.blue = current_color[2];
p.alpha = p.lifespan / flame_lifespan * 100;// * 0.3;
if (p.alpha <= 0) p.lifespan = 0;
VECTOR tVec;
vec_diff(tVec, p.x, p.skill_x); //subtract Old camera position
vec_rotate(tVec, vec_diff(NULL, camera.pan, p.skill1)); //rotate by old camera pan/tilt/roll
vec_add(tVec, camera.x); //add new camera position
vec_set(p.x, tVec); //position particle accordingly
//
vec_set(p.skill1, camera.pan); //set new LAST camera pan/tilt/roll
vec_set(p.skill_x, camera.x); //set new LAST camera position
}
// particle function: generates a fading explosion into vel direction
function effect_flame(PARTICLE *p)
{
var temp[3];
flame_randomize(temp, 1);
vec_add (p.vel_x, temp);
p.bmap = flame_particle;
p.flags |= (BRIGHT | MOVE | TRANSLUCENT);
p.lifespan = flame_lifespan;
p.size = 3;
vec_set(p.skill1, camera.pan); //set LAST camera pan/tilt/roll
vec_set(p.skill_x, camera.x); //set LAST camera position
p.event = flame_alphafade; // change to a shorter, faster function
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Particles on the screen
[Re: VeT]
#261833
04/20/09 14:07
04/20/09 14:07
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
vec_diff returning a pointer to itself must be a newer version that what you have. Funny, manual doesnt say so...
Dog-box is ancient old hardware. P4-3Gig, 512M-Ram 128M-Video.
Glad I could help.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|