Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 How to get camera plane ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

game_maker
Knave

Saudi Arabia
83 Posts

Posted - Jun 19 2004 :  6:16:51 PM  Show Profile  Visit game_maker's Homepage  Reply with Quote
{ Camera × Object } Collision

To do collision (Box or Shpere) I nead to got the plane from the view port => how can I get the Camera Plane ?

Edited by - game_maker on Jun 19 2004 6:24:49 PM

Eric Coleman
Gladiator

USA
811 Posts

Posted - Jun 19 2004 :  10:36:57 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Assuming you know the camera's position, then you can easily find the camera's plane.

use the vector

v.x = ViewMatrix.m13
v.y = ViewMatrix.m23
v.z = ViewMatrix.m33

and then calculate

p.x = ViewMatrix.m11 + CameraLocation.x
p.y = ViewMatrix.m21 + CameraLocation.y
p.z = ViewMatrix.m31 + CameraLocation.z

And finally use the function D3DXPlaneFromPointNormal in the D3DX library were the vector v is your plane's normal and p is a point in the plane.

Go to Top of Page

game_maker
Knave

Saudi Arabia
83 Posts

Posted - Jun 20 2004 :  12:50:29 AM  Show Profile  Visit game_maker's Homepage  Reply with Quote
very nice ^^

but this gives me equation of plane - infnite plane ? what I need is finite plane
Go to Top of Page

VBBR
Moderator

Brazil
617 Posts

Posted - Jun 20 2004 :  06:38:11 AM  Show Profile  Reply with Quote
Wouldn't it be more easy just checking with a bounding box/sphere for the camera?

Whatever. Who knows...
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Jun 20 2004 :  10:08:37 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
The camera isn't in a finite plane, so I'm not sure what you're looking for.
Go to Top of Page

game_maker
Knave

Saudi Arabia
83 Posts

Posted - Jun 20 2004 :  2:49:57 PM  Show Profile  Visit game_maker's Homepage  Reply with Quote
To do collision I must first compute the camera boundary right?

I can't compute the boundary from equation of plane with no limit's right?

So I think what I need is to find the borders in camera's plane....

The view port is a rectangular rotated in xyz ... right?

See I am totally with you with math stuff:

Equation of Plane:

ax + by + cz + d = 0

We can find the equation (i.e. finding a,b,c,d) if we have the normal vector to the plane and any point in the plane as you said

N: is the normal vector to the plane <a1,a2,a3>
P: is general point in the plane <x,y,z>
P1 : is a known point in the plane <x1,y1,z1>

Ok if we find P1P vector = <x-x1,y-y1,z-z1>

Notice that P1P is normal to N so the dot product is equal to zero

N . P1P = <a1,a2,a3> . <x-x1,y-y1,z-z1> = 0

a1(x-x1) + a2(y-y1) + a3(z-z1) = 0

a1x - a1x1 + a2y - a2y1 + a3z - a3z1 = 0

a1x + a2y + a3z -( a1x1 + a2y1 + a3z1) = 0

Finally:

a = a1
b = a2
c = a3
d = -(a1x1 + a2y1 + a3z1)

Ok if we take camera's position + rotation it will be the center of our boundary.... I need one corner point

Am I doing this wrong ?
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - Jun 20 2004 :  3:26:30 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Are you trying make the viewing frustum not collide with anything? I think you should probably do what VBBR suggests, use either a bounding box or sphere around the camera's position and test to see if that collides with anything.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.11 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.