Post

 Resources 

Console

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

 All Forums
 VBGamer
 VBGamer
 HELP: D3DX IntersectTri method does not work?

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
cbx Posted - Jun 22 2004 : 03:17:54 AM
I wrote a simple app to try out the IntersectTri method provided in the Direct3D9 API. The IntersectTri method is also availible in the D3D8 API.

http://msdn.microsoft.com/library/en-us/directx9_m/directx/ref/ns/microsoft.directx.direct3d/c/geometry/m/intersecttri.asp

This is the code i'm using...
Dim Hit As Direct3D.IntersectInformation  
  
Ret = Direct3D.Geometry.IntersectTri(mobjPts(0), mobjPts(1), mobjPts(2), RayPos, RayDir, Hit)  


Ret is a boolean
mobjPts(0), mobjPts(1), mobjPts(2) are vector3 structures
RayPos, RayDir are also vector3 structures.

The X,Y for mobjPts(0), mobjPts(1), mobjPts(2) are set using the mouse buttons, and the Z value for all three points is set to 0.

The X,Y for RayPos, RayDir are set using the mouse buttons, and the Z value for RayPos is set to -0.0000000000000001 and the Z value for RayDir is set to 0.0000000000000001.

But when I run the app the ray never seems to intersect the triangle. I have also tried variations like setting the raypos z value to to -10 and the Z value for RayDir is set to 10 but it does not help.

I don't believe I am doing anything wrong! Can anyone suggest why the IntersectTri method never returns true?


Download Attachment: IntersectTri.zip
16.08 KB
2   L A T E S T    R E P L I E S    (Newest First)
cbx Posted - Jun 23 2004 : 04:25:23 AM
It did work for me but rarely. It only seemed to work sometimes but not all the time, like for instance there are times when the ray would clearly be intersecting the triangle but not return a hit, but adjusting the ray ever so slightly would cause hit.

Anyway I am just in the process of exploring multiple techniques related to collision detection...
Eric Coleman Posted - Jun 22 2004 : 09:00:05 AM
For some reason, I've never had much luck getting DirectX 9 to work properly with VB.NET, so I can't modify the code or compile, but I did run the .exe you provided and this is what I got.



I looks like it works to me. However, I did notice that your ray isn't very long. Try drawing side views of the triangle and ray as well,
  
        e.Graphics.DrawLine(New Pen(Color.Red), mobjPts(0).X, mobjPts(0).Y, mobjPts(1).X, mobjPts(1).Y)  
        e.Graphics.DrawLine(New Pen(Color.Red), mobjPts(1).X, mobjPts(1).Y, mobjPts(2).X, mobjPts(2).Y)  
        e.Graphics.DrawLine(New Pen(Color.Red), mobjPts(2).X, mobjPts(2).Y, mobjPts(0).X, mobjPts(0).Y)  
        e.Graphics.DrawLine(New Pen(Me.ForeColor), RayPos.X, RayPos.Y, RayDir.X, RayDir.Y)  
  
        e.Graphics.DrawLine(New Pen(Color.Green), mobjPts(0).X, mobjPts(0).Z, mobjPts(1).X, mobjPts(1).Z)  
        e.Graphics.DrawLine(New Pen(Color.Green), mobjPts(1).X, mobjPts(1).Z, mobjPts(2).X, mobjPts(2).Z)  
        e.Graphics.DrawLine(New Pen(Color.Green), mobjPts(2).X, mobjPts(2).Z, mobjPts(0).X, mobjPts(0).Z)  
        e.Graphics.DrawLine(New Pen(Me.Cyan), RayPos.X, RayPos.Z, RayDir.X, RayDir.Z)  
  
        e.Graphics.DrawLine(New Pen(Color.Blue), mobjPts(0).Y, mobjPts(0).Z, mobjPts(1).Y, mobjPts(1).Z)  
        e.Graphics.DrawLine(New Pen(Color.Blue), mobjPts(1).Y, mobjPts(1).Z, mobjPts(2).Y, mobjPts(2).Z)  
        e.Graphics.DrawLine(New Pen(Color.Blue), mobjPts(2).Y, mobjPts(2).Z, mobjPts(0).Y, mobjPts(0).Z)  
        e.Graphics.DrawLine(New Pen(Me.Magenta), RayPos.Y, RayPos.Z, RayDir.Y, RayDir.Z)  
  

VBGamer © Go To Top Of Page
This page was generated in 0.1 seconds. Snitz Forums 2000

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