|
2 registered members (Grant, AndrewAMD),
911
guests, and 9
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
How to emulate draw_line3d
#141124
07/14/07 20:23
07/14/07 20:23
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
I have a physics level that I'm running in the A7 demo (so I really probably should use draw_line3d, but whatever) where when you spawn an entity, a line appears from the center of the level on the first one, and between the last one spawned and the new one just spawned on all the rest. The line is shown only for an instant, so you have to catch it, but it really looks no different from the real draw_line3d: Code:
function spawn_ball() { count_of_ents+= 1; ent_create ("earth.mdl",vector(random(200),random(-200),random(200)),ball); phent_addvellocal (_ball,vector(random(50),random(-50),random(-50)),vector(random(-20),random(15),random(-10))); while(1) { vec_set(temp,vector(_ball.x,_ball.y,_ball.z)); vec_to_screen(temp,camera); draw_line(temp,vector(255,255,255),100); draw_line(temp,vector(255,255,255),100); wait(1); } }
EDIT: I've also created a program that draws a fake "cube" in the "middle" of a level. Takes a lot of draw_lines, though! EDIT AGAIN: I think it would be better if I just gave a general format for the Code:
function whatever() { while(1) { vec_set(temp,vector(x,y,z)); vec_to_screen(temp,camera); draw_line(temp,vector(b,g,r),a); draw_line(vector(x,y,z),vector(b,g,r),a); wait(1); } }

Last edited by MrCode; 07/15/07 06:37.
|
|
|
Re: How to emulate draw_line3d
[Re: Xarthor]
#141126
07/15/07 20:44
07/15/07 20:44
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
i tried myself to but i didnt get somthing on the screen 2d lines but didnt saw it maby u find it out ore someone else sow hey can tel use some info for other people
(for me it isnt importent)
draw_line(VECTOR*, COLOR*, var alpha) Draw a line to the given XY position with the given color and transparency.
Parameters: VECTOR* - the end position of the line. The start position is the position of the last draw_line instruction. The Z value must be 0. COLOR* - the end color of the line. The start color is the color of the last draw_line instruction. If NULL is given, no line is drawn, but the position is set for the start of the next line. alpha - the end transparency of the line, 0..100. Speed: fast Example: function draw_red_rect(x1,y1,x2,y2) { while(1) { draw_line(vector(x1,y1,0),NULL,100); // move to first corner draw_line(vector(x2,y1,0),vector(0,0,255),100); draw_line(vector(x2,y2,0),vector(0,0,255),100); draw_line(vector(x1,y2,0),vector(0,0,255),100); draw_line(vector(x1,y1,0),vector(0,0,255),100); wait(1); }}
"empty"
|
|
|
Re: How to emulate draw_line3d
[Re: flits]
#141127
07/15/07 21:28
07/15/07 21:28
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Actually you need to have another vec_to_screen for the second vector. Sorry about that. Here's the real Code:
var point1[3]; var point2[3]; var color[3]= 255,255,255;
...
function vec_draw_line() { while(1) { vec_set(point1,vector(-25,-25,-25)); //setting up the positions vec_set(point2,vector(-25,-25,25)); vec_to_screen(point1,camera); //converting coordinates to 2D vec_to_screen(point2,camera); draw_line(point1,color,100); //these are now draw_line3d ;) draw_line(point2,color,100); wait(1); } }
This should draw a vertical "3D" line starting from coordinates -25,-25,-25. I tested this code, so now it should work. 
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
|