Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, TipmyPip, RealSerious3D), 892 guests, and 4 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
[solved] - vec_for_vertex und Sprites positions problem #349001
12/02/10 20:15
12/02/10 20:15
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
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);	
	}
}



Last edited by Ayumi; 12/02/10 23:09.
Re: vec_for_vertex und Sprites positions problem [Re: Ayumi] #349005
12/02/10 22:31
12/02/10 22:31
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
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.

Re: vec_for_vertex und Sprites positions problem [Re: Pappenheimer] #349011
12/02/10 23:00
12/02/10 23:00
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline OP
User
Ayumi  Offline OP
User

Joined: Oct 2008
Posts: 681
Germany
.....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;)


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