Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,119 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP

Serious User
VeT  Offline 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

Quote:

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
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);


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


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
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 Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
http://rapidshare.com/files/223527306/TestLevel.rar.html

Okay, 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:
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?


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
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 Offline
User
Poison  Offline
User

Joined: Apr 2007
Posts: 582
Germany
Hey vet, this seems to be working:
but not that good...-.-

Code:
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: Poison] #261812
04/20/09 11:14
04/20/09 11:14
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
hm... with "set" it works better than with "add".. but theoretically it may work better with "add"...


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
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 Offline
Expert
EvilSOB  Offline
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....
Code:
//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: EvilSOB] #261826
04/20/09 13:29
04/20/09 13:29
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
What "dog-box" is? smile very fast or very old?

Crash in the empty pointer in flame_alphafade, i'll study it.
Anyway, thank you for your help, you're great smile


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: Particles on the screen [Re: VeT] #261827
04/20/09 13:37
04/20/09 13:37
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline OP

Serious User
VeT  Offline OP

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
Code:
	VECTOR tVec;
	VECTOR tVec2;
	vec_diff(tVec, p.x, p.skill_x);                             //subtract Old camera position
	vec_diff(tVec2, camera.pan, p.skill1);
	vec_rotate(tVec, tVec2);     //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

WOW laugh laugh laugh laugh


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
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 Offline
Expert
EvilSOB  Offline
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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1