Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 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
c_trace and view entity #377285
07/11/11 19:12
07/11/11 19:12
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
hi,
is it possible to start a c_trace from a view entity?

how can i do that?

Re: c_trace and view entity [Re: GameScore] #377286
07/11/11 19:26
07/11/11 19:26
Joined: Mar 2009
Posts: 88
Walori Offline
Junior Member
Walori  Offline
Junior Member

Joined: Mar 2009
Posts: 88
It'd be something like this:

Code:
ENTITY * ent = some_entity;
function trace()
{

   var distance_from_camera = 0;
   VECTOR mouse_to_world;
   vec_set(mouse_to_world,vector(ent.x,ent.y,distance_from_camera));
   vec_for_screen (mouse_to_world, camera);

   c_trace(mouse_to_world,vec_to_somewhere,IGNORE_ME);

}



Last edited by Walori; 07/11/11 19:27.
Re: c_trace and view entity [Re: Walori] #377291
07/11/11 20:15
07/11/11 20:15
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
thnx,
but no solution
it doesnt work

i want to start a c_trace from a view entity
but the c_trace starts in the middle of the lvl

look here is the code i use

vec_set(trace_coords.x, vector(1500, 0, 0));
vec_rotate(trace_coords.x, laser_gun.pan);
vec_add(trace_coords.x, laser_gun.x);
if (c_trace(laser_gun.x, trace_coords.x, IGNORE_ME ) > 0) // hit something?
{
draw_line3d(my.x,NULL,100);
draw_line3d(my.x,COLOR_RED,100);
draw_line3d(target.x,COLOR_RED,100);
draw_point3d(target.x,COLOR_RED,100,3);
}

maybe i need to use vec_for_screen
but i do not know how

Re: c_trace and view entity [Re: GameScore] #377295
07/11/11 20:58
07/11/11 20:58
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
vec_for_screen is used to convert screen coordinates into world coordinates. However, as view entities are located neither in sceen space nor in world space but in view space, vec_for_screen alone is not enough: Before using vec_for_screen you have to use rel_to_screen to convert the view entity's coordinates into screen coordinates.

So just add a rel_to_sceen to Walori's code. This should do the trick.

Re: c_trace and view entity [Re: Myrkling] #377370
07/12/11 15:43
07/12/11 15:43
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
i was trying but i find no solution

Re: c_trace and view entity [Re: GameScore] #377442
07/13/11 08:20
07/13/11 08:20
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
The view entity is inside the camera, so you can use
Code:
c_trace(camera.x, trace_coords.x, IGNORE_ME )



[EDIT]
in case you want to have 'offset' from the lasergun.x
Code:
VECTOR temp;
...
vec_set(temp.x, lasergun.x);
vec_rotate(temp.x,camera.pan);
c_trace(vec_add(camera.x, temp.x), trace_coords.x, IGNORE_ME );



Warning: the code is not tested

Last edited by bart_the_13th; 07/13/11 08:26.
Re: c_trace and view entity [Re: bart_the_13th] #377898
07/17/11 18:54
07/17/11 18:54
Joined: Apr 2008
Posts: 245
GameScore Offline OP
Member
GameScore  Offline OP
Member

Joined: Apr 2008
Posts: 245
i got it tnx


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