Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
mouse click to manipulate closest vertex #291218
09/23/09 21:56
09/23/09 21:56
Joined: Feb 2006
Posts: 616
Netherlands
cartoon_baboon Offline OP
User
cartoon_baboon  Offline OP
User

Joined: Feb 2006
Posts: 616
Netherlands
Hi,

once mroe I find my nonexistent programming skills fail me. I've been trying to achieve the following. The camera is from above looking at a flat 3d model. By left clicking the mouse the closest vertex should be selected and manipulated by mouse movement till the mouse is released.

dragging the vertex works when I specify a vertex (for example 30):
Code:
var temp;
 	   vec_for_mesh (temp, me, 30);
    vec_add(temp,vector(mouse_force.x/5,mouse_force.y/5,0));
    vec_to_mesh(temp,me,30);



However converting screen positions to real world positions, using c_trace and hit.vertex is driving me crazy frown

Could someone please tell me the easiest way to get a c_trace from the mouse position and how to use hit.vertex. Of course maybe I'm barking up completely the wrong tree with this shocked

Thanks a lot!

Re: mouse click to manipulate closest vertex [Re: cartoon_baboon] #291249
09/24/09 06:59
09/24/09 06:59
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
For the tracing part you could try:
Code:
VECTOR trace_from;
VECTOR trace_to;

vec_set(trace_from,vector(mouse_cursor.x,mouse_cursor.y,50));
vec_set(trace_to,vector(mouse_cursor.x,mouse_cursor.y,10000)); // play with the 1000 if the trace is to short

vec_for_screen(trace_from,camera);
vec_for_screen(trace_to,camera);

result = c_trace(trace_from,trace_to,USE_POLYGON|SCAN_TEXTURE);
if(result > 0)
{
  vertex_number = hit.vertex;
}



Now vertex_number contains the closest hit vertex, and you can process it as you like.
Note: not tested!


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