Touching direction

Posted By: wdakfenixx

Touching direction - 10/03/12 18:41

Im trying to make a cube that executes different functions according with the face I´ve clicked, I just don´t know how to define wich one I´ve clicked, Any ideas?
Posted By: Uhrwerk

Re: Touching direction - 10/03/12 18:52

Calculate the difference vector between the clicked position and the cubes center. Then you can examine which of the three components got the greatest absolute value and its sign.
Posted By: gameplan

Re: Touching direction - 10/03/12 19:20

Or try to use this to get a vector normal to the specific cube face:

vec_set(to,mouse_dir3d);
vec_scale(to,2000);
vec_add(to,mouse_pos3d);
c_trace(mouse_pos3d,to,USE_BOX | IGNORE_SPRITES | IGNORE_FLAG2);
vec_set(to,target.x);
vec_set(vec_normal,normal);

As Uhrwerk said, you can examine the greatest value with the normalvector from this code.
Posted By: wdakfenixx

Re: Touching direction - 10/03/12 20:28

Uhrwerk: I get you, that was i tried to do, but i dont know how to especify the position i've clicked, if i use c_trace it returns the cube center
gameplan:thanks, but i'm not sure if i used that script correctly, but the result depends on my position and i need to be able to click any face from any position i.e. from some positions you can see tree faces of a cube and if im in that position i need to be able to click any of these faces
Posted By: Uhrwerk

Re: Touching direction - 10/03/12 20:49

c_trace should return the distance to the hit entity, not a vector. Or were you talking about the hit vector?
Posted By: wdakfenixx

Re: Touching direction - 10/03/12 20:50

yes i was talking of the hit vector
Posted By: Uhrwerk

Re: Touching direction - 10/03/12 21:03

Now that is strange. Have you set USE_POLYGON? Did you try to create a particle at the hit vector's position in order to actually see where it is?
Posted By: wdakfenixx

Re: Touching direction - 10/03/12 21:41

i had it dislabed before but even when it is, it place a sphere that i use as a mark weirdly, no matter where i click it place the sphere in the direction im looking each time closer to me
Code:
c_trace(camera.x,vec_rotate(vector(90000,0,0),camera.pan),USE_POLYGON|SCAN_TEXTURE);
	ent_create(SPHERE_MDL,hit.x,NULL);

Posted By: wdakfenixx

Re: Touching direction - 10/03/12 21:47

Ahhh now i get it, its because its going to put it at the "end" of the trace, i´ve solved it now
Posted By: wdakfenixx

Re: Touching direction - 10/03/12 22:09

Ahhh now i get it, its because its going to put it at the "end" of the trace, i´ve solved it now
© 2024 lite-C Forums