Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: get the point where a line crosses an imaginary plane? [Re: Myrkling] #381097
08/24/11 09:49
08/24/11 09:49
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Code:
mouse_dir3d*((camera.z-plane.z)/mouse_dir3d.z)+camera.xyz = position

Lets assume that you levels origin is within the plane and that
the camera is placed at (0|0|100):
                                    0
mouse_dir3d*(100/mouse_dir3d.z) +   0 = position
                                  100

                        1
Now, if mouse_dir3d is  1 / sqrt(3), the whole thing with values 
                       -1
looks like this:


 1                             0   -100
 1 / sqrt(3) * -173.205081 +   0 = -100
-1                           100    200

As you see this is wrong, as the correct position would be
(100|100|0)... Inverting mouse_dir3d would give correct results.
I wonder where I missed the stupid sign -.-


This however, should then just work:

void traceMouse(VECTOR *pos)
{
  vec_set(pos, mouse_dir3d);
  vec_normalize(pos, -1.0);
  vec_scale(pos, camera.z/pos.z);
  vec_add(pos, camera.x);
}



Re: get the point where a line crosses an imaginary plane? [Re: Slin] #381099
08/24/11 10:25
08/24/11 10:25
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
eh... the function you wrote os only working when iam below the plane and looking up.

it needs to be^^

Code:
vec_scale(pos, -camera.z/pos.z);



now its working grin

edit: @Myrkling: Sorry havent seen your answer. Thx for your effort too laugh

Last edited by Rackscha; 08/24/11 10:35.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: get the point where a line crosses an imaginary plane? [Re: Rackscha] #381105
08/24/11 11:18
08/24/11 11:18
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Code:
void traceMouse(VECTOR *pos)
{
  vec_set(pos, mouse_dir3d);
  vec_normalize(pos, 1.0);
  vec_scale(pos, camera.z/pos.z);
  vec_add(pos, camera.x);
}


Should then be a nicer solution. Now I am really confused...^^

Edit:
Code:
void intersectMouseGroundplane(VECTOR *pos, var height)
{
  vec_set(pos, mouse_dir3d);
  vec_normalize(pos, 1.0);
  vec_scale(pos, (camera.z-height)/pos.z);
  vec_add(pos, camera.x);
}



Last edited by Slin; 08/24/11 11:22.
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

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