Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,606 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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