alpha along vector (SOLVED!)

Posted By: deianthropus

alpha along vector (SOLVED!) - 07/23/10 21:43

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.
Posted By: Ottawa

Re: alpha along vector - 07/23/10 22:59

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.


Posted By: deianthropus

Re: alpha along vector - 07/23/10 23:22

Thanks, but no good. the game hangs on the set(you,transparent) and my.alpha = 50 functions. The vector can be temporary.
Posted By: Ottawa

Re: alpha along vector - 07/24/10 13:16

Hi!

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

Re: alpha along vector - 07/24/10 17:22

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?
Posted By: Ottawa

Re: alpha along vector - 07/24/10 21:49

Hi!


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

Re: alpha along vector - 07/24/10 22:01

Quote:

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

from the c_trace ?!
Posted By: DJBMASTER

Re: alpha along vector - 07/24/10 22:09

Also 'c_trace(camera.x,ball.x,IGNORE_FLAG2);' is cleaner.
Posted By: Ottawa

Re: alpha along vector - 07/24/10 23:56

Hi Widi

There are 3 instances of trace_hit in the manual.
Now I know. wink
Posted By: deianthropus

Re: alpha along vector - 07/25/10 18:33

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?
© 2024 lite-C Forums