Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Drag and Drop object #128621
05/08/07 13:33
05/08/07 13:33
Joined: May 2007
Posts: 30
F
fusukery Offline OP
Newbie
fusukery  Offline OP
Newbie
F

Joined: May 2007
Posts: 30
I have make a search but can not find a solution. I know drag and drop is not an easy thing, but anyone know how to do it? I do not know how to control object in 3D world throgh an 2D mouse

Re: Drag and Drop object [Re: fusukery] #128622
05/08/07 14:31
05/08/07 14:31
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
You need to use vec_for_screen to convert mouse (2D) coordinates to world (3D) coordinates.

Code:
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = YOUR_DISTANCE; // Depth


How you should compute the depth, depends on where you want the object to be. A c_trace could be used, as an example.
Have a look at the RPG Movement code in AUM34, that might be what you need.

Re: Drag and Drop object [Re: Claus_N] #128623
05/08/07 15:05
05/08/07 15:05
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
in entity function:
my.enable_mouse = on;

then loop
if(event_type == event_mouse) //touch by mouse
{
while(mouse_left == 1){dragging me;}
}

to keep object on ground and calculate angle from camera to mouse poniter in 3D world look at my click & go script


Never say never.
Re: Drag and Drop object [Re: Claus_N] #128624
05/08/07 15:07
05/08/07 15:07
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline
Serious User
Scorpion  Offline
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
Code:
function drag_event
{
my.red=255;//as long u drag it
my.green=0;//it is colored red
my.blue=0;//maybe u can do it also by event_touch
while(mouse_left)
{
proc_late();
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 5000;//maybe more? O_o
c_trace(camera.x,temp,ignore_me + use_box);
vec_Set(my.x,target.x);
wait(1);
}
my.red=255;
my.green=255;
my.blue=255;
}
action drag_me
{
my.enable_click = on;
my.event= drag_event;
}



Last edited by Scorpion; 05/08/07 15:11.
Re: Drag and Drop object [Re: Scorpion] #128625
05/08/07 17:32
05/08/07 17:32
Joined: Jan 2007
Posts: 126
Germany
Pinkhead Offline
Member
Pinkhead  Offline
Member

Joined: Jan 2007
Posts: 126
Germany
With this code the model disappears. But not shine red?
Maybe you can help.

Bye,

Pinkhead


I'm 14, NOW! RollingStone Fullversion Rolling Stone won by u19! -> German - Winnerlist
Re: Drag and Drop object [Re: Pinkhead] #128626
05/08/07 20:23
05/08/07 20:23
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Quote:

With this code the model disappears. But not shine red?
Maybe you can help.

Bye,

Pinkhead



Maybe the trace doesn't hit anything? Then the model would be placed at the nullvector (or at some random coordinates).

EDIT: Scorpion, the code needs a small change:
Code:
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 5000; //maybe more? O_o
target.x = mouse_pos.x;
target.y = mouse_pos.y;
target.z = 0;
vec_for_screen(temp,camera);
vec_for_screen(target,camera);

c_trace(target,temp,ignore_me + use_box);



Last edited by Claus_N; 05/08/07 20:28.
Re: Drag and Drop object [Re: Claus_N] #128627
05/09/07 03:47
05/09/07 03:47
Joined: May 2007
Posts: 30
F
fusukery Offline OP
Newbie
fusukery  Offline OP
Newbie
F

Joined: May 2007
Posts: 30
It doesnt work, I find out when click on the object, the model is place at the same position with the character , that s reason why the model disappear as metioned above

Re: Drag and Drop object [Re: fusukery] #128628
05/09/07 07:18
05/09/07 07:18
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
I works for me... Did you make the changes I posted above?

Here's the full code again, which worked for me:
Code:
function drag_event
{
my.red=255;//as long u drag it
my.green=0;//it is colored red
my.blue=0;//maybe u can do it also by event_touch
while(mouse_left)
{
proc_late();
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 5000;//maybe more? O_o
target.x = mouse_pos.x;
target.y = mouse_pos.y;
target.z = 0;
vec_for_screen(temp,camera);
vec_for_screen(target,camera);
c_trace(target,temp,ignore_me + use_box);
vec_Set(my.x,target.x);
wait(1);
}
my.red=255;
my.green=255;
my.blue=255;
}
action drag_me
{
my.enable_click = on;
my.event= drag_event;
}



Re: Drag and Drop object [Re: Claus_N] #128629
05/09/07 07:43
05/09/07 07:43
Joined: May 2007
Posts: 30
F
fusukery Offline OP
Newbie
fusukery  Offline OP
Newbie
F

Joined: May 2007
Posts: 30
I set target.z = 0; to target.z = 100; and I work, If not, we only could move model along the character

Re: Drag and Drop object [Re: fusukery] #128630
05/09/07 16:30
05/09/07 16:30
Joined: May 2007
Posts: 30
F
fusukery Offline OP
Newbie
fusukery  Offline OP
Newbie
F

Joined: May 2007
Posts: 30
There are a problem
When draging, the model is collided with other model at its center (pivot), so half of model is inside other. How could I make this model collide with its bouding box with other?

Page 1 of 2 1 2

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