Camera Position Question
Camera Position Question
Camera Position Question
Camera Position Question
Camera Position Question
Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question
Camera Position Question Camera Position Question
Camera Position Question
Go Back  Xtreme Visual Basic Talk > > > > Camera Position Question


Reply
 
Thread Tools Display Modes
  #1  
Old 05-10-2009, 09:36 AM
Chris Ara Chris Ara is offline
Centurion
 
Join Date: Feb 2005
Posts: 176
Default Camera Position Question


I'm trying to figure out how to get the world matrix position of a camera , for some simple box collision test. Basically I know you use the device.transform.view to get the position by getting the m41 , m42 , m43 values wich represent the current x,y,z position of the camera. The problem is when you rotate the camera the z value changes to the direction the camera is pointing. What I want is the camera position in relation to world matrix and the objects within not the camera matrix. Does DirectX provide any built in functions for this or do I have to do the math on my own(if so have any good places to show me). TYVM
Reply With Quote
  #2  
Old 05-10-2009, 09:53 AM
Qua's Avatar
QuaCamera Position Question Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

I'm not quite sure I understand you questiong. I assume that you're keeping track of the the location (x,y,z) alongside with at least the pitch and the heading of the camera. Are you then trying to determine which objects are contained within the view frustum? Or are you trying to determine which objects actually collides with the camera itself assuming that it is a box?
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #3  
Old 05-10-2009, 07:28 PM
Chris Ara Chris Ara is offline
Centurion
 
Join Date: Feb 2005
Posts: 176
Default

I want to know wich objects collide with the camera. I'm creating a bounding box around the camera wich I can use to determine collisions with other objects in the area , which are also use bounding boxes. I have figured out the math for this and works great so far. The math however depends on knowing the x,y,z location of an object. The problem is when you rotate a camera the Z axis changes or Y depending on wich direction. Basically even the camera is the same spot the location of the Z axis will change when you rotate from left to right. What happens is the Z axis is now what ever way the camera is facing. Not sure if any of that helps it is a big subject to try and fit into one paragraph. However I can determine if objects within the world collied now it's just a matter of camera now.
Reply With Quote
  #4  
Old 05-10-2009, 10:04 PM
Qua's Avatar
QuaCamera Position Question Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

I understand. Once the camera, and thus the bound box beloning to it, rotates you're all the sudden working with arbitrary axes which complicates the collision detection quite a bit from just doing axis aligned bounding box collision detection.

Doing collision on arbitrary axis is not easy, and I would suggest simplifying this process unless you mind losing a little bit of accuracy. There are several ways to simplify this:
  • Instead of using a bounding box for your object, use a sphere which is extremely easy to do collision detection for no matter the scale and rotation of the object. This works great for first person cameras where the user cannot actually see themselfes.
  • Save each of the 8 corners of the bounding box and do collision detection use these.
  • Recalculate the bounding box so it once again aligns with the world axises which allows you to do normal collision detection
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Camera Position Question
Camera Position Question
Camera Position Question Camera Position Question
Camera Position Question
Camera Position Question
Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question Camera Position Question
Camera Position Question
Camera Position Question
 
Camera Position Question
Camera Position Question
 
-->