3d mouse_pointer

Posted By: slowglider

3d mouse_pointer - 08/09/10 20:31


i want to create some lvl editor like in trackmania

the things is how to get te point were the mouse is on the right hight

the rest i think i can handle myself but the problem is vec_for_screen only gots a distance instead i want to have it on a certain hight like z = 0 ore somting

hope you understand me en that some can help me
Posted By: hopfel

Re: 3d mouse_pointer - 08/13/10 21:19

I made such a code a while ago, I hope its that what you're looking for:

Code:
VECTOR kreis_pos;
ANGLE kreis_ang;

while(1)
{

vec_set(kreis_pos,vector(mouse_pos.x,mouse_pos.y,10000));
vec_for_screen(kreis_pos,camera);

my.skill1=c_trace(camera.x,kreis_pos.x,IGNORE_SPRITES + IGNORE_MODELS);

vec_to_angle(kreis_ang,vector(kreis_pos.x-camera.x,kreis_pos.y-camera.y,kreis_pos.z-camera.z));
my.x=camera.x-(-my.skill1)*cos(kreis_ang.tilt)*cos(kreis_ang.pan);
my.y=camera.y-(-my.skill1)*cos(kreis_ang.tilt)*sin(kreis_ang.pan);
my.z=camera.z-(-my.skill1)*sin(kreis_ang.tilt);

wait(1);
}



my is the entity, which follows the mouse.
I think there's an easyer code but maybe you can use it. ^^
Posted By: slowglider

Re: 3d mouse_pointer - 08/14/10 08:25

thank buts not realy wat i want.

i want to give the heigth lets say z = 5 my entity wil always be my.z == 5 but then on the mouse_position

btw you reinvented the wheel there you could simple do this

Code:
vec_set(kreis_pos,vector(mouse_pos.x,mouse_pos.y,10000));
vec_for_screen(kreis_pos,camera);

my.skill1=c_trace(camera.x,kreis_pos.x,IGNORE_SPRITES + IGNORE_MODELS);

vec_set(kreis_pos,vector(mouse_pos.x,mouse_pos.y,my.skill1));
vec_for_screen(kreis_pos,camera);
vec_set(my.x,kreis_pos);


Posted By: hopfel

Re: 3d mouse_pointer - 08/14/10 10:58

Quote:
i want to give the heigth lets say z = 5 my entity wil always be my.z == 5 but then on the mouse_position


I think the best way for that is using trigonometry:

Code:
VECTOR kreis_pos;
ANGLE kreis_ang;

while(1)
{

vec_set(kreis_pos,vector(mouse_pos.x,mouse_pos.y,10000));
vec_for_screen(kreis_pos,camera);

vec_to_angle(kreis_ang,vector(kreis_pos.x-camera.x,kreis_pos.y-camera.y,kreis_pos.z-camera.z));

my.x=camera.x+(camera.z-5)*(tanv(kreis_ang.tilt-90))*cos(kreis_ang.pan);
my.y=camera.y+(camera.z-5)*(tanv(kreis_ang.tilt-90))*sin(kreis_ang.pan);
my.z=5;

wait(1);
}



Is it that what you mean?
Posted By: slowglider

Re: 3d mouse_pointer - 08/14/10 13:55

yeah many thanx it works great
© 2024 lite-C Forums