3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
alpha along vector (SOLVED!)
#334553
07/23/10 21:43
07/23/10 21:43
|
Joined: Apr 2010
Posts: 38
deianthropus
OP
Newbie
|
OP
Newbie
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.
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:
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
Ottawa
User
|
User
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* 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 Ver 7.86.2 Pro and Lite-C
|
|
|
Re: alpha along vector
[Re: deianthropus]
#334649
07/24/10 13:16
07/24/10 13:16
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
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 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
deianthropus
OP
Newbie
|
OP
Newbie
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: Ottawa]
#334727
07/24/10 22:01
07/24/10 22:01
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
where does "if(trace_hit)" get it's value?
from the c_trace ?!
|
|
|
|