Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mouse and vec_for_screen behavior question #137086
06/19/07 05:36
06/19/07 05:36
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline OP
Senior Expert
PHeMoX  Offline OP
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
I'm not using the quote code, however I am using exactly the same code for the vec_for_screen part, and that gives me the same deviation I'm currently dealing with.

If you click the object using this action you will be able to move it while it's under your mouse cursor, however, it's position will not stay exactly underneath the mouse cursor, instead, it has a deviation. The further you move the object away from the center, the bigger the deviation. (even if optical illusion, I don't want it to have this deviation...)

Code:
function pick_or_drop()
{
wait (1);
my.skill1 += 1;
if ((my.skill1 % 2) == 1) // clicked the object?
{
while (mouse_left == on) {wait (1);}
while (mouse_left == off) // move the object until the player presses the mouse button again
{
temp.x = pointer.x;
temp.y = pointer.y;
temp.z = 200; // move the object 200 quants below the camera, play with this value
vec_for_screen(temp.x, camera);
my.x = temp.x;
my.y = temp.y;
my.z = temp.z;
wait (1);
}
}
else // drop the object
{
vec_set (temp.x, my.x);
temp.z -= 3000;
trace_mode = ignore_me + ignore_sprites + ignore_models + use_box;
my.z -= trace (my.pos, temp); // place the object on the ground
}
}

action click_and_move
{
my.skill1 = 0;
my.enable_click = on;
my.event = pick_or_drop;
}



How can I fix this? I'm quite lost on how to solve this, especially because I don't quite get the problem. It should have the right coordinates because vec_for_screen took care of that, but apparently it doesn't quite.

The thing is, I'm trying to attach a particle effect to my mouse cursor using an object in 3D with a particle function attached. Thing is, the particle effect doesn't follow the cursor accurately, instead it has a huge deviation. I'm a total loss here, I've already tried adding certain values, but that only made it worse, probably because I do not quite understand the nature of this problem.

(by the way, "doing it the other way around" doesn't give deviations at all; meaning from 2D to 3D position like this;

Code:

bmap my_pcx = <my.pcx>;
panel my_pan
{
bmap = my_pcx;
layer = 15;
flags = overlay, refresh, visible;
}
function highlight_me()
{
var temporary;
while (1)
{
vec_set (temporary, my.x);
vec_to_screen (temporary, camera);
my_pan.pos_x = temporary.x;
my_pan.pos_y = temporary.y;
wait (1);
}
}
action my_entity
{
highlight_me(); // attach the panel to the entity
// put the rest of the code for your entity here
}


)



Edit: In the meantime I've got it working using a work-around, but any thoughts on this problem are still very welcome ..

Cheers

Last edited by PHeMoX; 06/19/07 06:28.

PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Mouse and vec_for_screen behavior question [Re: PHeMoX] #137087
06/20/07 06:46
06/20/07 06:46
Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
George Offline

Expert
George  Offline

Expert

Joined: Aug 2003
Posts: 2,011
Bucharest, Romania
Attaching particles to the mouse pointer sounds fun. I'll post a snippet in the following magazine (should be out in a week or so).

Re: Mouse and vec_for_screen behavior question [Re: George] #137088
06/20/07 12:04
06/20/07 12:04
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline OP
Senior Expert
PHeMoX  Offline OP
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Thanks George, much appreciated.

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Mouse and vec_for_screen behavior question [Re: George] #137089
02/11/08 23:51
02/11/08 23:51
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
Quote:

Attaching particles to the mouse pointer sounds fun. I'll post a snippet in the following magazine (should be out in a week or so).



yeah how you did it! i also want to know..

Re: Mouse and vec_for_screen behavior question [Re: MMike] #137090
02/13/08 13:27
02/13/08 13:27
Joined: Nov 2004
Posts: 862
Australia
DavidLancaster Offline
User
DavidLancaster  Offline
User

Joined: Nov 2004
Posts: 862
Australia
If you're using lite-c then there might be a lag when you try and do that, all tactics to attach anything in the 3D world to a 2D position on the screen gives me a lag in lite-c. I could be wrong, it's what I ran into using lite-c and gave up and stuck with c-script I posted asking for an answer and got no response (I think).


Moderated by  George 

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