XNA Game Development Forums
2012/05/18 05:41:00 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Tutorial 14  (Read 3896 times)
serus
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: 2006/08/12 07:37:37 »

I had several problems understanding tutorial 14. I'm not really into tree theory and had some problems understanding what Pick() does and what rayStart rayDirection and IntersectInformation do. Also a more detailed explanation on the pick method from the HMScene class would be nice. Hope anyone could help me.
Logged
Chr0n1x
Global Moderator
Sr. Member
*****
Offline Offline

Posts: 307


View Profile WWW
« Reply #1 on: 2006/08/17 22:51:41 »

Pick basically takes the mouse position on the screen and shoots a ray into the world space (3d directx world) and determines if that ray hits any object on the way through. It returns the 1st object it hits.
rayStart, rayDirection are exactly what they are named. The first is the starting point in worldspace for the ray that will shoot through the space, and the rayDirection is the direction it will go. IntersectInformation contains details about what the ray has intersected on its way through the space.
Since Mike is rewriting the tutorials for 2.0, and the Pick() function will be a bit different in 2.0, this explanation may not be valid when the new tutorial is released, but anyway...

The function takes in the mouselocation, camera and device. The mouse location is assigned to mouseLoc and a boolean variable which will tell us in the end if we found anything is set to false. (We have not found anything yet of couse Wink)
We declare the variables I explained in my 1st paragraph, and then put the camera's projection matrix into its own little variable.
Now comes the math. We use algebra to convert the mouse location to a location in the 3D world. I myself just copied that in, so mike would have to provide a better explanation of whats going on here.
Next we create a matrix like we do for our camera, but we invert it. More algebra to finish converting the mouselocation into the 3d space.
We set a distance and then go through every object in the scene to figure out if the ray created touches any of them. We keep the one that it touched and keep running through to make sure there are no other ones closer.
To check each object, we prep our model like we would for rendering, creating the World matrix for it. Then it is inverted(mike?).
The coordinates are transformed into 3d space and the direction is normalised (since it's a direction).
Then we use the built in Mesh.Intersect function to check if the mesh was hit, and return true or false depending on result.

(Disclaimer: This is a quick and dirty explanation of the function as I read through it line by line. Some parts need to be filled in like the purpose or workings of the algebra, but the rest should explain it fine. Any more questions just ask me. Ignore any spelling mistakes.)
Just ask if you still don't understand something. Smiley
Logged

XNASorcerer
Newbie
*
Offline Offline

Posts: 25



View Profile
« Reply #2 on: 2008/12/17 18:17:04 »

Where are those tutorials? I can not find them anymore. Sad
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #3 on: 2008/12/19 10:32:01 »

The old Managed DirectX tutorials are not exactly supported anymore :/ It has been a long time since Managed DirectX has been around, and the tutorials are far out of date.

Sooner or later I will go in and redo them all with DirectX10 (or 11 if it takes me that long!), but for now the old DirectX tut's are pretty much dead Sad
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Next Tutorial Hazy Mind XNA Engine mikeschuld 12 4868 Last post 2006/11/12 15:40:51
by mikeschuld
Tutorial 8 :: Post Processing Framework Tutorial Discussion « 1 2 3 4 » Chr0n1x 59 18066 Last post 2007/06/15 03:41:52
by Chr0n1x
Tutorial#3-Error1-Inconsistent accessibility: property type 'GameEngine.GScene' Hazy Mind 3D Engine delbar 5 4200 Last post 2006/12/30 03:23:31
by Nemo Krad
Tutorial 11 :: Finishing our Culling, Complete Octree Funcionality Tutorial Discussion « 1 2 » mikeschuld 19 9016 Last post 2007/08/11 15:11:32
by mikeschuld
I can't see anything on tutorial 4 More Rendering, Vertices and Indexes Hazy Mind 3D Engine moonsvista 5 2902 Last post 2007/03/30 14:37:05
by moonsvista
C# Tutorial Part 2 Addition Hazy Mind 3D Engine thoams 0 1712 Last post 2007/03/30 04:13:59
by thoams
Tutorial 7...Is this functionality common? Is this only useful onyl in testing? Hazy Mind XNA Engine Robin Sarac 1 1423 Last post 2007/04/03 17:24:41
by Chr0n1x
Tutorial one references issue Hazy Mind XNA Engine martindevans 3 1625 Last post 2007/04/06 07:22:09
by martindevans
Tutorial 4 - Why calling the Update-Method? Hazy Mind XNA Engine M-Nasty 2 1864 Last post 2007/08/14 21:44:08
by mikeschuld
Tutorial 13 :: Custom Content Types, Using the Content Pipeline Tutorial Discussion mikeschuld 5 2725 Last post 2007/08/03 09:07:00
by mikeschuld
Tutorial 1 PDF Hazy Mind XNA Engine carnelknowledge 2 1928 Last post 2007/09/05 12:19:26
by carnelknowledge
tutorial 3... where's my quad? Hazy Mind XNA Engine kubatrt 10 3281 Last post 2008/05/20 05:15:38
by kubatrt
Tutorial 9 - any requests? Hazy Mind XNA Engine « 1 2 » mikeschuld 22 8077 Last post 2008/05/28 01:34:00
by Nemo Krad
Tutorial 9 - Topic Vote Hazy Mind XNA Engine « 1 2 » mikeschuld 15 6267 Last post 2008/06/02 12:08:21
by mikeschuld
Post Tutorial 8 - advice needed! Hazy Mind XNA Engine solthar 5 2241 Last post 2008/09/03 20:47:57
by solthar
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.274 seconds with 19 queries.