Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 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
Particle moves with an Entity on a vertex #393678
02/06/12 10:29
02/06/12 10:29
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline OP
User
JoGa  Offline OP
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
Hey!
I have a questiona about particles.
My Particle Function moves the particle relativ with an entity.
The example from particles.c helped me.
But I need a additon, I can't do myself because I don't know how I should do that:
The particle is created on a vertex of the entity.
This entity is animated, so the function as it is, does not fit 100%.

How is it possible, to "tell" the particle to take the vertex-position?
The function "effect" does not have a return value lik the ent_create-function has.
Otherwise I could use this return value as a pointer and give him the vertexnumber as a skill p.skill70 for example.

Here is my code so far, I hope, somebody does understand my problem and can help me.
Code:
function p_flammen_in(PARTICLE *p)
{
	p.alpha += p.skill_a*time_step;
	if (p.alpha >= 15) p.bmap  = pct_p_fire02;
	if (p.alpha >= 30) p.bmap  = pct_p_fire01;
	//if (p.alpha >= 50) p.event = p_flammen_out;
	if(!you) return; // example from particles.c
	if(p.skill_x != 0)
	{ 
		vec_add(p.x,your.x);
		vec_sub(p.x,p.skill_x);
	}
	vec_set(p.skill_x,your.x); // store old "you" position
}
function p_condition_burning(PARTICLE* p)
{
	vec_add(p.vel_x,vector(random(2)-1,random(2)-1,0));
	set(p, MOVE | BRIGHT | TRANSLUCENT);
	p.alpha = random(10);
	p.bmap = pct_p_fire03;
	p.size = 20+random(5);
	p.gravity = - 0.4;
	p.skill_a = 8+random(4); // fade factor
	p.event = p_flammen_in;
}


// in a while-loop to circle through the vertices
vec_for_vertex(temp.x, my, integer(random(gesamt_vertices)));
effect(p_condition_burning,15,temp.x,NULL);



Last edited by JoGa; 02/06/12 10:29.
Re: Particle moves with an Entity on a vertex [Re: JoGa] #393716
02/06/12 15:26
02/06/12 15:26
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Nope.

I dont understand your problem, but I try and help anyway...

Try explaining again, in a different way, what you want.


If you mean that you just want to pass the vertex-number to the effect,
try this...
Code:
function p_flammen_in(PARTICLE *p)
{	... NO CHANGES ...	}

function p_condition_burning(PARTICLE* p)
{
	vec_for_vertex(p.skill_x, you, p.x);      //get THE vertex position
	vec_set(p.x, p.skill_x);                  //put particle there
	...
	ALL ELSE UNCHANGED
	...
}


// in a while-loop to circle through the vertices
effect(p_condition_burning, 15, vector(integer(random(gesamt_vertices)),0,0), NULL);

Is this what you mean?


Code:
function p_flammen_in(PARTICLE *p)
{	... NO CHANGES ...	}

function p_condition_burning(PARTICLE* p)
{
	vec_for_vertex(p.skill_x, you, integer(random(p.x)));      //get A vertex position
	vec_set(p.x, p.skill_x);                                   //put particle there
	...
	ALL ELSE UNCHANGED
	...
}


// in a while-loop to circle through the vertices
effect(p_condition_burning, 15, vector(gesamt_vertices,0,0), NULL);

Or maybe this...


What is the 'visual' effect you are trying to create?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
[solved] Re: Particle moves with an Entity on a vertex [Re: EvilSOB] #393754
02/06/12 19:18
02/06/12 19:18
Joined: Dec 2003
Posts: 988
Germany, Magdeburg
JoGa Offline OP
User
JoGa  Offline OP
User

Joined: Dec 2003
Posts: 988
Germany, Magdeburg
Thanks for your help.
ok, I try it again: The particle should move itself, but not in worldposition but in a relativ position to a defined vertex of a model (for example, every particle have to circle around his defined vertex).

MasterQ32 helped me and gave me some code, too.
It workes now; that way: The particle fades in and stay on the vertex.
So if the entity is animated, the entity is covered with the particles. After fading in, the particle fades out and is not attached on the vertex any more, so if the animation goes on and the entity is moving, it leaves a cloud behind it.

So it's okay, not perfect, but ok and it works .-D
Thansk for helping, the effect looks nice and that's fits for me.
Here the code, if somebody needs it, too:
Code:
//////////////////////////////
// Zustand: Brennen
//////////////////////////////

BMAP* pct_p_fire01	=	"pct_p_fire01.tga";
BMAP* pct_p_fire02	=	"pct_p_fire02.tga";
BMAP* pct_p_fire03	=	"pct_p_fire03.tga";

function p_flammen_out(PARTICLE *p)	// fading out and if entity moves, it leaves the flame behing
{
	p.alpha -= p.skill_c*time_step;
	if (p.alpha <= 30) p.bmap = pct_p_fire02;
	if (p.alpha <= 15) p.bmap = pct_p_fire03;
	if (p.alpha <=  0) p.lifespan = 0;
}
function p_flammen_in(PARTICLE *p)	// fading in and stay at position
{
	p.alpha += p.skill_c*time_step;
	if (p.alpha >= 15) p.bmap = pct_p_fire02;
	if (p.alpha >= 30) p.bmap = pct_p_fire01;
	if (p.alpha >= 50) p.event = p_flammen_out;
	you = p.skill_a;
	if(!you) {p.lifespan = 0; return;}
	vec_for_vertex(p.x, you, p.skill_b);
}

function p_condition_burning(PARTICLE* p)
{
	p.skill_a = p.vel_x;			// pointer auf brennende Entity
	p.skill_b = p.vel_y;			// Nummer des Vertex
	p.skill_c = 8+random(4); 		// Fadefaktor
	set(p, BRIGHT | TRANSLUCENT);
	p.alpha = random(10);
	p.bmap = pct_p_fire03;
	p.size = 16+random(5);
	p.event = p_flammen_in;
}


function eff_test_burning()
{
	VECTOR vel;
	int gesamt_vertices = ent_status(my, 0);
	while(1)
	{
		vel.x = me;
		vel.y = integer(random(gesamt_vertices));
		vel.z = 0;
		effect(p_condition_burning,1,my.x,vel); //pointer and vertex stored in vel
		wait(1);
	}
}



Thanks!!! :-D

Last edited by JoGa; 02/06/12 19:58.

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