Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Grant), 3,476 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
juergenwue, VladMak, Geir, ondrej, mredit
19208 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 | 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