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
alpha along vector (SOLVED!) #334553
07/23/10 21:43
07/23/10 21:43
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
EDIT: I just realized that just because C-trace runs, "you" is not necessarily set. Here's what I've come up with. Any entity without flag2 or skill30 is made translucent, and multiple obstructions can be made translucent.

Code:
function transpar_vector()
	{		
		if(c_trace(vector(camera.x,camera.y,camera.z),vector(ball.x,ball.y,ball.z),USE_BOX|IGNORE_FLAG2))
		{
			if (you)
				{
				if(!you.skill30)
					{
					set(you,TRANSLUCENT);
					set(you,FLAG2);
					you.alpha = 50;
					wait(1);
					reset(you,TRANSLUCENT);
					reset(you,FLAG2);
					}
				
				}
		wait(2);
		transpar_vector();
		}
		wait(1);
	}


That's it. Done deal.





(In case you're interested, here's the original question:)

I need to make translucent everything between the ball and camera. The code I have only hangs the program at startup. once I can set the opacity, I need to return the entity's alpha to is original opacity (not yet in code).

here's what I have:

Code:
function transparency_along_vector()
	{	
		VECTOR* stvec = vector(camera.x,camera.y,camera.z);
		VECTOR* tracer = vector(ball.x,ball.y,ball.z);
		
		c_trace(stvec,tracer,IGNORE_FLAG2 ); //ball object is flag2
			
		if(trace_hit)
		{
			set(you,TRANSLUCENT);
			you.alpha = 50;
			wait(1);	
		}
		
	}



also: putting a wait() function between setting translucency and alpha does not fix the hang-up.

Last edited by deianthropus; 07/25/10 19:09.
Re: alpha along vector [Re: deianthropus] #334561
07/23/10 22:59
07/23/10 22:59
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

1)Reduce the number of letters of the function name to something lower than 20.

2) In order to initialize your VECTOR* ....Look up vec_set in the manual.
and the declaration of VECTORS*

Quote:
VECTOR* vSpeed = {x=10;y=20;z=30;} // lite-C - address with .x, .y, .z
and
Declaring global struct pointers (f.i. VECTOR* v = {x=1;y=2;z=3;} ) inside functions will now issue an error message.



Last edited by Ottawa; 07/23/10 23:15.

Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: alpha along vector [Re: Ottawa] #334567
07/23/10 23:22
07/23/10 23:22
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
Thanks, but no good. the game hangs on the set(you,transparent) and my.alpha = 50 functions. The vector can be temporary.

Re: alpha along vector [Re: deianthropus] #334649
07/24/10 13:16
07/24/10 13:16
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

You will have to be more precise.
What did you do with your code?


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: alpha along vector [Re: Ottawa] #334692
07/24/10 17:22
07/24/10 17:22
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
I took your advice and renamed the function to less than 20 chars, and I removed the vector declarations, instead using a temporary vector for the parameters of c_trace, but the game hangs on the translucent or alpha instruction.

e.g c_trace(vector(camera.x,camera.y,camera.z),vector(ball.x,ball.y,ball.z),IGNORE_FLAG2);

The problem seems to be my transparency code. Does that code hang the renderer or game engine for you? I am calling the function constantly, so that the moment an entity passes between the object and the camera, the obstructing entity is rendered transparent. I also need to reset the entity's transparency when it is no longer along the vector.

BTW... "if" does not return true if the value is zero, right?

Re: alpha along vector [Re: deianthropus] #334722
07/24/10 21:49
07/24/10 21:49
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!


Looking at your code at the top,,,
where does "if(trace_hit)" get it's value?

Re: alpha along vector [Re: Ottawa] #334727
07/24/10 22:01
07/24/10 22:01
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Quote:

where does "if(trace_hit)" get it's value?

from the c_trace ?!

Re: alpha along vector [Re: Widi] #334731
07/24/10 22:09
07/24/10 22:09
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Also 'c_trace(camera.x,ball.x,IGNORE_FLAG2);' is cleaner.

Re: alpha along vector [Re: Widi] #334744
07/24/10 23:56
07/24/10 23:56
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi Widi

There are 3 instances of trace_hit in the manual.
Now I know. wink

Re: alpha along vector [Re: Ottawa] #334875
07/25/10 18:33
07/25/10 18:33
Joined: Apr 2010
Posts: 38
D
deianthropus Offline OP
Newbie
deianthropus  Offline OP
Newbie
D

Joined: Apr 2010
Posts: 38
The issue isn't my c-trace, I'm fairly confident. I know that works well enough. Any idea why my game hangs on the transparency functions? Does it have to do with the order of rendering? If I put this function in my main() function's while(1) loop, should there be some other condition before running the function? or perhaps does the order in which I call the function in relation to other functions affect my game in a way that might hang the engine?


Moderated by  HeelX, Spirit 

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