Jump to content
Xtreme .Net Talk

Phikwe

Members
  • Posts

    8
  • Joined

  • Last visited

Personal Information

  • .NET Preferred Language
    VB.NET

Phikwe's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Found the Answer! This is what I wrote in the other tread! Just thought I should put it here too in case people were look! :) Hey Guys! I found it for real now! It was not as hard as I thought it would be... I made a little function that does it.. Works like a charm! What you do is give it the X and Y coordinates and the mesh and it tells you if the (x,y) is over your mesh... If you want you could call ClosestHit.Dist to see how far your mesh is from the screen. Here is the function 'Determines if an (x,y) coordinate [could be of your mouse] in screen space is over a mesh Function DoesMouseHitMesh(ByVal meshAs mesh, ByVal x As Single, ByVal y As Single) As Boolean Dim viewport As Viewport Dim world As Matrix Dim proj As Matrix Dim view As Matrix Dim vIn As Vector3, vNear As Vector3, vFar As Vector3, vDir As Vector3 Dim ClosestHit As IntersectInformation viewport = device.Viewport world = device.Transform.World 'Now here you have to remember to get the world matrix that will be used on your mesh... proj = device.Transform.Projection view = device.Transform.View vIn.X = x : vIn.Y = y 'Compute point on Near Clip plane at cursor vIn.Z = 0 vNear = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, world) 'compute point on far clip plane at cursor vIn.Z = 1 vFar = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, world) 'Comput direction vector vDir = Microsoft.DirectX.Vector3.Subtract(vFar, vNear) If mesh.Intersect(vNear, vDir, ClosestHit) = True Then Return True End If End Function It works GRATE men! Later! Tell me if you need help in using it or dont understnad somthing...
  2. I got it working!!!!!!!!!!! :) :) :) Hey Guys! I found it for real now! It was not as hard as I thought it would be... I made a little function that does it.. Works like a charm! What you do is give it the X and Y coordinates and the mesh and it tells you if the (x,y) is over your mesh... If you want you could call ClosestHit.Dist to see how far your mesh is from the screen. Here is the function 'Determines if an (x,y) coordinate [could be of your mouse] in screen space is over a mesh Function DoesMouseHitMesh(ByVal meshAs mesh, ByVal x As Single, ByVal y As Single) As Boolean Dim viewport As Viewport Dim world As Matrix Dim proj As Matrix Dim view As Matrix Dim vIn As Vector3, vNear As Vector3, vFar As Vector3, vDir As Vector3 Dim ClosestHit As IntersectInformation viewport = device.Viewport world = device.Transform.World 'Now here you have to remember to get the world matrix that will be used on your mesh... proj = device.Transform.Projection view = device.Transform.View vIn.X = x : vIn.Y = y 'Compute point on Near Clip plane at cursor vIn.Z = 0 vNear = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, world) 'compute point on far clip plane at cursor vIn.Z = 1 vFar = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, world) 'Comput direction vector vDir = Microsoft.DirectX.Vector3.Subtract(vFar, vNear) If mesh.Intersect(vNear, vDir, ClosestHit) = True Then Return True End If End Function It works GRATE men! :) Later! Tell me if you need help in using it or dont understnad somthing...
  3. I found an answer! Hey men!! I FOUND the answer! Well at least one answer! But it involves alot of matrix stuff men! I found it in the DirectX 8 SDK using VB 6.. If you want to could look at the class I attached.. It has ALL the code needed to determine if a mesh (or all sub meshes of a mesh [they call it "frame" in this example]) falls in a given x , y coordinate on the screen. I my self am going to study it and post the DX 9 equivalent! I is not hard men but you have to first get the project and viewport matrixes your device is using then alpy them to get an resulting Intersect Ray and use that ray to find meshes that intersect with it then find the shortest "IntersectInformation.Dist" to see which mesh that was hit is the closest to the camera... :) Look at the "ViewportPick" function. it returns true if the a mesh is hit... I think I could make a .NET class in VB Later men! d3dPick.cls.txt
  4. Hey men! Your asking the same question I just asked! I will read what these people said and try to get back to you if I find anything... If you figure it out please tell me too! Thanks men!
  5. Hey guys! Anyone know how to edit your texture to make it seem the object is glowing or the object is transperent or the object is shining? Where could I go to learn ALL about texturing... The SDK does not tell me ANYTHING! Thanks ALOT GUYS!
  6. Hey People! New to this forum... I want to know if anyone here knows how to know when for example your mouse if over a particula mesh on the screen... I know how to use Mesh.Intersect to find out if a ray intersect a mesh and at what distace but I really want to know if my mouse if pointing to an object in the a 3D scene. I suppose I could figure out a way to put a ray where the camera is and point it in the direction the camera is pointing with an offset of where the mouse is. It will have to do with the projectiong matrix also.. But I was tryiing to find an easyer way of doing it... Maybe there is a function that is simular to Mesh.Intersect but tells if a point on the screen intersect or touches a mesh... haha I really hope you guys understood that! This is a cool forume and I am glad to know people are having simular problems to mine!! PLEASE ANSWER if you know a way I could do this! Thanks ALOT PEOPLE! PhikweG
×
×
  • Create New...