[solved] - vec_for_vertex und Sprites positions problem

Posted By: Ayumi

[solved] - vec_for_vertex und Sprites positions problem - 12/02/10 20:15

Huhu,...

ich habe ein etwas komplexeres Problem und kann es nicht loesen:

Beschreibung des Objektes:

Ich habe mir als Gegner oder auch als Waffe eine Selbstschuss-
anlage modelliert.
Diese ist frei drehbar und besteht aus 2 Teilen.

Nun wollte ich ein par Lichteffekte anbringen in Form eines
Sprites, davon gleich 4 Stueck.
Allen 4 Sprites weise ich per "Vec_for_vertex" eine Position
zu.
Ueber ent_create erzeuge ich sie mit der Selbstschussanlage.

Mein Problem:
Wenn sich der Turm dreht, veraendert sich auch die Position
des vertexes.Nur leider passen sich meine Sprites der
Position der Vertexe nicht an.

Hier der Code ausschnitt(einer von vielen moeglichen, ich
liste mal die kuerzeste auf).


Und nein, ich moechte keine 4 Funktionen mit 4 Pointern haben.^^
Wuerde mich ueber einen Anhaltspunkt, tip, rat oder was auch immer, freuen.

Code:
STRING* ss_sprite1 = "TE_flare.tga";

ENTITY* ssa_kannone;
ENTITY* ssa_drehtum1;

VECTOR ss_spritecoords1;			
VECTOR ss_spritecoords2;
VECTOR ss_spritecoords3;
VECTOR ss_spritecoords4;



action ss_kannone()
{
	ssa_kannone = my;
	set(my, POLYGON | LIGHT);
	//efire_bullets();           // Schussfunktion
	
	while(1)
	{
		ssa_posi();          // Position der Drehung und Blick zum Player
		wait(1);
	}
}

action ss_drehturm1()
{
	VECTOR temp;
	ssa_drehtum1 = my;
	set(my, POLYGON | LIGHT);
	
	vec_for_vertex(ss_spritecoords1 , my, 307);
	ent_create(ss_sprite1 ,ss_spritecoords1, ein_aus_ssa_sprites);
	
	while(1)
	{ 
                // wie gesagt, alles moegliche getestet, 
                // darum erscheint das hier etwas 
                // unsauber

		vec_set(temp, my.x);
		
//		temp.x += ss_spritecoords1.x;
//		temp.y += ss_spritecoords1.y;
//		temp.z += ss_spritecoords1.z;
		wait(1);
	}
	
//	vec_for_vertex(ss_spritecoords1 , my, 307);
//	vec_for_vertex(ss_spritecoords2 , my, 308);
//	vec_for_vertex(ss_spritecoords3 , my, 309);
//	vec_for_vertex(ss_spritecoords4 , my, 310);
//
//	ent_create(ss_sprite1 ,ss_spritecoords1, ein_aus_ssa_sprites);
//	ent_create(ss_sprite1 ,ss_spritecoords2, ein_aus_ssa_sprites);
//	ent_create(ss_sprite1 ,ss_spritecoords3, ein_aus_ssa_sprites);	
//	ent_create(ss_sprite1 ,ss_spritecoords4, ein_aus_ssa_sprites);
}



// Drehturm position, skill 1 ist die ID und skill 4 die Muni
function ssa_posi()
{
	VECTOR trace_coords2;
	proc_mode = PROC_LATE;
	if((my.skill1 == 1) && (my.skill4 > 0))
	{
		if ((c_scan(my.x, my.pan, vector(360, 180, 1000), IGNORE_ME | SCAN_FLAG2 | SCAN_ENTS) <5000) && (you == player))
		{
			vec_set (trace_coords2, player.x);
			vec_sub (trace_coords2, my.x);			
			vec_to_angle (ssa_drehtum1.pan, trace_coords2);
			vec_to_angle (my.pan, vector(trace_coords2.x, trace_coords2.y, trace_coords2.z));
			ssa_drehtum1.tilt = 0;
			ssa_drehtum1.roll = 0;				
			my.roll = 0;
				
			my.x = ssa_drehtum1.x - 28 * cos(ssa_drehtum1.pan); // Front-Punkt 60 Quants vor Modell
			my.y = ssa_drehtum1.y - 28 * sin(ssa_drehtum1.pan); // wird erstellt
			my.z = ssa_drehtum1.z + 26;
		}
	}
}



// und zu guter letzt die  Sprites funktion

function ein_aus_ssa_sprites()
{
	proc_mode = PROC_LATE;
	my.ambient = 100;					
	my.albedo = 100;												
	set(my, PASSABLE | TRANSLUCENT | ZNEAR | BRIGHT);
	
	var check = 0;
	while(1)
	{
		my.pan = 0; my.tilt = 0; my.roll = 0;		
		
		result = c_trace(my.x, camera.x, IGNORE_ME|IGNORE_PASSABLE|IGNORE_YOU);
		if(result) 				
		{ 
			my.alpha = maxv(0,my.alpha -7 * time_step);  	
			if(my.alpha <= 0) { set(my,INVISIBLE); }   
			my.scale_x = minv(0.1, vec_dist(my.x, camera.x) / 2048); 
			my.scale_y = my.scale_x;
		} 	
		else
		{	 
			reset(my,INVISIBLE); 
			my.scale_x = minv(0.1, vec_dist(my.x, camera.x) / 2048); 
			my.scale_y = my.scale_x;
			
			if(check == 0)
			{
				my.alpha = minv(100, my.alpha +7 * time_step); 
				if(my.alpha > 95) { my.alpha = 100; check = 1; }			
			}
			if(check == 1)
			{
				my.alpha = maxv(0,my.alpha -5 * time_step); 
				if(my.alpha < 3) { my.alpha = 0; wait(-1); check = 2; }
			}
			if(check == 2)
			{
				my.alpha = minv(100, my.alpha +5 * time_step); 
				if(my.alpha > 97) { my.alpha = 100; check = 1; }
			}
		}
		wait(1);	
	}
}


Posted By: Pappenheimer

Re: vec_for_vertex und Sprites positions problem - 12/02/10 22:31

vor die While-Schleife:
you = ent_create() sprite...
my.skill12 = handle(you);
in die While-Schleife:

you = ptr_for_handle(my.skill12);
vec_for_vertex(you.x,....);
...



Oder, du machst es über Partikel.
Posted By: Ayumi

Re: vec_for_vertex und Sprites positions problem - 12/02/10 23:00

.....wenigstens war ich im Ansatz richtig.
Ich hab es ueber den you handle versucht aber anscheind falsch gewaehlt.

Dank dir vielmals, es funktioniert.


...und ueber Partikel hab ich wieder extra code;)
© 2024 lite-C Forums